USBUS CDC ACM - USBUS CDC abstract control model

USBUS CDC ACM interface module. More...

Detailed Description

USBUS CDC ACM interface module.

Modules

 USBUS CDC ACM compile time configurations
 

Files

file  acm.h
 Interface and definitions for USB CDC ACM type interfaces in USBUS.
 

Data Structures

struct  usbus_cdcacm_device
 USBUS CDC ACM context struct. More...
 

Macros

#define USBUS_CDC_ACM_INT_EP_SIZE   (8)
 USBUS CDC ACM interrupt endpoint size.
 

Typedefs

typedef struct usbus_cdcacm_device usbus_cdcacm_device_t
 USBUS CDC ACM context struct forward declaration.
 
typedef void(* usbus_cdcacm_cb_t) (usbus_cdcacm_device_t *cdcacm, uint8_t *data, size_t len)
 CDC ACM data callback. More...
 
typedef int(* usbus_cdcacm_coding_cb_t) (usbus_cdcacm_device_t *cdcacm, uint32_t baud, uint8_t bits, uint8_t parity, uint8_t stop)
 CDC ACM line coding callback. More...
 

Enumerations

enum  usbus_cdcacm_line_state_t { USBUS_CDC_ACM_LINE_STATE_DISCONNECTED, USBUS_CDC_ACM_LINE_STATE_DTE }
 CDC ACM line state as reported by the host computer. More...
 

Functions

void usbus_cdc_acm_init (usbus_t *usbus, usbus_cdcacm_device_t *cdcacm, usbus_cdcacm_cb_t cb, usbus_cdcacm_coding_cb_t coding_cb, uint8_t *buf, size_t len)
 Initialize an USBUS CDC ACM interface. More...
 
size_t usbus_cdc_acm_submit (usbus_cdcacm_device_t *cdcacm, const uint8_t *buf, size_t len)
 Submit bytes to the CDC ACM handler. More...
 
void usbus_cdc_acm_flush (usbus_cdcacm_device_t *cdcacm)
 Flush the buffer to the USB host. More...
 
void usbus_cdc_acm_set_coding_cb (usbus_cdcacm_device_t *cdcacm, usbus_cdcacm_coding_cb_t coding_cb)
 Set the callback for control settings. More...
 

Typedef Documentation

◆ usbus_cdcacm_cb_t

typedef void(* usbus_cdcacm_cb_t) (usbus_cdcacm_device_t *cdcacm, uint8_t *data, size_t len)

CDC ACM data callback.

Callback for received data from the USB host

Parameters
[in]cdcacmCDC ACM handler context
[in]dataptr to the data
[in]lenLength of the received data

Definition at line 108 of file acm.h.

◆ usbus_cdcacm_coding_cb_t

typedef int(* usbus_cdcacm_coding_cb_t) (usbus_cdcacm_device_t *cdcacm, uint32_t baud, uint8_t bits, uint8_t parity, uint8_t stop)

CDC ACM line coding callback.

Callback for received line coding request from the USB host

Parameters
[in]cdcacmCDC ACM handler context
[in]baudrequested baud rate
[in]bitsrequested number of data bits
[in]parityrequested parity
[in]stoprequested number of stop bits
Returns
0 when the mode is available
negative if the mode is not available

Definition at line 125 of file acm.h.

Enumeration Type Documentation

◆ usbus_cdcacm_line_state_t

CDC ACM line state as reported by the host computer.

Enumerator
USBUS_CDC_ACM_LINE_STATE_DISCONNECTED 

No DTE connected.

USBUS_CDC_ACM_LINE_STATE_DTE 

DTE (e.g.

a personal computer) is present and connected

Definition at line 82 of file acm.h.

Function Documentation

◆ usbus_cdc_acm_flush()

void usbus_cdc_acm_flush ( usbus_cdcacm_device_t cdcacm)

Flush the buffer to the USB host.

Parameters
[in]cdcacmUSBUS CDC ACM handler context

◆ usbus_cdc_acm_init()

void usbus_cdc_acm_init ( usbus_t usbus,
usbus_cdcacm_device_t cdcacm,
usbus_cdcacm_cb_t  cb,
usbus_cdcacm_coding_cb_t  coding_cb,
uint8_t *  buf,
size_t  len 
)

Initialize an USBUS CDC ACM interface.

Parameters
[in]usbusUSBUS context to register with
[in]cdcacmUSBUS CDC ACM handler
[in]cbCallback for data from the USB interface
[in]coding_cbCallback for control settings
[in]bufBuffer for data to the USB interface
[in]lenSize in bytes of the buffer

◆ usbus_cdc_acm_set_coding_cb()

void usbus_cdc_acm_set_coding_cb ( usbus_cdcacm_device_t cdcacm,
usbus_cdcacm_coding_cb_t  coding_cb 
)

Set the callback for control settings.

Interrupts are disabled during update to ensure thread safety

Parameters
[in]cdcacmUSBUS CDC ACM handler context
[in]coding_cbCallback for control settings

◆ usbus_cdc_acm_submit()

size_t usbus_cdc_acm_submit ( usbus_cdcacm_device_t cdcacm,
const uint8_t *  buf,
size_t  len 
)

Submit bytes to the CDC ACM handler.

Parameters
[in]cdcacmUSBUS CDC ACM handler context
[in]bufbuffer to submit
[in]lenlength of the submitted buffer
Returns
Number of bytes added to the CDC ACM ring buffer