May 2020
Intermediate to advanced
496 pages
13h 54m
English
The USB's receiving StreamBuffer is populated by CDC_Receive_FS() in Drivers/HandsOnRTOS/usbd_cdc_if.c. This will look similar to the code from Chapter 11, Sharing Hardware Peripherals across Tasks, where the transmit side of the driver was developed:
static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len){ /* USER CODE BEGIN 6 */ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); xStreamBufferSendFromISR( *GetUsbRxStreamBuff(), Buf, *Len, &xHigherPriorityTaskWoken); USBD_CDC_ReceivePacket(&hUsbDeviceFS); portYIELD_FROM_ISR(xHigherPriorityTaskWoken); return (USBD_OK); /* USER CODE END 6 */}
Using a stream buffer instead of a queue allows larger blocks of memory to ...