mirror of
https://github.com/STMicroelectronics/stm32-mw-usb-device.git
synced 2026-02-08 20:18:07 -05:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
947131e000 | ||
|
|
d6e6bd2c66 | ||
|
|
2a0a3521ac | ||
|
|
0b06460a43 | ||
|
|
7b5e6886d2 | ||
|
|
bd79085c18 | ||
|
|
dccc30a45a |
@@ -1,31 +1,46 @@
|
|||||||
## Contributing guide
|
# Contributing guide
|
||||||
This document serves as a checklist before contributing to this repository.
|
|
||||||
It includes links to read up on if topics are unclear to you.
|
|
||||||
|
|
||||||
This guide mainly focuses on the proper use of Git.
|
This guide mainly focuses on the steps to follow to submit an issue or a pull request.
|
||||||
|
|
||||||
### 1. Before opening an issue
|
## 1. Issues
|
||||||
Please check the following boxes before posting an issue:
|
|
||||||
- [ ] `Make sure you are using the latest commit (major releases are Tagged, but corrections are available as new commits).`
|
|
||||||
- [ ] `Make sure your issue is a question/feedback/suggestions RELATED TO the software provided in this repository.` Otherwise, it should be discussed on the [ST Community/STM32 MCUs forum](https://community.st.com/s/group/0F90X000000AXsASAW/stm32-mcus).
|
|
||||||
- [ ] `Make sure your issue is not already reported/fixed on GitHub or discussed on a previous issue.` Please refer to this [dashboard](https://github.com/orgs/STMicroelectronics/projects/5) for the list of issues and pull-requests. Do not forget to browse into the **closed** issues.
|
|
||||||
|
|
||||||
### 2. Posting the issue
|
### 1.1 Before opening an issue
|
||||||
When you have checked the previous boxes. You will find two templates (Bug Report or Other Issue) available in the **Issues** tab of the repository ([link](https://github.com/STMicroelectronics/stm32_mw_usb_device/issues/new/choose)).
|
|
||||||
|
Before posting an issue, please ensure:
|
||||||
|
* You are using the latest commit.
|
||||||
|
* Your issue is **not** a vulnerability. Otherwise, please refer to section [3](CONTRIBUTING.md#3-vulnerabilities) below.
|
||||||
|
* Your issue is **related to** the software provided in this repository. Otherwise, please refer to section [4](CONTRIBUTING.md#4-support-requests-and-miscellaneous) below.
|
||||||
|
* Your issue is not already reported, fixed or discussed in a previous one. Remember to browse the **closed** issues.
|
||||||
|
|
||||||
|
### 1.2 Posting the issue
|
||||||
|
|
||||||
|
When you have checked the previous points, create a new report from the **Issues** tab of this repository. A couple of templates are available [here](../../issues/new/choose).
|
||||||
|
|
||||||
|
## 2. Pull Requests
|
||||||
|
|
||||||
|
### 2.1 Before opening a pull request
|
||||||
|
|
||||||
### 3. Pull Requests
|
|
||||||
STMicrolectronics is happy to receive contributions from the community, based on an initial Contributor License Agreement (CLA) procedure.
|
STMicrolectronics is happy to receive contributions from the community, based on an initial Contributor License Agreement (CLA) procedure.
|
||||||
|
|
||||||
* If you are an individual writing original source code and you are sure **you own the intellectual property**, then you need to sign an Individual CLA (https://cla.st.com).
|
* If you are an individual writing original source code and you are sure **you own the intellectual property**, then you need to sign an **Individual** [CLA](https://cla.st.com).
|
||||||
* If you work for a company that wants also to allow you to contribute with your work, your company needs to provide a Corporate CLA (https://cla.st.com) mentioning your GitHub account name.
|
* If you work for a company that wants also to allow you to contribute with your work, your company needs to provide a **Corporate** [CLA](https://cla.st.com) mentioning your GitHub account name.
|
||||||
* If you are not sure that a CLA (Individual or Corporate) has been signed for your GitHub account you can check here (https://cla.st.com).
|
* If you are not sure that a CLA (Individual or Corporate) has been signed for your GitHub account you can check the [CLA](https://cla.st.com) dedicated page.
|
||||||
|
|
||||||
Please note that:
|
> [!IMPORTANT]
|
||||||
* The Corporate CLA will always take precedence over the Individual CLA.
|
> Please note that:
|
||||||
* One CLA submission is sufficient, for any project proposed by STMicroelectronics.
|
> * The Corporate CLA will always take precedence over the Individual CLA.
|
||||||
|
> * One CLA submission is sufficient, for any project proposed by STMicroelectronics.
|
||||||
|
|
||||||
#### How to proceed
|
### 2.2 How to proceed
|
||||||
|
|
||||||
* We recommend to engage first a communication thru an issue, in order to present your proposal. Just to confirm that it corresponds to STMicroelectronics domain or scope.
|
* We recommend to engage first a communication thru an issue, in order to present your proposal, just to confirm that it corresponds to STMicroelectronics' domain or scope.
|
||||||
* Then fork the project to your GitHub account to further develop your contribution. Please use the latest commit version.
|
* Then fork the project to your GitHub account to further develop your contribution. Please use the latest commit version.
|
||||||
* Please, submit one Pull Request for one new feature or proposal. This will ease the analysis and the final merge if accepted.
|
* Please, submit one pull request per new feature or proposal. This will ease the analysis and the final merge if accepted.
|
||||||
|
|
||||||
|
## 3. Vulnerabilities
|
||||||
|
|
||||||
|
To report a **vulnerability**, please refer to the [SECURITY.md](./SECURITY.md) file for instructions.
|
||||||
|
|
||||||
|
## 4. Support requests and miscellaneous
|
||||||
|
|
||||||
|
For support requests or any other topics not related to the content of this repository, you can submit a post to the **ST Community** on the appropriate topic [page](https://community.st.com/s/topiccatalog).
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ extern "C" {
|
|||||||
#define USB_DEVICE_CLASS_AUDIO 0x01U
|
#define USB_DEVICE_CLASS_AUDIO 0x01U
|
||||||
#define AUDIO_SUBCLASS_AUDIOCONTROL 0x01U
|
#define AUDIO_SUBCLASS_AUDIOCONTROL 0x01U
|
||||||
#define AUDIO_SUBCLASS_AUDIOSTREAMING 0x02U
|
#define AUDIO_SUBCLASS_AUDIOSTREAMING 0x02U
|
||||||
|
#define AUDIO_SUBCLASS_MIDISTREAMING 0x03U
|
||||||
#define AUDIO_PROTOCOL_UNDEFINED 0x00U
|
#define AUDIO_PROTOCOL_UNDEFINED 0x00U
|
||||||
#define AUDIO_STREAMING_GENERAL 0x01U
|
#define AUDIO_STREAMING_GENERAL 0x01U
|
||||||
#define AUDIO_STREAMING_FORMAT_TYPE 0x02U
|
#define AUDIO_STREAMING_FORMAT_TYPE 0x02U
|
||||||
|
|||||||
@@ -162,6 +162,9 @@ USBD_ClassTypeDef USBD_AUDIO =
|
|||||||
USBD_AUDIO_GetCfgDesc,
|
USBD_AUDIO_GetCfgDesc,
|
||||||
USBD_AUDIO_GetDeviceQualifierDesc,
|
USBD_AUDIO_GetDeviceQualifierDesc,
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
|
||||||
|
NULL,
|
||||||
|
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef USE_USBD_COMPOSITE
|
#ifndef USE_USBD_COMPOSITE
|
||||||
@@ -742,8 +745,19 @@ static uint8_t USBD_AUDIO_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnu
|
|||||||
*/
|
*/
|
||||||
static uint8_t USBD_AUDIO_IsoOutIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
static uint8_t USBD_AUDIO_IsoOutIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||||
{
|
{
|
||||||
UNUSED(pdev);
|
USBD_AUDIO_HandleTypeDef *haudio;
|
||||||
UNUSED(epnum);
|
|
||||||
|
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
||||||
|
{
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
|
||||||
|
/* Prepare Out endpoint to receive next audio packet */
|
||||||
|
(void)USBD_LL_PrepareReceive(pdev, epnum,
|
||||||
|
&haudio->buffer[haudio->wr_ptr],
|
||||||
|
AUDIO_OUT_PACKET);
|
||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,10 +60,12 @@ extern "C" {
|
|||||||
#define CCID_CMD_FS_BINTERVAL 0x10U
|
#define CCID_CMD_FS_BINTERVAL 0x10U
|
||||||
#endif /* CCID_CMD_FS_BINTERVAL */
|
#endif /* CCID_CMD_FS_BINTERVAL */
|
||||||
|
|
||||||
|
#ifndef CCID_CMD_PACKET_SIZE
|
||||||
|
#define CCID_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */
|
||||||
|
#endif /* CCID_CMD_PACKET_SIZE */
|
||||||
|
|
||||||
#define CCID_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
|
#define CCID_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
|
||||||
#define CCID_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
|
#define CCID_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
|
||||||
#define CCID_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */
|
|
||||||
|
|
||||||
#define USB_CCID_CONFIG_DESC_SIZ 93U
|
#define USB_CCID_CONFIG_DESC_SIZ 93U
|
||||||
#define CCID_DATA_HS_IN_PACKET_SIZE CCID_DATA_HS_MAX_PACKET_SIZE
|
#define CCID_DATA_HS_IN_PACKET_SIZE CCID_DATA_HS_MAX_PACKET_SIZE
|
||||||
|
|||||||
@@ -129,6 +129,9 @@ USBD_ClassTypeDef USBD_CCID =
|
|||||||
USBD_CCID_GetOtherSpeedCfgDesc,
|
USBD_CCID_GetOtherSpeedCfgDesc,
|
||||||
USBD_CCID_GetDeviceQualifierDescriptor,
|
USBD_CCID_GetDeviceQualifierDescriptor,
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
|
||||||
|
NULL,
|
||||||
|
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef USE_USBD_COMPOSITE
|
#ifndef USE_USBD_COMPOSITE
|
||||||
|
|||||||
@@ -42,10 +42,10 @@ static void CCID_UpdateCommandStatus(USBD_HandleTypeDef *pdev, uint8_t cmd_stat
|
|||||||
uint8_t PC_to_RDR_IccPowerOn(USBD_HandleTypeDef *pdev)
|
uint8_t PC_to_RDR_IccPowerOn(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
/* Apply the ICC VCC
|
/* Apply the ICC VCC
|
||||||
Fills the Response buffer with ICC ATR
|
* Fills the Response buffer with ICC ATR
|
||||||
This Command is returned with RDR_to_PC_DataBlock();
|
* This Command is returned with RDR_to_PC_DataBlock();
|
||||||
*/
|
*/
|
||||||
USBD_CCID_HandleTypeDef *hccid = (USBD_CCID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_CCID_HandleTypeDef *hccid = (USBD_CCID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
uint8_t voltage;
|
uint8_t voltage;
|
||||||
uint8_t sc_voltage = 0U;
|
uint8_t sc_voltage = 0U;
|
||||||
uint8_t index;
|
uint8_t index;
|
||||||
|
|||||||
@@ -58,10 +58,13 @@ extern "C" {
|
|||||||
#define CDC_FS_BINTERVAL 0x10U
|
#define CDC_FS_BINTERVAL 0x10U
|
||||||
#endif /* CDC_FS_BINTERVAL */
|
#endif /* CDC_FS_BINTERVAL */
|
||||||
|
|
||||||
|
#ifndef CDC_CMD_PACKET_SIZE
|
||||||
|
#define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */
|
||||||
|
#endif /* CDC_CMD_PACKET_SIZE */
|
||||||
|
|
||||||
/* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
|
/* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
|
||||||
#define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
|
#define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
|
||||||
#define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
|
#define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
|
||||||
#define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */
|
|
||||||
|
|
||||||
#define USB_CDC_CONFIG_DESC_SIZ 67U
|
#define USB_CDC_CONFIG_DESC_SIZ 67U
|
||||||
#define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
|
#define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
|
||||||
|
|||||||
@@ -161,6 +161,9 @@ USBD_ClassTypeDef USBD_CDC =
|
|||||||
USBD_CDC_GetOtherSpeedCfgDesc,
|
USBD_CDC_GetOtherSpeedCfgDesc,
|
||||||
USBD_CDC_GetDeviceQualifierDescriptor,
|
USBD_CDC_GetDeviceQualifierDescriptor,
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
|
||||||
|
NULL,
|
||||||
|
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef USE_USBD_COMPOSITE
|
#ifndef USE_USBD_COMPOSITE
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ extern "C" {
|
|||||||
#define CDC_ECM_FS_BINTERVAL 0x10U
|
#define CDC_ECM_FS_BINTERVAL 0x10U
|
||||||
#endif /* CDC_ECM_FS_BINTERVAL */
|
#endif /* CDC_ECM_FS_BINTERVAL */
|
||||||
|
|
||||||
|
#ifndef CDC_ECM_CMD_PACKET_SIZE
|
||||||
|
#define CDC_ECM_CMD_PACKET_SIZE 16U /* Control Endpoint Packet size */
|
||||||
|
#endif /* CDC_ECM_CMD_PACKET_SIZE */
|
||||||
|
|
||||||
#ifndef USBD_SUPPORT_USER_STRING_DESC
|
#ifndef USBD_SUPPORT_USER_STRING_DESC
|
||||||
#define USBD_SUPPORT_USER_STRING_DESC 1U
|
#define USBD_SUPPORT_USER_STRING_DESC 1U
|
||||||
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||||
@@ -75,7 +79,6 @@ extern "C" {
|
|||||||
/* CDC_ECM Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
|
/* CDC_ECM Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
|
||||||
#define CDC_ECM_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
|
#define CDC_ECM_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
|
||||||
#define CDC_ECM_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
|
#define CDC_ECM_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
|
||||||
#define CDC_ECM_CMD_PACKET_SIZE 16U /* Control Endpoint Packet size */
|
|
||||||
|
|
||||||
#define CDC_ECM_CONFIG_DESC_SIZ 79U
|
#define CDC_ECM_CONFIG_DESC_SIZ 79U
|
||||||
|
|
||||||
|
|||||||
@@ -66,12 +66,14 @@ extern "C" {
|
|||||||
#define CDC_RNDIS_FS_BINTERVAL 0x10U
|
#define CDC_RNDIS_FS_BINTERVAL 0x10U
|
||||||
#endif /* CDC_RNDIS_FS_BINTERVAL */
|
#endif /* CDC_RNDIS_FS_BINTERVAL */
|
||||||
|
|
||||||
|
#ifndef CDC_RNDIS_CMD_PACKET_SIZE
|
||||||
|
#define CDC_RNDIS_CMD_PACKET_SIZE 16U /* Control Endpoint Packet size */
|
||||||
|
#endif /* CDC_RNDIS_CMD_PACKET_SIZE */
|
||||||
|
|
||||||
/* CDC_RNDIS Endpoints parameters: you can fine tune these values
|
/* CDC_RNDIS Endpoints parameters: you can fine tune these values
|
||||||
depending on the needed baudrates and performance. */
|
depending on the needed baudrates and performance. */
|
||||||
#define CDC_RNDIS_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
|
#define CDC_RNDIS_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
|
||||||
#define CDC_RNDIS_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
|
#define CDC_RNDIS_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
|
||||||
#define CDC_RNDIS_CMD_PACKET_SIZE 16U /* Control Endpoint Packet size */
|
|
||||||
|
|
||||||
#define CDC_RNDIS_CONFIG_DESC_SIZ 75U
|
#define CDC_RNDIS_CONFIG_DESC_SIZ 75U
|
||||||
#define CDC_RNDIS_DATA_HS_IN_PACKET_SIZE CDC_RNDIS_DATA_HS_MAX_PACKET_SIZE
|
#define CDC_RNDIS_DATA_HS_IN_PACKET_SIZE CDC_RNDIS_DATA_HS_MAX_PACKET_SIZE
|
||||||
|
|||||||
@@ -1452,7 +1452,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessQueryMsg(USBD_HandleTypeDef *pdev,
|
|||||||
|
|
||||||
case OID_GEN_CURRENT_PACKET_FILTER:
|
case OID_GEN_CURRENT_PACKET_FILTER:
|
||||||
QueryResponse->InfoBufLength = sizeof(uint32_t);
|
QueryResponse->InfoBufLength = sizeof(uint32_t);
|
||||||
QueryResponse->InfoBuf[0] = 0xFFFFFFU; /* USBD_CDC_RNDIS_DEVICE.packetFilter; */
|
QueryResponse->InfoBuf[0] = 0xFFFFFFU; /* USBD_CDC_RNDIS_DEVICE.packetFilter */
|
||||||
QueryResponse->Status = CDC_RNDIS_STATUS_SUCCESS;
|
QueryResponse->Status = CDC_RNDIS_STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -511,11 +511,11 @@ uint8_t USBD_CMPSIT_AddToConfDesc(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
/* Set IN endpoint slot */
|
/* Set IN endpoint slot */
|
||||||
iEp = pdev->tclasslist[pdev->classId].EpAdd[0];
|
iEp = pdev->tclasslist[pdev->classId].EpAdd[0];
|
||||||
USBD_CMPSIT_AssignEp(pdev, iEp, USBD_EP_TYPE_INTR, pdev->tclasslist[pdev->classId].CurrPcktSze);
|
USBD_CMPSIT_AssignEp(pdev, iEp, USBD_EP_TYPE_INTR,CUSTOM_HID_EPIN_SIZE);
|
||||||
|
|
||||||
/* Set OUT endpoint slot */
|
/* Set OUT endpoint slot */
|
||||||
iEp = pdev->tclasslist[pdev->classId].EpAdd[1];
|
iEp = pdev->tclasslist[pdev->classId].EpAdd[1];
|
||||||
USBD_CMPSIT_AssignEp(pdev, iEp, USBD_EP_TYPE_INTR, pdev->tclasslist[pdev->classId].CurrPcktSze);
|
USBD_CMPSIT_AssignEp(pdev, iEp, USBD_EP_TYPE_INTR, CUSTOM_HID_EPOUT_SIZE);
|
||||||
|
|
||||||
/* Configure and Append the Descriptor */
|
/* Configure and Append the Descriptor */
|
||||||
USBD_CMPSIT_CUSTOMHIDDesc(pdev, (uint32_t)pCmpstFSConfDesc, &CurrFSConfDescSz, (uint8_t)USBD_SPEED_FULL);
|
USBD_CMPSIT_CUSTOMHIDDesc(pdev, (uint32_t)pCmpstFSConfDesc, &CurrFSConfDescSz, (uint8_t)USBD_SPEED_FULL);
|
||||||
@@ -1393,7 +1393,12 @@ static void USBD_CMPSIT_CUSTOMHIDDesc(USBD_HandleTypeDef *pdev, uint32_t pConf,
|
|||||||
pDesc->bCountryCode = 0x00U;
|
pDesc->bCountryCode = 0x00U;
|
||||||
pDesc->bNumDescriptors = 0x01U;
|
pDesc->bNumDescriptors = 0x01U;
|
||||||
pDesc->bDescriptorType = 0x22U;
|
pDesc->bDescriptorType = 0x22U;
|
||||||
|
#ifdef USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED
|
||||||
|
pDesc->wItemLength = ((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->wReportDescLen;
|
||||||
|
#else
|
||||||
pDesc->wItemLength = USBD_CUSTOM_HID_REPORT_DESC_SIZE;
|
pDesc->wItemLength = USBD_CUSTOM_HID_REPORT_DESC_SIZE;
|
||||||
|
#endif /* USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED */
|
||||||
|
|
||||||
*Sze += (uint32_t)sizeof(USBD_DescTypeDef);
|
*Sze += (uint32_t)sizeof(USBD_DescTypeDef);
|
||||||
|
|
||||||
/* Descriptor of Custom HID endpoints */
|
/* Descriptor of Custom HID endpoints */
|
||||||
@@ -1403,7 +1408,7 @@ static void USBD_CMPSIT_CUSTOMHIDDesc(USBD_HandleTypeDef *pdev, uint32_t pConf,
|
|||||||
|
|
||||||
/* Append Endpoint descriptor to Configuration descriptor */
|
/* Append Endpoint descriptor to Configuration descriptor */
|
||||||
__USBD_CMPSIT_SET_EP(pdev->tclasslist[pdev->classId].Eps[1].add, \
|
__USBD_CMPSIT_SET_EP(pdev->tclasslist[pdev->classId].Eps[1].add, \
|
||||||
USBD_EP_TYPE_INTR, CUSTOM_HID_EPIN_SIZE, CUSTOM_HID_HS_BINTERVAL, CUSTOM_HID_FS_BINTERVAL);
|
USBD_EP_TYPE_INTR, CUSTOM_HID_EPOUT_SIZE, CUSTOM_HID_HS_BINTERVAL, CUSTOM_HID_FS_BINTERVAL);
|
||||||
|
|
||||||
/* Update Config Descriptor and IAD descriptor */
|
/* Update Config Descriptor and IAD descriptor */
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
|
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
|
||||||
|
|||||||
@@ -103,9 +103,16 @@ typedef enum
|
|||||||
typedef struct _USBD_CUSTOM_HID_Itf
|
typedef struct _USBD_CUSTOM_HID_Itf
|
||||||
{
|
{
|
||||||
uint8_t *pReport;
|
uint8_t *pReport;
|
||||||
|
#ifdef USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED
|
||||||
|
uint16_t wReportDescLen;
|
||||||
|
#endif /* USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED */
|
||||||
int8_t (* Init)(void);
|
int8_t (* Init)(void);
|
||||||
int8_t (* DeInit)(void);
|
int8_t (* DeInit)(void);
|
||||||
|
#ifdef USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED
|
||||||
|
int8_t (* OutEvent)(uint8_t *report_buffer);
|
||||||
|
#else
|
||||||
int8_t (* OutEvent)(uint8_t event_idx, uint8_t state);
|
int8_t (* OutEvent)(uint8_t event_idx, uint8_t state);
|
||||||
|
#endif /* USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED */
|
||||||
#ifdef USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED
|
#ifdef USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED
|
||||||
int8_t (* CtrlReqComplete)(uint8_t request, uint16_t wLength);
|
int8_t (* CtrlReqComplete)(uint8_t request, uint16_t wLength);
|
||||||
#endif /* USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED */
|
#endif /* USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED */
|
||||||
|
|||||||
@@ -128,6 +128,9 @@ USBD_ClassTypeDef USBD_CUSTOM_HID =
|
|||||||
USBD_CUSTOM_HID_GetOtherSpeedCfgDesc,
|
USBD_CUSTOM_HID_GetOtherSpeedCfgDesc,
|
||||||
USBD_CUSTOM_HID_GetDeviceQualifierDesc,
|
USBD_CUSTOM_HID_GetDeviceQualifierDesc,
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
|
||||||
|
NULL,
|
||||||
|
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef USE_USBD_COMPOSITE
|
#ifndef USE_USBD_COMPOSITE
|
||||||
@@ -284,6 +287,11 @@ static uint8_t USBD_CUSTOM_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
pdev->ep_in[CUSTOMHIDInEpAdd & 0xFU].is_used = 1U;
|
pdev->ep_in[CUSTOMHIDInEpAdd & 0xFU].is_used = 1U;
|
||||||
|
|
||||||
|
if (USBD_CUSTOMHID_OUTREPORT_BUF_SIZE < CUSTOM_HID_EPOUT_SIZE)
|
||||||
|
{
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Open EP OUT */
|
/* Open EP OUT */
|
||||||
(void)USBD_LL_OpenEP(pdev, CUSTOMHIDOutEpAdd, USBD_EP_TYPE_INTR,
|
(void)USBD_LL_OpenEP(pdev, CUSTOMHIDOutEpAdd, USBD_EP_TYPE_INTR,
|
||||||
CUSTOM_HID_EPOUT_SIZE);
|
CUSTOM_HID_EPOUT_SIZE);
|
||||||
@@ -397,9 +405,17 @@ static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev,
|
|||||||
}
|
}
|
||||||
#endif /* USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED */
|
#endif /* USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED */
|
||||||
#ifndef USBD_CUSTOMHID_EP0_OUT_PREPARE_RECEIVE_DISABLED
|
#ifndef USBD_CUSTOMHID_EP0_OUT_PREPARE_RECEIVE_DISABLED
|
||||||
|
|
||||||
|
if (req->wLength > USBD_CUSTOMHID_OUTREPORT_BUF_SIZE)
|
||||||
|
{
|
||||||
|
/* Stall EP0 */
|
||||||
|
USBD_CtlError(pdev, req);
|
||||||
|
return USBD_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
hhid->IsReportAvailable = 1U;
|
hhid->IsReportAvailable = 1U;
|
||||||
(void)USBD_CtlPrepareRx(pdev, hhid->Report_buf,
|
|
||||||
MIN(req->wLength, USBD_CUSTOMHID_OUTREPORT_BUF_SIZE));
|
(void)USBD_CtlPrepareRx(pdev, hhid->Report_buf, req->wLength);
|
||||||
#endif /* USBD_CUSTOMHID_EP0_OUT_PREPARE_RECEIVE_DISABLED */
|
#endif /* USBD_CUSTOMHID_EP0_OUT_PREPARE_RECEIVE_DISABLED */
|
||||||
break;
|
break;
|
||||||
#ifdef USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED
|
#ifdef USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED
|
||||||
@@ -479,7 +495,15 @@ static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)USBD_CtlSendData(pdev, pbuf, len);
|
if (pbuf != NULL)
|
||||||
|
{
|
||||||
|
(void)USBD_CtlSendData(pdev, pbuf, len);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
USBD_CtlError(pdev, req);
|
||||||
|
ret = USBD_FAIL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case USB_REQ_GET_INTERFACE:
|
case USB_REQ_GET_INTERFACE:
|
||||||
@@ -693,8 +717,13 @@ static uint8_t USBD_CUSTOM_HID_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
|
|
||||||
/* USB data will be immediately processed, this allow next USB traffic being
|
/* USB data will be immediately processed, this allow next USB traffic being
|
||||||
NAKed till the end of the application processing */
|
NAKed till the end of the application processing */
|
||||||
|
|
||||||
|
#ifdef USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED
|
||||||
|
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->OutEvent(hhid->Report_buf);
|
||||||
|
#else
|
||||||
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->OutEvent(hhid->Report_buf[0],
|
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->OutEvent(hhid->Report_buf[0],
|
||||||
hhid->Report_buf[1]);
|
hhid->Report_buf[1]);
|
||||||
|
#endif /* USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED */
|
||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
@@ -747,8 +776,12 @@ static uint8_t USBD_CUSTOM_HID_EP0_RxReady(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
if (hhid->IsReportAvailable == 1U)
|
if (hhid->IsReportAvailable == 1U)
|
||||||
{
|
{
|
||||||
|
#ifdef USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED
|
||||||
|
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->OutEvent(hhid->Report_buf);
|
||||||
|
#else
|
||||||
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->OutEvent(hhid->Report_buf[0],
|
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->OutEvent(hhid->Report_buf[0],
|
||||||
hhid->Report_buf[1]);
|
hhid->Report_buf[1]);
|
||||||
|
#endif /* USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED */
|
||||||
hhid->IsReportAvailable = 0U;
|
hhid->IsReportAvailable = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,11 @@ EndBSPDependencies */
|
|||||||
|
|
||||||
static int8_t TEMPLATE_CUSTOM_HID_Init(void);
|
static int8_t TEMPLATE_CUSTOM_HID_Init(void);
|
||||||
static int8_t TEMPLATE_CUSTOM_HID_DeInit(void);
|
static int8_t TEMPLATE_CUSTOM_HID_DeInit(void);
|
||||||
|
#ifdef USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED
|
||||||
|
static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t *report_buffer);
|
||||||
|
#else
|
||||||
static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t event_idx, uint8_t state);
|
static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t event_idx, uint8_t state);
|
||||||
|
#endif /* USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED */
|
||||||
|
|
||||||
#ifdef USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED
|
#ifdef USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED
|
||||||
static int8_t TEMPLATE_CUSTOM_HID_CtrlReqComplete(uint8_t request, uint16_t wLength);
|
static int8_t TEMPLATE_CUSTOM_HID_CtrlReqComplete(uint8_t request, uint16_t wLength);
|
||||||
@@ -49,6 +53,9 @@ __ALIGN_BEGIN static uint8_t TEMPLATE_CUSTOM_HID_ReportDesc[USBD_CUSTOM_HID_REPO
|
|||||||
USBD_CUSTOM_HID_ItfTypeDef USBD_CustomHID_template_fops =
|
USBD_CUSTOM_HID_ItfTypeDef USBD_CustomHID_template_fops =
|
||||||
{
|
{
|
||||||
TEMPLATE_CUSTOM_HID_ReportDesc,
|
TEMPLATE_CUSTOM_HID_ReportDesc,
|
||||||
|
#ifdef USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED
|
||||||
|
USBD_CUSTOM_HID_REPORT_DESC_SIZE,
|
||||||
|
#endif /* USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED */
|
||||||
TEMPLATE_CUSTOM_HID_Init,
|
TEMPLATE_CUSTOM_HID_Init,
|
||||||
TEMPLATE_CUSTOM_HID_DeInit,
|
TEMPLATE_CUSTOM_HID_DeInit,
|
||||||
TEMPLATE_CUSTOM_HID_OutEvent,
|
TEMPLATE_CUSTOM_HID_OutEvent,
|
||||||
@@ -95,10 +102,17 @@ static int8_t TEMPLATE_CUSTOM_HID_DeInit(void)
|
|||||||
* @param state: event state
|
* @param state: event state
|
||||||
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
|
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED
|
||||||
|
static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t *report_buffer)
|
||||||
|
{
|
||||||
|
UNUSED(report_buffer);
|
||||||
|
#else
|
||||||
static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t event_idx, uint8_t state)
|
static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t event_idx, uint8_t state)
|
||||||
{
|
{
|
||||||
UNUSED(event_idx);
|
UNUSED(event_idx);
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
#endif /* USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED */
|
||||||
|
|
||||||
/* Start next USB packet transfer once data processing is completed */
|
/* Start next USB packet transfer once data processing is completed */
|
||||||
if (USBD_CUSTOM_HID_ReceivePacket(&USBD_Device) != (uint8_t)USBD_OK)
|
if (USBD_CUSTOM_HID_ReceivePacket(&USBD_Device) != (uint8_t)USBD_OK)
|
||||||
@@ -151,7 +165,7 @@ static int8_t TEMPLATE_CUSTOM_HID_CtrlReqComplete(uint8_t request, uint16_t wLen
|
|||||||
static uint8_t *TEMPLATE_CUSTOM_HID_GetReport(uint16_t *ReportLength)
|
static uint8_t *TEMPLATE_CUSTOM_HID_GetReport(uint16_t *ReportLength)
|
||||||
{
|
{
|
||||||
UNUSED(ReportLength);
|
UNUSED(ReportLength);
|
||||||
uint8_t *pbuff;
|
uint8_t *pbuff = NULL;
|
||||||
|
|
||||||
return (pbuff);
|
return (pbuff);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define DFU_DESCRIPTOR_TYPE 0x21U
|
#define DFU_DESCRIPTOR_TYPE 0x21U
|
||||||
|
|
||||||
|
#define DFU_VENDOR_CMD_MAX 32U
|
||||||
|
|
||||||
|
|
||||||
/**************************************************/
|
/**************************************************/
|
||||||
/* DFU Requests DFU states */
|
/* DFU Requests DFU states */
|
||||||
@@ -126,6 +128,11 @@ extern "C" {
|
|||||||
#define DFU_MANIFEST_MASK (1U << 2)
|
#define DFU_MANIFEST_MASK (1U << 2)
|
||||||
#define DFU_STATUS_DEPTH 6U
|
#define DFU_STATUS_DEPTH 6U
|
||||||
|
|
||||||
|
#define IS_DFU_DOWNLOAD 0x0DFDFU
|
||||||
|
#define IS_DFU_UPLOAD 0x1DFDFU
|
||||||
|
#define IS_DFU_SETADDRESSPOINTER 0x2DFDFU
|
||||||
|
#define IS_DFU_PHY_ADDRESS 0x3DFDFU
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
DFU_DETACH = 0U,
|
DFU_DETACH = 0U,
|
||||||
@@ -176,6 +183,7 @@ typedef struct
|
|||||||
uint32_t wblock_num;
|
uint32_t wblock_num;
|
||||||
uint32_t wlength;
|
uint32_t wlength;
|
||||||
uint32_t data_ptr;
|
uint32_t data_ptr;
|
||||||
|
uint32_t app_addr_ptr;
|
||||||
uint32_t alt_setting;
|
uint32_t alt_setting;
|
||||||
|
|
||||||
uint8_t dev_status[DFU_STATUS_DEPTH];
|
uint8_t dev_status[DFU_STATUS_DEPTH];
|
||||||
@@ -193,6 +201,17 @@ typedef struct
|
|||||||
uint16_t (* Write)(uint8_t *src, uint8_t *dest, uint32_t Len);
|
uint16_t (* Write)(uint8_t *src, uint8_t *dest, uint32_t Len);
|
||||||
uint8_t *(* Read)(uint8_t *src, uint8_t *dest, uint32_t Len);
|
uint8_t *(* Read)(uint8_t *src, uint8_t *dest, uint32_t Len);
|
||||||
uint16_t (* GetStatus)(uint32_t Add, uint8_t cmd, uint8_t *buff);
|
uint16_t (* GetStatus)(uint32_t Add, uint8_t cmd, uint8_t *buff);
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
uint16_t (* GetVendorCMD)(uint8_t *cmd, uint8_t *cmdlength);
|
||||||
|
uint16_t (* VendorDownloadCMD)(uint8_t *pbuf, uint32_t BlockNumber, uint32_t wlength, uint32_t *status);
|
||||||
|
uint16_t (* VendorUploadCMD)(uint32_t Add, uint32_t BlockNumber, uint32_t *status);
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
uint16_t (* VendorCheck)(uint8_t *pbuf, uint32_t ReqType, uint32_t *status);
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
#if (USBD_DFU_VENDOR_EXIT_ENABLED == 1U)
|
||||||
|
uint16_t (* LeaveDFU)(uint32_t Add);
|
||||||
|
#endif /* USBD_DFU_VENDOR_EXIT_ENABLED */
|
||||||
} USBD_DFU_MediaTypeDef;
|
} USBD_DFU_MediaTypeDef;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|||||||
@@ -512,6 +512,7 @@ static uint8_t USBD_DFU_EP0_RxReady(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_DFU_EP0_TxReady
|
* @brief USBD_DFU_EP0_TxReady
|
||||||
* handle EP0 TRx Ready event
|
* handle EP0 TRx Ready event
|
||||||
@@ -521,9 +522,13 @@ static uint8_t USBD_DFU_EP0_RxReady(USBD_HandleTypeDef *pdev)
|
|||||||
static uint8_t USBD_DFU_EP0_TxReady(USBD_HandleTypeDef *pdev)
|
static uint8_t USBD_DFU_EP0_TxReady(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
USBD_SetupReqTypedef req;
|
USBD_SetupReqTypedef req;
|
||||||
|
uint32_t app_addr_ptr;
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
USBD_DFU_HandleTypeDef *hdfu = (USBD_DFU_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_DFU_HandleTypeDef *hdfu = (USBD_DFU_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
USBD_DFU_MediaTypeDef *DfuInterface = (USBD_DFU_MediaTypeDef *)pdev->pUserData[pdev->classId];
|
USBD_DFU_MediaTypeDef *DfuInterface = (USBD_DFU_MediaTypeDef *)pdev->pUserData[pdev->classId];
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U) || (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
uint32_t VendorStatus = 0U;
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
|
||||||
if (hdfu == NULL)
|
if (hdfu == NULL)
|
||||||
{
|
{
|
||||||
@@ -541,11 +546,43 @@ static uint8_t USBD_DFU_EP0_TxReady(USBD_HandleTypeDef *pdev)
|
|||||||
{
|
{
|
||||||
/* Nothing to do */
|
/* Nothing to do */
|
||||||
}
|
}
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Vendor specific DFU CMD */
|
||||||
|
if (DfuInterface->VendorDownloadCMD(hdfu->buffer.d8, hdfu->wblock_num,
|
||||||
|
hdfu->wlength, &VendorStatus) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
}
|
}
|
||||||
else if (hdfu->wlength == 5U)
|
else if (hdfu->wlength == 5U)
|
||||||
{
|
{
|
||||||
if (hdfu->buffer.d8[0] == DFU_CMD_SETADDRESSPOINTER)
|
if (hdfu->buffer.d8[0] == DFU_CMD_SETADDRESSPOINTER)
|
||||||
{
|
{
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
if (DfuInterface->VendorCheck(hdfu->buffer.d8, IS_DFU_SETADDRESSPOINTER, &VendorStatus) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
|
||||||
hdfu->data_ptr = hdfu->buffer.d8[1];
|
hdfu->data_ptr = hdfu->buffer.d8[1];
|
||||||
hdfu->data_ptr += (uint32_t)hdfu->buffer.d8[2] << 8;
|
hdfu->data_ptr += (uint32_t)hdfu->buffer.d8[2] << 8;
|
||||||
hdfu->data_ptr += (uint32_t)hdfu->buffer.d8[3] << 16;
|
hdfu->data_ptr += (uint32_t)hdfu->buffer.d8[3] << 16;
|
||||||
@@ -553,30 +590,114 @@ static uint8_t USBD_DFU_EP0_TxReady(USBD_HandleTypeDef *pdev)
|
|||||||
}
|
}
|
||||||
else if (hdfu->buffer.d8[0] == DFU_CMD_ERASE)
|
else if (hdfu->buffer.d8[0] == DFU_CMD_ERASE)
|
||||||
{
|
{
|
||||||
hdfu->data_ptr = hdfu->buffer.d8[1];
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
hdfu->data_ptr += (uint32_t)hdfu->buffer.d8[2] << 8;
|
if (DfuInterface->VendorCheck(hdfu->buffer.d8, IS_DFU_DOWNLOAD, &VendorStatus) != USBD_OK)
|
||||||
hdfu->data_ptr += (uint32_t)hdfu->buffer.d8[3] << 16;
|
|
||||||
hdfu->data_ptr += (uint32_t)hdfu->buffer.d8[4] << 24;
|
|
||||||
|
|
||||||
if (DfuInterface->Erase(hdfu->data_ptr) != USBD_OK)
|
|
||||||
{
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
|
||||||
|
app_addr_ptr = hdfu->buffer.d8[1];
|
||||||
|
app_addr_ptr += (uint32_t)hdfu->buffer.d8[2] << 8;
|
||||||
|
app_addr_ptr += (uint32_t)hdfu->buffer.d8[3] << 16;
|
||||||
|
app_addr_ptr += (uint32_t)hdfu->buffer.d8[4] << 24;
|
||||||
|
|
||||||
|
if (DfuInterface->Erase(app_addr_ptr) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = DFU_ERROR_VENDOR;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Vendor specific DFU CMD */
|
||||||
|
if (DfuInterface->VendorDownloadCMD(hdfu->buffer.d8, hdfu->wblock_num,
|
||||||
|
hdfu->wlength, &VendorStatus) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
if (hdfu->wlength > 0U)
|
||||||
|
{
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
if (DfuInterface->VendorCheck(hdfu->buffer.d8, IS_DFU_DOWNLOAD, &VendorStatus) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
|
||||||
|
/* Vendor specific DFU CMD */
|
||||||
|
if (DfuInterface->VendorDownloadCMD(hdfu->buffer.d8, hdfu->wblock_num,
|
||||||
|
hdfu->wlength, &VendorStatus) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
return (uint8_t)USBD_FAIL;
|
return (uint8_t)USBD_FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return (uint8_t)USBD_FAIL;
|
/* Reset the block number */
|
||||||
|
hdfu->wblock_num = 0U;
|
||||||
|
|
||||||
|
/* Call the error management function (command will be NAKed) */
|
||||||
|
req.bmRequest = 0U;
|
||||||
|
req.wLength = 1U;
|
||||||
|
USBD_CtlError(pdev, &req);
|
||||||
}
|
}
|
||||||
}
|
#else
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Reset the global length and block number */
|
/* Reset the global length and block number */
|
||||||
hdfu->wlength = 0U;
|
hdfu->wlength = 0U;
|
||||||
hdfu->wblock_num = 0U;
|
hdfu->wblock_num = 0U;
|
||||||
|
|
||||||
/* Call the error management function (command will be NAKed) */
|
/* Call the error management function (command will be NAKed) */
|
||||||
req.bmRequest = 0U;
|
req.bmRequest = 0U;
|
||||||
req.wLength = 1U;
|
req.wLength = 1U;
|
||||||
USBD_CtlError(pdev, &req);
|
USBD_CtlError(pdev, &req);
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Regular Download Command */
|
/* Regular Download Command */
|
||||||
@@ -584,12 +705,33 @@ static uint8_t USBD_DFU_EP0_TxReady(USBD_HandleTypeDef *pdev)
|
|||||||
{
|
{
|
||||||
if (hdfu->wblock_num > 1U)
|
if (hdfu->wblock_num > 1U)
|
||||||
{
|
{
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
if (DfuInterface->VendorCheck(hdfu->buffer.d8, IS_DFU_DOWNLOAD, &VendorStatus) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
|
||||||
/* Decode the required address */
|
/* Decode the required address */
|
||||||
addr = ((hdfu->wblock_num - 2U) * USBD_DFU_XFER_SIZE) + hdfu->data_ptr;
|
addr = ((hdfu->wblock_num - 2U) * USBD_DFU_XFER_SIZE) + hdfu->data_ptr;
|
||||||
|
|
||||||
/* Perform the write operation */
|
/* Perform the write operation */
|
||||||
if (DfuInterface->Write(hdfu->buffer.d8, (uint8_t *)addr, hdfu->wlength) != USBD_OK)
|
if (DfuInterface->Write(hdfu->buffer.d8, (uint8_t *)addr, hdfu->wlength) != USBD_OK)
|
||||||
{
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = DFU_ERROR_VENDOR;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
return (uint8_t)USBD_FAIL;
|
return (uint8_t)USBD_FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -670,7 +812,7 @@ static uint8_t *USBD_DFU_GetUsrStringDesc(USBD_HandleTypeDef *pdev, uint8_t inde
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Not supported Interface Descriptor index */
|
/* Not supported Interface Descriptor index */
|
||||||
length = 0U;
|
*length = 0U;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -758,6 +900,11 @@ static void DFU_Download(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
{
|
{
|
||||||
USBD_DFU_HandleTypeDef *hdfu = (USBD_DFU_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_DFU_HandleTypeDef *hdfu = (USBD_DFU_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
USBD_DFU_MediaTypeDef *DfuInterface = (USBD_DFU_MediaTypeDef *)pdev->pUserData[pdev->classId];
|
||||||
|
uint32_t VendorStatus = 0U;
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
|
||||||
if (hdfu == NULL)
|
if (hdfu == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -789,15 +936,36 @@ static void DFU_Download(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
/* 0 Data DNLOAD request */
|
/* 0 Data DNLOAD request */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* End of DNLOAD operation*/
|
/* End of DNLOAD operation */
|
||||||
if ((hdfu->dev_state == DFU_STATE_DNLOAD_IDLE) || (hdfu->dev_state == DFU_STATE_IDLE))
|
if ((hdfu->dev_state == DFU_STATE_DNLOAD_IDLE) || (hdfu->dev_state == DFU_STATE_IDLE))
|
||||||
{
|
{
|
||||||
hdfu->manif_state = DFU_MANIFEST_IN_PROGRESS;
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
hdfu->dev_state = DFU_STATE_MANIFEST_SYNC;
|
/* Fill the buffer to be checked with the address stored in data buffer */
|
||||||
hdfu->dev_status[1] = 0U;
|
hdfu->buffer.d8[1] = (uint8_t)(hdfu->data_ptr & 0xFFU);
|
||||||
hdfu->dev_status[2] = 0U;
|
hdfu->buffer.d8[2] = (uint8_t)((hdfu->data_ptr & 0xFF00U) >> 8U);
|
||||||
hdfu->dev_status[3] = 0U;
|
hdfu->buffer.d8[3] = (uint8_t)((hdfu->data_ptr & 0xFF0000U) >> 16U);
|
||||||
hdfu->dev_status[4] = hdfu->dev_state;
|
hdfu->buffer.d8[4] = (uint8_t)((hdfu->data_ptr & 0xFF000000U) >> 24U);
|
||||||
|
|
||||||
|
if (DfuInterface->VendorCheck(hdfu->buffer.d8, IS_DFU_SETADDRESSPOINTER, &VendorStatus) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
{
|
||||||
|
hdfu->manif_state = DFU_MANIFEST_IN_PROGRESS;
|
||||||
|
hdfu->dev_state = DFU_STATE_MANIFEST_SYNC;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -820,6 +988,13 @@ static void DFU_Upload(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
USBD_DFU_MediaTypeDef *DfuInterface = (USBD_DFU_MediaTypeDef *)pdev->pUserData[pdev->classId];
|
USBD_DFU_MediaTypeDef *DfuInterface = (USBD_DFU_MediaTypeDef *)pdev->pUserData[pdev->classId];
|
||||||
uint8_t *phaddr;
|
uint8_t *phaddr;
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
|
uint32_t CmdLength;
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
uint32_t VendorStatus = 0U;
|
||||||
|
uint8_t VendorCmdLength = 0U;
|
||||||
|
uint8_t VendorCmdBuffer[DFU_VENDOR_CMD_MAX];
|
||||||
|
uint8_t idx;
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
|
||||||
if (hdfu == NULL)
|
if (hdfu == NULL)
|
||||||
{
|
{
|
||||||
@@ -851,8 +1026,24 @@ static void DFU_Upload(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
hdfu->buffer.d8[1] = DFU_CMD_SETADDRESSPOINTER;
|
hdfu->buffer.d8[1] = DFU_CMD_SETADDRESSPOINTER;
|
||||||
hdfu->buffer.d8[2] = DFU_CMD_ERASE;
|
hdfu->buffer.d8[2] = DFU_CMD_ERASE;
|
||||||
|
|
||||||
|
CmdLength = 3U;
|
||||||
|
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
if (DfuInterface->GetVendorCMD != NULL)
|
||||||
|
{
|
||||||
|
(void)DfuInterface->GetVendorCMD(VendorCmdBuffer, (uint8_t *)&VendorCmdLength);
|
||||||
|
|
||||||
|
for (idx = 0U; idx < MIN(VendorCmdLength, DFU_VENDOR_CMD_MAX); idx++)
|
||||||
|
{
|
||||||
|
hdfu->buffer.d8[idx + 3U] = VendorCmdBuffer[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
CmdLength += MIN(VendorCmdLength, DFU_VENDOR_CMD_MAX);
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
|
||||||
/* Send the status data over EP0 */
|
/* Send the status data over EP0 */
|
||||||
(void)USBD_CtlSendData(pdev, (uint8_t *)(&(hdfu->buffer.d8[0])), 3U);
|
(void)USBD_CtlSendData(pdev, (uint8_t *)(&(hdfu->buffer.d8[0])), CmdLength);
|
||||||
}
|
}
|
||||||
else if (hdfu->wblock_num > 1U)
|
else if (hdfu->wblock_num > 1U)
|
||||||
{
|
{
|
||||||
@@ -863,13 +1054,48 @@ static void DFU_Upload(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
hdfu->dev_status[3] = 0U;
|
hdfu->dev_status[3] = 0U;
|
||||||
hdfu->dev_status[4] = hdfu->dev_state;
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
|
||||||
addr = ((hdfu->wblock_num - 2U) * USBD_DFU_XFER_SIZE) + hdfu->data_ptr;
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
/* Vendor specific DFU CMD */
|
||||||
|
if (DfuInterface->VendorUploadCMD(hdfu->data_ptr, hdfu->wblock_num, &VendorStatus) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_ERROR_STALLEDPKT;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
|
||||||
/* Return the physical address where data are stored */
|
/* Call the error management function (command will be NAKed) */
|
||||||
phaddr = DfuInterface->Read((uint8_t *)addr, hdfu->buffer.d8, hdfu->wlength);
|
USBD_CtlError(pdev, req);
|
||||||
|
}
|
||||||
|
|
||||||
/* Send the status data over EP0 */
|
if (VendorStatus == IS_DFU_PHY_ADDRESS)
|
||||||
(void)USBD_CtlSendData(pdev, phaddr, hdfu->wlength);
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
{
|
||||||
|
addr = ((hdfu->wblock_num - 2U) * USBD_DFU_XFER_SIZE) + hdfu->data_ptr;
|
||||||
|
|
||||||
|
/* Return the physical address where data are stored */
|
||||||
|
phaddr = DfuInterface->Read((uint8_t *)addr, hdfu->buffer.d8, hdfu->wlength);
|
||||||
|
|
||||||
|
if (phaddr == NULL)
|
||||||
|
{
|
||||||
|
hdfu->dev_state = DFU_ERROR_STALLEDPKT;
|
||||||
|
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
|
||||||
|
/* Call the error management function (command will be NAKed) */
|
||||||
|
USBD_CtlError(pdev, req);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Send the status data over EP0 */
|
||||||
|
(void)USBD_CtlSendData(pdev, phaddr, hdfu->wlength);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else /* unsupported hdfu->wblock_num */
|
else /* unsupported hdfu->wblock_num */
|
||||||
{
|
{
|
||||||
@@ -880,7 +1106,7 @@ static void DFU_Upload(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
hdfu->dev_status[3] = 0U;
|
hdfu->dev_status[3] = 0U;
|
||||||
hdfu->dev_status[4] = hdfu->dev_state;
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
|
||||||
/* Call the error management function (command will be NAKed */
|
/* Call the error management function (command will be NAKed) */
|
||||||
USBD_CtlError(pdev, req);
|
USBD_CtlError(pdev, req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -890,7 +1116,7 @@ static void DFU_Upload(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
hdfu->wlength = 0U;
|
hdfu->wlength = 0U;
|
||||||
hdfu->wblock_num = 0U;
|
hdfu->wblock_num = 0U;
|
||||||
|
|
||||||
/* Call the error management function (command will be NAKed */
|
/* Call the error management function (command will be NAKed) */
|
||||||
USBD_CtlError(pdev, req);
|
USBD_CtlError(pdev, req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -944,7 +1170,7 @@ static void DFU_GetStatus(USBD_HandleTypeDef *pdev)
|
|||||||
DfuInterface->GetStatus(hdfu->data_ptr, DFU_MEDIA_PROGRAM, hdfu->dev_status);
|
DfuInterface->GetStatus(hdfu->data_ptr, DFU_MEDIA_PROGRAM, hdfu->dev_status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else /* (hdfu->wlength==0)*/
|
else /* (hdfu->wlength == 0U) */
|
||||||
{
|
{
|
||||||
hdfu->dev_state = DFU_STATE_DNLOAD_IDLE;
|
hdfu->dev_state = DFU_STATE_DNLOAD_IDLE;
|
||||||
|
|
||||||
@@ -960,7 +1186,7 @@ static void DFU_GetStatus(USBD_HandleTypeDef *pdev)
|
|||||||
{
|
{
|
||||||
hdfu->dev_state = DFU_STATE_MANIFEST;
|
hdfu->dev_state = DFU_STATE_MANIFEST;
|
||||||
|
|
||||||
hdfu->dev_status[1] = 1U; /*bwPollTimeout = 1ms*/
|
hdfu->dev_status[1] = 1U; /* bwPollTimeout = 1ms */
|
||||||
hdfu->dev_status[2] = 0U;
|
hdfu->dev_status[2] = 0U;
|
||||||
hdfu->dev_status[3] = 0U;
|
hdfu->dev_status[3] = 0U;
|
||||||
hdfu->dev_status[4] = hdfu->dev_state;
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
@@ -1088,9 +1314,10 @@ static void DFU_Abort(USBD_HandleTypeDef *pdev)
|
|||||||
static void DFU_Leave(USBD_HandleTypeDef *pdev)
|
static void DFU_Leave(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
USBD_DFU_HandleTypeDef *hdfu = (USBD_DFU_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_DFU_HandleTypeDef *hdfu = (USBD_DFU_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
USBD_DFU_MediaTypeDef *DfuInterface = (USBD_DFU_MediaTypeDef *)pdev->pUserData[pdev->classId];
|
||||||
USBD_DFUFuncDescTypeDef *pDfuFunc = (USBD_DFUFuncDescTypeDef *)USBD_DFU_GetDfuFuncDesc(pdev->pConfDesc);
|
USBD_DFUFuncDescTypeDef *pDfuFunc = (USBD_DFUFuncDescTypeDef *)USBD_DFU_GetDfuFuncDesc(pdev->pConfDesc);
|
||||||
|
|
||||||
if ((hdfu == NULL) || (pDfuFunc == NULL))
|
if ((hdfu == NULL) || (DfuInterface == NULL) || (pDfuFunc == NULL))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1119,8 +1346,13 @@ static void DFU_Leave(USBD_HandleTypeDef *pdev)
|
|||||||
/* Disconnect the USB device */
|
/* Disconnect the USB device */
|
||||||
(void)USBD_Stop(pdev);
|
(void)USBD_Stop(pdev);
|
||||||
|
|
||||||
|
#if (USBD_DFU_VENDOR_EXIT_ENABLED == 1U)
|
||||||
|
/* Jump should be ensured by user application */
|
||||||
|
DfuInterface->LeaveDFU(hdfu->data_ptr);
|
||||||
|
#else
|
||||||
/* Generate system reset to allow jumping to the user code */
|
/* Generate system reset to allow jumping to the user code */
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
|
#endif /* USBD_DFU_VENDOR_EXIT_ENABLED */
|
||||||
|
|
||||||
/* The next instructions will not be reached (system reset) */
|
/* The next instructions will not be reached (system reset) */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,17 @@ uint16_t MEM_If_Write(uint8_t *src, uint8_t *dest, uint32_t Len);
|
|||||||
uint8_t *MEM_If_Read(uint8_t *src, uint8_t *dest, uint32_t Len);
|
uint8_t *MEM_If_Read(uint8_t *src, uint8_t *dest, uint32_t Len);
|
||||||
uint16_t MEM_If_DeInit(void);
|
uint16_t MEM_If_DeInit(void);
|
||||||
uint16_t MEM_If_GetStatus(uint32_t Add, uint8_t Cmd, uint8_t *buffer);
|
uint16_t MEM_If_GetStatus(uint32_t Add, uint8_t Cmd, uint8_t *buffer);
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
uint16_t MEM_If_GetVendorCMD(uint8_t *cmd, uint8_t *cmdlength);
|
||||||
|
uint16_t MEM_If_VendorDownloadCMD(uint8_t *pbuf, uint32_t BlockNumber, uint32_t wlength, uint32_t *status);
|
||||||
|
uint16_t MEM_If_VendorUploadCMD(uint32_t Add, uint32_t BlockNumber, uint32_t *status);
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
uint16_t MEM_If_VendorCheck(uint8_t *pbuf, uint32_t ReqType, uint32_t *status);
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
#if (USBD_DFU_VENDOR_EXIT_ENABLED == 1U)
|
||||||
|
uint16_t MEM_If_LeaveDFU(uint32_t Add);
|
||||||
|
#endif /* USBD_DFU_VENDOR_EXIT_ENABLED */
|
||||||
|
|
||||||
USBD_DFU_MediaTypeDef USBD_DFU_MEDIA_Template_fops =
|
USBD_DFU_MediaTypeDef USBD_DFU_MEDIA_Template_fops =
|
||||||
{
|
{
|
||||||
@@ -48,8 +59,19 @@ USBD_DFU_MediaTypeDef USBD_DFU_MEDIA_Template_fops =
|
|||||||
MEM_If_Write,
|
MEM_If_Write,
|
||||||
MEM_If_Read,
|
MEM_If_Read,
|
||||||
MEM_If_GetStatus,
|
MEM_If_GetStatus,
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
MEM_If_GetVendorCMD,
|
||||||
|
MEM_If_VendorDownloadCMD,
|
||||||
|
MEM_If_VendorUploadCMD,
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
MEM_If_VendorCheck,
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
#if (USBD_DFU_VENDOR_EXIT_ENABLED == 1U)
|
||||||
|
MEM_If_LeaveDFU
|
||||||
|
#endif /* USBD_DFU_VENDOR_EXIT_ENABLED */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief MEM_If_Init
|
* @brief MEM_If_Init
|
||||||
* Memory initialization routine.
|
* Memory initialization routine.
|
||||||
@@ -115,7 +137,7 @@ uint8_t *MEM_If_Read(uint8_t *src, uint8_t *dest, uint32_t Len)
|
|||||||
UNUSED(Len);
|
UNUSED(Len);
|
||||||
|
|
||||||
/* Return a valid address to avoid HardFault */
|
/* Return a valid address to avoid HardFault */
|
||||||
return (uint8_t *)(0);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,3 +166,85 @@ uint16_t MEM_If_GetStatus(uint32_t Add, uint8_t Cmd, uint8_t *buffer)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
/**
|
||||||
|
* @brief Get supported vendor specific commands
|
||||||
|
* @param pointer to supported vendor commands
|
||||||
|
* @param pointer to length of supported vendor commands
|
||||||
|
* @retval 0 if operation is successful
|
||||||
|
*/
|
||||||
|
uint16_t MEM_If_GetVendorCMD(uint8_t *cmd, uint8_t *cmdlength)
|
||||||
|
{
|
||||||
|
UNUSED(cmd);
|
||||||
|
UNUSED(cmdlength);
|
||||||
|
|
||||||
|
return 0U;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Vendor specific download commands
|
||||||
|
* @param pbuf DFU data buffer
|
||||||
|
* @param BlockNumber DFU memory block number
|
||||||
|
* @param wLength DFU request length
|
||||||
|
* @param pointer to DFU status
|
||||||
|
* @retval 0 if operation is successful
|
||||||
|
*/
|
||||||
|
uint16_t MEM_If_VendorDownloadCMD(uint8_t *pbuf, uint32_t BlockNumber, uint32_t wlength, uint32_t *status)
|
||||||
|
{
|
||||||
|
UNUSED(pbuf);
|
||||||
|
UNUSED(BlockNumber);
|
||||||
|
UNUSED(wlength);
|
||||||
|
UNUSED(status);
|
||||||
|
|
||||||
|
return 0U;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Vendor specific upload commands
|
||||||
|
* @param Add memory Address
|
||||||
|
* @param BlockNumber DFU memory block number
|
||||||
|
* @param pointer to DFU status
|
||||||
|
* @retval 0 if operation is successful
|
||||||
|
*/
|
||||||
|
uint16_t MEM_If_VendorUploadCMD(uint32_t Add, uint32_t BlockNumber, uint32_t *status)
|
||||||
|
{
|
||||||
|
UNUSED(Add);
|
||||||
|
UNUSED(BlockNumber);
|
||||||
|
UNUSED(status);
|
||||||
|
|
||||||
|
return 0U;
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
/**
|
||||||
|
* @brief Vendor memory check
|
||||||
|
* @param pbuf DFU data buffer
|
||||||
|
* @param ReqType IS_DFU_SETADDRESSPOINTER/DOWNLOAD/UPLOAD
|
||||||
|
* @param pointer to DFU status
|
||||||
|
* @retval 0 if operation is successful
|
||||||
|
*/
|
||||||
|
uint16_t MEM_If_VendorCheck(uint8_t *pbuf, uint32_t ReqType, uint32_t *status)
|
||||||
|
{
|
||||||
|
UNUSED(pbuf);
|
||||||
|
UNUSED(ReqType);
|
||||||
|
UNUSED(status);
|
||||||
|
|
||||||
|
return 0U;
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
|
||||||
|
#if (USBD_DFU_VENDOR_EXIT_ENABLED == 1U)
|
||||||
|
/**
|
||||||
|
* @brief Vendor Leave DFU
|
||||||
|
* @param Application address
|
||||||
|
* @retval 0 if operation is successful
|
||||||
|
*/
|
||||||
|
uint16_t MEM_If_LeaveDFU(uint32_t Add)
|
||||||
|
{
|
||||||
|
UNUSED(Add);
|
||||||
|
|
||||||
|
return 0U;
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_EXIT_ENABLED */
|
||||||
|
|||||||
@@ -128,6 +128,9 @@ USBD_ClassTypeDef USBD_HID =
|
|||||||
USBD_HID_GetOtherSpeedCfgDesc,
|
USBD_HID_GetOtherSpeedCfgDesc,
|
||||||
USBD_HID_GetDeviceQualifierDesc,
|
USBD_HID_GetDeviceQualifierDesc,
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
|
||||||
|
NULL,
|
||||||
|
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef USE_USBD_COMPOSITE
|
#ifndef USE_USBD_COMPOSITE
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ extern "C" {
|
|||||||
#define MSC_EPOUT_ADDR 0x01U
|
#define MSC_EPOUT_ADDR 0x01U
|
||||||
#endif /* MSC_EPOUT_ADDR */
|
#endif /* MSC_EPOUT_ADDR */
|
||||||
|
|
||||||
|
#ifndef MSC_BOT_MAX_LUN
|
||||||
|
#define MSC_BOT_MAX_LUN 0x2U
|
||||||
|
#endif /* MSC_BOT_MAX_LUN */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
@@ -82,6 +86,13 @@ typedef struct _USBD_STORAGE
|
|||||||
|
|
||||||
} USBD_StorageTypeDef;
|
} USBD_StorageTypeDef;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t size;
|
||||||
|
uint32_t nbr;
|
||||||
|
uint32_t addr;
|
||||||
|
uint32_t len;
|
||||||
|
} USBD_MSC_BOT_LUN_TypeDef;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -99,11 +110,7 @@ typedef struct
|
|||||||
uint8_t scsi_sense_tail;
|
uint8_t scsi_sense_tail;
|
||||||
uint8_t scsi_medium_state;
|
uint8_t scsi_medium_state;
|
||||||
|
|
||||||
uint16_t scsi_blk_size;
|
USBD_MSC_BOT_LUN_TypeDef scsi_blk[MSC_BOT_MAX_LUN];
|
||||||
uint32_t scsi_blk_nbr;
|
|
||||||
|
|
||||||
uint32_t scsi_blk_addr;
|
|
||||||
uint32_t scsi_blk_len;
|
|
||||||
} USBD_MSC_BOT_HandleTypeDef;
|
} USBD_MSC_BOT_HandleTypeDef;
|
||||||
|
|
||||||
/* Structure for MSC process */
|
/* Structure for MSC process */
|
||||||
|
|||||||
@@ -39,11 +39,13 @@ extern "C" {
|
|||||||
/** @defgroup USB_INFO_Exported_Defines
|
/** @defgroup USB_INFO_Exported_Defines
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define MODE_SENSE6_LEN 0x17U
|
#define MODE_SENSE6_LEN 0x04U
|
||||||
#define MODE_SENSE10_LEN 0x1BU
|
#define MODE_SENSE10_LEN 0x08U
|
||||||
#define LENGTH_INQUIRY_PAGE00 0x06U
|
#define LENGTH_INQUIRY_PAGE00 0x06U
|
||||||
#define LENGTH_INQUIRY_PAGE80 0x08U
|
#define LENGTH_INQUIRY_PAGE80 0x08U
|
||||||
#define LENGTH_FORMAT_CAPACITIES 0x14U
|
#define LENGTH_FORMAT_CAPACITIES 0x14U
|
||||||
|
#define DIAGNOSTIC_DATA_LEN 0x08U
|
||||||
|
#define LOG_PAGE_DATA_LEN 0x10U
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
@@ -74,6 +76,8 @@ extern uint8_t MSC_Page00_Inquiry_Data[LENGTH_INQUIRY_PAGE00];
|
|||||||
extern uint8_t MSC_Page80_Inquiry_Data[LENGTH_INQUIRY_PAGE80];
|
extern uint8_t MSC_Page80_Inquiry_Data[LENGTH_INQUIRY_PAGE80];
|
||||||
extern uint8_t MSC_Mode_Sense6_data[MODE_SENSE6_LEN];
|
extern uint8_t MSC_Mode_Sense6_data[MODE_SENSE6_LEN];
|
||||||
extern uint8_t MSC_Mode_Sense10_data[MODE_SENSE10_LEN];
|
extern uint8_t MSC_Mode_Sense10_data[MODE_SENSE10_LEN];
|
||||||
|
extern uint8_t MSC_Diagnostic_Data[DIAGNOSTIC_DATA_LEN];
|
||||||
|
extern uint8_t MSC_Log_Page_Data[LOG_PAGE_DATA_LEN];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
|
|||||||
@@ -70,8 +70,10 @@ extern "C" {
|
|||||||
#define SCSI_VERIFY12 0xAFU
|
#define SCSI_VERIFY12 0xAFU
|
||||||
#define SCSI_VERIFY16 0x8FU
|
#define SCSI_VERIFY16 0x8FU
|
||||||
|
|
||||||
#define SCSI_SEND_DIAGNOSTIC 0x1DU
|
|
||||||
#define SCSI_READ_FORMAT_CAPACITIES 0x23U
|
#define SCSI_READ_FORMAT_CAPACITIES 0x23U
|
||||||
|
#define SCSI_RECEIVE_DIAGNOSTIC_RESULTS 0x1CU
|
||||||
|
#define SCSI_SEND_DIAGNOSTIC 0x1DU
|
||||||
|
#define SCSI_REPORT_LUNS 0xA0U
|
||||||
|
|
||||||
#define NO_SENSE 0U
|
#define NO_SENSE 0U
|
||||||
#define RECOVERED_ERROR 1U
|
#define RECOVERED_ERROR 1U
|
||||||
@@ -88,9 +90,8 @@ extern "C" {
|
|||||||
#define VOLUME_OVERFLOW 13U
|
#define VOLUME_OVERFLOW 13U
|
||||||
#define MISCOMPARE 14U
|
#define MISCOMPARE 14U
|
||||||
|
|
||||||
|
|
||||||
#define INVALID_CDB 0x20U
|
#define INVALID_CDB 0x20U
|
||||||
#define INVALID_FIELED_IN_COMMAND 0x24U
|
#define INVALID_FIELD_IN_COMMAND 0x24U
|
||||||
#define PARAMETER_LIST_LENGTH_ERROR 0x1AU
|
#define PARAMETER_LIST_LENGTH_ERROR 0x1AU
|
||||||
#define INVALID_FIELD_IN_PARAMETER_LIST 0x26U
|
#define INVALID_FIELD_IN_PARAMETER_LIST 0x26U
|
||||||
#define ADDRESS_OUT_OF_RANGE 0x21U
|
#define ADDRESS_OUT_OF_RANGE 0x21U
|
||||||
|
|||||||
@@ -125,6 +125,9 @@ USBD_ClassTypeDef USBD_MSC =
|
|||||||
USBD_MSC_GetOtherSpeedCfgDesc,
|
USBD_MSC_GetOtherSpeedCfgDesc,
|
||||||
USBD_MSC_GetDeviceQualifierDescriptor,
|
USBD_MSC_GetDeviceQualifierDescriptor,
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
|
||||||
|
NULL,
|
||||||
|
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* USB Mass storage device Configuration Descriptor */
|
/* USB Mass storage device Configuration Descriptor */
|
||||||
@@ -309,6 +312,7 @@ uint8_t USBD_MSC_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
{
|
{
|
||||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
USBD_StatusTypeDef ret = USBD_OK;
|
USBD_StatusTypeDef ret = USBD_OK;
|
||||||
|
uint32_t max_lun;
|
||||||
uint16_t status_info = 0U;
|
uint16_t status_info = 0U;
|
||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
@@ -332,7 +336,8 @@ uint8_t USBD_MSC_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
if ((req->wValue == 0U) && (req->wLength == 1U) &&
|
if ((req->wValue == 0U) && (req->wLength == 1U) &&
|
||||||
((req->bmRequest & 0x80U) == 0x80U))
|
((req->bmRequest & 0x80U) == 0x80U))
|
||||||
{
|
{
|
||||||
hmsc->max_lun = (uint32_t)((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->GetMaxLun();
|
max_lun = (uint32_t)((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->GetMaxLun();
|
||||||
|
hmsc->max_lun = (max_lun > MSC_BOT_MAX_LUN) ? MSC_BOT_MAX_LUN : max_lun;
|
||||||
(void)USBD_CtlSendData(pdev, (uint8_t *)&hmsc->max_lun, 1U);
|
(void)USBD_CtlSendData(pdev, (uint8_t *)&hmsc->max_lun, 1U);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ static void MSC_BOT_CBW_Decode(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
if ((USBD_LL_GetRxDataSize(pdev, MSCOutEpAdd) != USBD_BOT_CBW_LENGTH) ||
|
if ((USBD_LL_GetRxDataSize(pdev, MSCOutEpAdd) != USBD_BOT_CBW_LENGTH) ||
|
||||||
(hmsc->cbw.dSignature != USBD_BOT_CBW_SIGNATURE) ||
|
(hmsc->cbw.dSignature != USBD_BOT_CBW_SIGNATURE) ||
|
||||||
(hmsc->cbw.bLUN > 1U) || (hmsc->cbw.bCBLength < 1U) ||
|
(hmsc->cbw.bLUN > hmsc->max_lun) || (hmsc->cbw.bCBLength < 1U) ||
|
||||||
(hmsc->cbw.bCBLength > 16U))
|
(hmsc->cbw.bCBLength > 16U))
|
||||||
{
|
{
|
||||||
SCSI_SenseCode(pdev, hmsc->cbw.bLUN, ILLEGAL_REQUEST, INVALID_CDB);
|
SCSI_SenseCode(pdev, hmsc->cbw.bLUN, ILLEGAL_REQUEST, INVALID_CDB);
|
||||||
|
|||||||
@@ -91,63 +91,46 @@ uint8_t MSC_Page80_Inquiry_Data[LENGTH_INQUIRY_PAGE80] =
|
|||||||
/* USB Mass storage sense 6 Data */
|
/* USB Mass storage sense 6 Data */
|
||||||
uint8_t MSC_Mode_Sense6_data[MODE_SENSE6_LEN] =
|
uint8_t MSC_Mode_Sense6_data[MODE_SENSE6_LEN] =
|
||||||
{
|
{
|
||||||
0x22,
|
0x03, /* MODE DATA LENGTH. The number of bytes that follow. */
|
||||||
0x00,
|
0x00, /* MEDIUM TYPE. 00h for SBC devices. */
|
||||||
0x00,
|
0x00, /* DEVICE-SPECIFIC PARAMETER. For SBC devices:
|
||||||
0x00,
|
* bit 7: WP. Set to 1 if the media is write-protected.
|
||||||
0x08,
|
* bits 6..5: reserved
|
||||||
0x12,
|
* bit 4: DPOFUA. Set to 1 if the device supports the DPO and FUA bits
|
||||||
0x00,
|
* bits 3..0: reserved */
|
||||||
0x00,
|
0x00 /* BLOCK DESCRIPTOR LENGTH */
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* USB Mass storage sense 10 Data */
|
/* USB Mass storage sense 10 Data */
|
||||||
uint8_t MSC_Mode_Sense10_data[MODE_SENSE10_LEN] =
|
uint8_t MSC_Mode_Sense10_data[MODE_SENSE10_LEN] =
|
||||||
{
|
{
|
||||||
0x00,
|
0x00, /* MODE DATA LENGTH MSB. */
|
||||||
0x26,
|
0x06, /* MODE DATA LENGTH LSB. The number of bytes that follow. */
|
||||||
0x00,
|
0x00, /* MEDIUM TYPE. 00h for SBC devices. */
|
||||||
0x00,
|
0x00, /* DEVICE-SPECIFIC PARAMETER. For SBC devices:
|
||||||
0x00,
|
* bit 7: WP. Set to 1 if the media is write-protected.
|
||||||
0x00,
|
* bits 6..5: reserved
|
||||||
0x00,
|
* bit 4: DPOFUA. Set to 1 if the device supports the DPO and FUA bits
|
||||||
0x00,
|
* bits 3..0: reserved */
|
||||||
0x08,
|
0x00, /* LONGLBA Set to zero */
|
||||||
0x12,
|
0x00, /* Reserved */
|
||||||
0x00,
|
0x00, /* BLOCK DESCRIPTOR LENGTH MSB. */
|
||||||
0x00,
|
0x00 /* BLOCK DESCRIPTOR LENGTH LSB. */
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
uint8_t MSC_Diagnostic_Data[DIAGNOSTIC_DATA_LEN] =
|
||||||
|
{
|
||||||
|
0x00, /* Byte 0: ADDITIONAL LENGTH (MSB) */
|
||||||
|
0x00, /* Byte 1: ADDITIONAL LENGTH (LSB) */
|
||||||
|
0x00, /* Byte 2: FRU CODE (most probable) */
|
||||||
|
0x00, /* Byte 3: FRU CODE */
|
||||||
|
0x00, /* Byte 4: FRU CODE */
|
||||||
|
0x00, /* Byte 5: FRU CODE (least probable) */
|
||||||
|
0x00, /* Byte 6: ERROR CODE (MSB) */
|
||||||
|
0x00, /* Byte 7: ERROR CODE (LSB) */
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ static int8_t SCSI_Write12(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *param
|
|||||||
static int8_t SCSI_Read10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
|
static int8_t SCSI_Read10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
|
||||||
static int8_t SCSI_Read12(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
|
static int8_t SCSI_Read12(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
|
||||||
static int8_t SCSI_Verify10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
|
static int8_t SCSI_Verify10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
|
||||||
|
static int8_t SCSI_ReportLuns(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
|
||||||
|
static int8_t SCSI_ReceiveDiagnosticResults(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
|
||||||
static int8_t SCSI_CheckAddressRange(USBD_HandleTypeDef *pdev, uint8_t lun,
|
static int8_t SCSI_CheckAddressRange(USBD_HandleTypeDef *pdev, uint8_t lun,
|
||||||
uint32_t blk_offset, uint32_t blk_nbr);
|
uint32_t blk_offset, uint32_t blk_nbr);
|
||||||
|
|
||||||
@@ -190,9 +192,16 @@ int8_t SCSI_ProcessCmd(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *cmd)
|
|||||||
ret = SCSI_Verify10(pdev, lun, cmd);
|
ret = SCSI_Verify10(pdev, lun, cmd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SCSI_REPORT_LUNS:
|
||||||
|
ret = SCSI_ReportLuns(pdev, lun, cmd);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SCSI_RECEIVE_DIAGNOSTIC_RESULTS:
|
||||||
|
ret = SCSI_ReceiveDiagnosticResults(pdev, lun, cmd);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
SCSI_SenseCode(pdev, lun, ILLEGAL_REQUEST, INVALID_CDB);
|
SCSI_SenseCode(pdev, lun, ILLEGAL_REQUEST, INVALID_CDB);
|
||||||
hmsc->bot_status = USBD_BOT_STATUS_ERROR;
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -283,7 +292,7 @@ static int8_t SCSI_Inquiry(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *param
|
|||||||
else /* Request Not supported */
|
else /* Request Not supported */
|
||||||
{
|
{
|
||||||
SCSI_SenseCode(pdev, hmsc->cbw.bLUN, ILLEGAL_REQUEST,
|
SCSI_SenseCode(pdev, hmsc->cbw.bLUN, ILLEGAL_REQUEST,
|
||||||
INVALID_FIELED_IN_COMMAND);
|
INVALID_FIELD_IN_COMMAND);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -319,14 +328,15 @@ static int8_t SCSI_ReadCapacity10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t
|
|||||||
UNUSED(params);
|
UNUSED(params);
|
||||||
int8_t ret;
|
int8_t ret;
|
||||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
USBD_MSC_BOT_LUN_TypeDef *p_scsi_blk = &hmsc->scsi_blk[lun];
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->GetCapacity(lun, &hmsc->scsi_blk_nbr,
|
ret = ((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->GetCapacity(lun, &p_scsi_blk->nbr,
|
||||||
&hmsc->scsi_blk_size);
|
&p_scsi_blk->size);
|
||||||
|
|
||||||
if ((ret != 0) || (hmsc->scsi_medium_state == SCSI_MEDIUM_EJECTED))
|
if ((ret != 0) || (hmsc->scsi_medium_state == SCSI_MEDIUM_EJECTED))
|
||||||
{
|
{
|
||||||
@@ -334,20 +344,19 @@ static int8_t SCSI_ReadCapacity10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
hmsc->bot_data[0] = (uint8_t)((hmsc->scsi_blk_nbr - 1U) >> 24);
|
hmsc->bot_data[0] = (uint8_t)((p_scsi_blk->nbr - 1U) >> 24);
|
||||||
hmsc->bot_data[1] = (uint8_t)((hmsc->scsi_blk_nbr - 1U) >> 16);
|
hmsc->bot_data[1] = (uint8_t)((p_scsi_blk->nbr - 1U) >> 16);
|
||||||
hmsc->bot_data[2] = (uint8_t)((hmsc->scsi_blk_nbr - 1U) >> 8);
|
hmsc->bot_data[2] = (uint8_t)((p_scsi_blk->nbr - 1U) >> 8);
|
||||||
hmsc->bot_data[3] = (uint8_t)(hmsc->scsi_blk_nbr - 1U);
|
hmsc->bot_data[3] = (uint8_t)(p_scsi_blk->nbr - 1U);
|
||||||
|
|
||||||
hmsc->bot_data[4] = (uint8_t)(hmsc->scsi_blk_size >> 24);
|
hmsc->bot_data[4] = (uint8_t)(p_scsi_blk->size >> 24);
|
||||||
hmsc->bot_data[5] = (uint8_t)(hmsc->scsi_blk_size >> 16);
|
hmsc->bot_data[5] = (uint8_t)(p_scsi_blk->size >> 16);
|
||||||
hmsc->bot_data[6] = (uint8_t)(hmsc->scsi_blk_size >> 8);
|
hmsc->bot_data[6] = (uint8_t)(p_scsi_blk->size >> 8);
|
||||||
hmsc->bot_data[7] = (uint8_t)(hmsc->scsi_blk_size);
|
hmsc->bot_data[7] = (uint8_t)(p_scsi_blk->size);
|
||||||
|
|
||||||
hmsc->bot_data_length = 8U;
|
hmsc->bot_data_length = 8U;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -364,14 +373,15 @@ static int8_t SCSI_ReadCapacity16(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t
|
|||||||
uint32_t idx;
|
uint32_t idx;
|
||||||
int8_t ret;
|
int8_t ret;
|
||||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
USBD_MSC_BOT_LUN_TypeDef *p_scsi_blk = &hmsc->scsi_blk[lun];
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->GetCapacity(lun, &hmsc->scsi_blk_nbr,
|
ret = ((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->GetCapacity(lun, &p_scsi_blk->nbr,
|
||||||
&hmsc->scsi_blk_size);
|
&p_scsi_blk->size);
|
||||||
|
|
||||||
if ((ret != 0) || (hmsc->scsi_medium_state == SCSI_MEDIUM_EJECTED))
|
if ((ret != 0) || (hmsc->scsi_medium_state == SCSI_MEDIUM_EJECTED))
|
||||||
{
|
{
|
||||||
@@ -389,15 +399,15 @@ static int8_t SCSI_ReadCapacity16(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t
|
|||||||
hmsc->bot_data[idx] = 0U;
|
hmsc->bot_data[idx] = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
hmsc->bot_data[4] = (uint8_t)((hmsc->scsi_blk_nbr - 1U) >> 24);
|
hmsc->bot_data[4] = (uint8_t)((p_scsi_blk->nbr - 1U) >> 24);
|
||||||
hmsc->bot_data[5] = (uint8_t)((hmsc->scsi_blk_nbr - 1U) >> 16);
|
hmsc->bot_data[5] = (uint8_t)((p_scsi_blk->nbr - 1U) >> 16);
|
||||||
hmsc->bot_data[6] = (uint8_t)((hmsc->scsi_blk_nbr - 1U) >> 8);
|
hmsc->bot_data[6] = (uint8_t)((p_scsi_blk->nbr - 1U) >> 8);
|
||||||
hmsc->bot_data[7] = (uint8_t)(hmsc->scsi_blk_nbr - 1U);
|
hmsc->bot_data[7] = (uint8_t)(p_scsi_blk->nbr - 1U);
|
||||||
|
|
||||||
hmsc->bot_data[8] = (uint8_t)(hmsc->scsi_blk_size >> 24);
|
hmsc->bot_data[8] = (uint8_t)(p_scsi_blk->size >> 24);
|
||||||
hmsc->bot_data[9] = (uint8_t)(hmsc->scsi_blk_size >> 16);
|
hmsc->bot_data[9] = (uint8_t)(p_scsi_blk->size >> 16);
|
||||||
hmsc->bot_data[10] = (uint8_t)(hmsc->scsi_blk_size >> 8);
|
hmsc->bot_data[10] = (uint8_t)(p_scsi_blk->size >> 8);
|
||||||
hmsc->bot_data[11] = (uint8_t)(hmsc->scsi_blk_size);
|
hmsc->bot_data[11] = (uint8_t)(p_scsi_blk->size);
|
||||||
|
|
||||||
hmsc->bot_data_length = ((uint32_t)params[10] << 24) |
|
hmsc->bot_data_length = ((uint32_t)params[10] << 24) |
|
||||||
((uint32_t)params[11] << 16) |
|
((uint32_t)params[11] << 16) |
|
||||||
@@ -477,6 +487,16 @@ static int8_t SCSI_ModeSense6(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *pa
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check If media is write-protected */
|
||||||
|
if (((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->IsWriteProtected(lun) != 0)
|
||||||
|
{
|
||||||
|
MSC_Mode_Sense6_data[2] |= (0x1U << 7); /* Set the WP (write protection) bit */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MSC_Mode_Sense10_data[2] &= ~(0x1U << 7); /* Clear the WP (write protection) bit */
|
||||||
|
}
|
||||||
|
|
||||||
if (params[4] <= len)
|
if (params[4] <= len)
|
||||||
{
|
{
|
||||||
len = params[4];
|
len = params[4];
|
||||||
@@ -506,6 +526,16 @@ static int8_t SCSI_ModeSense10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *p
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check If media is write-protected */
|
||||||
|
if (((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->IsWriteProtected(lun) != 0)
|
||||||
|
{
|
||||||
|
MSC_Mode_Sense10_data[3] |= (0x1U << 7); /* Set the WP (write protection) bit */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MSC_Mode_Sense10_data[3] &= ~(0x1U << 7); /* Clear the WP (write protection) bit */
|
||||||
|
}
|
||||||
|
|
||||||
if (params[8] <= len)
|
if (params[8] <= len)
|
||||||
{
|
{
|
||||||
len = params[8];
|
len = params[8];
|
||||||
@@ -623,7 +653,7 @@ static int8_t SCSI_StartStopUnit(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t
|
|||||||
|
|
||||||
if ((hmsc->scsi_medium_state == SCSI_MEDIUM_LOCKED) && ((params[4] & 0x3U) == 2U))
|
if ((hmsc->scsi_medium_state == SCSI_MEDIUM_LOCKED) && ((params[4] & 0x3U) == 2U))
|
||||||
{
|
{
|
||||||
SCSI_SenseCode(pdev, lun, ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
SCSI_SenseCode(pdev, lun, ILLEGAL_REQUEST, INVALID_FIELD_IN_COMMAND);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -692,6 +722,7 @@ static int8_t SCSI_AllowPreventRemovable(USBD_HandleTypeDef *pdev, uint8_t lun,
|
|||||||
static int8_t SCSI_Read10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params)
|
static int8_t SCSI_Read10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params)
|
||||||
{
|
{
|
||||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
USBD_MSC_BOT_LUN_TypeDef *p_scsi_blk = &hmsc->scsi_blk[lun];
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
{
|
{
|
||||||
@@ -720,21 +751,20 @@ static int8_t SCSI_Read10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
hmsc->scsi_blk_addr = ((uint32_t)params[2] << 24) |
|
p_scsi_blk->addr = ((uint32_t)params[2] << 24) |
|
||||||
((uint32_t)params[3] << 16) |
|
((uint32_t)params[3] << 16) |
|
||||||
((uint32_t)params[4] << 8) |
|
((uint32_t)params[4] << 8) |
|
||||||
(uint32_t)params[5];
|
(uint32_t)params[5];
|
||||||
|
|
||||||
hmsc->scsi_blk_len = ((uint32_t)params[7] << 8) | (uint32_t)params[8];
|
p_scsi_blk->len = ((uint32_t)params[7] << 8) | (uint32_t)params[8];
|
||||||
|
|
||||||
if (SCSI_CheckAddressRange(pdev, lun, hmsc->scsi_blk_addr,
|
if (SCSI_CheckAddressRange(pdev, lun, p_scsi_blk->addr, p_scsi_blk->len) < 0)
|
||||||
hmsc->scsi_blk_len) < 0)
|
|
||||||
{
|
{
|
||||||
return -1; /* error */
|
return -1; /* error */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cases 4,5 : Hi <> Dn */
|
/* cases 4,5 : Hi <> Dn */
|
||||||
if (hmsc->cbw.dDataLength != (hmsc->scsi_blk_len * hmsc->scsi_blk_size))
|
if (hmsc->cbw.dDataLength != (p_scsi_blk->len * p_scsi_blk->size))
|
||||||
{
|
{
|
||||||
SCSI_SenseCode(pdev, hmsc->cbw.bLUN, ILLEGAL_REQUEST, INVALID_CDB);
|
SCSI_SenseCode(pdev, hmsc->cbw.bLUN, ILLEGAL_REQUEST, INVALID_CDB);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -758,6 +788,7 @@ static int8_t SCSI_Read10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params
|
|||||||
static int8_t SCSI_Read12(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params)
|
static int8_t SCSI_Read12(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params)
|
||||||
{
|
{
|
||||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
USBD_MSC_BOT_LUN_TypeDef *p_scsi_blk = &hmsc->scsi_blk[lun];
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
{
|
{
|
||||||
@@ -785,24 +816,23 @@ static int8_t SCSI_Read12(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
hmsc->scsi_blk_addr = ((uint32_t)params[2] << 24) |
|
p_scsi_blk->addr = ((uint32_t)params[2] << 24) |
|
||||||
((uint32_t)params[3] << 16) |
|
((uint32_t)params[3] << 16) |
|
||||||
((uint32_t)params[4] << 8) |
|
((uint32_t)params[4] << 8) |
|
||||||
(uint32_t)params[5];
|
(uint32_t)params[5];
|
||||||
|
|
||||||
hmsc->scsi_blk_len = ((uint32_t)params[6] << 24) |
|
p_scsi_blk->len = ((uint32_t)params[6] << 24) |
|
||||||
((uint32_t)params[7] << 16) |
|
((uint32_t)params[7] << 16) |
|
||||||
((uint32_t)params[8] << 8) |
|
((uint32_t)params[8] << 8) |
|
||||||
(uint32_t)params[9];
|
(uint32_t)params[9];
|
||||||
|
|
||||||
if (SCSI_CheckAddressRange(pdev, lun, hmsc->scsi_blk_addr,
|
if (SCSI_CheckAddressRange(pdev, lun, p_scsi_blk->addr, p_scsi_blk->len) < 0)
|
||||||
hmsc->scsi_blk_len) < 0)
|
|
||||||
{
|
{
|
||||||
return -1; /* error */
|
return -1; /* error */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cases 4,5 : Hi <> Dn */
|
/* cases 4,5 : Hi <> Dn */
|
||||||
if (hmsc->cbw.dDataLength != (hmsc->scsi_blk_len * hmsc->scsi_blk_size))
|
if (hmsc->cbw.dDataLength != (p_scsi_blk->len * p_scsi_blk->size))
|
||||||
{
|
{
|
||||||
SCSI_SenseCode(pdev, hmsc->cbw.bLUN, ILLEGAL_REQUEST, INVALID_CDB);
|
SCSI_SenseCode(pdev, hmsc->cbw.bLUN, ILLEGAL_REQUEST, INVALID_CDB);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -826,6 +856,7 @@ static int8_t SCSI_Read12(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params
|
|||||||
static int8_t SCSI_Write10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params)
|
static int8_t SCSI_Write10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params)
|
||||||
{
|
{
|
||||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
USBD_MSC_BOT_LUN_TypeDef *p_scsi_blk = &hmsc->scsi_blk[lun];
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
@@ -867,22 +898,21 @@ static int8_t SCSI_Write10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *param
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
hmsc->scsi_blk_addr = ((uint32_t)params[2] << 24) |
|
p_scsi_blk->addr = ((uint32_t)params[2] << 24) |
|
||||||
((uint32_t)params[3] << 16) |
|
((uint32_t)params[3] << 16) |
|
||||||
((uint32_t)params[4] << 8) |
|
((uint32_t)params[4] << 8) |
|
||||||
(uint32_t)params[5];
|
(uint32_t)params[5];
|
||||||
|
|
||||||
hmsc->scsi_blk_len = ((uint32_t)params[7] << 8) |
|
p_scsi_blk->len = ((uint32_t)params[7] << 8) |
|
||||||
(uint32_t)params[8];
|
(uint32_t)params[8];
|
||||||
|
|
||||||
/* check if LBA address is in the right range */
|
/* check if LBA address is in the right range */
|
||||||
if (SCSI_CheckAddressRange(pdev, lun, hmsc->scsi_blk_addr,
|
if (SCSI_CheckAddressRange(pdev, lun, p_scsi_blk->addr, p_scsi_blk->len) < 0)
|
||||||
hmsc->scsi_blk_len) < 0)
|
|
||||||
{
|
{
|
||||||
return -1; /* error */
|
return -1; /* error */
|
||||||
}
|
}
|
||||||
|
|
||||||
len = hmsc->scsi_blk_len * hmsc->scsi_blk_size;
|
len = p_scsi_blk->len * p_scsi_blk->size;
|
||||||
|
|
||||||
/* cases 3,11,13 : Hn,Ho <> D0 */
|
/* cases 3,11,13 : Hn,Ho <> D0 */
|
||||||
if (hmsc->cbw.dDataLength != len)
|
if (hmsc->cbw.dDataLength != len)
|
||||||
@@ -916,6 +946,7 @@ static int8_t SCSI_Write10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *param
|
|||||||
static int8_t SCSI_Write12(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params)
|
static int8_t SCSI_Write12(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params)
|
||||||
{
|
{
|
||||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
USBD_MSC_BOT_LUN_TypeDef *p_scsi_blk = &hmsc->scsi_blk[lun];
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
@@ -958,24 +989,23 @@ static int8_t SCSI_Write12(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *param
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
hmsc->scsi_blk_addr = ((uint32_t)params[2] << 24) |
|
p_scsi_blk->addr = ((uint32_t)params[2] << 24) |
|
||||||
((uint32_t)params[3] << 16) |
|
((uint32_t)params[3] << 16) |
|
||||||
((uint32_t)params[4] << 8) |
|
((uint32_t)params[4] << 8) |
|
||||||
(uint32_t)params[5];
|
(uint32_t)params[5];
|
||||||
|
|
||||||
hmsc->scsi_blk_len = ((uint32_t)params[6] << 24) |
|
p_scsi_blk->len = ((uint32_t)params[6] << 24) |
|
||||||
((uint32_t)params[7] << 16) |
|
((uint32_t)params[7] << 16) |
|
||||||
((uint32_t)params[8] << 8) |
|
((uint32_t)params[8] << 8) |
|
||||||
(uint32_t)params[9];
|
(uint32_t)params[9];
|
||||||
|
|
||||||
/* check if LBA address is in the right range */
|
/* check if LBA address is in the right range */
|
||||||
if (SCSI_CheckAddressRange(pdev, lun, hmsc->scsi_blk_addr,
|
if (SCSI_CheckAddressRange(pdev, lun, p_scsi_blk->addr, p_scsi_blk->len) < 0)
|
||||||
hmsc->scsi_blk_len) < 0)
|
|
||||||
{
|
{
|
||||||
return -1; /* error */
|
return -1; /* error */
|
||||||
}
|
}
|
||||||
|
|
||||||
len = hmsc->scsi_blk_len * hmsc->scsi_blk_size;
|
len = p_scsi_blk->len * p_scsi_blk->size;
|
||||||
|
|
||||||
/* cases 3,11,13 : Hn,Ho <> D0 */
|
/* cases 3,11,13 : Hn,Ho <> D0 */
|
||||||
if (hmsc->cbw.dDataLength != len)
|
if (hmsc->cbw.dDataLength != len)
|
||||||
@@ -1009,6 +1039,7 @@ static int8_t SCSI_Write12(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *param
|
|||||||
static int8_t SCSI_Verify10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params)
|
static int8_t SCSI_Verify10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params)
|
||||||
{
|
{
|
||||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
USBD_MSC_BOT_LUN_TypeDef *p_scsi_blk = &hmsc->scsi_blk[lun];
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
{
|
{
|
||||||
@@ -1017,11 +1048,11 @@ static int8_t SCSI_Verify10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *para
|
|||||||
|
|
||||||
if ((params[1] & 0x02U) == 0x02U)
|
if ((params[1] & 0x02U) == 0x02U)
|
||||||
{
|
{
|
||||||
SCSI_SenseCode(pdev, lun, ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
SCSI_SenseCode(pdev, lun, ILLEGAL_REQUEST, INVALID_FIELD_IN_COMMAND);
|
||||||
return -1; /* Error, Verify Mode Not supported*/
|
return -1; /* Error, Verify Mode Not supported*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SCSI_CheckAddressRange(pdev, lun, hmsc->scsi_blk_addr, hmsc->scsi_blk_len) < 0)
|
if (SCSI_CheckAddressRange(pdev, lun, p_scsi_blk->addr, p_scsi_blk->len) < 0)
|
||||||
{
|
{
|
||||||
return -1; /* error */
|
return -1; /* error */
|
||||||
}
|
}
|
||||||
@@ -1031,6 +1062,90 @@ static int8_t SCSI_Verify10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *para
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SCSI_ReportLuns12
|
||||||
|
* Process ReportLuns command
|
||||||
|
* @retval status
|
||||||
|
*/
|
||||||
|
static int8_t SCSI_ReportLuns(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params)
|
||||||
|
{
|
||||||
|
USBD_MSC_BOT_HandleTypeDef *hmsc;
|
||||||
|
uint32_t lun_list_length;
|
||||||
|
uint32_t total_length;
|
||||||
|
uint8_t lun_idx;
|
||||||
|
|
||||||
|
UNUSED(lun);
|
||||||
|
UNUSED(params);
|
||||||
|
|
||||||
|
/* Define the report LUNs buffer Each LUN entry is 8 bytes */
|
||||||
|
static uint8_t lun_report[8U * (MSC_BOT_MAX_LUN + 1U)];
|
||||||
|
|
||||||
|
hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
|
||||||
|
if (hmsc == NULL)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize the report LUNs buffer */
|
||||||
|
(void)USBD_memset(lun_report, 0, sizeof(lun_report));
|
||||||
|
|
||||||
|
/* Set the LUN list length in the first 4 bytes */
|
||||||
|
lun_list_length = 8U * (hmsc->max_lun + 1U);
|
||||||
|
lun_report[0] = (uint8_t)(lun_list_length >> 24);
|
||||||
|
lun_report[1] = (uint8_t)(lun_list_length >> 16);
|
||||||
|
lun_report[2] = (uint8_t)(lun_list_length >> 8);
|
||||||
|
lun_report[3] = (uint8_t)(lun_list_length & 0xFFU);
|
||||||
|
|
||||||
|
/* Update the LUN list */
|
||||||
|
for (lun_idx = 0U; lun_idx <= hmsc->max_lun; lun_idx++)
|
||||||
|
{
|
||||||
|
/* LUN identifier is placed at the second byte of each 8-byte entry */
|
||||||
|
lun_report[(8U * (lun_idx + 1U)) + 1U] = lun_idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Calculate the total length of the report LUNs buffer */
|
||||||
|
total_length = lun_list_length + 8U;
|
||||||
|
|
||||||
|
/* Update the BOT data with the report LUNs buffer */
|
||||||
|
(void)SCSI_UpdateBotData(hmsc, lun_report, (uint16_t)total_length);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SCSI_ReceiveDiagnosticResults
|
||||||
|
* Process SCSI_Receive Diagnostic Results command
|
||||||
|
* @param lun: Logical unit number
|
||||||
|
* @param params: Command parameters
|
||||||
|
* @retval status
|
||||||
|
*/
|
||||||
|
static int8_t SCSI_ReceiveDiagnosticResults(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params)
|
||||||
|
{
|
||||||
|
UNUSED(lun);
|
||||||
|
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
uint16_t allocation_length;
|
||||||
|
|
||||||
|
/* Extract the allocation length from the CDB */
|
||||||
|
allocation_length = (((uint16_t)params[3] << 8) | (uint16_t)params[4]);
|
||||||
|
|
||||||
|
if (allocation_length == 0U)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ensure the allocation length does not exceed the diagnostic data length */
|
||||||
|
if (allocation_length > DIAGNOSTIC_DATA_LEN)
|
||||||
|
{
|
||||||
|
allocation_length = DIAGNOSTIC_DATA_LEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Send the diagnostic data to the host */
|
||||||
|
(void)SCSI_UpdateBotData(hmsc, MSC_Diagnostic_Data, allocation_length);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SCSI_CheckAddressRange
|
* @brief SCSI_CheckAddressRange
|
||||||
* Check address range
|
* Check address range
|
||||||
@@ -1043,13 +1158,14 @@ static int8_t SCSI_CheckAddressRange(USBD_HandleTypeDef *pdev, uint8_t lun,
|
|||||||
uint32_t blk_offset, uint32_t blk_nbr)
|
uint32_t blk_offset, uint32_t blk_nbr)
|
||||||
{
|
{
|
||||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
USBD_MSC_BOT_LUN_TypeDef *p_scsi_blk = &hmsc->scsi_blk[lun];
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((blk_offset + blk_nbr) > hmsc->scsi_blk_nbr)
|
if ((blk_offset + blk_nbr) > p_scsi_blk->nbr)
|
||||||
{
|
{
|
||||||
SCSI_SenseCode(pdev, lun, ILLEGAL_REQUEST, ADDRESS_OUT_OF_RANGE);
|
SCSI_SenseCode(pdev, lun, ILLEGAL_REQUEST, ADDRESS_OUT_OF_RANGE);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1067,6 +1183,7 @@ static int8_t SCSI_CheckAddressRange(USBD_HandleTypeDef *pdev, uint8_t lun,
|
|||||||
static int8_t SCSI_ProcessRead(USBD_HandleTypeDef *pdev, uint8_t lun)
|
static int8_t SCSI_ProcessRead(USBD_HandleTypeDef *pdev, uint8_t lun)
|
||||||
{
|
{
|
||||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
USBD_MSC_BOT_LUN_TypeDef *p_scsi_blk = &hmsc->scsi_blk[lun];
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
@@ -1074,7 +1191,7 @@ static int8_t SCSI_ProcessRead(USBD_HandleTypeDef *pdev, uint8_t lun)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = hmsc->scsi_blk_len * hmsc->scsi_blk_size;
|
len = p_scsi_blk->len * p_scsi_blk->size;
|
||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
@@ -1084,8 +1201,8 @@ static int8_t SCSI_ProcessRead(USBD_HandleTypeDef *pdev, uint8_t lun)
|
|||||||
len = MIN(len, MSC_MEDIA_PACKET);
|
len = MIN(len, MSC_MEDIA_PACKET);
|
||||||
|
|
||||||
if (((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->Read(lun, hmsc->bot_data,
|
if (((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->Read(lun, hmsc->bot_data,
|
||||||
hmsc->scsi_blk_addr,
|
p_scsi_blk->addr,
|
||||||
(len / hmsc->scsi_blk_size)) < 0)
|
(len / p_scsi_blk->size)) < 0)
|
||||||
{
|
{
|
||||||
SCSI_SenseCode(pdev, lun, HARDWARE_ERROR, UNRECOVERED_READ_ERROR);
|
SCSI_SenseCode(pdev, lun, HARDWARE_ERROR, UNRECOVERED_READ_ERROR);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1093,13 +1210,13 @@ static int8_t SCSI_ProcessRead(USBD_HandleTypeDef *pdev, uint8_t lun)
|
|||||||
|
|
||||||
(void)USBD_LL_Transmit(pdev, MSCInEpAdd, hmsc->bot_data, len);
|
(void)USBD_LL_Transmit(pdev, MSCInEpAdd, hmsc->bot_data, len);
|
||||||
|
|
||||||
hmsc->scsi_blk_addr += (len / hmsc->scsi_blk_size);
|
p_scsi_blk->addr += (len / p_scsi_blk->size);
|
||||||
hmsc->scsi_blk_len -= (len / hmsc->scsi_blk_size);
|
p_scsi_blk->len -= (len / p_scsi_blk->size);
|
||||||
|
|
||||||
/* case 6 : Hi = Di */
|
/* case 6 : Hi = Di */
|
||||||
hmsc->csw.dDataResidue -= len;
|
hmsc->csw.dDataResidue -= len;
|
||||||
|
|
||||||
if (hmsc->scsi_blk_len == 0U)
|
if (p_scsi_blk->len == 0U)
|
||||||
{
|
{
|
||||||
hmsc->bot_state = USBD_BOT_LAST_DATA_IN;
|
hmsc->bot_state = USBD_BOT_LAST_DATA_IN;
|
||||||
}
|
}
|
||||||
@@ -1116,6 +1233,7 @@ static int8_t SCSI_ProcessRead(USBD_HandleTypeDef *pdev, uint8_t lun)
|
|||||||
static int8_t SCSI_ProcessWrite(USBD_HandleTypeDef *pdev, uint8_t lun)
|
static int8_t SCSI_ProcessWrite(USBD_HandleTypeDef *pdev, uint8_t lun)
|
||||||
{
|
{
|
||||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
USBD_MSC_BOT_LUN_TypeDef *p_scsi_blk = &hmsc->scsi_blk[lun];
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
@@ -1123,7 +1241,7 @@ static int8_t SCSI_ProcessWrite(USBD_HandleTypeDef *pdev, uint8_t lun)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = hmsc->scsi_blk_len * hmsc->scsi_blk_size;
|
len = p_scsi_blk->len * p_scsi_blk->size;
|
||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
@@ -1132,27 +1250,26 @@ static int8_t SCSI_ProcessWrite(USBD_HandleTypeDef *pdev, uint8_t lun)
|
|||||||
|
|
||||||
len = MIN(len, MSC_MEDIA_PACKET);
|
len = MIN(len, MSC_MEDIA_PACKET);
|
||||||
|
|
||||||
if (((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->Write(lun, hmsc->bot_data,
|
if (((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->Write(lun, hmsc->bot_data, p_scsi_blk->addr,
|
||||||
hmsc->scsi_blk_addr,
|
(len / p_scsi_blk->size)) < 0)
|
||||||
(len / hmsc->scsi_blk_size)) < 0)
|
|
||||||
{
|
{
|
||||||
SCSI_SenseCode(pdev, lun, HARDWARE_ERROR, WRITE_FAULT);
|
SCSI_SenseCode(pdev, lun, HARDWARE_ERROR, WRITE_FAULT);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
hmsc->scsi_blk_addr += (len / hmsc->scsi_blk_size);
|
p_scsi_blk->addr += (len / p_scsi_blk->size);
|
||||||
hmsc->scsi_blk_len -= (len / hmsc->scsi_blk_size);
|
p_scsi_blk->len -= (len / p_scsi_blk->size);
|
||||||
|
|
||||||
/* case 12 : Ho = Do */
|
/* case 12 : Ho = Do */
|
||||||
hmsc->csw.dDataResidue -= len;
|
hmsc->csw.dDataResidue -= len;
|
||||||
|
|
||||||
if (hmsc->scsi_blk_len == 0U)
|
if (p_scsi_blk->len == 0U)
|
||||||
{
|
{
|
||||||
MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_PASSED);
|
MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_PASSED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
len = MIN((hmsc->scsi_blk_len * hmsc->scsi_blk_size), MSC_MEDIA_PACKET);
|
len = MIN((p_scsi_blk->len * p_scsi_blk->size), MSC_MEDIA_PACKET);
|
||||||
|
|
||||||
/* Prepare EP to Receive next packet */
|
/* Prepare EP to Receive next packet */
|
||||||
(void)USBD_LL_PrepareReceive(pdev, MSCOutEpAdd, hmsc->bot_data, len);
|
(void)USBD_LL_PrepareReceive(pdev, MSCOutEpAdd, hmsc->bot_data, len);
|
||||||
|
|||||||
@@ -67,9 +67,12 @@ extern "C" {
|
|||||||
#define MTP_FS_BINTERVAL 0x10U
|
#define MTP_FS_BINTERVAL 0x10U
|
||||||
#endif /* MTP_FS_BINTERVAL */
|
#endif /* MTP_FS_BINTERVAL */
|
||||||
|
|
||||||
|
#ifndef MTP_CMD_PACKET_SIZE
|
||||||
|
#define MTP_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */
|
||||||
|
#endif /* MTP_CMD_PACKET_SIZE */
|
||||||
|
|
||||||
#define MTP_DATA_MAX_HS_PACKET_SIZE 512U
|
#define MTP_DATA_MAX_HS_PACKET_SIZE 512U
|
||||||
#define MTP_DATA_MAX_FS_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
|
#define MTP_DATA_MAX_FS_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
|
||||||
#define MTP_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */
|
|
||||||
|
|
||||||
#define MTP_MEDIA_PACKET 512U
|
#define MTP_MEDIA_PACKET 512U
|
||||||
#define MTP_CONT_HEADER_SIZE 12U
|
#define MTP_CONT_HEADER_SIZE 12U
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ extern "C" {
|
|||||||
* Appendix C. Device Properties
|
* Appendix C. Device Properties
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* MTP device properties code*/
|
/* MTP device properties code */
|
||||||
#define MTP_DEV_PROP_UNDEFINED 0x5000U
|
#define MTP_DEV_PROP_UNDEFINED 0x5000U
|
||||||
#define MTP_DEV_PROP_BATTERY_LEVEL 0x5001U
|
#define MTP_DEV_PROP_BATTERY_LEVEL 0x5001U
|
||||||
#define MTP_DEV_PROP_FUNCTIONAL_MODE 0x5002U
|
#define MTP_DEV_PROP_FUNCTIONAL_MODE 0x5002U
|
||||||
@@ -336,7 +336,7 @@ extern "C" {
|
|||||||
#define MTP_CONT_TYPE_EVENT 4U
|
#define MTP_CONT_TYPE_EVENT 4U
|
||||||
|
|
||||||
#ifndef MTP_STORAGE_ID
|
#ifndef MTP_STORAGE_ID
|
||||||
#define MTP_STORAGE_ID 0x00010001U /* SD card is inserted*/
|
#define MTP_STORAGE_ID 0x00010001U /* SD card is inserted */
|
||||||
#endif /* MTP_STORAGE_ID */
|
#endif /* MTP_STORAGE_ID */
|
||||||
|
|
||||||
#define MTP_NBR_STORAGE_ID 1U
|
#define MTP_NBR_STORAGE_ID 1U
|
||||||
|
|||||||
@@ -53,15 +53,16 @@ extern "C" {
|
|||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
DATA_TYPE = 0x00,
|
DATA_TYPE = 0x00U,
|
||||||
REP_TYPE = 0x01,
|
REP_TYPE = 0x01U,
|
||||||
} MTP_CONTAINER_TYPE;
|
} MTP_CONTAINER_TYPE;
|
||||||
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
READ_FIRST_DATA = 0x00,
|
READ_FIRST_DATA = 0x00U,
|
||||||
READ_REST_OF_DATA = 0x01,
|
READ_REST_OF_DATA = 0x01U,
|
||||||
|
READ_SEND_ZLP_DATA = 0x02U
|
||||||
} MTP_READ_DATA_STATUS;
|
} MTP_READ_DATA_STATUS;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -128,6 +128,9 @@ USBD_ClassTypeDef USBD_MTP =
|
|||||||
USBD_MTP_GetOtherSpeedCfgDesc,
|
USBD_MTP_GetOtherSpeedCfgDesc,
|
||||||
USBD_MTP_GetDeviceQualifierDescriptor,
|
USBD_MTP_GetDeviceQualifierDescriptor,
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
|
||||||
|
NULL,
|
||||||
|
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef USE_USBD_COMPOSITE
|
#ifndef USE_USBD_COMPOSITE
|
||||||
|
|||||||
@@ -537,50 +537,30 @@ static void MTP_Get_PayloadContent(USBD_HandleTypeDef *pdev)
|
|||||||
{
|
{
|
||||||
USBD_MTP_HandleTypeDef *hmtp = (USBD_MTP_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MTP_HandleTypeDef *hmtp = (USBD_MTP_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
USBD_MTP_ItfTypeDef *hmtpif = (USBD_MTP_ItfTypeDef *)pdev->pUserData[pdev->classId];
|
USBD_MTP_ItfTypeDef *hmtpif = (USBD_MTP_ItfTypeDef *)pdev->pUserData[pdev->classId];
|
||||||
uint8_t *buffer = hmtp->GenericContainer.data;
|
uint8_t *buffer;
|
||||||
uint32_t i;
|
|
||||||
uint32_t n_idx;
|
uint32_t n_idx;
|
||||||
|
|
||||||
switch (hmtp->OperationsContainer.code)
|
switch (hmtp->OperationsContainer.code)
|
||||||
{
|
{
|
||||||
case MTP_OP_GET_DEVICE_INFO:
|
case MTP_OP_GET_DEVICE_INFO:
|
||||||
(void)MTP_Get_DeviceInfo();
|
(void)MTP_Get_DeviceInfo();
|
||||||
(void)USBD_memcpy(buffer, (const uint8_t *)&MTP_DeviceInfo, sizeof(MTP_DeviceInfo));
|
(void)USBD_memcpy(hmtp->GenericContainer.data, (const uint8_t *)&MTP_DeviceInfo,
|
||||||
|
MIN(sizeof(MTP_DeviceInfo), MTP_MEDIA_PACKET));
|
||||||
for (i = 0U; i < sizeof(MTP_StorageIDS); i++)
|
|
||||||
{
|
|
||||||
hmtp->GenericContainer.data[i] = buffer[i];
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MTP_OP_GET_STORAGE_IDS:
|
case MTP_OP_GET_STORAGE_IDS:
|
||||||
(void)MTP_Get_StorageIDS();
|
(void)MTP_Get_StorageIDS();
|
||||||
(void)USBD_memcpy(buffer, (const uint8_t *)&MTP_StorageIDS, sizeof(MTP_StorageIDS));
|
(void)USBD_memcpy(hmtp->GenericContainer.data, (const uint8_t *)&MTP_StorageIDS, sizeof(MTP_StorageIDS));
|
||||||
|
|
||||||
for (i = 0U; i < sizeof(MTP_StorageIDS); i++)
|
|
||||||
{
|
|
||||||
hmtp->GenericContainer.data[i] = buffer[i];
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MTP_OP_GET_STORAGE_INFO:
|
case MTP_OP_GET_STORAGE_INFO:
|
||||||
(void)MTP_Get_StorageInfo(pdev);
|
(void)MTP_Get_StorageInfo(pdev);
|
||||||
(void)USBD_memcpy(buffer, (const uint8_t *)&MTP_StorageInfo, sizeof(MTP_StorageInfo));
|
(void)USBD_memcpy(hmtp->GenericContainer.data, (const uint8_t *)&MTP_StorageInfo, sizeof(MTP_StorageInfo));
|
||||||
|
|
||||||
for (i = 0U; i < sizeof(MTP_StorageInfo); i++)
|
|
||||||
{
|
|
||||||
hmtp->GenericContainer.data[i] = buffer[i];
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MTP_OP_GET_OBJECT_HANDLES:
|
case MTP_OP_GET_OBJECT_HANDLES:
|
||||||
(void)MTP_Get_ObjectHandle(pdev);
|
(void)MTP_Get_ObjectHandle(pdev);
|
||||||
(void)USBD_memcpy(buffer, (const uint8_t *)&MTP_ObjectHandle, hmtp->ResponseLength);
|
(void)USBD_memcpy(hmtp->GenericContainer.data, (const uint8_t *)&MTP_ObjectHandle, hmtp->ResponseLength);
|
||||||
|
|
||||||
for (i = 0U; i < hmtp->ResponseLength; i++)
|
|
||||||
{
|
|
||||||
hmtp->GenericContainer.data[i] = buffer[i];
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MTP_OP_GET_OBJECT_INFO:
|
case MTP_OP_GET_OBJECT_INFO:
|
||||||
@@ -589,12 +569,7 @@ static void MTP_Get_PayloadContent(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
case MTP_OP_GET_OBJECT_PROPS_SUPPORTED:
|
case MTP_OP_GET_OBJECT_PROPS_SUPPORTED:
|
||||||
(void)MTP_Get_ObjectPropSupp();
|
(void)MTP_Get_ObjectPropSupp();
|
||||||
(void)USBD_memcpy(buffer, (const uint8_t *)&MTP_ObjectPropSupp, sizeof(MTP_ObjectPropSupp));
|
(void)USBD_memcpy(hmtp->GenericContainer.data, (const uint8_t *)&MTP_ObjectPropSupp, sizeof(MTP_ObjectPropSupp));
|
||||||
|
|
||||||
for (i = 0U; i < sizeof(MTP_ObjectPropSupp); i++)
|
|
||||||
{
|
|
||||||
hmtp->GenericContainer.data[i] = buffer[i];
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MTP_OP_GET_OBJECT_PROP_DESC:
|
case MTP_OP_GET_OBJECT_PROP_DESC:
|
||||||
@@ -604,12 +579,7 @@ static void MTP_Get_PayloadContent(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
case MTP_OP_GET_OBJECT_PROP_REFERENCES:
|
case MTP_OP_GET_OBJECT_PROP_REFERENCES:
|
||||||
MTP_Ref.ref_len = 0U;
|
MTP_Ref.ref_len = 0U;
|
||||||
(void)USBD_memcpy(buffer, (const uint8_t *)&MTP_Ref.ref_len, sizeof(MTP_Ref.ref_len));
|
(void)USBD_memcpy(hmtp->GenericContainer.data, (const uint8_t *)&MTP_Ref.ref_len, sizeof(MTP_Ref.ref_len));
|
||||||
|
|
||||||
for (i = 0U; i < sizeof(MTP_Ref.ref_len); i++)
|
|
||||||
{
|
|
||||||
hmtp->GenericContainer.data[i] = buffer[i];
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MTP_OP_GET_OBJECT_PROPLIST:
|
case MTP_OP_GET_OBJECT_PROPLIST:
|
||||||
@@ -618,20 +588,13 @@ static void MTP_Get_PayloadContent(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
case MTP_OP_GET_OBJECT_PROP_VALUE:
|
case MTP_OP_GET_OBJECT_PROP_VALUE:
|
||||||
buffer = MTP_Get_ObjectPropValue(pdev);
|
buffer = MTP_Get_ObjectPropValue(pdev);
|
||||||
for (i = 0U; i < hmtp->ResponseLength; i++)
|
(void)USBD_memcpy(hmtp->GenericContainer.data, (const uint8_t *)buffer, hmtp->ResponseLength);
|
||||||
{
|
|
||||||
hmtp->GenericContainer.data[i] = buffer[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MTP_OP_GET_DEVICE_PROP_DESC:
|
case MTP_OP_GET_DEVICE_PROP_DESC:
|
||||||
(void)MTP_Get_DevicePropDesc();
|
(void)MTP_Get_DevicePropDesc();
|
||||||
(void)USBD_memcpy(buffer, (const uint8_t *)&MTP_DevicePropDesc, sizeof(MTP_DevicePropDesc));
|
(void)USBD_memcpy(hmtp->GenericContainer.data, (const uint8_t *)&MTP_DevicePropDesc,
|
||||||
for (i = 0U; i < sizeof(MTP_DevicePropDesc); i++)
|
MIN(sizeof(MTP_DevicePropDesc), MTP_MEDIA_PACKET));
|
||||||
{
|
|
||||||
hmtp->GenericContainer.data[i] = buffer[i];
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MTP_OP_SEND_OBJECT_INFO:
|
case MTP_OP_SEND_OBJECT_INFO:
|
||||||
@@ -837,7 +800,7 @@ static void MTP_Get_ObjectPropDesc(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
case MTP_OB_PROP_PARENT_OBJECT :
|
case MTP_OB_PROP_PARENT_OBJECT :
|
||||||
MTP_ObjectPropDesc.ObjectPropertyCode = (uint16_t)(hmtp->OperationsContainer.Param1);
|
MTP_ObjectPropDesc.ObjectPropertyCode = (uint16_t)(hmtp->OperationsContainer.Param1);
|
||||||
MTP_ObjectPropDesc.DataType = MTP_DATATYPE_STR;
|
MTP_ObjectPropDesc.DataType = MTP_DATATYPE_UINT32;
|
||||||
MTP_ObjectPropDesc.GetSet = MTP_PROP_GET;
|
MTP_ObjectPropDesc.GetSet = MTP_PROP_GET;
|
||||||
MTP_ObjectPropDesc.DefValue = 0U;
|
MTP_ObjectPropDesc.DefValue = 0U;
|
||||||
MTP_ObjectPropDesc.GroupCode = 0U;
|
MTP_ObjectPropDesc.GroupCode = 0U;
|
||||||
@@ -951,8 +914,8 @@ static uint8_t *MTP_Get_ObjectPropValue(USBD_HandleTypeDef *pdev)
|
|||||||
*/
|
*/
|
||||||
static void MTP_Get_ObjectPropList(USBD_HandleTypeDef *pdev)
|
static void MTP_Get_ObjectPropList(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
USBD_MTP_HandleTypeDef *hmtp = (USBD_MTP_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MTP_HandleTypeDef *hmtp = (USBD_MTP_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
USBD_MTP_ItfTypeDef *hmtpif = (USBD_MTP_ItfTypeDef *)pdev->pUserData[pdev->classId];
|
USBD_MTP_ItfTypeDef *hmtpif = (USBD_MTP_ItfTypeDef *)pdev->pUserData[pdev->classId];
|
||||||
uint16_t filename[255];
|
uint16_t filename[255];
|
||||||
uint32_t storageid = MTP_STORAGE_ID;
|
uint32_t storageid = MTP_STORAGE_ID;
|
||||||
uint32_t default_val = 0U;
|
uint32_t default_val = 0U;
|
||||||
@@ -960,6 +923,7 @@ static void MTP_Get_ObjectPropList(USBD_HandleTypeDef *pdev)
|
|||||||
uint16_t format;
|
uint16_t format;
|
||||||
uint64_t objsize;
|
uint64_t objsize;
|
||||||
uint32_t parent_proval;
|
uint32_t parent_proval;
|
||||||
|
uint8_t mtp_pers_uniq_obj_id[16] = {0};
|
||||||
|
|
||||||
MTP_PropertiesList.MTP_Properties_len = SUPP_OBJ_PROP_LEN;
|
MTP_PropertiesList.MTP_Properties_len = SUPP_OBJ_PROP_LEN;
|
||||||
hmtp->ResponseLength = 4U; /* size of MTP_PropertiesList.MTP_Properties_len */
|
hmtp->ResponseLength = 4U; /* size of MTP_PropertiesList.MTP_Properties_len */
|
||||||
@@ -1020,9 +984,13 @@ static void MTP_Get_ObjectPropList(USBD_HandleTypeDef *pdev)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MTP_OB_PROP_PERS_UNIQ_OBJ_IDEN :
|
case MTP_OB_PROP_PERS_UNIQ_OBJ_IDEN :
|
||||||
|
/* Fill in the first 4 bytes with Param1 (Object ID) */
|
||||||
|
(void)USBD_memcpy(mtp_pers_uniq_obj_id, &hmtp->OperationsContainer.Param1,
|
||||||
|
sizeof(hmtp->OperationsContainer.Param1));
|
||||||
|
|
||||||
MTP_PropertiesList.MTP_Properties[i].PropertyCode = MTP_OB_PROP_PERS_UNIQ_OBJ_IDEN;
|
MTP_PropertiesList.MTP_Properties[i].PropertyCode = MTP_OB_PROP_PERS_UNIQ_OBJ_IDEN;
|
||||||
MTP_PropertiesList.MTP_Properties[i].Datatype = MTP_DATATYPE_UINT128;
|
MTP_PropertiesList.MTP_Properties[i].Datatype = MTP_DATATYPE_UINT128;
|
||||||
MTP_PropertiesList.MTP_Properties[i].propval = (uint8_t *)&hmtp->OperationsContainer.Param1;
|
MTP_PropertiesList.MTP_Properties[i].propval = (uint8_t *)mtp_pers_uniq_obj_id;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MTP_OB_PROP_PROTECTION_STATUS :
|
case MTP_OB_PROP_PROTECTION_STATUS :
|
||||||
@@ -1187,7 +1155,8 @@ static uint32_t MTP_build_data_proplist(USBD_HandleTypeDef *pdev,
|
|||||||
MTP_PropertiesListTypedef proplist, uint32_t idx)
|
MTP_PropertiesListTypedef proplist, uint32_t idx)
|
||||||
{
|
{
|
||||||
USBD_MTP_HandleTypeDef *hmtp = (USBD_MTP_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MTP_HandleTypeDef *hmtp = (USBD_MTP_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
uint8_t propval_size = (MTP_FileName.FileName_len * 2U) + 1U;
|
uint8_t *propval = proplist.MTP_Properties[idx].propval;
|
||||||
|
uint8_t propval_size = (propval[0] * 2U) + 1U;
|
||||||
uint32_t dataLength;
|
uint32_t dataLength;
|
||||||
|
|
||||||
dataLength = offsetof(MTP_PropertiesTypedef, propval);
|
dataLength = offsetof(MTP_PropertiesTypedef, propval);
|
||||||
|
|||||||
@@ -95,26 +95,38 @@ uint8_t USBD_MTP_STORAGE_ReadData(USBD_HandleTypeDef *pdev)
|
|||||||
{
|
{
|
||||||
USBD_MTP_HandleTypeDef *hmtp = (USBD_MTP_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MTP_HandleTypeDef *hmtp = (USBD_MTP_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
uint32_t *data_buff;
|
uint32_t *data_buff;
|
||||||
|
uint32_t buffer_size;
|
||||||
|
|
||||||
/* Get the data buffer pointer from the low layer interface */
|
/* Get the data buffer pointer from the low layer interface */
|
||||||
data_buff = ((USBD_MTP_ItfTypeDef *)pdev->pUserData[pdev->classId])->ScratchBuff;
|
data_buff = ((USBD_MTP_ItfTypeDef *)pdev->pUserData[pdev->classId])->ScratchBuff;
|
||||||
|
|
||||||
|
/* Get Data Buffer Size */
|
||||||
|
buffer_size = ((USBD_MTP_ItfTypeDef *)pdev->pUserData[pdev->classId])->ScratchBuffSze;
|
||||||
|
|
||||||
|
if ((data_buff == NULL) || (buffer_size < MTP_CONT_HEADER_SIZE))
|
||||||
|
{
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
switch (ReadDataStatus)
|
switch (ReadDataStatus)
|
||||||
{
|
{
|
||||||
case READ_FIRST_DATA:
|
case READ_FIRST_DATA:
|
||||||
/* Reset the data length */
|
/* Reset the data length */
|
||||||
MTP_DataLength.temp_length = 0U;
|
MTP_DataLength.temp_length = 0U;
|
||||||
|
|
||||||
/* Perform the low layer read operation on the scratch buffer */
|
|
||||||
(void)((USBD_MTP_ItfTypeDef *)pdev->pUserData[pdev->classId])->ReadData(hmtp->OperationsContainer.Param1,
|
|
||||||
(uint8_t *)data_buff, &MTP_DataLength);
|
|
||||||
|
|
||||||
/* Add the container header to the data buffer */
|
/* Add the container header to the data buffer */
|
||||||
(void)USBD_memcpy((uint8_t *)data_buff, (uint8_t *)&hmtp->GenericContainer, MTP_CONT_HEADER_SIZE);
|
(void)USBD_memcpy((uint8_t *)data_buff, (uint8_t *)&hmtp->GenericContainer, MTP_CONT_HEADER_SIZE);
|
||||||
|
|
||||||
|
/* Perform the low layer read operation on the scratch buffer
|
||||||
|
* first packet expected data length: MPS - MTP_CONT_HEADER_SIZE
|
||||||
|
*/
|
||||||
|
(void)((USBD_MTP_ItfTypeDef *)pdev->pUserData[pdev->classId])->ReadData(hmtp->OperationsContainer.Param1,
|
||||||
|
(uint8_t *)data_buff +
|
||||||
|
MTP_CONT_HEADER_SIZE, &MTP_DataLength);
|
||||||
|
|
||||||
/* Start USB data transmission to the host */
|
/* Start USB data transmission to the host */
|
||||||
(void)USBD_MTP_STORAGE_SendData(pdev, (uint8_t *)data_buff,
|
(void)USBD_MTP_STORAGE_SendData(pdev, (uint8_t *)data_buff,
|
||||||
MTP_DataLength.readbytes + MTP_CONT_HEADER_SIZE);
|
MIN((MTP_DataLength.readbytes + MTP_CONT_HEADER_SIZE), buffer_size));
|
||||||
|
|
||||||
/* Check if this will be the last packet to send ? */
|
/* Check if this will be the last packet to send ? */
|
||||||
if (MTP_DataLength.readbytes < ((uint32_t)hmtp->MaxPcktLen - MTP_CONT_HEADER_SIZE))
|
if (MTP_DataLength.readbytes < ((uint32_t)hmtp->MaxPcktLen - MTP_CONT_HEADER_SIZE))
|
||||||
@@ -138,24 +150,45 @@ uint8_t USBD_MTP_STORAGE_ReadData(USBD_HandleTypeDef *pdev)
|
|||||||
if (MTP_DataLength.temp_length == MTP_DataLength.totallen)
|
if (MTP_DataLength.temp_length == MTP_DataLength.totallen)
|
||||||
{
|
{
|
||||||
/* Start USB data transmission to the host */
|
/* Start USB data transmission to the host */
|
||||||
(void)USBD_MTP_STORAGE_SendData(pdev, (uint8_t *)data_buff, MTP_DataLength.readbytes);
|
(void)USBD_MTP_STORAGE_SendData(pdev, (uint8_t *)data_buff, MIN(MTP_DataLength.readbytes, buffer_size));
|
||||||
|
|
||||||
/* Move to response phase */
|
if (((MTP_DataLength.totallen + MTP_CONT_HEADER_SIZE) % hmtp->MaxPcktLen) == 0U)
|
||||||
hmtp->MTP_ResponsePhase = MTP_RESPONSE_PHASE;
|
{
|
||||||
|
/* Send ZLP Packet */
|
||||||
|
ReadDataStatus = READ_SEND_ZLP_DATA;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Move to response phase */
|
||||||
|
hmtp->MTP_ResponsePhase = MTP_RESPONSE_PHASE;
|
||||||
|
|
||||||
/* Reset the stat machine */
|
/* Reset the state machine */
|
||||||
ReadDataStatus = READ_FIRST_DATA;
|
ReadDataStatus = READ_FIRST_DATA;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Start USB data transmission to the host */
|
/* Start USB data transmission to the host */
|
||||||
(void)USBD_MTP_STORAGE_SendData(pdev, (uint8_t *)data_buff, MTP_DataLength.readbytes);
|
(void)USBD_MTP_STORAGE_SendData(pdev, (uint8_t *)data_buff, MIN(MTP_DataLength.readbytes, buffer_size));
|
||||||
|
|
||||||
/* Keep the state machine into sending next packet of data */
|
/* Keep the state machine into sending next packet of data */
|
||||||
ReadDataStatus = READ_REST_OF_DATA;
|
ReadDataStatus = READ_REST_OF_DATA;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case READ_SEND_ZLP_DATA:
|
||||||
|
|
||||||
|
/* Send ZLP to the host */
|
||||||
|
(void)USBD_MTP_STORAGE_SendData(pdev, (uint8_t *)data_buff, 0U);
|
||||||
|
|
||||||
|
/* Move to response phase */
|
||||||
|
hmtp->MTP_ResponsePhase = MTP_RESPONSE_PHASE;
|
||||||
|
|
||||||
|
/* Reset the state machine */
|
||||||
|
ReadDataStatus = READ_FIRST_DATA;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -176,7 +209,8 @@ uint8_t USBD_MTP_STORAGE_SendContainer(USBD_HandleTypeDef *pdev, MTP_CONTAINER_
|
|||||||
{
|
{
|
||||||
case DATA_TYPE:
|
case DATA_TYPE:
|
||||||
/* send header + data : hmtp->ResponseLength = header size + data size */
|
/* send header + data : hmtp->ResponseLength = header size + data size */
|
||||||
(void)USBD_MTP_STORAGE_SendData(pdev, (uint8_t *)&hmtp->GenericContainer, hmtp->ResponseLength);
|
(void)USBD_MTP_STORAGE_SendData(pdev, (uint8_t *)&hmtp->GenericContainer, MIN(sizeof(MTP_GenericContainerTypeDef),
|
||||||
|
hmtp->ResponseLength));
|
||||||
break;
|
break;
|
||||||
case REP_TYPE:
|
case REP_TYPE:
|
||||||
/* send header without data */
|
/* send header without data */
|
||||||
@@ -185,7 +219,8 @@ uint8_t USBD_MTP_STORAGE_SendContainer(USBD_HandleTypeDef *pdev, MTP_CONTAINER_
|
|||||||
hmtp->GenericContainer.length = hmtp->ResponseLength;
|
hmtp->GenericContainer.length = hmtp->ResponseLength;
|
||||||
hmtp->GenericContainer.type = MTP_CONT_TYPE_RESPONSE;
|
hmtp->GenericContainer.type = MTP_CONT_TYPE_RESPONSE;
|
||||||
|
|
||||||
(void)USBD_MTP_STORAGE_SendData(pdev, (uint8_t *)&hmtp->GenericContainer, hmtp->ResponseLength);
|
(void)USBD_MTP_STORAGE_SendData(pdev, (uint8_t *)&hmtp->GenericContainer, MIN(sizeof(MTP_GenericContainerTypeDef),
|
||||||
|
hmtp->ResponseLength));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -245,7 +280,7 @@ uint8_t USBD_MTP_STORAGE_ReceiveOpt(USBD_HandleTypeDef *pdev)
|
|||||||
*/
|
*/
|
||||||
uint8_t USBD_MTP_STORAGE_ReceiveData(USBD_HandleTypeDef *pdev)
|
uint8_t USBD_MTP_STORAGE_ReceiveData(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
USBD_MTP_HandleTypeDef *hmtp = (USBD_MTP_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MTP_HandleTypeDef *hmtp = (USBD_MTP_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
switch (hmtp->RECEIVE_DATA_STATUS)
|
switch (hmtp->RECEIVE_DATA_STATUS)
|
||||||
{
|
{
|
||||||
case RECEIVE_COMMAND_DATA :
|
case RECEIVE_COMMAND_DATA :
|
||||||
@@ -410,15 +445,21 @@ static uint8_t USBD_MTP_STORAGE_DecodeOperations(USBD_HandleTypeDef *pdev)
|
|||||||
static uint8_t USBD_MTP_STORAGE_ReceiveContainer(USBD_HandleTypeDef *pdev,
|
static uint8_t USBD_MTP_STORAGE_ReceiveContainer(USBD_HandleTypeDef *pdev,
|
||||||
uint32_t *pDst, uint32_t len)
|
uint32_t *pDst, uint32_t len)
|
||||||
{
|
{
|
||||||
USBD_MTP_HandleTypeDef *hmtp = (USBD_MTP_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MTP_HandleTypeDef *hmtp = (USBD_MTP_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
uint32_t Counter;
|
uint32_t Counter;
|
||||||
uint32_t *pdst = pDst;
|
uint32_t *pdst = pDst;
|
||||||
|
|
||||||
for (Counter = 0; Counter < len; Counter++)
|
if ((pDst == NULL) || (len > MTP_MEDIA_PACKET))
|
||||||
|
{
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Counter = 0U; Counter < len; Counter++)
|
||||||
{
|
{
|
||||||
*pdst = (hmtp->rx_buff[Counter]);
|
*pdst = (hmtp->rx_buff[Counter]);
|
||||||
pdst++;
|
pdst++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,17 +497,14 @@ void USBD_MTP_STORAGE_Cancel(USBD_HandleTypeDef *pdev,
|
|||||||
* @param len: Data Length
|
* @param len: Data Length
|
||||||
* @retval status value
|
* @retval status value
|
||||||
*/
|
*/
|
||||||
static uint8_t USBD_MTP_STORAGE_SendData(USBD_HandleTypeDef *pdev, uint8_t *buf,
|
static uint8_t USBD_MTP_STORAGE_SendData(USBD_HandleTypeDef *pdev, uint8_t *buf, uint32_t len)
|
||||||
uint32_t len)
|
|
||||||
{
|
{
|
||||||
USBD_MTP_HandleTypeDef *hmtp = (USBD_MTP_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
|
||||||
uint32_t length = MIN(hmtp->GenericContainer.length, len);
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MTPInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
MTPInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
(void)USBD_LL_Transmit(pdev, MTPInEpAdd, buf, length);
|
(void)USBD_LL_Transmit(pdev, MTPInEpAdd, buf, len);
|
||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,6 +141,9 @@ USBD_ClassTypeDef USBD_PRNT =
|
|||||||
USBD_PRNT_GetOtherSpeedCfgDesc,
|
USBD_PRNT_GetOtherSpeedCfgDesc,
|
||||||
USBD_PRNT_GetDeviceQualifierDescriptor,
|
USBD_PRNT_GetDeviceQualifierDescriptor,
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
|
||||||
|
NULL,
|
||||||
|
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef USE_USBD_COMPOSITE
|
#ifndef USE_USBD_COMPOSITE
|
||||||
|
|||||||
@@ -377,7 +377,8 @@ typedef struct
|
|||||||
{
|
{
|
||||||
uint32_t interface;
|
uint32_t interface;
|
||||||
uint32_t uvc_state;
|
uint32_t uvc_state;
|
||||||
uint8_t buffer[UVC_TOTAL_BUF_SIZE];
|
uint32_t uvc_size;
|
||||||
|
uint8_t *uvc_buffer;
|
||||||
VIDEO_OffsetTypeDef offset;
|
VIDEO_OffsetTypeDef offset;
|
||||||
USBD_VIDEO_ControlTypeDef control;
|
USBD_VIDEO_ControlTypeDef control;
|
||||||
} USBD_VIDEO_HandleTypeDef;
|
} USBD_VIDEO_HandleTypeDef;
|
||||||
|
|||||||
@@ -140,6 +140,9 @@ USBD_ClassTypeDef USBD_VIDEO =
|
|||||||
USBD_VIDEO_GetOtherSpeedCfgDesc,
|
USBD_VIDEO_GetOtherSpeedCfgDesc,
|
||||||
USBD_VIDEO_GetDeviceQualifierDesc,
|
USBD_VIDEO_GetDeviceQualifierDesc,
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
|
||||||
|
NULL,
|
||||||
|
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* USB VIDEO device Configuration Descriptor (same for all speeds thanks to user defines) */
|
/* USB VIDEO device Configuration Descriptor (same for all speeds thanks to user defines) */
|
||||||
@@ -498,6 +501,11 @@ static uint8_t USBD_VIDEO_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *
|
|||||||
uint16_t len;
|
uint16_t len;
|
||||||
uint8_t *pbuf;
|
uint8_t *pbuf;
|
||||||
|
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
|
VIDEOinEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_ISOC, (uint8_t)pdev->classId);
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
switch (req->bmRequest & USB_REQ_TYPE_MASK)
|
switch (req->bmRequest & USB_REQ_TYPE_MASK)
|
||||||
{
|
{
|
||||||
/* Class Requests -------------------------------*/
|
/* Class Requests -------------------------------*/
|
||||||
@@ -643,6 +651,11 @@ static uint8_t USBD_VIDEO_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
uint32_t RemainData = 0U;
|
uint32_t RemainData = 0U;
|
||||||
uint32_t DataOffset = 0U;
|
uint32_t DataOffset = 0U;
|
||||||
|
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
|
VIDEOinEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_ISOC, (uint8_t)pdev->classId);
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Check if the Streaming has already been started */
|
/* Check if the Streaming has already been started */
|
||||||
if (hVIDEO->uvc_state == UVC_PLAY_STATUS_STREAMING)
|
if (hVIDEO->uvc_state == UVC_PLAY_STATUS_STREAMING)
|
||||||
{
|
{
|
||||||
@@ -692,9 +705,12 @@ static uint8_t USBD_VIDEO_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
packet[1] = payload_header[1];
|
packet[1] = payload_header[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hVIDEO->uvc_buffer = (uint8_t *)&packet;
|
||||||
|
hVIDEO->uvc_size = (uint32_t)PcktSze;
|
||||||
|
|
||||||
/* Transmit the packet on Endpoint */
|
/* Transmit the packet on Endpoint */
|
||||||
(void)USBD_LL_Transmit(pdev, (uint8_t)(epnum | 0x80U),
|
(void)USBD_LL_Transmit(pdev, (uint8_t)(epnum | 0x80U),
|
||||||
(uint8_t *)&packet, (uint32_t)PcktSze);
|
hVIDEO->uvc_buffer, hVIDEO->uvc_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Exit with no error code */
|
/* Exit with no error code */
|
||||||
@@ -712,11 +728,19 @@ static uint8_t USBD_VIDEO_SOF(USBD_HandleTypeDef *pdev)
|
|||||||
USBD_VIDEO_HandleTypeDef *hVIDEO = (USBD_VIDEO_HandleTypeDef *) pdev->pClassDataCmsit[pdev->classId];
|
USBD_VIDEO_HandleTypeDef *hVIDEO = (USBD_VIDEO_HandleTypeDef *) pdev->pClassDataCmsit[pdev->classId];
|
||||||
uint8_t payload[2] = {0x02U, 0x00U};
|
uint8_t payload[2] = {0x02U, 0x00U};
|
||||||
|
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
|
VIDEOinEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_ISOC, (uint8_t)pdev->classId);
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Check if the Streaming has already been started by SetInterface AltSetting 1 */
|
/* Check if the Streaming has already been started by SetInterface AltSetting 1 */
|
||||||
if (hVIDEO->uvc_state == UVC_PLAY_STATUS_READY)
|
if (hVIDEO->uvc_state == UVC_PLAY_STATUS_READY)
|
||||||
{
|
{
|
||||||
|
hVIDEO->uvc_buffer = (uint8_t *)&payload;
|
||||||
|
hVIDEO->uvc_size = 2U;
|
||||||
|
|
||||||
/* Transmit the first packet indicating that Streaming is starting */
|
/* Transmit the first packet indicating that Streaming is starting */
|
||||||
(void)USBD_LL_Transmit(pdev, VIDEOinEpAdd, (uint8_t *)payload, 2U);
|
(void)USBD_LL_Transmit(pdev, VIDEOinEpAdd, hVIDEO->uvc_buffer, hVIDEO->uvc_size);
|
||||||
|
|
||||||
/* Enable Streaming state */
|
/* Enable Streaming state */
|
||||||
hVIDEO->uvc_state = UVC_PLAY_STATUS_STREAMING;
|
hVIDEO->uvc_state = UVC_PLAY_STATUS_STREAMING;
|
||||||
@@ -735,8 +759,17 @@ static uint8_t USBD_VIDEO_SOF(USBD_HandleTypeDef *pdev)
|
|||||||
*/
|
*/
|
||||||
static uint8_t USBD_VIDEO_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
static uint8_t USBD_VIDEO_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||||
{
|
{
|
||||||
UNUSED(pdev);
|
USBD_VIDEO_HandleTypeDef *hVIDEO = (USBD_VIDEO_HandleTypeDef *) pdev->pClassDataCmsit[pdev->classId];
|
||||||
UNUSED(epnum);
|
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
|
VIDEOinEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_ISOC, (uint8_t)pdev->classId);
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
|
if (epnum == (VIDEOinEpAdd & 0xFU))
|
||||||
|
{
|
||||||
|
(void)USBD_LL_Transmit(pdev, VIDEOinEpAdd, hVIDEO->uvc_buffer, hVIDEO->uvc_size);
|
||||||
|
}
|
||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ extern "C" {
|
|||||||
#define USBD_MAX_STR_DESC_SIZ 0x100U
|
#define USBD_MAX_STR_DESC_SIZ 0x100U
|
||||||
#define USBD_SELF_POWERED 1U
|
#define USBD_SELF_POWERED 1U
|
||||||
#define USBD_DEBUG_LEVEL 2U
|
#define USBD_DEBUG_LEVEL 2U
|
||||||
|
/* #define USBD_USER_REGISTER_CALLBACK 1U */
|
||||||
|
|
||||||
/* ECM, RNDIS, DFU Class Config */
|
/* ECM, RNDIS, DFU Class Config */
|
||||||
#define USBD_SUPPORT_USER_STRING_DESC 1U
|
#define USBD_SUPPORT_USER_STRING_DESC 1U
|
||||||
@@ -64,6 +65,8 @@ extern "C" {
|
|||||||
#define USBD_CDC_INTERVAL 2000U
|
#define USBD_CDC_INTERVAL 2000U
|
||||||
|
|
||||||
/* DFU Class Config */
|
/* DFU Class Config */
|
||||||
|
/* #define USBD_DFU_VENDOR_CMD_ENABLED 1U */
|
||||||
|
/* #define USBD_DFU_VENDOR_EXIT_ENABLED 1U */
|
||||||
#define USBD_DFU_MAX_ITF_NUM 1U
|
#define USBD_DFU_MAX_ITF_NUM 1U
|
||||||
#define USBD_DFU_XFERS_IZE 1024U
|
#define USBD_DFU_XFERS_IZE 1024U
|
||||||
|
|
||||||
@@ -76,10 +79,12 @@ extern "C" {
|
|||||||
#define USBD_CUSTOMHID_OUTREPORT_BUF_SIZE 0x02U
|
#define USBD_CUSTOMHID_OUTREPORT_BUF_SIZE 0x02U
|
||||||
#define USBD_CUSTOM_HID_REPORT_DESC_SIZE 163U
|
#define USBD_CUSTOM_HID_REPORT_DESC_SIZE 163U
|
||||||
|
|
||||||
|
/* #define USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED */
|
||||||
/* #define USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED */
|
/* #define USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED */
|
||||||
/* #define USBD_CUSTOMHID_OUT_PREPARE_RECEIVE_DISABLED */
|
/* #define USBD_CUSTOMHID_OUT_PREPARE_RECEIVE_DISABLED */
|
||||||
/* #define USBD_CUSTOMHID_EP0_OUT_PREPARE_RECEIVE_DISABLED */
|
/* #define USBD_CUSTOMHID_EP0_OUT_PREPARE_RECEIVE_DISABLED */
|
||||||
/* #define USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED */
|
/* #define USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED */
|
||||||
|
/* #define USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED */
|
||||||
|
|
||||||
/* VIDEO Class Config */
|
/* VIDEO Class Config */
|
||||||
#define UVC_1_1 /* #define UVC_1_0 */
|
#define UVC_1_1 /* #define UVC_1_0 */
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev);
|
|||||||
USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev);
|
USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev);
|
||||||
USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev);
|
USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev);
|
||||||
USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass);
|
USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass);
|
||||||
|
#if (USBD_USER_REGISTER_CALLBACK == 1U)
|
||||||
|
USBD_StatusTypeDef USBD_RegisterDevStateCallback(USBD_HandleTypeDef *pdev, USBD_DevStateCallbackTypeDef pUserCallback);
|
||||||
|
#endif /* USBD_USER_REGISTER_CALLBACK */
|
||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
USBD_StatusTypeDef USBD_RegisterClassComposite(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass,
|
USBD_StatusTypeDef USBD_RegisterClassComposite(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass,
|
||||||
|
|||||||
@@ -305,12 +305,13 @@ typedef struct
|
|||||||
/* USB Device handle structure */
|
/* USB Device handle structure */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint32_t status;
|
|
||||||
uint32_t total_length;
|
uint32_t total_length;
|
||||||
uint32_t rem_length;
|
uint32_t rem_length;
|
||||||
uint32_t maxpacket;
|
uint32_t bInterval;
|
||||||
uint16_t is_used;
|
uint16_t maxpacket;
|
||||||
uint16_t bInterval;
|
uint8_t status;
|
||||||
|
uint8_t is_used;
|
||||||
|
uint8_t *pbuffer;
|
||||||
} USBD_EndpointTypeDef;
|
} USBD_EndpointTypeDef;
|
||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
@@ -390,8 +391,15 @@ typedef struct _USBD_HandleTypeDef
|
|||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
USBD_CompositeElementTypeDef tclasslist[USBD_MAX_SUPPORTED_CLASS];
|
USBD_CompositeElementTypeDef tclasslist[USBD_MAX_SUPPORTED_CLASS];
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
#if (USBD_USER_REGISTER_CALLBACK == 1U)
|
||||||
|
void (* DevStateCallback)(uint8_t dev_state, uint8_t cfgidx); /*!< User Notification callback */
|
||||||
|
#endif /* USBD_USER_REGISTER_CALLBACK */
|
||||||
} USBD_HandleTypeDef;
|
} USBD_HandleTypeDef;
|
||||||
|
|
||||||
|
#if (USBD_USER_REGISTER_CALLBACK == 1U)
|
||||||
|
typedef void (*USBD_DevStateCallbackTypeDef)(uint8_t dev_state, uint8_t cfgidx); /*!< pointer to User callback function */
|
||||||
|
#endif /* USBD_USER_REGISTER_CALLBACK */
|
||||||
|
|
||||||
/* USB Device endpoint direction */
|
/* USB Device endpoint direction */
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,6 +25,10 @@
|
|||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
/* Exported types ------------------------------------------------------------*/
|
||||||
/* Exported constants --------------------------------------------------------*/
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/*
|
||||||
|
* User to provide a unique ID to define the USB device serial number
|
||||||
|
* The use of UID_BASE register can be considered as an example
|
||||||
|
*/
|
||||||
#define DEVICE_ID1 (UID_BASE)
|
#define DEVICE_ID1 (UID_BASE)
|
||||||
#define DEVICE_ID2 (UID_BASE + 0x4U)
|
#define DEVICE_ID2 (UID_BASE + 0x4U)
|
||||||
#define DEVICE_ID3 (UID_BASE + 0x8U)
|
#define DEVICE_ID3 (UID_BASE + 0x8U)
|
||||||
|
|||||||
@@ -83,11 +83,11 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_Init
|
* @brief USBD_Init
|
||||||
* Initializes the device stack and load the class driver
|
* Initialize the device stack and load the class driver
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param pdesc: Descriptor structure address
|
* @param pdesc: Descriptor structure address
|
||||||
* @param id: Low level core index
|
* @param id: Low level core index
|
||||||
* @retval None
|
* @retval status: USBD Status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev,
|
USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev,
|
||||||
USBD_DescriptorsTypeDef *pdesc, uint8_t id)
|
USBD_DescriptorsTypeDef *pdesc, uint8_t id)
|
||||||
@@ -142,9 +142,9 @@ USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_DeInit
|
* @brief USBD_DeInit
|
||||||
* Re-Initialize the device library
|
* De-Initialize the device library
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status: status
|
* @retval status: USBD Status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev)
|
USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
@@ -195,7 +195,7 @@ USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev)
|
|||||||
/**
|
/**
|
||||||
* @brief USBD_RegisterClass
|
* @brief USBD_RegisterClass
|
||||||
* Link class driver to Device Core.
|
* Link class driver to Device Core.
|
||||||
* @param pDevice : Device Handle
|
* @param pdev: Device Handle
|
||||||
* @param pclass: Class handle
|
* @param pclass: Class handle
|
||||||
* @retval USBD Status
|
* @retval USBD Status
|
||||||
*/
|
*/
|
||||||
@@ -228,7 +228,7 @@ USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDe
|
|||||||
#endif /* USE_USB_FS */
|
#endif /* USE_USB_FS */
|
||||||
|
|
||||||
/* Increment the NumClasses */
|
/* Increment the NumClasses */
|
||||||
pdev->NumClasses ++;
|
pdev->NumClasses++;
|
||||||
|
|
||||||
return USBD_OK;
|
return USBD_OK;
|
||||||
}
|
}
|
||||||
@@ -243,10 +243,10 @@ USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDe
|
|||||||
* @param EpAddr: Endpoint Address handle
|
* @param EpAddr: Endpoint Address handle
|
||||||
* @retval USBD Status
|
* @retval USBD Status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_RegisterClassComposite(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass,
|
USBD_StatusTypeDef USBD_RegisterClassComposite(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass,
|
||||||
USBD_CompositeClassTypeDef classtype, uint8_t *EpAddr)
|
USBD_CompositeClassTypeDef classtype, uint8_t *EpAddr)
|
||||||
{
|
{
|
||||||
USBD_StatusTypeDef ret = USBD_OK;
|
USBD_StatusTypeDef ret = USBD_OK;
|
||||||
uint16_t len = 0U;
|
uint16_t len = 0U;
|
||||||
|
|
||||||
if ((pdev->classId < USBD_MAX_SUPPORTED_CLASS) && (pdev->NumClasses < USBD_MAX_SUPPORTED_CLASS))
|
if ((pdev->classId < USBD_MAX_SUPPORTED_CLASS) && (pdev->NumClasses < USBD_MAX_SUPPORTED_CLASS))
|
||||||
@@ -291,12 +291,12 @@ USBD_StatusTypeDef USBD_RegisterClassComposite(USBD_HandleTypeDef *pdev, USBD_C
|
|||||||
/**
|
/**
|
||||||
* @brief USBD_UnRegisterClassComposite
|
* @brief USBD_UnRegisterClassComposite
|
||||||
* UnLink all composite class drivers from Device Core.
|
* UnLink all composite class drivers from Device Core.
|
||||||
* @param pDevice : Device Handle
|
* @param pdev: Device Handle
|
||||||
* @retval USBD Status
|
* @retval USBD Status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_UnRegisterClassComposite(USBD_HandleTypeDef *pdev)
|
USBD_StatusTypeDef USBD_UnRegisterClassComposite(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
USBD_StatusTypeDef ret = USBD_FAIL;
|
USBD_StatusTypeDef ret = USBD_OK;
|
||||||
uint8_t idx1;
|
uint8_t idx1;
|
||||||
uint8_t idx2;
|
uint8_t idx2;
|
||||||
|
|
||||||
@@ -358,10 +358,23 @@ USBD_StatusTypeDef USBD_UnRegisterClassComposite(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
|
#if (USBD_USER_REGISTER_CALLBACK == 1U)
|
||||||
|
/**
|
||||||
|
* @brief USBD_RegisterDevStateCallback
|
||||||
|
* @param pdev : Device Handle
|
||||||
|
* @param pUserCallback: User Callback
|
||||||
|
* @retval USBD Status
|
||||||
|
*/
|
||||||
|
USBD_StatusTypeDef USBD_RegisterDevStateCallback(USBD_HandleTypeDef *pdev, USBD_DevStateCallbackTypeDef pUserCallback)
|
||||||
|
{
|
||||||
|
pdev->DevStateCallback = pUserCallback;
|
||||||
|
|
||||||
|
return USBD_OK;
|
||||||
|
}
|
||||||
|
#endif /* USBD_USER_REGISTER_CALLBACK */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_Start
|
* @brief USBD_Start
|
||||||
* Start the USB Device Core.
|
* Start the USB Device Core.
|
||||||
@@ -487,7 +500,7 @@ USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
* Clear current configuration
|
* Clear current configuration
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param cfgidx: configuration index
|
* @param cfgidx: configuration index
|
||||||
* @retval status: USBD_StatusTypeDef
|
* @retval status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||||
{
|
{
|
||||||
@@ -527,6 +540,7 @@ USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
* @brief USBD_LL_SetupStage
|
* @brief USBD_LL_SetupStage
|
||||||
* Handle the setup stage
|
* Handle the setup stage
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
|
* @param psetup: setup packet buffer pointer
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup)
|
USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup)
|
||||||
@@ -576,6 +590,8 @@ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev,
|
|||||||
USBD_StatusTypeDef ret = USBD_OK;
|
USBD_StatusTypeDef ret = USBD_OK;
|
||||||
uint8_t idx;
|
uint8_t idx;
|
||||||
|
|
||||||
|
UNUSED(pdata);
|
||||||
|
|
||||||
if (epnum == 0U)
|
if (epnum == 0U)
|
||||||
{
|
{
|
||||||
pep = &pdev->ep_out[0];
|
pep = &pdev->ep_out[0];
|
||||||
@@ -585,8 +601,9 @@ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev,
|
|||||||
if (pep->rem_length > pep->maxpacket)
|
if (pep->rem_length > pep->maxpacket)
|
||||||
{
|
{
|
||||||
pep->rem_length -= pep->maxpacket;
|
pep->rem_length -= pep->maxpacket;
|
||||||
|
pep->pbuffer += pep->maxpacket;
|
||||||
|
|
||||||
(void)USBD_CtlContinueRx(pdev, pdata, MIN(pep->rem_length, pep->maxpacket));
|
(void)USBD_CtlContinueRx(pdev, pep->pbuffer, MAX(pep->rem_length, pep->maxpacket));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -661,6 +678,7 @@ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev,
|
|||||||
* Handle data in stage
|
* Handle data in stage
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param epnum: endpoint index
|
* @param epnum: endpoint index
|
||||||
|
* @param pdata: data pointer
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev,
|
USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev,
|
||||||
@@ -670,6 +688,8 @@ USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev,
|
|||||||
USBD_StatusTypeDef ret;
|
USBD_StatusTypeDef ret;
|
||||||
uint8_t idx;
|
uint8_t idx;
|
||||||
|
|
||||||
|
UNUSED(pdata);
|
||||||
|
|
||||||
if (epnum == 0U)
|
if (epnum == 0U)
|
||||||
{
|
{
|
||||||
pep = &pdev->ep_in[0];
|
pep = &pdev->ep_in[0];
|
||||||
@@ -679,8 +699,9 @@ USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev,
|
|||||||
if (pep->rem_length > pep->maxpacket)
|
if (pep->rem_length > pep->maxpacket)
|
||||||
{
|
{
|
||||||
pep->rem_length -= pep->maxpacket;
|
pep->rem_length -= pep->maxpacket;
|
||||||
|
pep->pbuffer += pep->maxpacket;
|
||||||
|
|
||||||
(void)USBD_CtlContinueSendData(pdev, pdata, pep->rem_length);
|
(void)USBD_CtlContinueSendData(pdev, pep->pbuffer, pep->rem_length);
|
||||||
|
|
||||||
/* Prepare endpoint for premature end of transfer */
|
/* Prepare endpoint for premature end of transfer */
|
||||||
(void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
|
(void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
|
||||||
@@ -753,7 +774,6 @@ USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev,
|
|||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
|
||||||
USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev)
|
USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
USBD_StatusTypeDef ret = USBD_OK;
|
USBD_StatusTypeDef ret = USBD_OK;
|
||||||
@@ -836,7 +856,6 @@ USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev,
|
|||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
|
||||||
USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev)
|
USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
if (pdev->dev_state != USBD_STATE_SUSPENDED)
|
if (pdev->dev_state != USBD_STATE_SUSPENDED)
|
||||||
@@ -855,7 +874,6 @@ USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev)
|
|||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
|
||||||
USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev)
|
USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
if (pdev->dev_state == USBD_STATE_SUSPENDED)
|
if (pdev->dev_state == USBD_STATE_SUSPENDED)
|
||||||
@@ -872,7 +890,6 @@ USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev)
|
|||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
|
||||||
USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
|
USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
/* The SOF event can be distributed for all classes that support it */
|
/* The SOF event can be distributed for all classes that support it */
|
||||||
@@ -913,6 +930,7 @@ USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
|
|||||||
* @brief USBD_LL_IsoINIncomplete
|
* @brief USBD_LL_IsoINIncomplete
|
||||||
* Handle iso in incomplete event
|
* Handle iso in incomplete event
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
|
* @param epnum: Endpoint number
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev,
|
USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev,
|
||||||
@@ -938,6 +956,7 @@ USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev,
|
|||||||
* @brief USBD_LL_IsoOUTIncomplete
|
* @brief USBD_LL_IsoOUTIncomplete
|
||||||
* Handle iso out incomplete event
|
* Handle iso out incomplete event
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
|
* @param epnum: Endpoint number
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev,
|
USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev,
|
||||||
|
|||||||
@@ -46,7 +46,9 @@
|
|||||||
/** @defgroup USBD_REQ_Private_Defines
|
/** @defgroup USBD_REQ_Private_Defines
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
#ifndef USBD_MAX_STR_DESC_SIZ
|
||||||
|
#define USBD_MAX_STR_DESC_SIZ 64U
|
||||||
|
#endif /* USBD_MAX_STR_DESC_SIZ */
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
@@ -421,7 +423,7 @@ USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef
|
|||||||
* Handle Get Descriptor requests
|
* Handle Get Descriptor requests
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param req: usb request
|
* @param req: usb request
|
||||||
* @retval status
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||||
{
|
{
|
||||||
@@ -454,7 +456,7 @@ static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *r
|
|||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
if ((uint8_t)(pdev->NumClasses) > 0U)
|
if ((uint8_t)(pdev->NumClasses) > 0U)
|
||||||
{
|
{
|
||||||
pbuf = (uint8_t *)USBD_CMPSIT.GetHSConfigDescriptor(&len);
|
pbuf = (uint8_t *)USBD_CMPSIT.GetHSConfigDescriptor(&len);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
@@ -468,12 +470,12 @@ static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *r
|
|||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
if ((uint8_t)(pdev->NumClasses) > 0U)
|
if ((uint8_t)(pdev->NumClasses) > 0U)
|
||||||
{
|
{
|
||||||
pbuf = (uint8_t *)USBD_CMPSIT.GetFSConfigDescriptor(&len);
|
pbuf = (uint8_t *)USBD_CMPSIT.GetFSConfigDescriptor(&len);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
{
|
{
|
||||||
pbuf = (uint8_t *)pdev->pClass[0]->GetFSConfigDescriptor(&len);
|
pbuf = (uint8_t *)pdev->pClass[0]->GetFSConfigDescriptor(&len);
|
||||||
}
|
}
|
||||||
pbuf[1] = USB_DESC_TYPE_CONFIGURATION;
|
pbuf[1] = USB_DESC_TYPE_CONFIGURATION;
|
||||||
}
|
}
|
||||||
@@ -558,7 +560,6 @@ static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *r
|
|||||||
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
|
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
|
||||||
pbuf = NULL;
|
pbuf = NULL;
|
||||||
|
|
||||||
|
|
||||||
for (uint32_t idx = 0U; (idx < pdev->NumClasses); idx++)
|
for (uint32_t idx = 0U; (idx < pdev->NumClasses); idx++)
|
||||||
{
|
{
|
||||||
if (pdev->pClass[idx]->GetUsrStrDescriptor != NULL)
|
if (pdev->pClass[idx]->GetUsrStrDescriptor != NULL)
|
||||||
@@ -576,13 +577,12 @@ static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||||
|
|
||||||
#if (USBD_CLASS_USER_STRING_DESC == 1U)
|
#if (USBD_CLASS_USER_STRING_DESC == 1U)
|
||||||
if (pdev->pDesc->GetUserStrDescriptor != NULL)
|
if (pdev->pDesc->GetUserStrDescriptor != NULL)
|
||||||
{
|
{
|
||||||
pbuf = pdev->pDesc->GetUserStrDescriptor(pdev->dev_speed, (req->wValue), &len);
|
pbuf = pdev->pDesc->GetUserStrDescriptor(pdev->dev_speed, LOBYTE(req->wValue), &len);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -677,7 +677,7 @@ static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *r
|
|||||||
* Set device address
|
* Set device address
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param req: usb request
|
* @param req: usb request
|
||||||
* @retval status
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void USBD_SetAddress(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
static void USBD_SetAddress(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||||
{
|
{
|
||||||
@@ -751,6 +751,13 @@ static USBD_StatusTypeDef USBD_SetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReq
|
|||||||
{
|
{
|
||||||
(void)USBD_CtlSendStatus(pdev);
|
(void)USBD_CtlSendStatus(pdev);
|
||||||
pdev->dev_state = USBD_STATE_CONFIGURED;
|
pdev->dev_state = USBD_STATE_CONFIGURED;
|
||||||
|
|
||||||
|
#if (USBD_USER_REGISTER_CALLBACK == 1U)
|
||||||
|
if (pdev->DevStateCallback != NULL)
|
||||||
|
{
|
||||||
|
pdev->DevStateCallback(USBD_STATE_CONFIGURED, cfgidx);
|
||||||
|
}
|
||||||
|
#endif /* USBD_USER_REGISTER_CALLBACK */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -809,7 +816,7 @@ static USBD_StatusTypeDef USBD_SetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReq
|
|||||||
* Handle Get device configuration request
|
* Handle Get device configuration request
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param req: usb request
|
* @param req: usb request
|
||||||
* @retval status
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void USBD_GetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
static void USBD_GetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||||
{
|
{
|
||||||
@@ -843,7 +850,7 @@ static void USBD_GetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
* Handle Get Status request
|
* Handle Get Status request
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param req: usb request
|
* @param req: usb request
|
||||||
* @retval status
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void USBD_GetStatus(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
static void USBD_GetStatus(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||||
{
|
{
|
||||||
@@ -884,7 +891,7 @@ static void USBD_GetStatus(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
* Handle Set device feature request
|
* Handle Set device feature request
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param req: usb request
|
* @param req: usb request
|
||||||
* @retval status
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void USBD_SetFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
static void USBD_SetFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||||
{
|
{
|
||||||
@@ -910,7 +917,7 @@ static void USBD_SetFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
* Handle clear device feature request
|
* Handle clear device feature request
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param req: usb request
|
* @param req: usb request
|
||||||
* @retval status
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void USBD_ClrFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
static void USBD_ClrFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||||
{
|
{
|
||||||
@@ -936,8 +943,8 @@ static void USBD_ClrFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
/**
|
/**
|
||||||
* @brief USBD_ParseSetupRequest
|
* @brief USBD_ParseSetupRequest
|
||||||
* Copy buffer into setup structure
|
* Copy buffer into setup structure
|
||||||
* @param pdev: device instance
|
|
||||||
* @param req: usb request
|
* @param req: usb request
|
||||||
|
* @param pdata: setup data pointer
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata)
|
void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata)
|
||||||
@@ -997,7 +1004,7 @@ void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pdesc = desc;
|
pdesc = desc;
|
||||||
*len = ((uint16_t)USBD_GetLen(pdesc) * 2U) + 2U;
|
*len = MIN(USBD_MAX_STR_DESC_SIZ, ((uint16_t)USBD_GetLen(pdesc) * 2U) + 2U);
|
||||||
|
|
||||||
unicode[idx] = *(uint8_t *)len;
|
unicode[idx] = *(uint8_t *)len;
|
||||||
idx++;
|
idx++;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ USBD_DescriptorsTypeDef Class_Desc =
|
|||||||
USBD_Class_ConfigStrDescriptor,
|
USBD_Class_ConfigStrDescriptor,
|
||||||
USBD_Class_InterfaceStrDescriptor,
|
USBD_Class_InterfaceStrDescriptor,
|
||||||
#if (USBD_CLASS_USER_STRING_DESC == 1)
|
#if (USBD_CLASS_USER_STRING_DESC == 1)
|
||||||
USBD_CLASS_UserStrDescriptor,
|
USBD_Class_UserStrDescriptor,
|
||||||
#endif /* USB_CLASS_USER_STRING_DESC */
|
#endif /* USB_CLASS_USER_STRING_DESC */
|
||||||
|
|
||||||
#if ((USBD_LPM_ENABLED == 1) || (USBD_CLASS_BOS_ENABLED == 1))
|
#if ((USBD_LPM_ENABLED == 1) || (USBD_CLASS_BOS_ENABLED == 1))
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
|
|||||||
/* Set EP0 State */
|
/* Set EP0 State */
|
||||||
pdev->ep0_state = USBD_EP0_DATA_IN;
|
pdev->ep0_state = USBD_EP0_DATA_IN;
|
||||||
pdev->ep_in[0].total_length = len;
|
pdev->ep_in[0].total_length = len;
|
||||||
|
pdev->ep_in[0].pbuffer = pbuf;
|
||||||
|
|
||||||
#ifdef USBD_AVOID_PACKET_SPLIT_MPS
|
#ifdef USBD_AVOID_PACKET_SPLIT_MPS
|
||||||
pdev->ep_in[0].rem_length = 0U;
|
pdev->ep_in[0].rem_length = 0U;
|
||||||
@@ -133,6 +134,7 @@ USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
|
|||||||
/* Set EP0 State */
|
/* Set EP0 State */
|
||||||
pdev->ep0_state = USBD_EP0_DATA_OUT;
|
pdev->ep0_state = USBD_EP0_DATA_OUT;
|
||||||
pdev->ep_out[0].total_length = len;
|
pdev->ep_out[0].total_length = len;
|
||||||
|
pdev->ep_out[0].pbuffer = pbuf;
|
||||||
|
|
||||||
#ifdef USBD_AVOID_PACKET_SPLIT_MPS
|
#ifdef USBD_AVOID_PACKET_SPLIT_MPS
|
||||||
pdev->ep_out[0].rem_length = 0U;
|
pdev->ep_out[0].rem_length = 0U;
|
||||||
|
|||||||
94
LICENSE.md
Normal file
94
LICENSE.md
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
This software component is provided to you as part of a software package and
|
||||||
|
applicable license terms are in the Package_license file. If you received this
|
||||||
|
software component outside of a package or without applicable license terms,
|
||||||
|
the terms of the SLA0044 license shall apply and are fully reproduced below:
|
||||||
|
|
||||||
|
SLA0044 Rev6/October 2025
|
||||||
|
|
||||||
|
## Software license agreement
|
||||||
|
|
||||||
|
### __ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT__
|
||||||
|
|
||||||
|
BY CLICKING ON THE "I ACCEPT" BUTTON OR BY UNZIPPING, INSTALLING, COPYING,
|
||||||
|
DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE OR ANY PART THEREOF,
|
||||||
|
INCLUDING ANY RELATED DOCUMENTATION (collectively the “SOFTWARE”)
|
||||||
|
FROM STMICROELECTRONICS INTERNATIONAL N.V, SWISS BRANCH AND/OR
|
||||||
|
ITS AFFILIATED COMPANIES (collectively “STMICROELECTRONICS”),
|
||||||
|
YOU (hereinafter referred also to as “THE RECIPIENT”), ON BEHALF OF YOURSELF,
|
||||||
|
OR ON BEHALF OF ANY ENTITY BY WHICH YOU ARE EMPLOYED AND/OR ENGAGED,
|
||||||
|
AGREE TO BE BOUND BY THIS AGREEMENT.
|
||||||
|
|
||||||
|
Under STMICROELECTRONICS’ intellectual property rights, the redistribution,
|
||||||
|
reproduction and use in source and binary forms of the SOFTWARE or any part
|
||||||
|
thereof, with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
1. Redistribution of source code (modified or not) must retain any copyright
|
||||||
|
notice accompanying the SOFTWARE, this list of conditions and the disclaimer below.
|
||||||
|
|
||||||
|
2. Redistributions in binary form, except as embedded into a processing unit device
|
||||||
|
manufactured by or for STMicroelectronics or a software update for any such device,
|
||||||
|
must reproduce the accompanying copyright notice, this list of conditions,
|
||||||
|
and the below disclaimer in capital type, in the documentation and/or
|
||||||
|
other materials provided with the distribution.
|
||||||
|
|
||||||
|
3. Neither the name of STMicroelectronics nor the names of other contributors
|
||||||
|
to the SOFTWARE may be used to endorse or promote products derived
|
||||||
|
from the SOFTWARE or part thereof without specific written permission.
|
||||||
|
|
||||||
|
4. The SOFTWARE or any part thereof, including modifications and/or
|
||||||
|
derivative works of the SOFTWARE, must be used and execute solely
|
||||||
|
and exclusively on or in combination with a processing unit device
|
||||||
|
manufactured by or for STMicroelectronics.
|
||||||
|
|
||||||
|
5. No use, reproduction or redistribution of the SOFTWARE partially
|
||||||
|
or totally may be done in any manner that would subject the SOFTWARE
|
||||||
|
to any Open Source Terms. “Open Source Terms” shall mean
|
||||||
|
any open source license which requires as part of distribution
|
||||||
|
of software that the source code of such software is distributed
|
||||||
|
therewith or otherwise made available, or open source license
|
||||||
|
that substantially complies with the Open Source definition specified
|
||||||
|
at www.opensource.org and any other comparable open source license
|
||||||
|
such as for example GNU General Public License (GPL),
|
||||||
|
Eclipse Public License (EPL), Apache Software License, BSD license
|
||||||
|
or MIT license.
|
||||||
|
|
||||||
|
6. STMicroelectronics has no obligation to provide any maintenance,
|
||||||
|
support or updates for the SOFTWARE.
|
||||||
|
|
||||||
|
7. The SOFTWARE is and will remain the exclusive property of
|
||||||
|
STMicroelectronics and its licensors. The RECIPIENT will not take
|
||||||
|
any action that jeopardizes STMicroelectronics and its
|
||||||
|
licensors' proprietary rights or acquire any rights in the SOFTWARE,
|
||||||
|
except the limited rights specified hereunder.
|
||||||
|
|
||||||
|
8. The RECIPIENT shall comply with all applicable laws and regulations
|
||||||
|
affecting the use of the SOFTWARE or any part thereof including
|
||||||
|
any applicable export control law or regulation.
|
||||||
|
|
||||||
|
9. Redistribution and use of the SOFTWARE or any part thereof other
|
||||||
|
than as permitted under this AGREEMENT is void and will automatically
|
||||||
|
terminate RECIPIENT’s rights under this AGREEMENT.
|
||||||
|
|
||||||
|
10. The RECIPIENT shall be solely liable to determine and verify that
|
||||||
|
the SOFTWARE is fit for the RECIPIENT intended use, environment or
|
||||||
|
application and comply with all regulatory, safety and security
|
||||||
|
related requirements concerning any use.
|
||||||
|
|
||||||
|
DISCLAIMER:
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING,BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, ARE
|
||||||
|
DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW.
|
||||||
|
IN NO EVENT SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||||
|
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS,
|
||||||
|
WHETHER EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL
|
||||||
|
PROPERTY RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY.
|
||||||
86
LICENSE.txt
86
LICENSE.txt
@@ -1,86 +0,0 @@
|
|||||||
This software component is provided to you as part of a software package and
|
|
||||||
applicable license terms are in the Package_license file. If you received this
|
|
||||||
software component outside of a package or without applicable license terms,
|
|
||||||
the terms of the SLA0044 license shall apply and are fully reproduced below:
|
|
||||||
|
|
||||||
SLA0044 Rev5/February 2018
|
|
||||||
|
|
||||||
Software license agreement
|
|
||||||
|
|
||||||
ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT
|
|
||||||
|
|
||||||
BY INSTALLING, COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE
|
|
||||||
OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS
|
|
||||||
INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES
|
|
||||||
(STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON
|
|
||||||
BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES
|
|
||||||
TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT.
|
|
||||||
|
|
||||||
Under STMicroelectronics’ intellectual property rights, the redistribution,
|
|
||||||
reproduction and use in source and binary forms of the software or any part
|
|
||||||
thereof, with or without modification, are permitted provided that the following
|
|
||||||
conditions are met:
|
|
||||||
|
|
||||||
1. Redistribution of source code (modified or not) must retain any copyright
|
|
||||||
notice, this list of conditions and the disclaimer set forth below as items 10
|
|
||||||
and 11.
|
|
||||||
|
|
||||||
2. Redistributions in binary form, except as embedded into microcontroller or
|
|
||||||
microprocessor device manufactured by or for STMicroelectronics or a software
|
|
||||||
update for such device, must reproduce any copyright notice provided with the
|
|
||||||
binary code, this list of conditions, and the disclaimer set forth below as
|
|
||||||
items 10 and 11, in documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
|
|
||||||
3. Neither the name of STMicroelectronics nor the names of other contributors to
|
|
||||||
this software may be used to endorse or promote products derived from this
|
|
||||||
software or part thereof without specific written permission.
|
|
||||||
|
|
||||||
4. This software or any part thereof, including modifications and/or derivative
|
|
||||||
works of this software, must be used and execute solely and exclusively on or in
|
|
||||||
combination with a microcontroller or microprocessor device manufactured by or
|
|
||||||
for STMicroelectronics.
|
|
||||||
|
|
||||||
5. No use, reproduction or redistribution of this software partially or totally
|
|
||||||
may be done in any manner that would subject this software to any Open Source
|
|
||||||
Terms. “Open Source Terms” shall mean any open source license which requires as
|
|
||||||
part of distribution of software that the source code of such software is
|
|
||||||
distributed therewith or otherwise made available, or open source license that
|
|
||||||
substantially complies with the Open Source definition specified at
|
|
||||||
www.opensource.org and any other comparable open source license such as for
|
|
||||||
example GNU General Public License (GPL), Eclipse Public License (EPL), Apache
|
|
||||||
Software License, BSD license or MIT license.
|
|
||||||
|
|
||||||
6. STMicroelectronics has no obligation to provide any maintenance, support or
|
|
||||||
updates for the software.
|
|
||||||
|
|
||||||
7. The software is and will remain the exclusive property of STMicroelectronics
|
|
||||||
and its licensors. The recipient will not take any action that jeopardizes
|
|
||||||
STMicroelectronics and its licensors' proprietary rights or acquire any rights
|
|
||||||
in the software, except the limited rights specified hereunder.
|
|
||||||
|
|
||||||
8. The recipient shall comply with all applicable laws and regulations affecting
|
|
||||||
the use of the software or any part thereof including any applicable export
|
|
||||||
control law or regulation.
|
|
||||||
|
|
||||||
9. Redistribution and use of this software or any part thereof other than as
|
|
||||||
permitted under this license is void and will automatically terminate your
|
|
||||||
rights under this license.
|
|
||||||
|
|
||||||
10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE
|
|
||||||
DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL
|
|
||||||
STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
||||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER
|
|
||||||
EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY
|
|
||||||
RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY.
|
|
||||||
|
|
||||||
80
License.md
80
License.md
@@ -1,80 +0,0 @@
|
|||||||
SLA0044 Rev5/February 2018
|
|
||||||
|
|
||||||
## Software license agreement
|
|
||||||
|
|
||||||
### __ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT__
|
|
||||||
|
|
||||||
BY INSTALLING, COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE
|
|
||||||
OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS
|
|
||||||
INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES
|
|
||||||
(STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON
|
|
||||||
BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES
|
|
||||||
TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT.
|
|
||||||
|
|
||||||
Under STMicroelectronics’ intellectual property rights, the redistribution,
|
|
||||||
reproduction and use in source and binary forms of the software or any part
|
|
||||||
thereof, with or without modification, are permitted provided that the following
|
|
||||||
conditions are met:
|
|
||||||
|
|
||||||
1. Redistribution of source code (modified or not) must retain any copyright
|
|
||||||
notice, this list of conditions and the disclaimer set forth below as items 10
|
|
||||||
and 11.
|
|
||||||
|
|
||||||
2. Redistributions in binary form, except as embedded into microcontroller or
|
|
||||||
microprocessor device manufactured by or for STMicroelectronics or a software
|
|
||||||
update for such device, must reproduce any copyright notice provided with the
|
|
||||||
binary code, this list of conditions, and the disclaimer set forth below as
|
|
||||||
items 10 and 11, in documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
|
|
||||||
3. Neither the name of STMicroelectronics nor the names of other contributors to
|
|
||||||
this software may be used to endorse or promote products derived from this
|
|
||||||
software or part thereof without specific written permission.
|
|
||||||
|
|
||||||
4. This software or any part thereof, including modifications and/or derivative
|
|
||||||
works of this software, must be used and execute solely and exclusively on or in
|
|
||||||
combination with a microcontroller or microprocessor device manufactured by or
|
|
||||||
for STMicroelectronics.
|
|
||||||
|
|
||||||
5. No use, reproduction or redistribution of this software partially or totally
|
|
||||||
may be done in any manner that would subject this software to any Open Source
|
|
||||||
Terms. “Open Source Terms” shall mean any open source license which requires as
|
|
||||||
part of distribution of software that the source code of such software is
|
|
||||||
distributed therewith or otherwise made available, or open source license that
|
|
||||||
substantially complies with the Open Source definition specified at
|
|
||||||
www.opensource.org and any other comparable open source license such as for
|
|
||||||
example GNU General Public License (GPL), Eclipse Public License (EPL), Apache
|
|
||||||
Software License, BSD license or MIT license.
|
|
||||||
|
|
||||||
6. STMicroelectronics has no obligation to provide any maintenance, support or
|
|
||||||
updates for the software.
|
|
||||||
|
|
||||||
7. The software is and will remain the exclusive property of STMicroelectronics
|
|
||||||
and its licensors. The recipient will not take any action that jeopardizes
|
|
||||||
STMicroelectronics and its licensors' proprietary rights or acquire any rights
|
|
||||||
in the software, except the limited rights specified hereunder.
|
|
||||||
|
|
||||||
8. The recipient shall comply with all applicable laws and regulations affecting
|
|
||||||
the use of the software or any part thereof including any applicable export
|
|
||||||
control law or regulation.
|
|
||||||
|
|
||||||
9. Redistribution and use of this software or any part thereof other than as
|
|
||||||
permitted under this license is void and will automatically terminate your
|
|
||||||
rights under this license.
|
|
||||||
|
|
||||||
10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE
|
|
||||||
DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL
|
|
||||||
STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
||||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER
|
|
||||||
EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY
|
|
||||||
RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY.
|
|
||||||
50
README.md
50
README.md
@@ -1,36 +1,40 @@
|
|||||||
# Middleware USB Device MCU Component
|
# USB Device Middleware Library MCU Software Component
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Overview
|
## Overview of the STM32Cube MCU offer on GitHub
|
||||||
|
|
||||||
**STM32Cube** is an STMicroelectronics original initiative to ease developers' life by reducing efforts, time and cost.
|
**STM32Cube** is an original initiative by STMicroelectronics to **simplify** prototyping and development by **reducing** effort, time, and cost. It supports the entire ARM™ Cortex-based STM32 microcontroller portfolio and provides a **comprehensive** software solution including:
|
||||||
|
* The CMSIS Core and Device interfaces enabling access to processor core features and device-specific peripherals of STM32 microcontrollers.
|
||||||
|
* The STM32 HAL-LL drivers, an abstraction layer offering a set of APIs ensuring maximized portability across the STM32 portfolio.
|
||||||
|
* The BSP drivers enabling access to peripherals on the STM32 development boards, external to the microcontroller itself.
|
||||||
|
* A consistent set of middleware libraries offering standardized, high-level functionalities — such as USB, TCP/IP, file systems, and graphics.
|
||||||
|
* A full set of software projects (basic examples, applications, and demonstrations) that showcase specific functionalities or use cases, and provided with support for multiple IDEs.
|
||||||
|
|
||||||
**STM32Cube** covers the overall STM32 products portfolio. It includes a comprehensive embedded software platform delivered for each STM32 series.
|
The **STM32Cube embedded software** is available in two flavors:
|
||||||
* The CMSIS modules (core and device) corresponding to the ARM(tm) core implemented in this STM32 product.
|
* The **MCU Firmware** _monolithic_ offer, where **all** software components (Drivers, Middleware, Projects, Utilities) are included in a **single** repository for each STM32 series.
|
||||||
* The STM32 HAL-LL drivers, an abstraction layer offering a set of APIs ensuring maximized portability across the STM32 portfolio.
|
* The **MCU Software Components** _modular_ offer, where **each** software component (mainly Drivers and Middleware) is provided in a **dedicated** repository, allowing users to **select** only the components they need.
|
||||||
* The BSP drivers of each evaluation, demonstration or nucleo board provided for this STM32 series.
|
|
||||||
* A consistent set of middleware libraries such as RTOS, USB, FatFS, graphics, touch sensing library...
|
|
||||||
* A full set of software projects (basic examples, applications, and demonstrations) for each board provided for this STM32 series.
|
|
||||||
|
|
||||||
Two models of publication are proposed for the STM32Cube embedded software:
|
The complete list of repositories is available [here](https://github.com/STMicroelectronics/STM32Cube_MCU_Overall_Offer/blob/master/README.md#content).
|
||||||
* The monolithic **MCU Package**: all STM32Cube software modules of one STM32 series are present (Drivers, Middleware, Projects, Utilities) in the repository (usual name **STM32Cubexx**, xx corresponding to the STM32 series).
|
|
||||||
* The **MCU component**: each STM32Cube software module being part of the STM32Cube MCU Package, is delivered as an individual repository, allowing the user to select and get only the required software functions.
|
|
||||||
|
|
||||||
## Description
|
## Repository content
|
||||||
|
|
||||||
This **stm32_mw_usb_device** MCU component repository is one element **common to all** STM32Cube MCU embedded software packages, providing the **USB Device MCU Middleware** part.
|
This repository provides the STM32Cube **USB Device** Middleware Library, **common to every** STM32Cube MCU firmware that supports it.
|
||||||
|
|
||||||
It represents ST offer to ensure the support of USB Devices on STM32 MCUs.
|
This represents STMicroelectronics’ offering to support the USB Device role on STM32 MCUs. It includes two main modules:
|
||||||
It includes two main modules:
|
|
||||||
* **Core** module for the USB device standard peripheral control APIs. It includes the files ensuring USB 2.0 standard code implementation for an USB device.
|
- **Core**: provides USB Device standard peripheral control APIs implementing the USB 2.0 standard code for a USB device. These APIs are called in every USB Device application, regardless of the desired functionality.
|
||||||
These files’ APIs will be called within every USB device application regardless of the desired functionality.
|
|
||||||
* **Class** module for the commonly supported classes APIs. it includes the files including different USB device classes. All STM32 USB classes are implemented according to the USB 2.0 and every class’s specifications. These files’ APIs will be called within USB device applications according to the desired functionality.
|
- **Class**: provides APIs for commonly supported USB Device classes complying with USB 2.0 standard and their respective class specifications. These APIs are called in USB Device applications based on the desired functionality.
|
||||||
|
|
||||||
## Release note
|
## Release note
|
||||||
|
|
||||||
Details about the content of this release are available in the release note [here](https://htmlpreview.github.io/?https://github.com/STMicroelectronics/stm32_mw_usb_device/blob/master/Release_Notes.html).
|
Details about the content of this release are available in the release note [here](https://htmlpreview.github.io/?https://github.com/STMicroelectronics/stm32-mw-usb-device/blob/master/Release_Notes.html).
|
||||||
|
|
||||||
## Troubleshooting
|
## Compatibility information
|
||||||
|
|
||||||
Please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) guide.
|
Please refer to the **release note** in the firmware repository for the STM32 series you are using ([list](https://github.com/STMicroelectronics/STM32Cube_MCU_Overall_Offer/blob/master/README.md#stm32cube-mcu-packages)). It is **important** to use a **consistent set** of software component versions (i.e., CMSIS, HAL-LL, BSP, MW) as specified in the release note.
|
||||||
|
|
||||||
|
## Feedback and contributions
|
||||||
|
|
||||||
|
Please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) guide.
|
||||||
|
|||||||
@@ -59,9 +59,169 @@ Page</a> : STM32Cube USB Wiki Page</li>
|
|||||||
<section id="update-history" class="col-sm-12 col-lg-8">
|
<section id="update-history" class="col-sm-12 col-lg-8">
|
||||||
<h1>Update History</h1>
|
<h1>Update History</h1>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section23" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section26" checked aria-hidden="true">
|
||||||
<label for="collapse-section23" aria-hidden="true">V2.11.1 /
|
<label for="collapse-section26" aria-hidden="true">V2.11.5 /
|
||||||
|
26-September-2025</label>
|
||||||
|
<div>
|
||||||
|
<h2 id="main-changes">Main Changes</h2>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr class="header">
|
||||||
|
<th style="text-align: left;">Headline</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr class="even">
|
||||||
|
<td style="text-align: left;"><strong>USB Core:</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td style="text-align: left;">SLA0044 Legal terms updated to latest revision (Rev 6 / October 2025)</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="even">
|
||||||
|
<td style="text-align: left;"><strong>USB Classes:</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="even">
|
||||||
|
<td style="text-align: left;">Add missing NULL pointer for user string descriptor</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td style="text-align: left;"><strong>USB MTP Class:</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="even">
|
||||||
|
<td style="text-align: left;">Minor enhancement; improve device data buffer management</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="collapse">
|
||||||
|
<input type="checkbox" id="collapse-section25" aria-hidden="true">
|
||||||
|
<label for="collapse-section25" aria-hidden="true">V2.11.4 /
|
||||||
|
11-April-2025</label>
|
||||||
|
<div>
|
||||||
|
<h2 id="main-changes">Main Changes</h2>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr class="header">
|
||||||
|
<th style="text-align: left;">Headline</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr class="even">
|
||||||
|
<td style="text-align: left;"><strong>USB Core:</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td style="text-align: left;">Fix return value of USBD_UnRegisterClassComposite function</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="even">
|
||||||
|
<td style="text-align: left;">Increment EP0 data buffer inside HAL data callbacks</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td style="text-align: left;"><strong>USB MSC Class:</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="even">
|
||||||
|
<td style="text-align: left;">Adding multi LUN support</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td style="text-align: left;"><strong>USB CustomHID Class:</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="even">
|
||||||
|
<td style="text-align: left;">Adding support of different CustomHID report descriptor sizes</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td style="text-align: left;">Fix composite builder CustomHID EP size</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="even">
|
||||||
|
<td style="text-align: left;"><strong>USB MTP Class:</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td style="text-align: left;">Minor enhancement; improve device data buffer management</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="collapse">
|
||||||
|
<input type="checkbox" id="collapse-section24" aria-hidden="true">
|
||||||
|
<label for="collapse-section24" aria-hidden="true">V2.11.3 /
|
||||||
|
20-December-2023</label>
|
||||||
|
<div>
|
||||||
|
<h2 id="main-changes">Main Changes</h2>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr class="header">
|
||||||
|
<th style="text-align: left;">Headline</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr class="even">
|
||||||
|
<td style="text-align: left;"><strong>USB Core:</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td style="text-align: left;">Minor enhancement; add a check on device string descriptor length</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="even">
|
||||||
|
<td style="text-align: left;"><strong>USB DFU Class:</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td style="text-align: left;">Improve DFU Vendor Commands support</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="collapse">
|
||||||
|
<input type="checkbox" id="collapse-section23" aria-hidden="true">
|
||||||
|
<label for="collapse-section23" aria-hidden="true">V2.11.2 /
|
||||||
|
17-April-2023</label>
|
||||||
|
<div>
|
||||||
|
<h2 id="main-changes">Main Changes</h2>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr class="header">
|
||||||
|
<th style="text-align: left;">Headline</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr class="even">
|
||||||
|
<td style="text-align: left;"><strong>USB Core:</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td style="text-align: left;">Adding user callback to get device configuration state</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="even">
|
||||||
|
<td style="text-align: left;"><strong>USB DFU Class:</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td style="text-align: left;">Adding DFU Vendor Commands support</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="even">
|
||||||
|
<td style="text-align: left;"><strong>USB MSC Class:</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td style="text-align: left;">fix data sense response to be aligned with SBC-3 specification</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="even">
|
||||||
|
<td style="text-align: left;"><strong>USB AUDIO Class:</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td style="text-align: left;">restart AUDIO ISO endpoint during ISO incomplete event</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="even">
|
||||||
|
<td style="text-align: left;"><strong>USB VIDEO Class:</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="odd">
|
||||||
|
<td style="text-align: left;">restart VIDEO ISO endpoint during ISO incomplete event</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="collapse">
|
||||||
|
<input type="checkbox" id="collapse-section22" aria-hidden="true">
|
||||||
|
<label for="collapse-section22" aria-hidden="true">V2.11.1 /
|
||||||
27-September-2022</label>
|
27-September-2022</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes">Main Changes</h2>
|
<h2 id="main-changes">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -105,10 +265,12 @@ CustomHID, MSC & Video Classes:</strong></td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section22" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section21" aria-hidden="true">
|
||||||
<label for="collapse-section22" aria-hidden="true">V2.11.0 /
|
<label for="collapse-section21" aria-hidden="true">V2.11.0 /
|
||||||
25-March-2022</label>
|
25-March-2022</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes">Main Changes</h2>
|
<h2 id="main-changes">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -122,7 +284,7 @@ CustomHID, MSC & Video Classes:</strong></td>
|
|||||||
</tr>
|
</tr>
|
||||||
<tr class="even">
|
<tr class="even">
|
||||||
<td style="text-align: left;">Correction of the support of
|
<td style="text-align: left;">Correction of the support of
|
||||||
VS_PROBE_CONTROL & VS_COMMIT_CONTROL requets</td>
|
VS_PROBE_CONTROL & VS_COMMIT_CONTROL requests</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="odd">
|
<tr class="odd">
|
||||||
<td style="text-align: left;"><strong>USB AUDIO Class:</strong></td>
|
<td style="text-align: left;"><strong>USB AUDIO Class:</strong></td>
|
||||||
@@ -177,10 +339,12 @@ style</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section21" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section20" aria-hidden="true">
|
||||||
<label for="collapse-section21" aria-hidden="true">V2.10.0 /
|
<label for="collapse-section20" aria-hidden="true">V2.10.0 /
|
||||||
03-Sept-2021</label>
|
03-Sept-2021</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-1">Main Changes</h2>
|
<h2 id="main-changes-1">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -216,10 +380,12 @@ selected</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section20" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section19" aria-hidden="true">
|
||||||
<label for="collapse-section20" aria-hidden="true">V2.9.0 /
|
<label for="collapse-section19" aria-hidden="true">V2.9.0 /
|
||||||
06-July-2021</label>
|
06-July-2021</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-2">Main Changes</h2>
|
<h2 id="main-changes-2">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -249,7 +415,7 @@ Serial Bus Device Class Media Transfer Protocol Revision 1.1</td>
|
|||||||
Style</td>
|
Style</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="even">
|
<tr class="even">
|
||||||
<td style="text-align: left;">Update the way to declare licenses</td>
|
<td style="text-align: left;">Update the way to declare Legal terms</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="odd">
|
<tr class="odd">
|
||||||
<td style="text-align: left;"><strong>USB CDC/RNDIS/ECM
|
<td style="text-align: left;"><strong>USB CDC/RNDIS/ECM
|
||||||
@@ -262,10 +428,12 @@ missing casting during class handler allocation</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section19" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section18" aria-hidden="true">
|
||||||
<label for="collapse-section19" aria-hidden="true">V2.8.0 /
|
<label for="collapse-section18" aria-hidden="true">V2.8.0 /
|
||||||
10-Mars-2021</label>
|
10-Mars-2021</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-3">Main Changes</h2>
|
<h2 id="main-changes-3">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -312,10 +480,12 @@ format support</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section17" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section17" aria-hidden="true">
|
||||||
<label for="collapse-section17" aria-hidden="true">V2.7.1 /
|
<label for="collapse-section17" aria-hidden="true">V2.7.1 /
|
||||||
18-August-2020</label>
|
18-August-2020</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-4">Main Changes</h2>
|
<h2 id="main-changes-4">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -331,10 +501,12 @@ check to Class handler</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section16" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section16" aria-hidden="true">
|
||||||
<label for="collapse-section16" aria-hidden="true">V2.7.0 /
|
<label for="collapse-section16" aria-hidden="true">V2.7.0 /
|
||||||
12-August-2020</label>
|
12-August-2020</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-5">Main Changes</h2>
|
<h2 id="main-changes-5">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -416,10 +588,12 @@ user code</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section15" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section15" aria-hidden="true">
|
||||||
<label for="collapse-section15" aria-hidden="true">V2.6.1 /
|
<label for="collapse-section15" aria-hidden="true">V2.6.1 /
|
||||||
05-June-2020</label>
|
05-June-2020</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-6">Main Changes</h2>
|
<h2 id="main-changes-6">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -456,10 +630,12 @@ compatibility with device library version below v2.6.0</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section14" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section14" aria-hidden="true">
|
||||||
<label for="collapse-section14" aria-hidden="true">V2.6.0 /
|
<label for="collapse-section14" aria-hidden="true">V2.6.0 /
|
||||||
27-December-2019</label>
|
27-December-2019</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-7">Main Changes</h2>
|
<h2 id="main-changes-7">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -539,10 +715,12 @@ transfer: USBD_CUSTOM_HID_ReceivePacket()</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section13" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section13" aria-hidden="true">
|
||||||
<label for="collapse-section13" aria-hidden="true">V2.5.3 /
|
<label for="collapse-section13" aria-hidden="true">V2.5.3 /
|
||||||
30-April-2019</label>
|
30-April-2019</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-8">Main Changes</h2>
|
<h2 id="main-changes-8">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -578,10 +756,12 @@ device state only if the current state is USBD_STATE_SUSPENDED</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section12" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section12" aria-hidden="true">
|
||||||
<label for="collapse-section12" aria-hidden="true">V2.5.2 /
|
<label for="collapse-section12" aria-hidden="true">V2.5.2 /
|
||||||
27-Mars-2019</label>
|
27-Mars-2019</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-9">Main Changes</h2>
|
<h2 id="main-changes-9">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -598,10 +778,12 @@ NVIC_SystemReset() prototype change</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section11" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section11" aria-hidden="true">
|
||||||
<label for="collapse-section11" aria-hidden="true">V2.5.1 /
|
<label for="collapse-section11" aria-hidden="true">V2.5.1 /
|
||||||
03-August-2018</label>
|
03-August-2018</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-10">Main Changes</h2>
|
<h2 id="main-changes-10">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -611,8 +793,8 @@ NVIC_SystemReset() prototype change</td>
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr class="odd">
|
<tr class="odd">
|
||||||
<td style="text-align: left;">Update license section by adding path to
|
<td style="text-align: left;">Update Legal terms section by adding path to
|
||||||
get copy of ST Ultimate Liberty license</td>
|
get copy of ST Ultimate Liberty Legal terms</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="even">
|
<tr class="even">
|
||||||
<td style="text-align: left;">Core: Fix unexpected stall during status
|
<td style="text-align: left;">Core: Fix unexpected stall during status
|
||||||
@@ -633,10 +815,12 @@ Break on USBD_Template_Setup API</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section10" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section10" aria-hidden="true">
|
||||||
<label for="collapse-section10" aria-hidden="true">V2.5.0 /
|
<label for="collapse-section10" aria-hidden="true">V2.5.0 /
|
||||||
15-December-2017</label>
|
15-December-2017</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-11">Main Changes</h2>
|
<h2 id="main-changes-11">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -646,7 +830,7 @@ Break on USBD_Template_Setup API</td>
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr class="odd">
|
<tr class="odd">
|
||||||
<td style="text-align: left;">Update license section</td>
|
<td style="text-align: left;">Update Legal terms section</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="even">
|
<tr class="even">
|
||||||
<td style="text-align: left;">Update some functions to be MISRAC 2004
|
<td style="text-align: left;">Update some functions to be MISRAC 2004
|
||||||
@@ -683,10 +867,12 @@ machine</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section9" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section9" aria-hidden="true">
|
||||||
<label for="collapse-section9" aria-hidden="true">V2.4.2 /
|
<label for="collapse-section9" aria-hidden="true">V2.4.2 /
|
||||||
11-December-2015</label>
|
11-December-2015</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-12">Main Changes</h2>
|
<h2 id="main-changes-12">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -705,10 +891,12 @@ by #include “usbd_cdc.h”</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section8" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section8" aria-hidden="true">
|
||||||
<label for="collapse-section8" aria-hidden="true">V2.4.1 /
|
<label for="collapse-section8" aria-hidden="true">V2.4.1 /
|
||||||
19-June-2015</label>
|
19-June-2015</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-13">Main Changes</h2>
|
<h2 id="main-changes-13">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -744,10 +932,12 @@ DMA half transfer</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section7" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section7" aria-hidden="true">
|
||||||
<label for="collapse-section7" aria-hidden="true">V2.4.0 /
|
<label for="collapse-section7" aria-hidden="true">V2.4.0 /
|
||||||
28-February-2015</label>
|
28-February-2015</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-14">Main Changes</h2>
|
<h2 id="main-changes-14">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -802,10 +992,12 @@ CDC_SET_CONTROL_LINE_STATE and similar no-data setup requests.</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section6" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section6" aria-hidden="true">
|
||||||
<label for="collapse-section6" aria-hidden="true">V2.3.0 /
|
<label for="collapse-section6" aria-hidden="true">V2.3.0 /
|
||||||
04-November-2014</label>
|
04-November-2014</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-15">Main Changes</h2>
|
<h2 id="main-changes-15">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -836,10 +1028,12 @@ update</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section5" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section5" aria-hidden="true">
|
||||||
<label for="collapse-section5" aria-hidden="true">V2.2.0 /
|
<label for="collapse-section5" aria-hidden="true">V2.2.0 /
|
||||||
13-June-2014</label>
|
13-June-2014</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-16">Main Changes</h2>
|
<h2 id="main-changes-16">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -891,10 +1085,12 @@ USBD_HID_CLASS)</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section4" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section4" aria-hidden="true">
|
||||||
<label for="collapse-section4" aria-hidden="true">V2.1.0 /
|
<label for="collapse-section4" aria-hidden="true">V2.1.0 /
|
||||||
22-April-2014</label>
|
22-April-2014</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-17">Main Changes</h2>
|
<h2 id="main-changes-17">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -938,10 +1134,12 @@ usbd_customhid_if_template.c/h</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section3" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section3" aria-hidden="true">
|
||||||
<label for="collapse-section3" aria-hidden="true">V2.0.0 /
|
<label for="collapse-section3" aria-hidden="true">V2.0.0 /
|
||||||
18-February-2014</label>
|
18-February-2014</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-18">Main Changes</h2>
|
<h2 id="main-changes-18">Main Changes</h2>
|
||||||
<p>Major update based on STM32Cube specification.</p>
|
<p>Major update based on STM32Cube specification.</p>
|
||||||
<table>
|
<table>
|
||||||
@@ -961,10 +1159,12 @@ compatible.</td>
|
|||||||
<p><strong>This version has to be used only with STM32Cube based
|
<p><strong>This version has to be used only with STM32Cube based
|
||||||
development</strong></p>
|
development</strong></p>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section2" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section2" aria-hidden="true">
|
||||||
<label for="collapse-section2" aria-hidden="true">V1.1.0 /
|
<label for="collapse-section2" aria-hidden="true">V1.1.0 /
|
||||||
19-March-2012</label>
|
19-March-2012</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-19">Main Changes</h2>
|
<h2 id="main-changes-19">Main Changes</h2>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -977,8 +1177,8 @@ development</strong></p>
|
|||||||
<td style="text-align: left;">Official support of STM32F4xx devices</td>
|
<td style="text-align: left;">Official support of STM32F4xx devices</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="even">
|
<tr class="even">
|
||||||
<td style="text-align: left;">All source files: license disclaimer text
|
<td style="text-align: left;">All source files: Legal terms disclaimer text
|
||||||
update and add link to the License file on ST Internet.</td>
|
update and add link to the Legal terms file on ST Internet.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="odd">
|
<tr class="odd">
|
||||||
<td style="text-align: left;">Handle test mode in the set feature
|
<td style="text-align: left;">Handle test mode in the set feature
|
||||||
@@ -998,15 +1198,18 @@ to take into account error during Control OUT stage</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="collapse">
|
<div class="collapse">
|
||||||
<input type="checkbox" id="collapse-section1" checked aria-hidden="true">
|
<input type="checkbox" id="collapse-section1" aria-hidden="true">
|
||||||
<label for="collapse-section1" aria-hidden="true">V1.0.0 /
|
<label for="collapse-section1" aria-hidden="true">V1.0.0 /
|
||||||
22-July-2011</label>
|
22-July-2011</label>
|
||||||
|
<div>
|
||||||
<h2 id="main-changes-20">Main Changes</h2>
|
<h2 id="main-changes-20">Main Changes</h2>
|
||||||
<p>First official version for STM32F105/7xx and STM32F2xx devices</p>
|
<p>First official version for STM32F105/7xx and STM32F2xx devices</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<footer class="sticky">
|
<footer class="sticky">
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column" style="width:95%;">
|
<div class="column" style="width:95%;">
|
||||||
|
|||||||
520
Release_Notes.md
520
Release_Notes.md
@@ -1,520 +0,0 @@
|
|||||||
---
|
|
||||||
pagetitle: Release Notes for STM32Cube USB Device Library
|
|
||||||
lang: en
|
|
||||||
header-includes: <link rel="icon" type="image/x-icon" href="_htmresc/favicon.png" />
|
|
||||||
---
|
|
||||||
|
|
||||||
::: {.row}
|
|
||||||
::: {.col-sm-12 .col-lg-4}
|
|
||||||
|
|
||||||
<center>
|
|
||||||
# Release Notes for <mark>STM32Cube USB Device Library</mark>
|
|
||||||
Copyright © 2015 STMicroelectronics\
|
|
||||||
|
|
||||||
[](https://www.st.com){.logo}
|
|
||||||
</center>
|
|
||||||
|
|
||||||
# Purpose
|
|
||||||
|
|
||||||
The USB device library comes on top of the STM32Cube™ USB device HAL driver and
|
|
||||||
offers all the APIs required to develop an USB device application.
|
|
||||||
|
|
||||||
The main USB device library features are:
|
|
||||||
|
|
||||||
- Support of multi packet transfer features allowing sending big amount of data without
|
|
||||||
splitting it into max packet size transfers.
|
|
||||||
- Support of most common USB Class drivers (HID, MSC, DFU, CDC-ACM, CDC-ECM, RNDIS, MTP, AUDIO1.0, Printer, Video, Composite)
|
|
||||||
- Configuration files to interface with Cube HAL and change the library configuration without changing
|
|
||||||
the library code (Read Only).
|
|
||||||
- 32-bits aligned data structures to handle DMA based transfer in High speed modes.
|
|
||||||
|
|
||||||
Here is the list of references to user documents:
|
|
||||||
|
|
||||||
- [UM1734](https://www.st.com/resource/en/user_manual/DM00108129.pdf) : STM32Cube USB device library User Manual
|
|
||||||
- [Wiki Page](https://wiki.st.com/stm32mcu/wiki/USB_overview) : STM32Cube USB Wiki Page
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.col-sm-12 .col-lg-8}
|
|
||||||
# Update History
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section23" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section23" aria-hidden="true">V2.11.1 / 27-September-2022</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
Improvement of the memory management
|
|
||||||
**USB Core:**
|
|
||||||
Fix some compilation warnings related to unused parameters
|
|
||||||
Improve some code parts style
|
|
||||||
Add check on the USB Device status in USBD_LL_Suspend before suspending it
|
|
||||||
**USB CDC-ACM Class:**
|
|
||||||
Remove redundant prototype declaration of USBD_CDC_GetOtherSpeedCfgDesc()
|
|
||||||
**USB CompositeBuilder, CCID, CDC_ECM, CDC_RNDIS, CustomHID, MSC & Video Classes:**
|
|
||||||
Improve some code parts style
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.col-sm-12 .col-lg-8}
|
|
||||||
# Update History
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section22" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section22" aria-hidden="true">V2.11.0 / 25-March-2022</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
**USB VIDEO Class:**
|
|
||||||
Correction of the support of VS_PROBE_CONTROL & VS_COMMIT_CONTROL requets
|
|
||||||
**USB AUDIO Class:**
|
|
||||||
Correction of the check on AUDIO_TOTAL_BUF_SIZE to avoid vulnerabilities
|
|
||||||
**USB HID Class:**
|
|
||||||
Modification of some constants names to avoid duplication versus USB host library
|
|
||||||
**USB CustomHID Class:**
|
|
||||||
Add support of Get Report control request
|
|
||||||
Allow disabling EP OUT prepare receive using a dedicated macros that can be defined in usbd_conf.h application file
|
|
||||||
Add support of Report Descriptor with length greater than 255 bytes
|
|
||||||
**USB CCID Class:**
|
|
||||||
Fix minor Code Spelling warning
|
|
||||||
**USB All Classes:**
|
|
||||||
Update all classes to support composite multi-instance using the class id parameter
|
|
||||||
Fix code spelling and improve code style
|
|
||||||
fix misraC 2012 rule 10.3
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section21" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section21" aria-hidden="true">V2.10.0 / 03-Sept-2021</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
**Integration of new USB device Class driver:**
|
|
||||||
Adding support of Composite devices with an auto generation of composite device configuration descriptors
|
|
||||||
**USB All Classes:**
|
|
||||||
Fix Code Spelling and improve Code Style
|
|
||||||
Update device class drivers to support Composite devices
|
|
||||||
Improve declaration of USB configuration descriptor table which is allocated if the composite builder is not selected
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section20" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section20" aria-hidden="true">V2.9.0 / 06-July-2021</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
**Integration of new USB device Class driver:**
|
|
||||||
USB CCID Class driver based on Universal Serial Bus Device Class Definition for Integrated Circuit(s) Cards Interface Devices Revision 1.1
|
|
||||||
USB MTP Class driver based on Universal Serial Bus Device Class Media Transfer Protocol Revision 1.1
|
|
||||||
**USB All Classes:**
|
|
||||||
Fix Code Spelling and improve Code Style
|
|
||||||
Update the way to declare licenses
|
|
||||||
**USB CDC/RNDIS/ECM Classes:**
|
|
||||||
Fix compilation warning with C++ due to missing casting during class handler allocation
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section19" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section19" aria-hidden="true">V2.8.0 / 10-Mars-2021</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
**Integration of new USB device Class driver:**
|
|
||||||
USB Printer Class driver based on Universal Serial Bus Device Class Definition for Printing Devices Version 1.1
|
|
||||||
**USB All Classes:**
|
|
||||||
Fix USB buffer overflow vulnerability for CDC, CDC-ECM, CDC-RNDIS, DFU, AUDIO, CustomHID, and Video Classes
|
|
||||||
Fix compilation warning with C++ due to missing casting during class handler allocation
|
|
||||||
Enhance comments of USB configuration descriptors fields
|
|
||||||
**USB Video Class:**
|
|
||||||
Fix missing closing bracket for extern "C" in usbd_video.h
|
|
||||||
Fix USBCV test with Uncompressed video format support
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section17" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section17" aria-hidden="true">V2.7.1 / 18-August-2020</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
USB All Class: Add NULL pointer access check to Class handler
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section16" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section16" aria-hidden="true">V2.7.0 / 12-August-2020</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
**Integration of new USB device Class driver:**
|
|
||||||
USB video Class driver based on USB-IF video class definition version 1.1
|
|
||||||
**USB Core:**
|
|
||||||
Enhance NULL pointer check in Core APIs
|
|
||||||
Allow supporting both USER and USER Class string desc
|
|
||||||
Add support of USB controller which handles packet-size splitting by hardware
|
|
||||||
Avoid compilation warning due macro redefinition
|
|
||||||
change added to USBD_HandleTypeDef structure: dev_state, old_dev_state and ep0_state declaration become volatile to disable compiler optimization
|
|
||||||
Word spelling correction and file indentation improved
|
|
||||||
usbd_conf.h/c Template file updated to suggest using by default a static memory allocation for Class handler
|
|
||||||
**USB All Classes:**
|
|
||||||
Word spelling correction and file indentation improved
|
|
||||||
Allow updating device config descriptor Max power from user code usbd_conf.h using USBD_MAX_POWER define
|
|
||||||
Fix device config descriptor bmAttributes value which depends on user code define USBD_SELF_POWERED
|
|
||||||
**USB CDC Class:**
|
|
||||||
Class specific request, add protection to limit the maximum data length to be sent by the CDC device
|
|
||||||
**USB CustomHID Class:**
|
|
||||||
Allow changing CustomHID data EP size from user code
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section15" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section15" aria-hidden="true">V2.6.1 / 05-June-2020</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
Fix minor misra-c 2012 violations
|
|
||||||
**USB Core:**
|
|
||||||
minor rework on USBD_Init() USBD_DeInit()
|
|
||||||
Fix warning issue with Keil due to missing return value of setup API
|
|
||||||
**USB CDC Class:**
|
|
||||||
Fix file indentation
|
|
||||||
Avoid accessing to NULL pointer in case TransmitCplt() user fops is not defined to allow application compatibility with device library version below v2.6.0
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section14" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section14" aria-hidden="true">V2.6.0 / 27-December-2019</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
Integration of three new USB device Class drivers:CDC ECM , CDC RNDIS Microsoft, USB Billboard
|
|
||||||
Fix mandatory misra-c 2012 violations
|
|
||||||
update user core and class template files
|
|
||||||
**USB Core:**
|
|
||||||
Fix unexpected EP0 stall during enumeration phase
|
|
||||||
Improve APIs error management and prevent accessing NULL pointers
|
|
||||||
**USB MSC Class:**
|
|
||||||
Fix USBCV specific class tests
|
|
||||||
Fix multiple error with SCSI commands handling
|
|
||||||
Protect medium access when host ask for medium ejection
|
|
||||||
**USB CDC Class:**
|
|
||||||
Add new function to inform user that current IN transfer is completed
|
|
||||||
update transmit and receive APIs to transfer up to 64KB
|
|
||||||
**USB AUDIO Class:**
|
|
||||||
Fix audio sync start buffer size
|
|
||||||
update user callback periodicTC args by adding pointer to user buffer and size
|
|
||||||
**USB CustomHID Class:**
|
|
||||||
Rework the OUT transfer complete and prevent automatically re-enabling the OUT EP
|
|
||||||
Add new user API to restart the OUT transfer: USBD_CUSTOM_HID_ReceivePacket()
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section13" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section13" aria-hidden="true">V2.5.3 / 30-April-2019</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
Fix misra-c 2012 high severity violations
|
|
||||||
**Core driver:**
|
|
||||||
protect shared macros __ALIGN_BEGIN, __ALIGN_END with C directive #ifndef
|
|
||||||
update Core driver and DFU Class driver to use USBD_SUPPORT_USER_STRING_DESC instead of USBD_SUPPORT_USER_STRING
|
|
||||||
prevent accessing to NULL pointer if the get descriptor functions are not defined
|
|
||||||
Update on USBD_LL_Resume(), restore the device state only if the current state is USBD_STATE_SUSPENDED
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section12" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section12" aria-hidden="true">V2.5.2 / 27-Mars-2019</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
DFU Class: fix compilation warning due to unreachable instruction code introduced with CMSIS V5.4.0 NVIC_SystemReset() prototype change
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section11" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section11" aria-hidden="true">V2.5.1 / 03-August-2018</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
Update license section by adding path to get copy of ST Ultimate Liberty license
|
|
||||||
Core: Fix unexpected stall during status OUT phase
|
|
||||||
DFU Class: rework hdfu struct to prevent unaligned addresses
|
|
||||||
MSC Class: fix lba address overflow during large file transfers greater than 4Go
|
|
||||||
Template Class: add missing Switch case Break on USBD_Template_Setup API
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section10" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section10" aria-hidden="true">V2.5.0 / 15-December-2017</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
Update license section
|
|
||||||
Update some functions to be MISRAC 2004 compliant
|
|
||||||
Add HS and OtherSpeed configuration descriptor for HID and CustomHID classes
|
|
||||||
Correct error handling in all class setup function
|
|
||||||
Add usbd_desc_template.c/ usbd_desc_template.h templates files
|
|
||||||
Add support of class and vendor request
|
|
||||||
CDC Class: fix zero-length packet issue in bulk IN transfer
|
|
||||||
Fix compilation warning with unused arguments for some functions
|
|
||||||
Improve USB Core enumeration state machine
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section9" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section9" aria-hidden="true">V2.4.2 / 11-December-2015</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
**CDC Class**
|
|
||||||
usbd_cdc.c: change #include "USBD_CDC.h" by #include "usbd_cdc.h"
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section8" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section8" aria-hidden="true">V2.4.1 / 19-June-2015</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
**CDC Class**
|
|
||||||
usbd_cdc.c: comments update
|
|
||||||
**MSC Class**
|
|
||||||
usbd_msc_bot.h: update to be C++ compliant
|
|
||||||
**AUDIO Class**
|
|
||||||
usbd_audio.c: fix issue when Host sends GetInterface command it gets a wrong value
|
|
||||||
usbd_audio.c: remove useless management of DMA half transfer
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section7" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section7" aria-hidden="true">V2.4.0 / 28-February-2015</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
**Core Driver**
|
|
||||||
Add support of Link Power Management (LPM): add new API GetBOSDescriptor(), that is used only if USBD_LPM_ENABLED switch is enabled in usbd_conf.h file
|
|
||||||
usbd_core.c: Fix bug of unsupported premature Host Out stage during data In stage (ie. when endpoint 0 maximum data size is 8 and Host requests GetDeviceDescriptor for the first time)
|
|
||||||
usbd_ctlreq.c: Fix bug of unsupported Endpoint Class requests (ie. Audio SetCurrent request for endpoint sampling rate setting)
|
|
||||||
**HID Class**
|
|
||||||
Updating Polling time API USBD_HID_GetPollingInterval() to query this period for HS and FS
|
|
||||||
usbd_hid.c: Fix USBD_LL_CloseEP() function call in USBD_HID_DeInit() replacing endpoint size by endpoint address.
|
|
||||||
**CDC Class**
|
|
||||||
usbd_cdc.c: Add missing GetInterface request management in USBD_CDC_Setup() function
|
|
||||||
usbd_cdc.c: Update USBD_CDC_Setup() function to allow correct user implementation of CDC_SET_CONTROL_LINE_STATE and similar no-data setup requests.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section6" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section6" aria-hidden="true">V2.3.0 / 04-November-2014</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
Update all drivers to be C++ compliant
|
|
||||||
**CDC Class**
|
|
||||||
usbd_cdc.c: fix clear flag issue in USBD_CDC_TransmitPacket() function
|
|
||||||
usbd_cdc_if_template.c: update TEMPLATE_Receive() function header comment
|
|
||||||
Miscellaneous source code comments update
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section5" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section5" aria-hidden="true">V2.2.0 / 13-June-2014</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
Source code comments review and update
|
|
||||||
**HID class**
|
|
||||||
Remove unused API USBD_HID_DeviceQualifierDescriptor()
|
|
||||||
Add a new API in the HID class to query the poll time USBD_HID_GetPollingInterval()
|
|
||||||
**CDC class**
|
|
||||||
Bug fix: missing handling ZeroLength Setup request
|
|
||||||
**All classes**
|
|
||||||
Add alias for the class definition, it's defined as macro with capital letter
|
|
||||||
ex. for the HID, the USBD_HID_CLASS macro is defined this way #define USBD_HID_CLASS &USBD_HID
|
|
||||||
and the application code can use the previous definition: &USBD_HID ex. USBD_RegisterClass(&USBD_Device, &USBD_HID) or the new USBD_HID_CLASS ex. USBD_RegisterClass(&USBD_Device, USBD_HID_CLASS)
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section4" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section4" aria-hidden="true">V2.1.0 / 22-April-2014</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
usbd_conf_template.c: update file with the right content (it was using MSC memory management layer)
|
|
||||||
usbd_conf_template.h: change include of stm32f4xx.h by stm32xxx.h and add comment to inform user to adapt it to the device used
|
|
||||||
Several enhancements in CustomHID class
|
|
||||||
Update the Custom HID class driver to simplify the link with user processes
|
|
||||||
Optimize the Custom HID class driver and reduce footprint
|
|
||||||
Add USBD_CUSTOM_HID_RegisterInterface() API to link user process to custom HID class
|
|
||||||
Add Custom HID interface template file usbd_customhid_if_template.c/h
|
|
||||||
Miscellaneous comments update
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section3" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section3" aria-hidden="true">V2.0.0 / 18-February-2014</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Major update based on STM32Cube specification.
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
Library Core, Classes architecture and APIs modified vs. V1.1.0, and thus the 2 versions are not compatible.
|
|
||||||
|
|
||||||
|
|
||||||
**This version has to be used only with STM32Cube based development**
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section2" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section2" aria-hidden="true">V1.1.0 / 19-March-2012</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
Headline
|
|
||||||
---------
|
|
||||||
Official support of STM32F4xx devices
|
|
||||||
All source files: license disclaimer text update and add link to the License file on ST Internet.
|
|
||||||
Handle test mode in the set feature request
|
|
||||||
Handle dynamically the USB SELF POWERED feature
|
|
||||||
Handle correctly the USBD_CtlError process to take into account error during Control OUT stage
|
|
||||||
Miscellaneous bug fix
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
::: {.collapse}
|
|
||||||
<input type="checkbox" id="collapse-section1" checked aria-hidden="true">
|
|
||||||
<label for="collapse-section1" aria-hidden="true">V1.0.0 / 22-July-2011</label>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
## Main Changes
|
|
||||||
|
|
||||||
First official version for STM32F105/7xx and STM32F2xx devices
|
|
||||||
|
|
||||||
</div>
|
|
||||||
:::
|
|
||||||
|
|
||||||
:::
|
|
||||||
:::
|
|
||||||
|
|
||||||
<footer class="sticky">
|
|
||||||
::: {.columns}
|
|
||||||
::: {.column width="95%"}
|
|
||||||
:::
|
|
||||||
::: {.column width="5%"}
|
|
||||||
<abbr title="Based on template cx566953 version 2.1">Info</abbr>
|
|
||||||
:::
|
|
||||||
:::
|
|
||||||
</footer>
|
|
||||||
31
SECURITY.md
Normal file
31
SECURITY.md
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# Report potential product security vulnerabilities
|
||||||
|
|
||||||
|
ST places a high priority on security, and our Product Security Incident
|
||||||
|
Response Team (PSIRT) is committed to rapidly addressing potential security
|
||||||
|
vulnerabilities affecting our products. PSIRT's long history and vast experience
|
||||||
|
in security allows ST to perform clear analyses and provide appropriate guidance
|
||||||
|
on mitigations and solutions when applicable.
|
||||||
|
|
||||||
|
If you wish to report potential security vulnerabilities regarding our products,
|
||||||
|
**please do not report them through public GitHub issues.** Instead, we
|
||||||
|
encourage you to report them to our ST PSIRT following the process described at:
|
||||||
|
**https://www.st.com/content/st_com/en/security/report-vulnerabilities.html**
|
||||||
|
|
||||||
|
### IMPORTANT - READ CAREFULLY:
|
||||||
|
|
||||||
|
STMicroelectronics International N.V., on behalf of itself, its affiliates and
|
||||||
|
subsidiaries, (collectively “ST”) takes all potential security vulnerability
|
||||||
|
reports or other related communications (“Report(s)”) seriously. In order to
|
||||||
|
review Your Report (the terms “You” and “Yours” include your employer, and all
|
||||||
|
affiliates, subsidiaries and related persons or entities) and take actions as
|
||||||
|
deemed appropriate, ST requires that we have the rights and Your permission to
|
||||||
|
do so.
|
||||||
|
|
||||||
|
As such, by submitting Your Report to ST, You agree that You have the right to
|
||||||
|
do so, and You grant to ST the rights to use the Report for purposes related to
|
||||||
|
security vulnerability analysis, testing, correction, patching, reporting and
|
||||||
|
any other related purpose or function.
|
||||||
|
|
||||||
|
By submitting Your Report, You agree that ST’s
|
||||||
|
[Privacy Policy](https://www.st.com/content/st_com/en/common/privacy-portal.html)
|
||||||
|
applies to all related communications.
|
||||||
Reference in New Issue
Block a user