USB Device ACM API#

USB Device CDC ACM API.

Modules#

sl_usbd_cdc_acm_line_coding_t

sl_usbd_cdc_acm_callbacks_t

Functions#

sl_status_t

GLOBAL VARIABLES.

sl_status_t
sl_usbd_cdc_acm_create_instance(uint16_t line_state_interval, uint16_t call_mgmt_capabilities, sl_usbd_cdc_acm_callbacks_t *p_acm_callbacks, uint8_t *p_subclass_nbr)

Add a new instance of the CDC ACM serial emulation subclass.

sl_status_t
sl_usbd_cdc_acm_add_to_configuration(uint8_t subclass_nbr, uint8_t config_nbr)

Add a CDC ACM subclass class instance into USB device configuration.

sl_status_t
sl_usbd_cdc_acm_is_enabled(uint8_t subclass_nbr, bool *p_enabled)

Get the CDC ACM serial emulation subclass enable state.

sl_status_t
sl_usbd_cdc_acm_read(uint8_t subclass_nbr, uint8_t *p_buf, uint32_t buf_len, uint16_t timeout, uint32_t *p_xfer_len)

Receive data on the CDC ACM serial emulation subclass.

sl_status_t
sl_usbd_cdc_acm_read_async(uint8_t subclass_nbr, uint8_t *p_buf, uint32_t buf_len, sl_usbd_cdc_async_function_t async_fnct, void *p_async_arg)

Receive data on the CDC ACM serial emulation subclass asynchronously.

sl_status_t
sl_usbd_cdc_acm_write(uint8_t subclass_nbr, uint8_t *p_buf, uint32_t buf_len, uint16_t timeout, uint32_t *p_xfer_len)

Send data on the CDC ACM serial emulation subclass.

sl_status_t
sl_usbd_cdc_acm_write_async(uint8_t subclass_nbr, uint8_t *p_buf, uint32_t buf_len, sl_usbd_cdc_async_function_t async_fnct, void *p_async_arg)

Send data on the CDC ACM serial emulation subclass asynchronously.

sl_status_t
sl_usbd_cdc_acm_get_line_control_state(uint8_t subclass_nbr, uint8_t *p_line_ctrl)

Return the state of control lines.

sl_status_t
sl_usbd_cdc_acm_get_line_coding(uint8_t subclass_nbr, sl_usbd_cdc_acm_line_coding_t *p_line_coding)

Get the current state of the line coding.

sl_status_t
sl_usbd_cdc_acm_set_line_coding(uint8_t subclass_nbr, sl_usbd_cdc_acm_line_coding_t *p_line_coding)

Set a new line coding.

sl_status_t
sl_usbd_cdc_acm_set_line_state_event(uint8_t subclass_nbr, uint8_t events)

Set a line state event(s).

sl_status_t
sl_usbd_cdc_acm_clear_line_state_event(uint8_t subclass_nbr, uint8_t events)

Clear a line state event(s).

Macros#

#define
SL_USBD_CDC_ACM_NBR_NONE 255u

MODULE.

#define
SL_USBD_CDC_ACM_PARITY_NONE 0u

PORT SETTINGS DEFINES.

#define
SL_USBD_CDC_ACM_PARITY_ODD 1u
#define
SL_USBD_CDC_ACM_PARITY_EVEN 2u
#define
SL_USBD_CDC_ACM_PARITY_MARK 3u
#define
SL_USBD_CDC_ACM_PARITY_SPACE 4u
#define
SL_USBD_CDC_ACM_STOP_BIT_1 0u
#define
SL_USBD_CDC_ACM_STOP_BIT_1_5 1u
#define
SL_USBD_CDC_ACM_STOP_BIT_2 2u
#define
SL_USBD_CDC_ACM_CTRL_BREAK 0x01u

LINE EVENTS FLAGS DEFINES.

#define
SL_USBD_CDC_ACM_CTRL_RTS 0x02u
#define
SL_USBD_CDC_ACM_CTRL_DTR 0x04u
#define
SL_USBD_CDC_ACM_STATE_DCD 0x01u
#define
SL_USBD_CDC_ACM_STATE_DSR 0x02u
#define
SL_USBD_CDC_ACM_STATE_BREAK 0x04u
#define
SL_USBD_CDC_ACM_STATE_RING 0x08u
#define
SL_USBD_CDC_ACM_STATE_FRAMING 0x10u
#define
SL_USBD_CDC_ACM_STATE_PARITY 0x20u
#define
SL_USBD_CDC_ACM_STATE_OVERUN 0x40u
#define
SL_USBD_CDC_ACM_CALL_MGMT_DEV 0x01u

CALL MANAGEMENT CAPABILITIES.

#define
SL_USBD_CDC_ACM_CALL_MGMT_DATA_CCI_DCI 0x02u
#define
SL_USBD_CDC_ACM_CALL_MGMT_DATA_OVER_DCI (0x02u | 0x01u)

Function Documentation#

sl_usbd_cdc_acm_init#

sl_status_t sl_usbd_cdc_acm_init (void )

GLOBAL VARIABLES.

Parameters
N/A

MACROS GLOBAL CONSTANTS FUNCTION PROTOTYPES CDC ACM FUNCTIONS

Initialize the CDC ACM serial emulation subclass.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 170 of file protocol/usb/inc/sl_usbd_class_cdc_acm.h

sl_usbd_cdc_acm_create_instance#

sl_status_t sl_usbd_cdc_acm_create_instance (uint16_t line_state_interval, uint16_t call_mgmt_capabilities, sl_usbd_cdc_acm_callbacks_t * p_acm_callbacks, uint8_t * p_subclass_nbr)

Add a new instance of the CDC ACM serial emulation subclass.

Parameters
N/Aline_state_interval

Line state notification interval in milliseconds (value must be a power of 2).

N/Acall_mgmt_capabilities

Call Management Capabilities bitmap. OR'ed of the following flags:

  • SL_USBD_CDC_ACM_CALL_MGMT_DEV Device handles call management itself.

  • SL_USBD_CDC_ACM_CALL_MGMT_DATA_CCI_DCI Device can send/receive call management information over a Data Class interface.

N/Ap_acm_callbacks

Optional pointers to callback functions to be called on various events.

N/Ap_subclass_nbr

Param to variable that will receive CDC ACM serial emulation subclass instance number.

Returns

  • Return SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 201 of file protocol/usb/inc/sl_usbd_class_cdc_acm.h

sl_usbd_cdc_acm_add_to_configuration#

sl_status_t sl_usbd_cdc_acm_add_to_configuration (uint8_t subclass_nbr, uint8_t config_nbr)

Add a CDC ACM subclass class instance into USB device configuration.

Parameters
N/Asubclass_nbr

CDC ACM serial emulation subclass instance number.

N/Aconfig_nbr

Configuration index to add new test class interface to.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 215 of file protocol/usb/inc/sl_usbd_class_cdc_acm.h

sl_usbd_cdc_acm_is_enabled#

sl_status_t sl_usbd_cdc_acm_is_enabled (uint8_t subclass_nbr, bool * p_enabled)

Get the CDC ACM serial emulation subclass enable state.

Parameters
N/Asubclass_nbr

CDC ACM serial emulation subclass instance number.

N/Ap_enabled

Boolean to a variable that will receive enable status. The variable is set to true, CDC ACM serial emulation is enabled. The variable is set to false, CDC ACM serial emulation is not enabled.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 229 of file protocol/usb/inc/sl_usbd_class_cdc_acm.h

sl_usbd_cdc_acm_read#

sl_status_t sl_usbd_cdc_acm_read (uint8_t subclass_nbr, uint8_t * p_buf, uint32_t buf_len, uint16_t timeout, uint32_t * p_xfer_len)

Receive data on the CDC ACM serial emulation subclass.

Parameters
N/Asubclass_nbr

CDC ACM serial emulation subclass instance number.

N/Ap_buf

Pointer to the destination buffer to receive data.

N/Abuf_len

Number of octets to receive.

N/Atimeout

Timeout, in milliseconds.

N/Ap_xfer_len

Pointer to a variable that will receive transfer length. If no errors are returned, the variable is set to number of octets received, otherwise it is set to 0.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 249 of file protocol/usb/inc/sl_usbd_class_cdc_acm.h

sl_usbd_cdc_acm_read_async#

sl_status_t sl_usbd_cdc_acm_read_async (uint8_t subclass_nbr, uint8_t * p_buf, uint32_t buf_len, sl_usbd_cdc_async_function_t async_fnct, void * p_async_arg)

Receive data on the CDC ACM serial emulation subclass asynchronously.

Parameters
N/Asubclass_nbr

CDC ACM serial emulation subclass instance number.

N/Ap_buf

Pointer to the destination buffer to receive data.

N/Abuf_len

Number of octets to receive.

N/Aasync_fnct

Function that will be invoked upon completion of receive operation.

N/Ap_async_arg

Pointer to the argument that will be passed as parameter of 'async_fnct'.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 270 of file protocol/usb/inc/sl_usbd_class_cdc_acm.h

sl_usbd_cdc_acm_write#

sl_status_t sl_usbd_cdc_acm_write (uint8_t subclass_nbr, uint8_t * p_buf, uint32_t buf_len, uint16_t timeout, uint32_t * p_xfer_len)

Send data on the CDC ACM serial emulation subclass.

Parameters
N/Asubclass_nbr

CDC ACM serial emulation subclass instance number.

N/Ap_buf

Pointer to the buffer of data that will be transmitted.

N/Abuf_len

Number of octets to transmit.

N/Atimeout

Timeout in milliseconds.

N/Ap_xfer_len

Pointer to a variable that will receive transfer length. If no errors are returned, the variable is set to number of octets transmitted, otherwise it is set to 0.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 293 of file protocol/usb/inc/sl_usbd_class_cdc_acm.h

sl_usbd_cdc_acm_write_async#

sl_status_t sl_usbd_cdc_acm_write_async (uint8_t subclass_nbr, uint8_t * p_buf, uint32_t buf_len, sl_usbd_cdc_async_function_t async_fnct, void * p_async_arg)

Send data on the CDC ACM serial emulation subclass asynchronously.

Parameters
N/Asubclass_nbr

CDC ACM serial emulation subclass instance number.

N/Ap_buf

Pointer to the buffer of data that will be transmitted.

N/Abuf_len

Number of octets to transmit.

N/Aasync_fnct

Function that will be invoked upon completion of transfer operation.

N/Ap_async_arg

Pointer to the argument that will be passed as parameter of 'async_fnct'.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 314 of file protocol/usb/inc/sl_usbd_class_cdc_acm.h

sl_usbd_cdc_acm_get_line_control_state#

sl_status_t sl_usbd_cdc_acm_get_line_control_state (uint8_t subclass_nbr, uint8_t * p_line_ctrl)

Return the state of control lines.

Parameters
N/Asubclass_nbr

CDC ACM serial emulation subclass instance number.

N/Ap_line_ctrl

Pointer to the variable that will be set with the state of the control lines, encoded in bit fields.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 330 of file protocol/usb/inc/sl_usbd_class_cdc_acm.h

sl_usbd_cdc_acm_get_line_coding#

sl_status_t sl_usbd_cdc_acm_get_line_coding (uint8_t subclass_nbr, sl_usbd_cdc_acm_line_coding_t * p_line_coding)

Get the current state of the line coding.

Parameters
N/Asubclass_nbr

CDC ACM serial emulation subclass instance number.

N/Ap_line_coding

Pointer to the structure where the current line coding will be stored.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 342 of file protocol/usb/inc/sl_usbd_class_cdc_acm.h

sl_usbd_cdc_acm_set_line_coding#

sl_status_t sl_usbd_cdc_acm_set_line_coding (uint8_t subclass_nbr, sl_usbd_cdc_acm_line_coding_t * p_line_coding)

Set a new line coding.

Parameters
N/Asubclass_nbr

CDC ACM serial emulation subclass instance number.

N/Ap_line_coding

Pointer to the structure that contains the new line coding.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 354 of file protocol/usb/inc/sl_usbd_class_cdc_acm.h

sl_usbd_cdc_acm_set_line_state_event#

sl_status_t sl_usbd_cdc_acm_set_line_state_event (uint8_t subclass_nbr, uint8_t events)

Set a line state event(s).

Parameters
N/Asubclass_nbr

CDC ACM serial emulation subclass instance number.

N/Aevents

Line state event(s) to set. OR'ed of the following flags:

  • SL_USBD_CDC_ACM_STATE_DCD

  • SL_USBD_CDC_ACM_STATE_DSR

  • SL_USBD_CDC_ACM_STATE_BREAK

  • SL_USBD_CDC_ACM_STATE_RING

  • SL_USBD_CDC_ACM_STATE_FRAMING

  • SL_USBD_CDC_ACM_STATE_PARITY

  • SL_USBD_CDC_ACM_STATE_OVERUN

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 373 of file protocol/usb/inc/sl_usbd_class_cdc_acm.h

sl_usbd_cdc_acm_clear_line_state_event#

sl_status_t sl_usbd_cdc_acm_clear_line_state_event (uint8_t subclass_nbr, uint8_t events)

Clear a line state event(s).

Parameters
N/Asubclass_nbr

CDC ACM serial emulation subclass instance number.

N/Aevents

Line state event(s) set to be cleared. OR'ed of the following flags (see Note #1) :

  • SL_USBD_CDC_ACM_STATE_DCD Set DCD signal (Rx carrier).

  • SL_USBD_CDC_ACM_STATE_DSR Set DSR signal (Tx carrier).

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

Note

  • (1) USB PSTN spec ver 1.20 states: "For the irregular signals like break, the incoming ring signal, or the overrun error state, this will reset their values to zero and again will not send another notification until their state changes." The irregular events are automatically cleared by the ACM serial emulation subclass.


Definition at line 393 of file protocol/usb/inc/sl_usbd_class_cdc_acm.h