/** * @brief VCP_DataTx * CDC data to be sent to the Host (app) over USB * @param Buf: Buffer of data to be sent * @param Len: Number of data to be sent (in bytes) * @retval Result of the operation: USBD_OK if all operations are OK else VCP_FAIL */ static uint16_t VCP_DataTx(const uint8_t* Buf, uint32_t Len) { /* make sure that any paragraph end frame is not in play could just check for: USB_CDC_ZLP, but better to be safe and wait for any existing transmission to complete. */ while (USB_Tx_State != 0); for (uint32_t i = 0; i < Len; i++) { APP_Rx_Buffer[APP_Rx_ptr_in] = Buf[i]; APP_Rx_ptr_in = (APP_Rx_ptr_in + 1) % APP_RX_DATA_SIZE; while (CDC_Send_FreeBytes() == 0) { delay(1); } } return USBD_OK; }
static uint32_t usbTxBytesFree(const serialPort_t *instance) { UNUSED(instance); return CDC_Send_FreeBytes(); }
uint32_t usbTxBytesFree() { return CDC_Send_FreeBytes(); }