ICARUS OS (Intelligent Cooperative Architecture for Real-time Unified Systems) 0.1.0
Preemptive Real-Time Operating System for ARM Cortex-M7
Loading...
Searching...
No Matches
cdc_rx.c File Reference

USB CDC receive ring buffer implementation. More...

#include "icarus/cdc_rx.h"
#include "icarus/config.h"
#include <stddef.h>

Go to the source code of this file.

Functions

void __cdc_rx_init (void)
 
void __cdc_rx_push (const uint8_t *data, uint32_t len)
 
bool __cdc_rx_read_byte (uint8_t *out)
 
uint32_t __cdc_rx_available (void)
 

Variables

static volatile uint8_t rx_buf [512]
 
static volatile uint32_t rx_head
 
static volatile uint32_t rx_tail
 

Detailed Description

USB CDC receive ring buffer implementation.

SPSC (single-producer single-consumer) ring buffer. Producer: CDC_Receive_FS callback (USB interrupt context). Consumer: any RTOS task draining bytes.

The buffer and indices live in DTCM_DATA_PRIV (privileged-only tightly-coupled memory). Public read accessors go through SVC gates (SVC_CDC_RX_READ_BYTE / SVC_CDC_RX_AVAILABLE) so unprivileged thread-mode tasks can use them once the MPU is locked. The producer call site is the USB CDC ISR, which is already in privileged handler context — it calls the __cdc_rx_push privileged variant directly to avoid issuing an SVC from a high-priority interrupt.

Author
Souham Biswas
Date
2026

Definition in file cdc_rx.c.

Function Documentation

◆ __cdc_rx_available()

uint32_t __cdc_rx_available ( void  )

Definition at line 66 of file cdc_rx.c.

References CDC_RX_BUF_SIZE, rx_head, and rx_tail.

Referenced by cdc_rx_available(), and SVC_Handler_C().

◆ __cdc_rx_init()

void __cdc_rx_init ( void  )

Definition at line 38 of file cdc_rx.c.

References rx_head, and rx_tail.

Referenced by cdc_rx_init(), and SVC_Handler_C().

◆ __cdc_rx_push()

void __cdc_rx_push ( const uint8_t *  data,
uint32_t  len 
)

Definition at line 43 of file cdc_rx.c.

References CDC_RX_BUF_SIZE, rx_buf, rx_head, and rx_tail.

Referenced by cdc_rx_push().

◆ __cdc_rx_read_byte()

bool __cdc_rx_read_byte ( uint8_t *  out)

Definition at line 57 of file cdc_rx.c.

References CDC_RX_BUF_SIZE, rx_buf, rx_head, and rx_tail.

Referenced by cdc_rx_read_byte(), and SVC_Handler_C().

Variable Documentation

◆ rx_buf

volatile uint8_t rx_buf[512]
static

Definition at line 32 of file cdc_rx.c.

Referenced by __cdc_rx_push(), and __cdc_rx_read_byte().

◆ rx_head

volatile uint32_t rx_head
static

Definition at line 33 of file cdc_rx.c.

Referenced by __cdc_rx_available(), __cdc_rx_init(), __cdc_rx_push(), and __cdc_rx_read_byte().

◆ rx_tail

volatile uint32_t rx_tail
static

Definition at line 34 of file cdc_rx.c.

Referenced by __cdc_rx_available(), __cdc_rx_init(), __cdc_rx_push(), and __cdc_rx_read_byte().