41 #if (MODE_HOST_SUPPORTED && TUSB_CFG_HOST_CDC)
43 #define _TINY_USB_SOURCE_FILE_
63 cdch_data_t
const * p_cdc = &cdch_data[pipe_hdl.dev_addr-1];
72 STATIC_ INLINE_
bool tusbh_cdc_is_mounted(uint8_t dev_addr)
78 return pipehandle_is_valid(cdch_data[dev_addr-1].pipe_in) &&
79 pipehandle_is_valid(cdch_data[dev_addr-1].pipe_out);
85 if ( !tusbh_cdc_is_mounted(dev_addr) )
return false;
87 cdch_data_t
const * p_cdc = &cdch_data[dev_addr-1];
92 return hcd_pipe_is_busy( p_cdc->pipe_notification );
95 return hcd_pipe_is_busy( p_cdc->pipe_in );
98 return hcd_pipe_is_busy( p_cdc->pipe_out );
112 return tusbh_cdc_is_mounted(dev_addr) &&
119 ASSERT( tusbh_cdc_is_mounted(dev_addr), TUSB_ERROR_CDCH_DEVICE_NOT_MOUNTED);
120 ASSERT( p_data != NULL && length, TUSB_ERROR_INVALID_PARA);
123 if ( hcd_pipe_is_busy(pipe_out) )
return TUSB_ERROR_INTERFACE_IS_BUSY;
125 return hcd_pipe_xfer( pipe_out, (
void *) p_data, length, is_notify);
130 ASSERT( tusbh_cdc_is_mounted(dev_addr), TUSB_ERROR_CDCH_DEVICE_NOT_MOUNTED);
131 ASSERT( p_buffer != NULL && length, TUSB_ERROR_INVALID_PARA);
134 if ( hcd_pipe_is_busy(pipe_in) )
return TUSB_ERROR_INTERFACE_IS_BUSY;
136 return hcd_pipe_xfer( pipe_in, p_buffer, length, is_notify);
157 return TUSB_ERROR_CDC_UNSUPPORTED_PROTOCOL;
160 uint8_t
const * p_desc;
163 p_desc = descriptor_next ( (uint8_t
const *) p_interface_desc );
164 p_cdc = &cdch_data[dev_addr-1];
172 while( TUSB_DESC_TYPE_INTERFACE_CLASS_SPECIFIC == p_desc[DESCRIPTOR_OFFSET_TYPE] )
179 (*p_length) += p_desc[DESCRIPTOR_OFFSET_LENGTH];
180 p_desc = descriptor_next(p_desc);
183 if ( TUSB_DESC_TYPE_ENDPOINT == p_desc[DESCRIPTOR_OFFSET_TYPE])
187 (*p_length) += p_desc[DESCRIPTOR_OFFSET_LENGTH];
188 p_desc = descriptor_next(p_desc);
190 ASSERT(pipehandle_is_valid(p_cdc->pipe_notification), TUSB_ERROR_HCD_OPEN_PIPE_FAILED);
194 if ( (TUSB_DESC_TYPE_INTERFACE == p_desc[DESCRIPTOR_OFFSET_TYPE]) &&
197 (*p_length) += p_desc[DESCRIPTOR_OFFSET_LENGTH];
198 p_desc = descriptor_next(p_desc);
201 for(uint32_t i=0; i<2; i++)
204 ASSERT_INT(TUSB_DESC_TYPE_ENDPOINT, p_endpoint->
bDescriptorType, TUSB_ERROR_USBH_DESCRIPTOR_CORRUPTED);
205 ASSERT_INT(TUSB_XFER_BULK, p_endpoint->
bmAttributes.xfer, TUSB_ERROR_USBH_DESCRIPTOR_CORRUPTED);
208 &p_cdc->pipe_in : &p_cdc->pipe_out;
210 (*p_pipe_hdl) = hcd_pipe_open(dev_addr, p_endpoint,
TUSB_CLASS_CDC);
211 ASSERT ( pipehandle_is_valid(*p_pipe_hdl), TUSB_ERROR_HCD_OPEN_PIPE_FAILED );
213 (*p_length) += p_desc[DESCRIPTOR_OFFSET_LENGTH];
214 p_desc = descriptor_next( p_desc );
226 void cdch_isr(
pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes)
228 tusbh_cdc_xfer_isr( pipe_hdl.dev_addr, event, get_app_pipeid(pipe_hdl), xferred_bytes );
231 void cdch_close(uint8_t dev_addr)
233 cdch_data_t * p_cdc = &cdch_data[dev_addr-1];
235 (void) hcd_pipe_close(p_cdc->pipe_notification);
236 (void) hcd_pipe_close(p_cdc->pipe_in);
237 (void) hcd_pipe_close(p_cdc->pipe_out);
239 memclr_(p_cdc,
sizeof(cdch_data_t));
USB Standard Interface Descriptor (section 9.6.1 table 9-12)
Abstract Control Model [USBPSTN1.2].
#define ATTR_WARN_UNUSED_RESULT
The warn_unused_result attribute causes a warning to be emitted if a caller of the function with this...
uint8_t bInterfaceProtocol
Protocol code (assigned by the USB). These codes are qualified by the value of the bInterfaceClass ...
#define TUSB_CFG_HOST_DEVICE_MAX
Maximum number of device host stack can manage If hub class is not enabled, set this equal to numbe...
#define ATTR_PURE
Many functions have no effects except the return value and their return value depends only on the par...
bool tusbh_cdc_serial_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT
Check if device support CDC Serial interface or not.
tusb_error_t tusbh_cdc_receive(uint8_t dev_addr, void *p_buffer, uint32_t length, bool is_notify)
Perform USB IN transfer to get data from device.
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.
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)
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...
tusb_error_t tusbh_cdc_send(uint8_t dev_addr, void const *p_data, uint32_t length, bool is_notify)
Perform USB OUT transfer to device.
void tusbh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes)
Callback function that is invoked when an transferring event occurred.
Abstract Control Management Functional Descriptor.
tusb_error_t
Error Code returned.
void tusbh_cdc_mounted_cb(uint8_t dev_addr)
Callback function that will be invoked when a device with CDC Abstract Control Model interface is mou...
void tusbh_cdc_unmounted_cb(uint8_t dev_addr)
Callback function that will be invoked when a device with CDC Abstract Control Model interface is unm...
#define ATTR_ALWAYS_INLINE
Generally, functions are not inlined unless optimization is specified. For functions declared inline...
uint8_t bEndpointAddress
The address of the endpoint on the USB device described by this descriptor. The address is encoded as...
bool tusbh_cdc_is_busy(uint8_t dev_addr, cdc_pipeid_t pipeid) ATTR_PURE ATTR_WARN_UNUSED_RESULT
Check if the interface is currently busy or not.