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.h File Reference
#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Macros

#define CDC_WRITE_MAX_RETRIES   500u
 Maximum number of busy-retry attempts inside CDC_Write.
 

Functions

bool CDC_Write (const uint8_t *data, uint16_t len)
 Push len bytes to the USB CDC IN endpoint.
 
bool CDC_WriteString (const char *s)
 Convenience wrapper that pushes a NUL-terminated C string.
 

Macro Definition Documentation

◆ CDC_WRITE_MAX_RETRIES

#define CDC_WRITE_MAX_RETRIES   500u

Maximum number of busy-retry attempts inside CDC_Write.

Each retry sleeps one OS tick (task_active_sleep(1)), so the upper bound on a single CDC_Write call is roughly CDC_WRITE_MAX_RETRIES ticks. Default 500 → about 0.5 s at the kernel's 1 ms tick.

Definition at line 47 of file cdc.h.

Function Documentation

◆ CDC_Write()

bool CDC_Write ( const uint8_t *  data,
uint16_t  len 
)

Push len bytes to the USB CDC IN endpoint.

Parameters
dataPointer to the bytes to send (must be non-NULL when len > 0).
lenNumber of bytes to send.
Returns
true if the bytes were accepted by the CDC stack within CDC_WRITE_MAX_RETRIES busy-retries; false otherwise (caller's bytes were not sent).
Note
Must be called from task context — the busy-retry path uses task_active_sleep(1) and would deadlock from an ISR.
The transmit buffer the ST middleware accepts is borrowed, not copied. The pointer data must remain valid until the function returns.

Definition at line 33 of file cdc.c.

References CDC_Transmit_FS(), CDC_WRITE_MAX_RETRIES, and task_active_sleep().

Referenced by CDC_WriteString().

◆ CDC_WriteString()

bool CDC_WriteString ( const char *  s)

Convenience wrapper that pushes a NUL-terminated C string.

Parameters
sNUL-terminated string. NULL is treated as a no-op success.
Returns
true on success, false if the underlying CDC_Write could not flush within the retry budget.

Definition at line 112 of file cdc.c.

References CDC_Write().