Skip to content

Commit

Permalink
Merge pull request #2028 from fpistm/stm32_mw_usb_device
Browse files Browse the repository at this point in the history
chore(usb): update to stm32_mw_usb_device v2.11.1
  • Loading branch information
fpistm committed Jun 1, 2023
2 parents 7efab52 + 5be7a2b commit abce8f6
Show file tree
Hide file tree
Showing 92 changed files with 15,865 additions and 4,219 deletions.
300 changes: 212 additions & 88 deletions cores/arduino/stm32/usb/cdc/usbd_cdc.c

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions cores/arduino/stm32/usb/cdc/usbd_cdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,19 @@ extern USBD_ClassTypeDef USBD_CDC;
uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev,
USBD_CDC_ItfTypeDef *fops);

#ifdef USE_USBD_COMPOSITE
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
uint32_t length, uint8_t ClassId);
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId);
uint8_t USBD_CDC_ClearBuffer(USBD_HandleTypeDef *pdev, uint8_t ClassId);
#else
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
uint32_t length);

uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev);
uint8_t USBD_CDC_ClearBuffer(USBD_HandleTypeDef *pdev);
#endif /* USE_USBD_COMPOSITE */
uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev);
uint8_t USBD_CDC_ClearBuffer(USBD_HandleTypeDef *pdev);
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev);
/**
* @}
*/
Expand Down
20 changes: 20 additions & 0 deletions cores/arduino/stm32/usb/cdc/usbd_cdc_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ USBD_HandleTypeDef hUSBD_Device_CDC;

static bool CDC_initialized = false;
static bool CDC_DTR_enabled = true;
#if defined(ICACHE) && defined (HAL_ICACHE_MODULE_ENABLED) && !defined(HAL_ICACHE_MODULE_DISABLED)
static bool icache_enabled = false;
#endif /* ICACHE && HAL_ICACHE_MODULE_ENABLED && !HAL_ICACHE_MODULE_DISABLED */

/* Received Data over USB are stored in this buffer */
CDC_TransmitQueue_TypeDef TransmitQueue;
Expand Down Expand Up @@ -270,6 +273,15 @@ static int8_t USBD_CDC_TransmitCplt(uint8_t *Buf, uint32_t *Len, uint8_t epnum)

void CDC_init(void)
{
#if defined(ICACHE) && defined (HAL_ICACHE_MODULE_ENABLED) && !defined(HAL_ICACHE_MODULE_DISABLED)
if (HAL_ICACHE_IsEnabled() == 1) {
icache_enabled = true;
/* Disable instruction cache prior to internal cacheable memory update */
if (HAL_ICACHE_Disable() != HAL_OK) {
Error_Handler();
}
}
#endif /* ICACHE && HAL_ICACHE_MODULE_ENABLED && !HAL_ICACHE_MODULE_DISABLED */
if (!CDC_initialized) {
/* Init Device Library */
if (USBD_Init(&hUSBD_Device_CDC, &USBD_Desc, 0) == USBD_OK) {
Expand All @@ -294,6 +306,14 @@ void CDC_deInit(void)
USBD_DeInit(&hUSBD_Device_CDC);
CDC_initialized = false;
}
#if defined(ICACHE) && defined (HAL_ICACHE_MODULE_ENABLED) && !defined(HAL_ICACHE_MODULE_DISABLED)
if (icache_enabled) {
/* Re-enable instruction cache */
if (HAL_ICACHE_Enable() != HAL_OK) {
Error_Handler();
}
}
#endif /* ICACHE && HAL_ICACHE_MODULE_ENABLED && !HAL_ICACHE_MODULE_DISABLED */
}

bool CDC_connected()
Expand Down
Loading

0 comments on commit abce8f6

Please sign in to comment.