summaryrefslogtreecommitdiff
path: root/tinyusb
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-07-03 10:53:16 +0700
committerhathach <[email protected]>2013-07-03 10:53:16 +0700
commitb3f98bc15a47bea88806cbfdc899d46efe40d921 (patch)
tree30cfadb9e0cb4bf128bbdd2dd544e61ef8a259f8 /tinyusb
parent539c7cdbe16d7805eac053a6779f509a4c9b4c68 (diff)
rename cdc descriptor type
add tusbh_cdc_mounted_isr & tusbh_cdc_unmounted_isr
Diffstat (limited to 'tinyusb')
-rw-r--r--tinyusb/class/cdc.h38
-rw-r--r--tinyusb/class/cdc_host.c12
-rw-r--r--tinyusb/class/cdc_host.h16
3 files changed, 38 insertions, 28 deletions
diff --git a/tinyusb/class/cdc.h b/tinyusb/class/cdc.h
index 8923d53bf..b8a60bee2 100644
--- a/tinyusb/class/cdc.h
+++ b/tinyusb/class/cdc.h
@@ -184,7 +184,7 @@ typedef enum {
GET_ATM_VC_STATISTICS = 0x53,
MDLM_SEMANTIC_MODEL = 0x60,
-}tusb_cdc_management_request_t;
+}cdc_management_request_t;
//--------------------------------------------------------------------+
// MANAGEMENT ELEMENENT NOTIFICATION (NOTIFICATION ENDPOINT)
@@ -202,7 +202,7 @@ typedef enum {
LINE_STATE_CHANGE = 0x29,
CONNECTION_SPEED_CHANGE = 0x2A,
MDLM_SEMANTIC_MODEL_NOTIFICATION = 0x40,
-}tusb_cdc_notification_t;
+}cdc_notification_request_t;
//--------------------------------------------------------------------+
// FUNCTIONAL DESCRIPTOR
@@ -211,8 +211,8 @@ typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
- uint16_t bcdCDC ; ///< CDC release number in Binary-Coded Decimal
-}tusb_cdc_func_header_t;
+ uint16_t bcdCDC ; ///< CDC release number in Binary-Coded Decimal
+}cdc_desc_func_header_t;
typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes.
@@ -220,9 +220,9 @@ typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
uint8_t bControlInterface ; ///< Interface number of Communication Interface
uint8_t bSubordinateInterface ; ///< Array of Interface number of Data Interface
-}tusb_cdc_func_union_t;
+}cdc_desc_func_union_t;
-#define tusb_cdc_func_union_n_t(no_slave)\
+#define cdc_desc_func_union_n_t(no_slave)\
ATTR_PACKED_STRUCT(struct) { \
uint8_t bLength ;\
uint8_t bDescriptorType ;\
@@ -237,9 +237,9 @@ typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
uint8_t iCountryCodeRelDate ; ///< Index of a string giving the release date for the implemented ISO 3166 Country Codes.
uint16_t wCountryCode[] ; ///< Country code in the format as defined in [ISO3166], release date as specified inoffset 3 for the first supported country.
-}tusb_cdc_func_country_selection_t;
+}cdc_desc_func_country_selection_t;
-#define tusb_cdc_func_country_selection_n_t(no_country) \
+#define cdc_desc_func_country_selection_n_t(no_country) \
ATTR_PACKED_STRUCT(struct) {\
uint8_t bLength ;\
uint8_t bDescriptorType ;\
@@ -263,7 +263,7 @@ typedef ATTR_PACKED_STRUCT(struct) {
} bmCapabilities;
uint8_t bDataInterface;
-}tusb_cdc_func_call_management_t;
+}cdc_desc_func_call_management_t;
typedef struct {
uint8_t support_comm_request : 1; ///< Device supports the request combination of Set_Comm_Feature, Clear_Comm_Feature, and Get_Comm_Feature.
@@ -271,16 +271,16 @@ typedef struct {
uint8_t support_send_break : 1; ///< Device supports the request Send_Break
uint8_t support_notification_network_connection : 1; ///< Device supports the notification Network_Connection.
uint8_t : 0;
-}cdc_fun_acm_capability_t;
+}cdc_acm_capability_t;
-STATIC_ASSERT(sizeof(cdc_fun_acm_capability_t) == 1, "mostly problem with compiler");
+STATIC_ASSERT(sizeof(cdc_acm_capability_t) == 1, "mostly problem with compiler");
typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
- cdc_fun_acm_capability_t bmCapabilities ;
-}tusb_cdc_func_abstract_control_management_t;
+ cdc_acm_capability_t bmCapabilities ;
+}cdc_desc_func_abstract_control_management_t;
typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes.
@@ -292,7 +292,7 @@ typedef ATTR_PACKED_STRUCT(struct) {
uint8_t support_pulse_request : 1; ///< Device supports the request combination of Pulse_Setup, Send_Pulse, and Set_Pulse_Time.
uint8_t : 0;
} bmCapabilities;
-}tusb_cdc_func_direct_line_management_t;
+}cdc_desc_func_direct_line_management_t;
typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes.
@@ -300,7 +300,7 @@ typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
uint8_t bRingerVolSteps ;
uint8_t bNumRingerPatterns ;
-}tusb_cdc_func_telephone_ringer_t;
+}cdc_desc_func_telephone_ringer_t;
typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes.
@@ -312,7 +312,7 @@ typedef ATTR_PACKED_STRUCT(struct) {
uint8_t computer_centric_mode : 1;
uint8_t : 0;
} bmCapabilities;
-}tusb_cdc_func_telephone_operational_modes_t;
+}cdc_desc_func_telephone_operational_modes_t;
typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes.
@@ -327,10 +327,10 @@ typedef ATTR_PACKED_STRUCT(struct) {
uint32_t line_state_change : 1; ///< 0 : Does not support line state change notification. 1 : Does support line state change notification
uint32_t : 0;
} bmCapabilities;
-}tusb_cdc_func_telephone_call_state_reporting_capabilities_t;
+}cdc_desc_func_telephone_call_state_reporting_capabilities_t;
-static inline uint8_t functional_desc_typeof(uint8_t const * p_desc) ATTR_PURE ATTR_ALWAYS_INLINE;
-static inline uint8_t functional_desc_typeof(uint8_t const * p_desc)
+static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc) ATTR_PURE ATTR_ALWAYS_INLINE;
+static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc)
{
return p_desc[2];
}
diff --git a/tinyusb/class/cdc_host.c b/tinyusb/class/cdc_host.c
index 867dddeb8..d2830e41e 100644
--- a/tinyusb/class/cdc_host.c
+++ b/tinyusb/class/cdc_host.c
@@ -134,9 +134,9 @@ tusb_error_t cdch_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
while( TUSB_DESC_TYPE_INTERFACE_CLASS_SPECIFIC == p_desc[DESCRIPTOR_OFFSET_TYPE] )
{ // Communication Functional Descriptors
- if ( CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT == functional_desc_typeof(p_desc) )
+ if ( CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT == cdc_functional_desc_typeof(p_desc) )
{ // save ACM bmCapabilities
- p_cdc->acm_capability = ((tusb_cdc_func_abstract_control_management_t const *) p_desc)->bmCapabilities;
+ p_cdc->acm_capability = ((cdc_desc_func_abstract_control_management_t const *) p_desc)->bmCapabilities;
}
(*p_length) += p_desc[DESCRIPTOR_OFFSET_LENGTH];
@@ -178,9 +178,9 @@ tusb_error_t cdch_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
}
// FIXME mounted class flag is not set yet
- if (tusbh_cdc_isr)
+ if (tusbh_cdc_mounted_isr)
{
- tusbh_cdc_isr(dev_addr, TUSB_EVENT_INTERFACE_OPEN);
+ tusbh_cdc_mounted_isr(dev_addr);
}
return TUSB_ERROR_NONE;
@@ -217,9 +217,9 @@ void cdch_close(uint8_t dev_addr)
memclr_(p_cdc, sizeof(cdch_data_t));
- if (tusbh_cdc_isr)
+ if (tusbh_cdc_unmounted_isr)
{
- tusbh_cdc_isr(dev_addr, TUSB_EVENT_INTERFACE_CLOSE);
+ tusbh_cdc_unmounted_isr(dev_addr);
}
ASSERT(err1 == TUSB_ERROR_NONE &&
diff --git a/tinyusb/class/cdc_host.h b/tinyusb/class/cdc_host.h
index fde2e2e11..100042b50 100644
--- a/tinyusb/class/cdc_host.h
+++ b/tinyusb/class/cdc_host.h
@@ -54,15 +54,25 @@
extern "C" {
#endif
+typedef enum {
+ CDC_PIPE_NOTIFICATION = 1,
+ CDC_PIPE_DATA_IN,
+ CDC_PIPE_DATA_OUT
+}cdc_pipeid_t;
+
//--------------------------------------------------------------------+
// APPLICATION PUBLIC API
//--------------------------------------------------------------------+
bool tusbh_cdc_serial_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
bool tusbh_cdc_rndis_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
-
-void tusbh_cdc_isr(uint8_t dev_addr, tusb_event_t event) ATTR_WEAK;
tusb_error_t tusbh_cdc_send(uint8_t dev_addr, void const * p_data, uint32_t length, bool is_notify);
tusb_error_t tusbh_cdc_receive(uint8_t dev_addr, void * p_buffer, uint32_t length, bool is_notify);
+
+//------------- Application Callback -------------//
+void tusbh_cdc_mounted_isr(uint8_t dev_addr) ATTR_WEAK;
+void tusbh_cdc_unmounted_isr(uint8_t dev_addr) ATTR_WEAK;
+void tusbh_cdc_isr(uint8_t dev_addr, tusb_event_t event) ATTR_WEAK;
+void tusbh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event) ATTR_WEAK;
//--------------------------------------------------------------------+
// USBH-CLASS API
//--------------------------------------------------------------------+
@@ -71,7 +81,7 @@ tusb_error_t tusbh_cdc_receive(uint8_t dev_addr, void * p_buffer, uint32_t lengt
typedef struct {
uint8_t interface_number;
uint8_t interface_protocol;
- cdc_fun_acm_capability_t acm_capability;
+ cdc_acm_capability_t acm_capability;
pipe_handle_t pipe_notification, pipe_out, pipe_in;