From 0322ef071cfae8dd20058c81359b01924b5e569e Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Wed, 11 Oct 2017 00:13:33 -0700 Subject: [PATCH] check for usb busy --- Src/syscalls.c | 1 - Src/usbd_cdc_if.c | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Src/syscalls.c b/Src/syscalls.c index e58a4420..3cd2a073 100644 --- a/Src/syscalls.c +++ b/Src/syscalls.c @@ -36,7 +36,6 @@ int _write(int file, char *data, int len) { if (len > UART_TX_BUFFER_SIZE) return 0; // Check if transfer is already ongoing - // TODO: use HAL_UART_GetState if(huart4.gState != HAL_UART_STATE_READY) return 0; // memcpy data into uart_tx_buf diff --git a/Src/usbd_cdc_if.c b/Src/usbd_cdc_if.c index 57680540..e3882cce 100644 --- a/Src/usbd_cdc_if.c +++ b/Src/usbd_cdc_if.c @@ -300,7 +300,10 @@ uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len) //Check length if (Len > APP_TX_DATA_SIZE) return USBD_FAIL; - // TODO: check busy + // Check for ongoing transmission + USBD_CDC_HandleTypeDef* hcdc = (USBD_CDC_HandleTypeDef*) hUsbDeviceFS.pClassData; + if (hcdc->TxState != 0) + return USBD_BUSY; // memcpy Buf into UserTxBufferFS memcpy(UserTxBufferFS, Buf, Len); // Update Len