Skip to Content
Hands-On RTOS with Microcontrollers
book

Hands-On RTOS with Microcontrollers

by Brian Amos
May 2020
Intermediate to advanced
496 pages
13h 54m
English
Packt Publishing
Content preview from Hands-On RTOS with Microcontrollers

The USB virtual comm driver

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On RTOS with Microcontrollers - Second Edition

Hands-On RTOS with Microcontrollers - Second Edition

Jim Yuill, Penn Linder

Publisher Resources

ISBN: 9781838826734Supplemental Content