Data Structures | Enumerations | Functions

USB CDC Class Enumerations and Descriptors
[Public API]

Packet structs, constants, and callback functions implementing the "Universal Serial Bus Class Definitions for Communication Devices" (commonly the USB CDC Specification), version 1.1. More...

Data Structures

struct  cdc_functional_descriptor_header
 CDC Functional Descriptor Header. More...
struct  cdc_acm_functional_descriptor
 CDC Abstract Control Management Functional Descriptor. More...
struct  cdc_union_functional_descriptor
 CDC Union Functional Registor. More...
struct  cdc_notification_header
struct  cdc_serial_state_notification
struct  cdc_line_coding
 CDC Line Coding Structure. More...

Enumerations

enum  CDCDescriptorTypes { DESC_CS_INTERFACE = 0x24, DESC_CS_ENDPOINT = 0x25 }
 

CDC Descriptor types: 5.2.3.


enum  CDCFunctionalDescriptorSubtypes { CDC_FUNCTIONAL_DESCRIPTOR_SUBTYPE_HEADER = 0x0, CDC_FUNCTIONAL_DESCRIPTOR_SUBTYPE_ACM = 0x2, CDC_FUNCTIONAL_DESCRIPTOR_SUBTYPE_UNION = 0x6 }
enum  CDCACMCapabilities { CDC_ACM_CAPABILITY_COMM_FEATURES = 0x1, CDC_ACM_CAPABILITY_LINE_CODINGS = 0x2, CDC_ACM_CAPABILITY_SEND_BREAK = 0x4, CDC_ACM_CAPABILITY_NETWORK_CONNECTION = 0x8 }
 

Abstract Control Management (ACM) capabilities.

More...
enum  CDCRequests {
  CDC_SEND_ENCAPSULATED_COMMAND = 0x0, CDC_GET_ENCAPSULATED_RESPONSE = 0x1, CDC_SET_COMM_FEATURE = 0x2, CDC_GET_COMM_FEATURE = 0x3,
  CDC_CLEAR_COMM_FEATURE = 0x4, CDC_SET_LINE_CODING = 0x20, CDC_GET_LINE_CODING = 0x21, CDC_SET_CONTROL_LINE_STATE = 0x22,
  CDC_SEND_BREAK = 0x23
}
 

CDC ACM Class Requests.

More...
enum  CDCCommFeatureSelector { CDC_FEATURE_ABSTRACT_STATE = 0x1, CDC_FEATURE_COUNTRY_SETTING = 0x2 }
 

CDC Communication Feature Selector Codes.

More...
enum  CDCCharFormat { CDC_CHAR_FORMAT_1_STOP_BIT = 0, CDC_CHAR_FORMAT_1_POINT_5_STOP_BITS = 1, CDC_CHAR_FORMAT_2_STOP_BITS = 2 }
 

CDC Character Format.

More...
enum  CDCParityType {
  CDC_PARITY_NONE = 0, CDC_PARITY_ODD = 1, CDC_PARITY_EVEN = 2, CDC_PARITY_MARK = 3,
  CDC_PARITY_SPACE = 4
}
 

CDC Parity Type.

More...
enum  CDCNotifications { CDC_NETWORK_CONNECTION = 0x0, CDC_RESPONSE_AVAILABLE = 0x1, CDC_SERIAL_STATE = 0x20 }
 

CDC Class-Specific Notification Codes.

More...

Functions

uint8_t process_cdc_setup_request (const struct setup_packet *setup)
 Process CDC Setup Request.
int8_t CDC_SEND_ENCAPSULATED_COMMAND_CALLBACK (uint8_t interface, uint16_t length)
 CDC SEND_ENCAPSULATED_COMMAND callback.
int16_t CDC_GET_ENCAPSULATED_RESPONSE_CALLBACK (uint8_t interface, uint16_t length, const void **response, usb_ep0_data_stage_callback *callback, void **context)
 CDC GET_ENCAPSULATED_RESPONSE callback.
int8_t CDC_SET_COMM_FEATURE_CALLBACK (uint8_t interface, bool idle_setting, bool data_multiplexed_state)
 CDC SET_COMM_FEATURE callback.
int8_t CDC_CLEAR_COMM_FEATURE_CALLBACK (uint8_t interface, bool idle_setting, bool data_multiplexed_state)
 CDC CLEAR_COMM_FEATURE callback.
int8_t CDC_GET_COMM_FEATURE_CALLBACK (uint8_t interface, bool *idle_setting, bool *data_multiplexed_state)
 CDC GET_COMM_FEATURE callback.
int8_t CDC_SET_LINE_CODING_CALLBACK (uint8_t interface, const struct cdc_line_coding *coding)
 CDC SET_LINE_CODING callback.
int8_t CDC_GET_LINE_CODING_CALLBACK (uint8_t interface, struct cdc_line_coding *coding)
 CDC GET_LINE_CODING callback.
int8_t CDC_SET_CONTROL_LINE_STATE_CALLBACK (uint8_t interface, bool dtr, bool dts)
 CDC SET_CONTROL_LINE_STATE callback.
int8_t CDC_SEND_BREAK_CALLBACK (uint8_t interface, uint16_t duration)
 CDC SEND_BREAK callback.

Detailed Description

Packet structs, constants, and callback functions implementing the "Universal Serial Bus Class Definitions for Communication Devices" (commonly the USB CDC Specification), version 1.1.

For more information, see the above referenced document, available from http://www.usb.org .


Enumeration Type Documentation

Abstract Control Management (ACM) capabilities.

See section 5.2.3.3 of the CDC Specification, version 1.1.

CDC Character Format.

These values are used in the bCharFormat field of the GET_LINE_CODING and SET_LINE_CODING requests. See section 6.2.13 (table 50) of the CDC Specification, version 1.1.

CDC Communication Feature Selector Codes.

See section 6.2.4, Table 47 of the CDC Specification, version 1.1.

CDC Class-Specific Notification Codes.

See section 6.3 (table 68) of the CDC Specification, version 1.1.

CDC Parity Type.

These values are used in the bParityType field of the GET_LINE_CODING and SET_LINE_CODING requests. See section 6.2.13 (table 50) of the CDC Specification, version 1.1.

CDC ACM Class Requests.

These are the class requests needed for ACM (see section 6.2, table 45). Others are omitted. Get in contact with Signal 11 if you need something specific.


Function Documentation

int8_t CDC_CLEAR_COMM_FEATURE_CALLBACK ( uint8_t  interface,
bool  idle_setting,
bool  data_multiplexed_state 
)

CDC CLEAR_COMM_FEATURE callback.

The USB Stack will call this function when a CLEAR_COMM_FEATURE request has been received from the host. The device should clear the idle setting and/or data multiplexed state if requested. There is no way to refuse this message. If this message is not supported by the device, simply do not define CDC_CLEAR_COMM_FEATURE_CALLBACK.

Parameters:
interfaceThe interface for which the command is intended
idle_settingWhether to clear the idle setting. True = clear the idle setting.
data_multiplexed_stateWhether to clear the data multiplexed state. True = clear the multiplexed state.
Returns:
Return 0 if the request can be handled or -1 if it cannot. Returning -1 will cause STALL to be returned to the host.
int8_t CDC_GET_COMM_FEATURE_CALLBACK ( uint8_t  interface,
bool *  idle_setting,
bool *  data_multiplexed_state 
)

CDC GET_COMM_FEATURE callback.

The USB Stack will call this function when a GET_COMM_FEATURE request has been received from the host. This function should set the idle_setting and multiplexed_state pointers to their current values.

Parameters:
interfaceThe interface for which the report is requested
idle_settingSet to the current value of the idle setting.
multiplexed_stateSet to the current value of the multiplexed state.
Returns:
Return 0 if the request can be handled or -1 if it cannot. Returning -1 will cause STALL to be returned to the host.
int16_t CDC_GET_ENCAPSULATED_RESPONSE_CALLBACK ( uint8_t  interface,
uint16_t  length,
const void **  response,
usb_ep0_data_stage_callback callback,
void **  context 
)

CDC GET_ENCAPSULATED_RESPONSE callback.

The USB Stack will call this function when a GET_ENCAPSULATED_RESPONSE request has been received from the host. This function should set the response pointer to a buffer containing the response data and return the length of the response. Once the transfer has completed, callback will be called with the context pointer provided. The buffer pointed to by response should be considered to be owned by the USB stack until the callback is called and should not be modified by the application until that time.

Parameters:
interfaceThe interface for which the report is requested
lengthThe length of the response requested by the host
responseA pointer to a pointer which should be set to the response data.
callbackA callback function to call when the transfer completes. This parameter is mandatory. Once the callback is called, the transfer is over, and the buffer can be considered to be owned by the application again.
contextA pointer to be passed to the callback. The USB stack does not dereference this pointer.
Returns:
Return 0 if the request can be handled or -1 if it cannot. Returning -1 will cause STALL to be returned to the host.
int8_t CDC_GET_LINE_CODING_CALLBACK ( uint8_t  interface,
struct cdc_line_coding coding 
)

CDC GET_LINE_CODING callback.

The USB Stack will call this function when a GET_LINE_CODING request has been received from the host. This function should set the values in the structure pointed to by coding to the current line coding values.

Parameters:
interfaceThe interface for which the report is requested
codingPointer to a structure which must be filled with the current line coding values.
callbackA callback function to call when the transfer completes. This parameter is mandatory. Once the callback is called, the transfer is over, and the buffer can be considered to be owned by the application again.
contextA pointer to be passed to the callback. The USB stack does not dereference this pointer.
Returns:
Return 0 if the request can be handled or -1 if it cannot. Returning -1 will cause STALL to be returned to the host.
int8_t CDC_SEND_BREAK_CALLBACK ( uint8_t  interface,
uint16_t  duration 
)

CDC SEND_BREAK callback.

The USB Stack will call this function when a SEND_BREAK request has been received from the host. The device should then assert a break condition for the specified number of milliseconds.

Parameters:
interfaceThe interface for which the command is intended
durationThe duration of the break in milliseconds
Returns:
Return 0 if the request can be handled or -1 if it cannot. Returning -1 will cause STALL to be returned to the host.
int8_t CDC_SEND_ENCAPSULATED_COMMAND_CALLBACK ( uint8_t  interface,
uint16_t  length 
)

CDC SEND_ENCAPSULATED_COMMAND callback.

The USB Stack will call this function when a GET_ENCAPSULATED_COMMAND request has been received from the host. There are two ways to handle this:

1. If the request can't be handled, return -1. This will send a STALL to the host. 2. If the request can be handled, call usb_start_receive_ep0_data_stage() with a buffer to be filled with the command data and a callback which will get called when the data stage is complete. The callback is required, and the command data buffer passed to usb_start_receive_ep0_data_stage() must remain valid until the callback is called.

It is worth noting that only one control transfer can be active at any given time. Once HID_SET_REPORT_CALLBACK() has been called, it will not be called again until the next transfer, meaning that if the application-provided HID_SET_REPORT_CALLBACK() function performs option 1 above, the callback function passed to usb_start_receive_ep0_data_stage() will be called before any other setup transfer can happen again. Thus, it is safe to use the same buffer for all control transfers if desired.

Parameters:
interfaceThe interface for which the command is intended
lengthThe length of the command which will be present in the data stage.
Returns:
Return 0 if the request can be handled or -1 if it cannot. Returning -1 will cause STALL to be returned to the host.
int8_t CDC_SET_COMM_FEATURE_CALLBACK ( uint8_t  interface,
bool  idle_setting,
bool  data_multiplexed_state 
)

CDC SET_COMM_FEATURE callback.

The USB Stack will call this function when a SET_COMM_FEATURE request has been received from the host. The device should set the idle setting and/or data multiplexed state if requested. There is no way to refuse this message. If this message is not supported by the device, simply do not define CDC_SET_COMM_FEATURE_CALLBACK.

Parameters:
interfaceThe interface for which the command is intended
idle_settingWhether to set the idle setting. True = clear the idle setting.
data_multiplexed_stateWhether to set the data multiplexed state. True = clear the multiplexed state.
Returns:
Return 0 if the request can be handled or -1 if it cannot. Returning -1 will cause STALL to be returned to the host.
int8_t CDC_SET_CONTROL_LINE_STATE_CALLBACK ( uint8_t  interface,
bool  dtr,
bool  dts 
)

CDC SET_CONTROL_LINE_STATE callback.

The USB Stack will call this function when a SET_CONTROL_LINE_STATE request has been received from the host. The device should then set the control lines as requested.

Parameters:
interfaceThe interface for which the command is intended
dtrThe state of the DTR line. True = activated.
rtsThe state of the RTS line. True = activated.
Returns:
Return 0 if the request can be handled or -1 if it cannot. Returning -1 will cause STALL to be returned to the host.
int8_t CDC_SET_LINE_CODING_CALLBACK ( uint8_t  interface,
const struct cdc_line_coding coding 
)

CDC SET_LINE_CODING callback.

The USB Stack will call this function when a SET_LINE_CODING request has been received from the host. The device should then set the line coding to the specified values. There is no way to refuse this message. If this message is not supported by the device, simply do not define CDC_SET_LINE_CODING_CALLBACK.

Parameters:
interfaceThe interface for which the command is intended
codingThe new line coding set by the host
Returns:
Return 0 if the request can be handled or -1 if it cannot. Returning -1 will cause STALL to be returned to the host.
uint8_t process_cdc_setup_request ( const struct setup_packet setup )

Process CDC Setup Request.

Process a setup request which has been unhandled as if it is potentially a CDC setup request. This function will then call appropriate callbacks into the appliction if the setup packet is one recognized by the CDC specification.

Parameters:
setupA setup packet to handle
Returns:
Returns 0 if the setup packet could be processed or -1 if it could not.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator