Hi all!
I am trying to include a virtual COM through an USB in KEIL uVision5 with the API and functions that KEIL provides.
I have been improving my code, and now I am at the point to be able to receive characters from the host (PC). My problem now is that I don't understand how the function "USBD_CDCn_ACM_SendData" works.
My purpose is to include the function "USBD_CDC_ACM_WriteData" inside "SendData" function. I know that WriteData is an asynchronous function, but it never interrupts the program.
My code is:
// Called when when all data was sent. void USBD_CDC0_ACM_SendData (int32_t len) { // Add code for handling new data send int32_t cnt; cnt = USBD_CDC_ACM_WriteData(0, mantTxBuf, len); if(cnt<0) {} //error }
where "mantTxBuf" is my pointer to the transmitter buffer. I am sharing the same buffer with UART and USB, because my intention is that when I use the USB, the UART will be disable and viceversa. I am secure that there are data ready to be sent on my buffer, but this function never interrupts.
I have tried to implement the "WriteData" function inside the function "USBD_CDC0_ACM_DataSent" (www.keil.com/.../group__usbd__cdc_functions__acm__api.html but it neither interrupts.
I have the following questions about it:
1. How "USBD_CDCn_ACM_SendData" works?
2. Should I implement the asynchronous function to send data ("USBD_CDC_ACM_WriteData") as a independent function?
3. Is there another strategy to send data when I have characters in my Tx buff ("mantTxBuff")??
Thank you very much!
Hi Milorad,
Thank you very much for your answer. Yesterday I was fighting with my code and finally I understood how this functions work. It works how you have said.
Thank you very much again.
BR.