diff options
| author | hathach <[email protected]> | 2019-06-10 18:50:59 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-06-10 18:50:59 +0700 |
| commit | 393492823ce037a2e46d367d61fad1235859af2e (patch) | |
| tree | 7bc829e94b0a542e6990566e71ec293a600d3553 /src/class/cdc | |
| parent | 69e98215ea94bf5d6a8adc042732fe2a67df9764 (diff) | |
| parent | 7156bfb54d5e9e13c8574b2384a47bd5554798a9 (diff) | |
Merge pull request #80 from hathach/develop
added usbd_edpt_xfer/usbd_edpt_busy to replace dcd_edpt_transfer/dcd_edpt_busy()
Diffstat (limited to 'src/class/cdc')
| -rw-r--r-- | src/class/cdc/cdc.h | 28 | ||||
| -rw-r--r-- | src/class/cdc/cdc_device.c | 20 | ||||
| -rw-r--r-- | src/class/cdc/cdc_device.h | 8 | ||||
| -rw-r--r-- | src/class/cdc/cdc_rndis_host.c | 2 |
4 files changed, 28 insertions, 30 deletions
diff --git a/src/class/cdc/cdc.h b/src/class/cdc/cdc.h index 200f6eaae..2e865bdbb 100644 --- a/src/class/cdc/cdc.h +++ b/src/class/cdc/cdc.h @@ -212,7 +212,7 @@ typedef enum // FUNCTIONAL DESCRIPTOR (COMMUNICATION INTERFACE)
//--------------------------------------------------------------------+
/// Header Functional Descriptor (Communication Interface)
-typedef struct ATTR_PACKED
+typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
@@ -221,7 +221,7 @@ typedef struct ATTR_PACKED }cdc_desc_func_header_t;
/// Union Functional Descriptor (Communication Interface)
-typedef struct ATTR_PACKED
+typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
@@ -231,7 +231,7 @@ typedef struct ATTR_PACKED }cdc_desc_func_union_t;
#define cdc_desc_func_union_n_t(no_slave)\
- struct ATTR_PACKED { \
+ struct TU_ATTR_PACKED { \
uint8_t bLength ;\
uint8_t bDescriptorType ;\
uint8_t bDescriptorSubType ;\
@@ -240,7 +240,7 @@ typedef struct ATTR_PACKED }
/// Country Selection Functional Descriptor (Communication Interface)
-typedef struct ATTR_PACKED
+typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
@@ -250,7 +250,7 @@ typedef struct ATTR_PACKED }cdc_desc_func_country_selection_t;
#define cdc_desc_func_country_selection_n_t(no_country) \
- struct ATTR_PACKED {\
+ struct TU_ATTR_PACKED {\
uint8_t bLength ;\
uint8_t bDescriptorType ;\
uint8_t bDescriptorSubType ;\
@@ -264,7 +264,7 @@ typedef struct ATTR_PACKED /// \brief Call Management Functional Descriptor
/// \details This functional descriptor describes the processing of calls for the Communications Class interface.
-typedef struct ATTR_PACKED
+typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
@@ -280,7 +280,7 @@ typedef struct ATTR_PACKED }cdc_desc_func_call_management_t;
-typedef struct ATTR_PACKED
+typedef struct TU_ATTR_PACKED
{
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.
@@ -293,7 +293,7 @@ TU_VERIFY_STATIC(sizeof(cdc_acm_capability_t) == 1, "mostly problem with compile /// \brief Abstract Control Management Functional Descriptor
/// \details This functional descriptor describes the commands supported by by the Communications Class interface with SubClass code of \ref CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL
-typedef struct ATTR_PACKED
+typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
@@ -303,7 +303,7 @@ typedef struct ATTR_PACKED /// \brief Direct Line Management Functional Descriptor
/// \details This functional descriptor describes the commands supported by the Communications Class interface with SubClass code of \ref CDC_FUNC_DESC_DIRECT_LINE_MANAGEMENT
-typedef struct ATTR_PACKED
+typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
@@ -319,7 +319,7 @@ typedef struct ATTR_PACKED /// \brief Telephone Ringer Functional Descriptor
/// \details The Telephone Ringer functional descriptor describes the ringer capabilities supported by the Communications Class interface,
/// with the SubClass code of \ref CDC_COMM_SUBCLASS_TELEPHONE_CONTROL_MODEL
-typedef struct ATTR_PACKED
+typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
@@ -331,7 +331,7 @@ typedef struct ATTR_PACKED /// \brief Telephone Operational Modes Functional Descriptor
/// \details The Telephone Operational Modes functional descriptor describes the operational modes supported by
/// the Communications Class interface, with the SubClass code of \ref CDC_COMM_SUBCLASS_TELEPHONE_CONTROL_MODEL
-typedef struct ATTR_PACKED
+typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
@@ -347,7 +347,7 @@ typedef struct ATTR_PACKED /// \brief Telephone Call and Line State Reporting Capabilities Descriptor
/// \details The Telephone Call and Line State Reporting Capabilities functional descriptor describes the abilities of a
/// telephone device to report optional call and line states.
-typedef struct ATTR_PACKED
+typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
@@ -371,7 +371,7 @@ static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc) //--------------------------------------------------------------------+
// Requests
//--------------------------------------------------------------------+
-typedef struct ATTR_PACKED
+typedef struct TU_ATTR_PACKED
{
uint32_t bit_rate;
uint8_t stop_bits; ///< 0: 1 stop bit - 1: 1.5 stop bits - 2: 2 stop bits
@@ -381,7 +381,7 @@ typedef struct ATTR_PACKED TU_VERIFY_STATIC(sizeof(cdc_line_coding_t) == 7, "size is not correct");
-typedef struct ATTR_PACKED
+typedef struct TU_ATTR_PACKED
{
uint16_t dte_is_present : 1; ///< Indicates to DCE if DTE is presentor not. This signal corresponds to V.24 signal 108/2 and RS-232 signal DTR.
uint16_t half_duplex_carrier_control : 1;
diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c index 1583b71fa..0a41147c9 100644 --- a/src/class/cdc/cdc_device.c +++ b/src/class/cdc/cdc_device.c @@ -73,23 +73,21 @@ typedef struct //--------------------------------------------------------------------+
CFG_TUSB_MEM_SECTION static cdcd_interface_t _cdcd_itf[CFG_TUD_CDC];
-// TODO will be replaced by dcd_edpt_busy()
-bool pending_read_from_host;
+//bool pending_read_from_host; TODO remove
static void _prep_out_transaction (uint8_t itf)
{
cdcd_interface_t* p_cdc = &_cdcd_itf[itf];
// skip if previous transfer not complete
- // dcd_edpt_busy() doesn't work, probably transfer is complete but not properly handled by the stack
-// if ( dcd_edpt_busy(TUD_OPT_RHPORT, p_cdc->ep_out) ) return;
- if (pending_read_from_host) return;
+ if ( usbd_edpt_busy(TUD_OPT_RHPORT, p_cdc->ep_out) ) return;
+ //if (pending_read_from_host) return;
// Prepare for incoming data but only allow what we can store in the ring buffer.
uint16_t max_read = tu_fifo_remaining(&p_cdc->rx_ff);
if ( max_read >= CFG_TUD_CDC_EPSIZE )
{
- dcd_edpt_xfer(TUD_OPT_RHPORT, p_cdc->ep_out, p_cdc->epout_buf, CFG_TUD_CDC_EPSIZE);
- pending_read_from_host = true;
+ usbd_edpt_xfer(TUD_OPT_RHPORT, p_cdc->ep_out, p_cdc->epout_buf, CFG_TUD_CDC_EPSIZE);
+// pending_read_from_host = true;
}
}
@@ -183,13 +181,13 @@ uint32_t tud_cdc_n_write(uint8_t itf, void const* buffer, uint32_t bufsize) bool tud_cdc_n_write_flush (uint8_t itf)
{
cdcd_interface_t* p_cdc = &_cdcd_itf[itf];
- TU_VERIFY( !dcd_edpt_busy(TUD_OPT_RHPORT, p_cdc->ep_in) ); // skip if previous transfer not complete
+ TU_VERIFY( !usbd_edpt_busy(TUD_OPT_RHPORT, p_cdc->ep_in) ); // skip if previous transfer not complete
uint16_t count = tu_fifo_read_n(&_cdcd_itf[itf].tx_ff, p_cdc->epin_buf, CFG_TUD_CDC_EPSIZE);
if ( count )
{
TU_VERIFY( tud_cdc_n_connected(itf) ); // fifo is empty if not connected
- TU_ASSERT( dcd_edpt_xfer(TUD_OPT_RHPORT, p_cdc->ep_in, p_cdc->epin_buf, count) );
+ TU_ASSERT( usbd_edpt_xfer(TUD_OPT_RHPORT, p_cdc->ep_in, p_cdc->epin_buf, count) );
}
return true;
@@ -298,7 +296,7 @@ bool cdcd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t }
// Prepare for incoming data
- pending_read_from_host = false;
+// pending_read_from_host = false;
_prep_out_transaction(cdc_id);
return true;
@@ -394,7 +392,7 @@ bool cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_ if (tud_cdc_rx_cb && tu_fifo_count(&p_cdc->rx_ff) ) tud_cdc_rx_cb(itf);
// prepare for OUT transaction
- pending_read_from_host = false;
+// pending_read_from_host = false;
_prep_out_transaction(itf);
}
diff --git a/src/class/cdc/cdc_device.h b/src/class/cdc/cdc_device.h index 9e1087631..3c1af9dbf 100644 --- a/src/class/cdc/cdc_device.h +++ b/src/class/cdc/cdc_device.h @@ -91,16 +91,16 @@ static inline bool tud_cdc_write_flush (void) //--------------------------------------------------------------------+
// Invoked when received new data
-ATTR_WEAK void tud_cdc_rx_cb(uint8_t itf);
+TU_ATTR_WEAK void tud_cdc_rx_cb(uint8_t itf);
// Invoked when received `wanted_char`
-ATTR_WEAK void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char);
+TU_ATTR_WEAK void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char);
// Invoked when line state DTR & RTS are changed via SET_CONTROL_LINE_STATE
-ATTR_WEAK void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts);
+TU_ATTR_WEAK void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts);
// Invoked when line coding is change via SET_LINE_CODING
-ATTR_WEAK void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding);
+TU_ATTR_WEAK void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding);
/** @} */
/** @} */
diff --git a/src/class/cdc/cdc_rndis_host.c b/src/class/cdc/cdc_rndis_host.c index c604aef4a..767b917a1 100644 --- a/src/class/cdc/cdc_rndis_host.c +++ b/src/class/cdc/cdc_rndis_host.c @@ -41,7 +41,7 @@ #define RNDIS_MSG_PAYLOAD_MAX (1024*4) CFG_TUSB_MEM_SECTION static uint8_t msg_notification[CFG_TUSB_HOST_DEVICE_MAX][8]; -CFG_TUSB_MEM_SECTION ATTR_ALIGNED(4) static uint8_t msg_payload[RNDIS_MSG_PAYLOAD_MAX]; +CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4) static uint8_t msg_payload[RNDIS_MSG_PAYLOAD_MAX]; static rndish_data_t rndish_data[CFG_TUSB_HOST_DEVICE_MAX]; |
