2018-07-09 01:12 PM
I am using usb port nucleo f429zi. I know I need cdc library and I want to write some protocol (for example modbus) between usb and PC, so my program in PC can communicate with controller, is it possible to use IT to listen to usb port, and when message receiving on Usb and interrupt trigger and analyze the received data, also any way to get number of bytes controller received?
2018-07-09 05:02 PM
Look at the data at the End-Point level? Or how you are called back with the data, which provides a buffer and size?
/**
* @brief USBD_CDC_DataOut * Data received on non-control Out endpoint * @param pdev: device instance * @param epnum: endpoint number * @retval status */static uint8_t USBD_CDC_DataOut (USBD_HandleTypeDef *pdev, uint8_t epnum){ USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*) pdev->pClassData;/* Get the received data length */
hcdc->RxLength = USBD_LL_GetRxDataSize (pdev, epnum);/* USB data will be immediately processed, this allow next USB traffic being
NAKed till the end of the application Xfer */ if(pdev->pClassData != NULL) { ((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Receive(hcdc->RxBuffer, &hcdc->RxLength);return USBD_OK;
} else { return USBD_FAIL; }}