nRF5 SDK v13.0.0
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions

nRF52840 only: Module with types, definitions and API used by CDC ACM class. More...

Modules

 USB CDC ACM class configuration
 
 USB CDC ACM internals
 nRF52840 only: Internals of the USB ACM class implementation.
 
 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,interfaces_configs,user_ev_handler,raw_descriptors)
 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_tapp_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 to be read. 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_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:

Macro Definition Documentation

#define APP_USBD_CDC_ACM_DEFAULT_DESC (   comm_interface,
  comm_epin,
  data_interface,
  data_epin,
  data_epout 
)
Value:
APP_USBD_CDC_IAD_DSC(comm_interface, \
APP_USBD_CDC_COMM_INTERFACE_DSC(comm_interface, \
APP_USBD_CDC_HEADER_DSC(0x0110) \
APP_USBD_CDC_CALL_MGMT_DSC(0x03, data_interface) \
APP_USBD_CDC_ACM_DSC(0x02) \
APP_USBD_CDC_UNION_DSC(comm_interface, data_interface) \
APP_USBD_CDC_COM_EP_DSC(comm_epin, NRF_DRV_USBD_EPSIZE) \
APP_USBD_CDC_DATA_INTERFACE_DSC(data_interface, 0, 0) \
APP_USBD_CDC_DATA_EP_DSC(data_epin, data_epout, NRF_DRV_USBD_EPSIZE)

Default CDC ACM descriptors.

Parameters
comm_interfaceCOMM interface number.
comm_epinCOMM interface IN endpoint.
data_interfaceDATA interface number.
data_epinDATA interface IN endpoint.
data_epoutDATA interface OUT endpoint.
#define APP_USBD_CDC_ACM_GLOBAL_DEF (   instance_name,
  interfaces_configs,
  user_ev_handler,
  raw_descriptors 
)
Value:
interfaces_configs, \
user_ev_handler, \
raw_descriptors)

Global definition of app_usbd_cdc_acm_t class instance.

Parameters
instance_nameName of global instance.
interfaces_configsInterfaces configurations.
user_ev_handlerUser event handler (optional).
raw_descriptorsRaw descriptor table.
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:
void cdc_acm_user_ev_handler(app_usbd_class_inst_t const * p_inst,

Enumeration Type Documentation

Serial line state.

Enumerator
APP_USBD_CDC_ACM_LINE_STATE_DTR 

Line state bit DTR.

APP_USBD_CDC_ACM_LINE_STATE_RTS 

Line state bit RTS.

Serial state notifications.

Enumerator
APP_USBD_CDC_ACM_SERIAL_STATE_DCD 

Notification bit DCD.

APP_USBD_CDC_ACM_SERIAL_STATE_DSR 

Notification bit DSR.

APP_USBD_CDC_ACM_SERIAL_STATE_BREAK 

Notification bit BREAK.

APP_USBD_CDC_ACM_SERIAL_STATE_RING 

Notification bit RING.

APP_USBD_CDC_ACM_SERIAL_STATE_FRAMING 

Notification bit FRAMING.

APP_USBD_CDC_ACM_SERIAL_STATE_PARITY 

Notification bit PARITY.

APP_USBD_CDC_ACM_SERIAL_STATE_OVERRUN 

Notification bit OVERRUN.

Events passed to user event handler.

Note
Example prototype of user event handler:
void cdc_acm_user_ev_handler(app_usbd_class_inst_t const * p_inst,
Enumerator
APP_USBD_CDC_ACM_USER_EVT_RX_DONE 

User event RX_DONE.

APP_USBD_CDC_ACM_USER_EVT_TX_DONE 

User event TX_DONE.

APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN 

User event PORT_OPEN.

APP_USBD_CDC_ACM_USER_EVT_PORT_CLOSE 

User event PORT_CLOSE.

Function Documentation

static app_usbd_cdc_acm_t const* app_usbd_cdc_acm_class_get ( app_usbd_class_inst_t const *  p_inst)
inlinestatic

Helper function to get cdc_acm from base class instance.

Parameters
[in]p_instBase class instance.
Returns
CDC ACM class handle.
static app_usbd_class_inst_t const* app_usbd_cdc_acm_class_inst_get ( app_usbd_cdc_acm_t const *  p_cdc_acm)
inlinestatic

Helper function to get class instance from CDC ACM class.

Parameters
[in]p_cdc_acmCDC ACM class instance (defined by APP_USBD_CDC_ACM_GLOBAL_DEF).
Returns
Base class instance.
static app_usbd_cdc_acm_req_t* app_usbd_cdc_acm_class_request_get ( app_usbd_cdc_acm_t const *  p_cdc_acm)
inlinestatic

Helper function to get cdc_acm specific request from cdc_acm class.

Parameters
[in]p_cdc_acmCDC 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_acmCDC ACM class instance (defined by APP_USBD_CDC_ACM_GLOBAL_DEF).
[in]line_stateLine control value type.
[out]valueLine 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.

Parameters
[in]p_cdc_acmCDC ACM class instance (defined by APP_USBD_CDC_ACM_GLOBAL_DEF).
[out]p_bufOutput buffer.
[in]lengthOutput buffer length (must by multiple of NRF_DRV_USBD_EPSIZE).
Returns
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 to be 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.

Parameters
[in]p_cdc_acmCDC 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_acmCDC ACM class instance (defined by APP_USBD_CDC_ACM_GLOBAL_DEF).
[in]serial_stateSerial state notification type.
[in]valueSerial 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_acmCDC ACM class instance (defined by APP_USBD_CDC_ACM_GLOBAL_DEF).
[in]p_bufInput buffer.
[in]lengthInput buffer length.
Returns
Standard error code.

Documentation feedback | Developer Zone | Subscribe | Updated