nRF52840 only: Module with types, definitions and API used by CDC ACM class. More...
Modules |
|
| USB CDC ACM internals | |
|
nRF52840 only:
Internals of the USB ACM class implementation.
|
|
| USB CDC ACM class configuration | |
| CDC class descriptors | |
|
nRF52840 only:
Descriptors used in the USB CDC class implementation.A group of macros used to initialize CDC descriptors
|
|
| CDC class types | |
|
nRF52840 only:
Variable types used by the CDC class implementation.
|
|
Data Structures |
|
| struct | app_usbd_cdc_acm_t |
|
CDC ACM class instance type.
More...
|
|
Macros |
|
| #define | APP_USBD_CDC_ACM_DEFAULT_DESC (comm_interface,comm_epin,data_interface,data_epin,data_epout) |
|
Default CDC ACM descriptors.
More...
|
|
| #define | APP_USBD_CDC_ACM_GLOBAL_DEF (instance_name,user_ev_handler,comm_ifc,data_ifc,comm_ein,data_ein,data_eout,cdc_protocol) |
|
Global definition of
app_usbd_cdc_acm_t
class instance.
More...
|
|
Typedefs |
|
|
typedef enum
app_usbd_cdc_acm_user_event_e |
app_usbd_cdc_acm_user_event_t |
|
Events passed to user event handler.
More...
|
|
Enumerations |
|
| enum |
app_usbd_cdc_acm_user_event_e
{
APP_USBD_CDC_ACM_USER_EVT_RX_DONE , APP_USBD_CDC_ACM_USER_EVT_TX_DONE , APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN , APP_USBD_CDC_ACM_USER_EVT_PORT_CLOSE } |
|
Events passed to user event handler.
More...
|
|
| enum |
app_usbd_cdc_acm_serial_state_t
{
APP_USBD_CDC_ACM_SERIAL_STATE_DCD = (1u << 0), APP_USBD_CDC_ACM_SERIAL_STATE_DSR = (1u << 1), APP_USBD_CDC_ACM_SERIAL_STATE_BREAK = (1u << 2), APP_USBD_CDC_ACM_SERIAL_STATE_RING = (1u << 3), APP_USBD_CDC_ACM_SERIAL_STATE_FRAMING = (1u << 4), APP_USBD_CDC_ACM_SERIAL_STATE_PARITY = (1u << 5), APP_USBD_CDC_ACM_SERIAL_STATE_OVERRUN = (1u << 6) } |
|
Serial state notifications.
More...
|
|
| enum |
app_usbd_cdc_acm_line_state_t
{
APP_USBD_CDC_ACM_LINE_STATE_DTR = (1u << 0), APP_USBD_CDC_ACM_LINE_STATE_RTS = (1u << 1) } |
|
Serial line state.
More...
|
|
Functions |
|
|
static
app_usbd_class_inst_t
const * |
app_usbd_cdc_acm_class_inst_get ( app_usbd_cdc_acm_t const *p_cdc_acm) |
|
Helper function to get class instance from CDC ACM class.
More...
|
|
| static app_usbd_cdc_acm_req_t * | app_usbd_cdc_acm_class_request_get ( app_usbd_cdc_acm_t const *p_cdc_acm) |
|
Helper function to get cdc_acm specific request from cdc_acm class.
More...
|
|
| static app_usbd_cdc_acm_t const * | app_usbd_cdc_acm_class_get ( app_usbd_class_inst_t const *p_inst) |
|
Helper function to get cdc_acm from base class instance.
More...
|
|
| ret_code_t | app_usbd_cdc_acm_write ( app_usbd_cdc_acm_t const *p_cdc_acm, const void *p_buf, size_t length) |
|
Writes data to CDC ACM serial port.
More...
|
|
| size_t | app_usbd_cdc_acm_rx_size ( app_usbd_cdc_acm_t const *p_cdc_acm) |
|
Returns the amount of data that was read.
More...
|
|
| size_t | app_usbd_cdc_acm_bytes_stored ( app_usbd_cdc_acm_t const *p_cdc_acm) |
|
Returns the amount of data that was stored into internal buffer.
More...
|
|
| ret_code_t | app_usbd_cdc_acm_read ( app_usbd_cdc_acm_t const *p_cdc_acm, void *p_buf, size_t length) |
|
Reads data from CDC ACM serial port.
More...
|
|
| ret_code_t | app_usbd_cdc_acm_read_any ( app_usbd_cdc_acm_t const *p_cdc_acm, void *p_buf, size_t length) |
|
Read any data from CDC ACM port up to given buffer size.
More...
|
|
| ret_code_t | app_usbd_cdc_acm_serial_state_notify ( app_usbd_cdc_acm_t const *p_cdc_acm, app_usbd_cdc_acm_serial_state_t serial_state, bool value) |
|
Serial state notification via IN interrupt endpoint.
More...
|
|
| ret_code_t | app_usbd_cdc_acm_line_state_get ( app_usbd_cdc_acm_t const *p_cdc_acm, app_usbd_cdc_acm_line_state_t line_state, uint32_t *value) |
|
Control line value get.
More...
|
|
Detailed Description
nRF52840 only: Module with types, definitions and API used by CDC ACM class.
References:
- "Universal Serial Bus Class Definitions for Communications Devices" Revision 1.2, November 3, 2010
- "Universal Serial Bus Communications Class Subclass Specification for PSTN Devices" Revision 1.2, February 9, 2007
Macro Definition Documentation
| #define APP_USBD_CDC_ACM_DEFAULT_DESC | ( | comm_interface, | |
| comm_epin, | |||
| data_interface, | |||
| data_epin, | |||
| data_epout | |||
| ) |
Default CDC ACM descriptors.
- Parameters
-
comm_interface COMM interface number. comm_epin COMM interface IN endpoint. data_interface DATA interface number. data_epin DATA interface IN endpoint. data_epout DATA interface OUT endpoint.
| #define APP_USBD_CDC_ACM_GLOBAL_DEF | ( | instance_name, | |
| user_ev_handler, | |||
| comm_ifc, | |||
| data_ifc, | |||
| comm_ein, | |||
| data_ein, | |||
| data_eout, | |||
| cdc_protocol | |||
| ) |
Global definition of app_usbd_cdc_acm_t class instance.
- Parameters
-
instance_name Name of global instance. user_ev_handler User event handler (optional). comm_ifc Interface number of cdc_acm control. data_ifc Interface number of cdc_acm DATA. comm_ein COMM subclass IN endpoint. data_ein DATA subclass IN endpoint. data_eout DATA subclass OUT endpoint. cdc_protocol CDC protocol app_usbd_cdc_comm_protocol_t
- Note
- This macro is just simplified version of APP_USBD_CDC_ACM_GLOBAL_DEF_INTERNAL .
Typedef Documentation
Events passed to user event handler.
- Note
- Example prototype of user event handler:
Enumeration Type Documentation
Serial state notifications.
Events passed to user event handler.
- Note
- Example prototype of user event handler:
Function Documentation
| size_t app_usbd_cdc_acm_bytes_stored | ( | app_usbd_cdc_acm_t const * | p_cdc_acm | ) |
Returns the amount of data that was stored into internal buffer.
This function should be used on APP_USBD_CDC_ACM_USER_EVT_RX_DONE event to get information how many bytes are waiting in internal buffer.
- Parameters
-
[in] p_cdc_acm CDC ACM class instance (defined by APP_USBD_CDC_ACM_GLOBAL_DEF ).
- Returns
- Amount of data waiting.
|
inline static |
Helper function to get cdc_acm from base class instance.
- Parameters
-
[in] p_inst Base class instance.
- Returns
- CDC ACM class handle.
|
inline static |
Helper function to get class instance from CDC ACM class.
- Parameters
-
[in] p_cdc_acm CDC ACM class instance (defined by APP_USBD_CDC_ACM_GLOBAL_DEF ).
- Returns
- Base class instance.
|
inline static |
Helper function to get cdc_acm specific request from cdc_acm class.
- Parameters
-
[in] p_cdc_acm CDC ACM class instance (defined by APP_USBD_CDC_ACM_GLOBAL_DEF ).
- Returns
- CDC ACM class specific request.
| ret_code_t app_usbd_cdc_acm_line_state_get | ( | app_usbd_cdc_acm_t const * | p_cdc_acm , |
| app_usbd_cdc_acm_line_state_t | line_state , | ||
| uint32_t * | value | ||
| ) |
Control line value get.
- Parameters
-
[in] p_cdc_acm CDC ACM class instance (defined by APP_USBD_CDC_ACM_GLOBAL_DEF ). [in] line_state Line control value type. [out] value Line control value.
- Returns
- Standard error code.
| ret_code_t app_usbd_cdc_acm_read | ( | app_usbd_cdc_acm_t const * | p_cdc_acm , |
| void * | p_buf , | ||
| size_t | length | ||
| ) |
Reads data from CDC ACM serial port.
This function uses internal buffer and double buffering for continuous transmission.
If there is enough data in internal buffer to fill user buffer, NRF_SUCCESS is returned and data is immediately available in the user buffer.
If not, up to two user buffers can be scheduled, function returns NRF_ERROR_IO_PENDING when first buffer is filled and APP_USBD_CDC_ACM_USER_EVT_RX_DONE event is generated.
- Parameters
-
[in] p_cdc_acm CDC ACM class instance (defined by APP_USBD_CDC_ACM_GLOBAL_DEF ). [out] p_buf Output buffer. [in] length Number of bytes to read.
- Return values
-
NRF_SUCCESS Data is stored into user buffer. NRF_ERROR_IO_PENDING Awaiting transmission, when data is stored into user buffer, APP_USBD_CDC_ACM_USER_EVT_RX_DONE event will be raised. NRF_ERROR_BUSY There are already 2 buffers queued for transfers. other Standard error code.
| ret_code_t app_usbd_cdc_acm_read_any | ( | app_usbd_cdc_acm_t const * | p_cdc_acm , |
| void * | p_buf , | ||
| size_t | length | ||
| ) |
Read any data from CDC ACM port up to given buffer size.
This function is very similar to the app_usbd_cdc_acm_read but it returns data as quick as any data is available, even if the given buffer was not totally full.
- Note
- This function cannot use double buffering.
- To check the number of bytes really read use app_usbd_cdc_acm_rx_size function.
- Parameters
-
p_cdc_acm CDC ACM class instance (defined by APP_USBD_CDC_ACM_GLOBAL_DEF ). [out] p_buf Output buffer. [in] length Maximum number of bytes to read.
- Return values
-
NRF_SUCCESS Data is stored into user buffer. NRF_ERROR_IO_PENDING Awaiting transmission, when data is stored into user buffer, APP_USBD_CDC_ACM_USER_EVT_RX_DONE event will be raised. NRF_ERROR_BUSY There is already buffer set for a transfer. other Standard error code.
| size_t app_usbd_cdc_acm_rx_size | ( | app_usbd_cdc_acm_t const * | p_cdc_acm | ) |
Returns the amount of data that was read.
This function should be used on APP_USBD_CDC_ACM_USER_EVT_RX_DONE event to get information how many bytes have been transfered into user buffer.
- Parameters
-
[in] p_cdc_acm CDC ACM class instance (defined by APP_USBD_CDC_ACM_GLOBAL_DEF ).
- Returns
- Amount of data transfered.
| ret_code_t app_usbd_cdc_acm_serial_state_notify | ( | app_usbd_cdc_acm_t const * | p_cdc_acm , |
| app_usbd_cdc_acm_serial_state_t | serial_state , | ||
| bool | value | ||
| ) |
Serial state notification via IN interrupt endpoint.
- Parameters
-
[in] p_cdc_acm CDC ACM class instance (defined by APP_USBD_CDC_ACM_GLOBAL_DEF ). [in] serial_state Serial state notification type. [in] value Serial state value.
- Returns
- Standard error code.
| ret_code_t app_usbd_cdc_acm_write | ( | app_usbd_cdc_acm_t const * | p_cdc_acm , |
| const void * | p_buf , | ||
| size_t | length | ||
| ) |
Writes data to CDC ACM serial port.
This is asynchronous call. User should wait for APP_USBD_CDC_ACM_USER_EVT_TX_DONE event to be sure that all data has been sent and input buffer could be accessed again.
- Parameters
-
[in] p_cdc_acm CDC ACM class instance (defined by APP_USBD_CDC_ACM_GLOBAL_DEF ). [in] p_buf Input buffer. [in] length Input buffer length.
- Returns
- Standard error code.