Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(usb): update to stm32_mw_usb_device v2.11.1 #2028

Merged
merged 5 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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