volatile static uint32_t s_recvSize = 0;
volatile static uint32_t s_sendSize = 0;
volatile static uint8_t s_sendComplete = 0;
-volatile static uint8_t s_currRecvIndex = 0;
static uint32_t s_usbBulkMaxPacketSize = FS_CDC_VCOM_BULK_OUT_PACKET_SIZE;
/*******************************************************************************
* Prototypes
return count;
}
-/* See virtual_com.h for documentation of this function. */
-status_t USB_VcomReadBlocking(usb_device_handle baseAddr, uint8_t *buf, size_t count)
-{
- status_t error = kStatus_Success;
- size_t bufIndex = 0U, bytesToReceive = 0U;
- assert(count != 0U);
-
- /* Waiting for the USB ready. */
- while ((s_cdcVcom.attach != 1) || (s_cdcVcom.startTransactions != 1))
- {
- };
-
- do
- {
- /* If no receive request. */
- if (s_recvSize <= 0)
- {
- if (kStatus_USB_Success !=
- USB_DeviceRecvRequest(baseAddr, USB_CDC_VCOM_BULK_OUT_ENDPOINT, s_currRecvBuf, s_usbBulkMaxPacketSize))
- {
- return kStatus_Fail;
- }
- s_currRecvIndex = 0;
- }
- /* Waiting for data received by virtual com. */
- while (s_recvSize <= 0)
- {
- };
-
- /* When receive request is error. */
- if (0xFFFFFFFFU == s_recvSize)
- {
- /* Waiting for the USB ready and transfer started. */
- while ((s_cdcVcom.attach != 1) || (s_cdcVcom.startTransactions != 1))
- {
- };
- s_recvSize = 0;
- }
- else
- {
- bytesToReceive = MIN(count, s_recvSize);
- memcpy((void *)&buf[bufIndex], s_currRecvBuf + s_currRecvIndex, bytesToReceive);
- count -= bytesToReceive;
- s_recvSize -= bytesToReceive;
- bufIndex += bytesToReceive;
- s_currRecvIndex += bytesToReceive;
- }
- } while (0U != count);
- return error;
-}
-
/* See virtual_com.h for documentation of this function. */
usb_device_handle USB_VcomInit(void)
{
*/
void USB_VcomDeinit(usb_device_handle deviceHandle);
-/*!
- * @brief USB recive data from host using a blocking method.
- *
- * This function recives data from host by usb cdc protocol
- * @param baseAddr pointer to USB device handle.
- * @param buf pointer to the data.
- * @param count size of the transfer.
- *
- * @return A USB error code or kStatus_USB_Success.
- */
-status_t USB_VcomReadBlocking(usb_device_handle baseAddr, uint8_t *buf, size_t count);
-
/*!
* @brief USB send data to host using a blocking method.
*