tinyusb
cdc_host.h
Go to the documentation of this file.
1 /**************************************************************************/
37 /**************************************************************************/
38 
39 
40 #ifndef _TUSB_CDC_HOST_H_
41 #define _TUSB_CDC_HOST_H_
42 
43 #include "common/common.h"
44 #include "host/usbh.h"
45 #include "cdc.h"
46 
47 #ifdef __cplusplus
48  extern "C" {
49 #endif
50 
51 //--------------------------------------------------------------------+
52 // CDC APPLICATION PUBLIC API
53 //--------------------------------------------------------------------+
66 
77 
89 tusb_error_t tusbh_cdc_send(uint8_t dev_addr, void const * p_data, uint32_t length, bool is_notify);
90 
102 tusb_error_t tusbh_cdc_receive(uint8_t dev_addr, void * p_buffer, uint32_t length, bool is_notify);
103 
104 //--------------------------------------------------------------------+
105 // CDC APPLICATION CALLBACKS
106 //--------------------------------------------------------------------+
111 void tusbh_cdc_mounted_cb(uint8_t dev_addr);
112 
117 void tusbh_cdc_unmounted_cb(uint8_t dev_addr);
118 
130 void tusbh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes);
131 
134 
135 //--------------------------------------------------------------------+
136 // USBH-CLASS API
137 //--------------------------------------------------------------------+
138 #ifdef _TINY_USB_SOURCE_FILE_
139 
140 typedef struct {
141  uint8_t interface_number;
142  uint8_t interface_protocol;
143 
144  cdc_acm_capability_t acm_capability;
145 
146  pipe_handle_t pipe_notification, pipe_out, pipe_in;
147 
148 } cdch_data_t;
149 
150 extern cdch_data_t cdch_data[TUSB_CFG_HOST_DEVICE_MAX]; // TODO consider to move to cdch internal header file
151 
152 void cdch_init(void);
153 tusb_error_t cdch_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length) ATTR_WARN_UNUSED_RESULT;
154 void cdch_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes);
155 void cdch_close(uint8_t dev_addr);
156 
157 #endif
158 
159 #ifdef __cplusplus
160  }
161 #endif
162 
163 #endif /* _TUSB_CDC_HOST_H_ */
USB Standard Interface Descriptor (section 9.6.1 table 9-12)
Definition: std_descriptors.h:90
#define ATTR_WARN_UNUSED_RESULT
The warn_unused_result attribute causes a warning to be emitted if a caller of the function with this...
Definition: compiler_gcc.h:118
Definition: hcd.h:55
#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...
Definition: configuration.txt:35
#define ATTR_PURE
Many functions have no effects except the return value and their return value depends only on the par...
Definition: compiler_gcc.h:96
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.
cdc_pipeid_t
CDC Pipe ID, used to indicate which pipe the API is addressing to (Notification, Out, In)
Definition: cdc.h:58
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.
tusb_error_t
Error Code returned.
Definition: tusb_errors.h:100
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...
Definition: cdc.h:284
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.