summaryrefslogtreecommitdiff
path: root/tinyusb/class
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-07-01 11:29:23 +0700
committerhathach <[email protected]>2013-07-01 11:29:23 +0700
commite1883fcd263456ffc7ef318e4f549364fff3945e (patch)
tree83e25d86fd87136e2660c8f86475bde4e5f3462d /tinyusb/class
parente94ce81b045069f12e29ea355c2248ef6254ca0d (diff)
add acm_capability saving to host data & its test
Diffstat (limited to 'tinyusb/class')
-rw-r--r--tinyusb/class/cdc.h42
-rw-r--r--tinyusb/class/cdc_host.c5
-rw-r--r--tinyusb/class/cdc_host.h2
3 files changed, 33 insertions, 16 deletions
diff --git a/tinyusb/class/cdc.h b/tinyusb/class/cdc.h
index 14c7c800b..04f412c9a 100644
--- a/tinyusb/class/cdc.h
+++ b/tinyusb/class/cdc.h
@@ -264,17 +264,21 @@ typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bDataInterface;
}tusb_cdc_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.
+ uint8_t support_line_request : 1; ///< Device supports the request combination of Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding, and the notification Serial_State.
+ 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;
+
+STATIC_ASSERT(sizeof(cdc_fun_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_
- struct {
- uint8_t support_comm_request : 1; ///< Device supports the request combination of Set_Comm_Feature, Clear_Comm_Feature, and Get_Comm_Feature.
- uint8_t support_line_request : 1; ///< Device supports the request combination of Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding, and the notification Serial_State.
- 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;
- } bmCapabilities;
+ 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;
typedef ATTR_PACKED_STRUCT(struct) {
@@ -314,16 +318,22 @@ typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
struct {
- uint32_t interrupted_dialtone : 1; ///< 0 – Reports only dialtone (does not differentiate between normal and interrupted dialtone). 1 – Reports interrupted dialtone in addition to normal dialtone
- uint32_t ringback_busy_fastbusy : 1; ///< 0 – Reports only dialing state. 1 – Reports ringback, busy, and fast busy states.
- uint32_t caller_id : 1; ///< 0 – Does not report caller ID. 1 – Reports caller ID information.
- uint32_t incoming_distinctive : 1; ///< 0 – Reports only incoming ringing. 1 – Reports incoming distinctive ringing patterns.
- uint32_t dual_tone_multi_freq : 1; ///< 0 – Cannot report dual tone multi-frequency (DTMF) digits input remotely over the telephone line. 1 – Can report DTMF digits input remotely over the telephone line.
- uint32_t line_state_change : 1; ///< 0 – Does not support line state change notification. 1 – Does support line state change notificatio
+ uint32_t interrupted_dialtone : 1; ///< 0 : Reports only dialtone (does not differentiate between normal and interrupted dialtone). 1 : Reports interrupted dialtone in addition to normal dialtone
+ uint32_t ringback_busy_fastbusy : 1; ///< 0 : Reports only dialing state. 1 : Reports ringback, busy, and fast busy states.
+ uint32_t caller_id : 1; ///< 0 : Does not report caller ID. 1 : Reports caller ID information.
+ uint32_t incoming_distinctive : 1; ///< 0 : Reports only incoming ringing. 1 : Reports incoming distinctive ringing patterns.
+ uint32_t dual_tone_multi_freq : 1; ///< 0 : Cannot report dual tone multi-frequency (DTMF) digits input remotely over the telephone line. 1 : Can report DTMF digits input remotely over the telephone line.
+ 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;
+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)
+{
+ return p_desc[2];
+}
+
#ifdef __cplusplus
}
diff --git a/tinyusb/class/cdc_host.c b/tinyusb/class/cdc_host.c
index f4d82fc6f..81d992c21 100644
--- a/tinyusb/class/cdc_host.c
+++ b/tinyusb/class/cdc_host.c
@@ -89,6 +89,11 @@ 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) )
+ { // save ACM bmCapabilities
+ p_cdc->acm_capability = ((tusb_cdc_func_abstract_control_management_t const *) p_desc)->bmCapabilities;
+ }
+
(*p_length) += p_desc[DESCRIPTOR_OFFSET_LENGTH];
p_desc = descriptor_next(p_desc);
}
diff --git a/tinyusb/class/cdc_host.h b/tinyusb/class/cdc_host.h
index 12132ca68..a40cea64e 100644
--- a/tinyusb/class/cdc_host.h
+++ b/tinyusb/class/cdc_host.h
@@ -66,6 +66,8 @@
typedef struct {
uint8_t interface_number;
uint8_t interface_protocol;
+ cdc_fun_acm_capability_t acm_capability;
+
pipe_handle_t pipe_notification, pipe_out, pipe_in;
} cdch_data_t;