41 #if (MODE_DEVICE_SUPPORTED && TUSB_CFG_DEVICE_CDC)
43 #define _TINY_USB_SOURCE_FILE_
57 uint8_t interface_number;
66 cdcd_data_t cdcd_data[CONTROLLER_DEVICE_NUMBER];
70 ASSERT(tusbd_is_configured(coreid), TUSB_ERROR_USBD_DEVICE_NOT_CONFIGURED);
72 cdcd_data_t* p_cdc = &cdcd_data[coreid];
74 ASSERT_FALSE ( dcd_pipe_is_busy(p_cdc->edpt_hdl[pipeid]), TUSB_ERROR_INTERFACE_IS_BUSY);
75 ASSERT_STATUS( dcd_pipe_xfer(p_cdc->edpt_hdl[pipeid], p_buffer, length, is_notify) );
77 return TUSB_ERROR_NONE;
85 return dcd_pipe_is_busy( cdcd_data[coreid].edpt_hdl[pipeid] );
103 memclr_(cdcd_data,
sizeof(cdcd_data_t)*CONTROLLER_DEVICE_NUMBER);
107 for(uint8_t i=0; i<CONTROLLER_DEVICE_NUMBER; i++) cdcd_line_coding[i].data_bits = 8;
117 return TUSB_ERROR_CDC_UNSUPPORTED_PROTOCOL;
120 uint8_t
const * p_desc = descriptor_next ( (uint8_t
const *) p_interface_desc );
121 cdcd_data_t * p_cdc = &cdcd_data[coreid];
126 while( TUSB_DESC_TYPE_INTERFACE_CLASS_SPECIFIC == p_desc[DESCRIPTOR_OFFSET_TYPE] )
133 (*p_length) += p_desc[DESCRIPTOR_OFFSET_LENGTH];
134 p_desc = descriptor_next(p_desc);
137 if ( TUSB_DESC_TYPE_ENDPOINT == p_desc[DESCRIPTOR_OFFSET_TYPE])
141 (*p_length) += p_desc[DESCRIPTOR_OFFSET_LENGTH];
142 p_desc = descriptor_next(p_desc);
144 ASSERT(endpointhandle_is_valid(p_cdc->edpt_hdl[
CDC_PIPE_NOTIFICATION]), TUSB_ERROR_DCD_OPEN_PIPE_FAILED);
148 if ( (TUSB_DESC_TYPE_INTERFACE == p_desc[DESCRIPTOR_OFFSET_TYPE]) &&
151 (*p_length) += p_desc[DESCRIPTOR_OFFSET_LENGTH];
152 p_desc = descriptor_next(p_desc);
155 for(uint32_t i=0; i<2; i++)
158 ASSERT_INT(TUSB_DESC_TYPE_ENDPOINT, p_endpoint->
bDescriptorType, TUSB_ERROR_DESCRIPTOR_CORRUPTED);
159 ASSERT_INT(TUSB_XFER_BULK, p_endpoint->
bmAttributes.xfer, TUSB_ERROR_DESCRIPTOR_CORRUPTED);
164 (*p_edpt_hdl) = dcd_pipe_open(coreid, p_endpoint,
TUSB_CLASS_CDC);
165 ASSERT ( endpointhandle_is_valid(*p_edpt_hdl), TUSB_ERROR_DCD_OPEN_PIPE_FAILED );
167 (*p_length) += p_desc[DESCRIPTOR_OFFSET_LENGTH];
168 p_desc = descriptor_next( p_desc );
176 return TUSB_ERROR_NONE;
179 void cdcd_close(uint8_t coreid)
182 memclr_(&cdcd_data[coreid],
sizeof(cdcd_data_t));
190 if (p_request->bmRequestType_bit.type != TUSB_REQUEST_TYPE_CLASS)
return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT;
192 switch(p_request->bRequest)
194 case CDC_REQUEST_GET_LINE_CODING:
195 dcd_pipe_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction,
196 (uint8_t*) &cdcd_line_coding[coreid], min16_of(
sizeof(
cdc_line_coding_t), p_request->wLength),
false );
199 case CDC_REQUEST_SET_LINE_CODING:
200 dcd_pipe_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction,
201 (uint8_t*) &cdcd_line_coding[coreid], min16_of(
sizeof(
cdc_line_coding_t), p_request->wLength),
false );
205 case CDC_REQUEST_SET_CONTROL_LINE_STATE:
209 default:
return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT;
212 return TUSB_ERROR_NONE;
217 cdcd_data_t
const * p_cdc = &cdcd_data[edpt_hdl.coreid];
221 if ( endpointhandle_is_equal(edpt_hdl, p_cdc->edpt_hdl[pipeid]) )
228 return TUSB_ERROR_NONE;
USB Standard Interface Descriptor (section 9.6.1 table 9-12)
Abstract Control Model [USBPSTN1.2].
uint8_t bInterfaceProtocol
Protocol code (assigned by the USB). These codes are qualified by the value of the bInterfaceClass ...
void tusbd_cdc_mounted_cb(uint8_t coreid)
Callback function that will be invoked when this interface is mounted (configured) by USB host...
bool tusbd_cdc_is_busy(uint8_t coreid, cdc_pipeid_t pipeid) ATTR_PURE ATTR_WARN_UNUSED_RESULT
Check if the interface is currently busy or not.
struct tusb_descriptor_endpoint_t::@8 bmAttributes
This field describes the endpoint's attributes when it is configured using the bConfigurationValue. Bits 1..0: Transfer Type - 00 = Control - 01 = Isochronous - 10 = Bulk - 11 = Interrupt If not an isochronous endpoint, bits 5..2 are reserved and must be set to zero. If isochronous, they are defined as follows: Bits 3..2: Synchronization Type - 00 = No Synchronization - 01 = Asynchronous - 10 = Adaptive - 11 = Synchronous Bits 5..4: Usage Type - 00 = Data endpoint - 01 = Feedback endpoint - 10 = Implicit feedback Data endpoint - 11 = Reserved Refer to Chapter 5 of USB 2.0 specification for more information. All other bits are reserved and must be reset to zero. Reserved bits must be ignored by the host.
#define TUSB_CFG_ATTR_USBRAM
void tusbd_cdc_unmounted_cb(uint8_t coreid)
Callback function that will be invoked when this interface is unmounted (bus reset/unplugged) ...
AT Commands defined by TIA for CDMA.
static bool is_in_range(uint32_t lower, uint32_t value, uint32_t upper) ATTR_ALWAYS_INLINE ATTR_CONST
inclusive range checking
uint8_t bDescriptorType
ENDPOINT Descriptor Type.
uint8_t bInterfaceSubClass
Subclass code (assigned by the USB-IF). These codes are qualified by the value of the bInterfaceCla...
Abstract Control Management Functional Descriptor.
USB Standard Endpoint Descriptor (section 9.6.1 table 9-13)
tusb_error_t tusbd_cdc_receive(uint8_t coreid, void *p_buffer, uint32_t length, bool is_notify)
Submit USB transfer.
void tusbd_cdc_xfer_cb(uint8_t coreid, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes)
Callback function that is invoked when an completion (error or success) of an USB transfer previously...
cdc_pipeid_t
CDC Pipe ID, used to indicate which pipe the API is addressing to (Notification, Out, In)
uint8_t bInterfaceNumber
Number of this interface. Zero-based value identifying the index in the array of concurrent interface...
Abstract Control Management Functional Descriptor.
tusb_error_t
Error Code returned.
tusb_error_t tusbd_cdc_send(uint8_t coreid, void *p_data, uint32_t length, bool is_notify)
Submit USB transfer.
uint8_t bEndpointAddress
The address of the endpoint on the USB device described by this descriptor. The address is encoded as...