check for usb busy

This commit is contained in:
Oskar Weigl
2017-10-11 00:13:33 -07:00
parent 8db9d2cc69
commit 0322ef071c
2 changed files with 4 additions and 2 deletions
-1
View File
@@ -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
+4 -1
View File
@@ -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