-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)