How to use usb cdc_receive_hs on main() ?
Hey. I'm trying to create a program that receives 4 bytes long strings from my pc and transfer them through an spi connection to a peripheral device, throught a usb connection.
I've set my stm32 nucleo board up as a usb device and generated the required file. The thing that i noticed though is that i could use the cdc_transmit_hs function inside the main.c super loop, if declared as extern, but i couldn't do the same with the receive counterpart. The only thing that i tried and seemed to work is echoing the data inside the receive function, meaning :
static int8_t CDC_Receive_HS(uint8_t* Buf, uint32_t *Len)
{
/* USER CODE BEGIN 11 */
USBD_CDC_SetRxBuffer(&hUsbDeviceHS, &Buf[0]);
USBD_CDC_ReceivePacket(&hUsbDeviceHS);
uint8_t rxMessage[40]={'\0'};
sprintf(rxMessage, "Command is %c,%d,%d,%d\r\n",Buf[0],Buf[1], Buf[2], Buf[3] );
CDC_Transmit_HS(rxMessage,sizeof(rxMessage));
return (USBD_OK);
/* USER CODE END 11 */
}Is there an actual way to use this function inside the main?Should i use a global array and a flag to signal the main file, that some data is being received, or is it not thread safe ?
