2014-06-19 04:37 AM
Hi all,
I am trying to retarget printf over USB-VCP and I am stcuk !I implemented the putc function in the following way:****************************************int fputc(int ch, FILE *f){ USBD_CDC_SetTxBuffer(&hUSBDDevice, (uint8_t *)&ch, 1); if(USBD_CDC_TransmitPacket(&hUSBDDevice) != USBD_OK) { /* Device is busy */ /* what should I return ? */ } return ch;}*****************************************As you know fputc is called by printf for printing a single character and it is called in a loop until all characters are printed.What I am facing is that it may happen the USB is busy while sending the previous character. What do I have to do at this condition? fputc return -1 ?PS: I am STM32 Cube V2.0.0 ''18-February-2014''Thanks #usb-vcp-printf2014-06-19 07:37 AM
Consider whether you can buffer outgoing characters, send multiple at a time, or wait until a later time if the USB is currently busy.