weak atrribute work around removed from CCRX_Port
This commit is contained in:
@@ -215,8 +215,9 @@ typedef enum
|
||||
// Class Specific Functional Descriptor (Communication Interface)
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
TU_PACK_STRUCT_BEGIN // Start of definition of packed structs (used by the CCRX toolchain)
|
||||
|
||||
/// Header Functional Descriptor (Communication Interface)
|
||||
TU_PACK_STRUCT_BEGIN
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes.
|
||||
@@ -224,10 +225,8 @@ typedef struct TU_ATTR_PACKED
|
||||
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUNC_DESC_
|
||||
uint16_t bcdCDC ; ///< CDC release number in Binary-Coded Decimal
|
||||
}cdc_desc_func_header_t;
|
||||
TU_PACK_STRUCT_END
|
||||
|
||||
/// Union Functional Descriptor (Communication Interface)
|
||||
TU_PACK_STRUCT_BEGIN
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes.
|
||||
@@ -236,7 +235,8 @@ typedef struct TU_ATTR_PACKED
|
||||
uint8_t bControlInterface ; ///< Interface number of Communication Interface
|
||||
uint8_t bSubordinateInterface ; ///< Array of Interface number of Data Interface
|
||||
}cdc_desc_func_union_t;
|
||||
TU_PACK_STRUCT_END
|
||||
|
||||
TU_PACK_STRUCT_END // End of definition of packed structs (used by the CCRX toolchain)
|
||||
|
||||
#define cdc_desc_func_union_n_t(no_slave)\
|
||||
TU_PACK_STRUCT_BEGIN \
|
||||
@@ -249,8 +249,10 @@ TU_PACK_STRUCT_END
|
||||
} \
|
||||
TU_PACK_STRUCT_END
|
||||
|
||||
|
||||
TU_PACK_STRUCT_BEGIN // Start of definition of packed structs (used by the CCRX toolchain)
|
||||
|
||||
/// Country Selection Functional Descriptor (Communication Interface)
|
||||
TU_PACK_STRUCT_BEGIN
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes.
|
||||
@@ -259,7 +261,8 @@ typedef struct TU_ATTR_PACKED
|
||||
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.
|
||||
}cdc_desc_func_country_selection_t;
|
||||
TU_PACK_STRUCT_END
|
||||
|
||||
TU_PACK_STRUCT_END // End of definition of packed structs (used by the CCRX toolchain)
|
||||
|
||||
#define cdc_desc_func_country_selection_n_t(no_country) \
|
||||
TU_PACK_STRUCT_BEGIN \
|
||||
@@ -276,29 +279,28 @@ TU_PACK_STRUCT_END
|
||||
// PUBLIC SWITCHED TELEPHONE NETWORK (PSTN) SUBCLASS
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
TU_PACK_STRUCT_BEGIN // Start of definition of packed structs (used by the CCRX toolchain)
|
||||
|
||||
/// \brief Call Management Functional Descriptor
|
||||
/// \details This functional descriptor describes the processing of calls for the Communications Class interface.
|
||||
TU_PACK_STRUCT_BEGIN
|
||||
TU_BIT_FIELD_ORDER_BEGIN
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
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_
|
||||
|
||||
TU_BIT_FIELD_ORDER_BEGIN
|
||||
struct {
|
||||
uint8_t handle_call : 1; ///< 0 - Device sends/receives call management information only over the Communications Class interface. 1 - Device can send/receive call management information over a Data Class interface.
|
||||
uint8_t send_recv_call : 1; ///< 0 - Device does not handle call management itself. 1 - Device handles call management itself.
|
||||
uint8_t TU_RESERVED : 6;
|
||||
} bmCapabilities;
|
||||
TU_BIT_FIELD_ORDER_END
|
||||
|
||||
uint8_t bDataInterface;
|
||||
}cdc_desc_func_call_management_t;
|
||||
TU_PACK_STRUCT_END
|
||||
TU_BIT_FIELD_ORDER_END
|
||||
|
||||
|
||||
TU_PACK_STRUCT_BEGIN
|
||||
TU_BIT_FIELD_ORDER_BEGIN
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
@@ -309,13 +311,11 @@ typedef struct TU_ATTR_PACKED
|
||||
uint8_t TU_RESERVED : 4;
|
||||
}cdc_acm_capability_t;
|
||||
TU_BIT_FIELD_ORDER_END
|
||||
TU_PACK_STRUCT_END
|
||||
|
||||
TU_VERIFY_STATIC(sizeof(cdc_acm_capability_t) == 1, "mostly problem with compiler");
|
||||
|
||||
/// \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
|
||||
TU_PACK_STRUCT_BEGIN
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes.
|
||||
@@ -323,31 +323,27 @@ typedef struct TU_ATTR_PACKED
|
||||
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
|
||||
cdc_acm_capability_t bmCapabilities ;
|
||||
}cdc_desc_func_acm_t;
|
||||
TU_PACK_STRUCT_END
|
||||
|
||||
/// \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
|
||||
TU_PACK_STRUCT_BEGIN
|
||||
TU_BIT_FIELD_ORDER_BEGIN
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
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_
|
||||
TU_BIT_FIELD_ORDER_BEGIN
|
||||
struct {
|
||||
uint8_t require_pulse_setup : 1; ///< Device requires extra Pulse_Setup request during pulse dialing sequence to disengage holding circuit.
|
||||
uint8_t support_aux_request : 1; ///< Device supports the request combination of Set_Aux_Line_State, Ring_Aux_Jack, and notification Aux_Jack_Hook_State.
|
||||
uint8_t support_pulse_request : 1; ///< Device supports the request combination of Pulse_Setup, Send_Pulse, and Set_Pulse_Time.
|
||||
uint8_t TU_RESERVED : 5;
|
||||
} bmCapabilities;
|
||||
TU_BIT_FIELD_ORDER_END
|
||||
}cdc_desc_func_direct_line_management_t;
|
||||
TU_PACK_STRUCT_END
|
||||
TU_BIT_FIELD_ORDER_END
|
||||
|
||||
/// \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
|
||||
TU_PACK_STRUCT_BEGIN
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes.
|
||||
@@ -356,38 +352,34 @@ typedef struct TU_ATTR_PACKED
|
||||
uint8_t bRingerVolSteps ;
|
||||
uint8_t bNumRingerPatterns ;
|
||||
}cdc_desc_func_telephone_ringer_t;
|
||||
TU_PACK_STRUCT_END
|
||||
|
||||
/// \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
|
||||
TU_PACK_STRUCT_BEGIN
|
||||
TU_BIT_FIELD_ORDER_BEGIN
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
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_
|
||||
TU_BIT_FIELD_ORDER_BEGIN
|
||||
struct {
|
||||
uint8_t simple_mode : 1;
|
||||
uint8_t standalone_mode : 1;
|
||||
uint8_t computer_centric_mode : 1;
|
||||
uint8_t TU_RESERVED : 5;
|
||||
} bmCapabilities;
|
||||
TU_BIT_FIELD_ORDER_END
|
||||
}cdc_desc_func_telephone_operational_modes_t;
|
||||
TU_PACK_STRUCT_END
|
||||
TU_BIT_FIELD_ORDER_END
|
||||
|
||||
/// \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.
|
||||
TU_PACK_STRUCT_BEGIN
|
||||
TU_BIT_FIELD_ORDER_BEGIN
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
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_
|
||||
TU_BIT_FIELD_ORDER_BEGIN
|
||||
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.
|
||||
@@ -397,9 +389,8 @@ typedef struct TU_ATTR_PACKED
|
||||
uint32_t line_state_change : 1; ///< 0 : Does not support line state change notification. 1 : Does support line state change notification
|
||||
uint32_t TU_RESERVED : 26;
|
||||
} bmCapabilities;
|
||||
TU_BIT_FIELD_ORDER_END
|
||||
}cdc_desc_func_telephone_call_state_reporting_capabilities_t;
|
||||
TU_PACK_STRUCT_END
|
||||
TU_BIT_FIELD_ORDER_END
|
||||
|
||||
static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc)
|
||||
{
|
||||
@@ -409,7 +400,6 @@ static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc)
|
||||
//--------------------------------------------------------------------+
|
||||
// Requests
|
||||
//--------------------------------------------------------------------+
|
||||
TU_PACK_STRUCT_BEGIN
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint32_t bit_rate;
|
||||
@@ -417,11 +407,9 @@ typedef struct TU_ATTR_PACKED
|
||||
uint8_t parity; ///< 0: None - 1: Odd - 2: Even - 3: Mark - 4: Space
|
||||
uint8_t data_bits; ///< can be 5, 6, 7, 8 or 16
|
||||
} cdc_line_coding_t;
|
||||
TU_PACK_STRUCT_END
|
||||
|
||||
TU_VERIFY_STATIC(sizeof(cdc_line_coding_t) == 7, "size is not correct");
|
||||
|
||||
TU_PACK_STRUCT_BEGIN
|
||||
TU_BIT_FIELD_ORDER_BEGIN
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
@@ -430,7 +418,9 @@ typedef struct TU_ATTR_PACKED
|
||||
uint16_t : 14;
|
||||
} cdc_line_control_state_t;
|
||||
TU_BIT_FIELD_ORDER_END
|
||||
TU_PACK_STRUCT_END
|
||||
|
||||
TU_PACK_STRUCT_END // End of definition of packed structs (used by the CCRX toolchain)
|
||||
|
||||
|
||||
TU_VERIFY_STATIC(sizeof(cdc_line_control_state_t) == 2, "size is not correct");
|
||||
|
||||
|
@@ -33,15 +33,6 @@
|
||||
|
||||
#include "cdc_device.h"
|
||||
|
||||
#if defined(TU_HAS_NO_ATTR_WEAK)
|
||||
static void (*const MAKE_WEAK_FUNC(tud_cdc_rx_cb))(uint8_t) = TUD_CDC_RX_CB;
|
||||
static void (*const MAKE_WEAK_FUNC(tud_cdc_rx_wanted_cb))(uint8_t, char) = TUD_CDC_RX_WANTED_CB;
|
||||
static void (*const MAKE_WEAK_FUNC(tud_cdc_tx_complete_cb))(uint8_t) = TUD_CDC_TX_COMPLETE_CB;
|
||||
static void (*const MAKE_WEAK_FUNC(tud_cdc_line_state_cb))(uint8_t, bool, bool) = TUD_CDC_LINE_STATE_CB;
|
||||
static void (*const MAKE_WEAK_FUNC(tud_cdc_line_coding_cb))(uint8_t, cdc_line_coding_t const*) = TUD_CDC_LINE_CODING_CB;
|
||||
static void (*const MAKE_WEAK_FUNC(tud_cdc_send_break_cb))(uint8_t, uint16_t) = TUD_CDC_SEND_BREAK_CB;
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -370,7 +361,7 @@ bool cdcd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t
|
||||
}
|
||||
else if ( stage == CONTROL_STAGE_ACK)
|
||||
{
|
||||
if ( MAKE_WEAK_FUNC(tud_cdc_line_coding_cb) ) MAKE_WEAK_FUNC(tud_cdc_line_coding_cb)(itf, &p_cdc->line_coding);
|
||||
if ( tud_cdc_line_coding_cb ) tud_cdc_line_coding_cb(itf, &p_cdc->line_coding);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -405,7 +396,7 @@ bool cdcd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t
|
||||
TU_LOG2(" Set Control Line State: DTR = %d, RTS = %d\r\n", dtr, rts);
|
||||
|
||||
// Invoke callback
|
||||
if ( MAKE_WEAK_FUNC(tud_cdc_line_state_cb) ) MAKE_WEAK_FUNC(tud_cdc_line_state_cb)(itf, dtr, rts);
|
||||
if ( tud_cdc_line_state_cb ) tud_cdc_line_state_cb(itf, dtr, rts);
|
||||
}
|
||||
break;
|
||||
case CDC_REQUEST_SEND_BREAK:
|
||||
@@ -416,7 +407,7 @@ bool cdcd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t
|
||||
else if (stage == CONTROL_STAGE_ACK)
|
||||
{
|
||||
TU_LOG2(" Send Break\r\n");
|
||||
if ( MAKE_WEAK_FUNC(tud_cdc_send_break_cb) ) MAKE_WEAK_FUNC(tud_cdc_send_break_cb)(itf, request->wValue);
|
||||
if ( tud_cdc_send_break_cb ) tud_cdc_send_break_cb(itf, request->wValue);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -447,19 +438,19 @@ bool cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
|
||||
tu_fifo_write_n(&p_cdc->rx_ff, &p_cdc->epout_buf, xferred_bytes);
|
||||
|
||||
// Check for wanted char and invoke callback if needed
|
||||
if ( MAKE_WEAK_FUNC(tud_cdc_rx_wanted_cb) && (((signed char) p_cdc->wanted_char) != -1) )
|
||||
if ( tud_cdc_rx_wanted_cb && (((signed char) p_cdc->wanted_char) != -1) )
|
||||
{
|
||||
for ( uint32_t i = 0; i < xferred_bytes; i++ )
|
||||
{
|
||||
if ( (p_cdc->wanted_char == p_cdc->epout_buf[i]) && !tu_fifo_empty(&p_cdc->rx_ff) )
|
||||
{
|
||||
MAKE_WEAK_FUNC(tud_cdc_rx_wanted_cb)(itf, p_cdc->wanted_char);
|
||||
tud_cdc_rx_wanted_cb(itf, p_cdc->wanted_char);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// invoke receive callback (if there is still data)
|
||||
if (MAKE_WEAK_FUNC(tud_cdc_rx_cb) && !tu_fifo_empty(&p_cdc->rx_ff) ) MAKE_WEAK_FUNC(tud_cdc_rx_cb)(itf);
|
||||
if (tud_cdc_rx_cb && !tu_fifo_empty(&p_cdc->rx_ff) ) tud_cdc_rx_cb(itf);
|
||||
|
||||
// prepare for OUT transaction
|
||||
_prep_out_transaction(p_cdc);
|
||||
@@ -471,7 +462,7 @@ bool cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
|
||||
if ( ep_addr == p_cdc->ep_in )
|
||||
{
|
||||
// invoke transmit callback to possibly refill tx fifo
|
||||
if ( MAKE_WEAK_FUNC(tud_cdc_tx_complete_cb) ) MAKE_WEAK_FUNC(tud_cdc_tx_complete_cb)(itf);
|
||||
if ( tud_cdc_tx_complete_cb ) tud_cdc_tx_complete_cb(itf);
|
||||
|
||||
if ( 0 == tud_cdc_n_write_flush(itf) )
|
||||
{
|
||||
|
@@ -129,7 +129,6 @@ static inline bool tud_cdc_write_clear (void);
|
||||
// Application Callback API (weak is optional)
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
#if !defined(TU_HAS_NO_ATTR_WEAK)
|
||||
// Invoked when received new data
|
||||
TU_ATTR_WEAK void tud_cdc_rx_cb(uint8_t itf);
|
||||
|
||||
@@ -148,62 +147,6 @@ TU_ATTR_WEAK void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p
|
||||
// Invoked when received send break
|
||||
TU_ATTR_WEAK void tud_cdc_send_break_cb(uint8_t itf, uint16_t duration_ms);
|
||||
|
||||
#else
|
||||
#if ADD_WEAK_FUNC_TUD_CDC_RX_CB
|
||||
#define TUD_CDC_RX_CB tud_cdc_rx_cb
|
||||
#endif
|
||||
#ifndef TUD_CDC_RX_CB
|
||||
#define TUD_CDC_RX_CB NULL
|
||||
#else
|
||||
extern void TUD_CDC_RX_CB(uint8_t itf);
|
||||
#endif
|
||||
|
||||
#if ADD_WEAK_FUNC_TUD_CDC_RX_WANTED_CB
|
||||
#define TUD_CDC_RX_WANTED_CB tud_cdc_rx_wanted_cb
|
||||
#endif
|
||||
#ifndef TUD_CDC_RX_WANTED_CB
|
||||
#define TUD_CDC_RX_WANTED_CB NULL
|
||||
#else
|
||||
extern void TUD_CDC_RX_WANTED_CB(uint8_t itf, char wanted_char);
|
||||
#endif
|
||||
|
||||
#if ADD_WEAK_FUNC_TUD_CDC_TX_COMPLETE_CB
|
||||
#define TUD_CDC_TX_COMPLETE_CB tud_cdc_tx_complete_cb
|
||||
#endif
|
||||
#ifndef TUD_CDC_TX_COMPLETE_CB
|
||||
#define TUD_CDC_TX_COMPLETE_CB NULL
|
||||
#else
|
||||
extern void TUD_CDC_TX_COMPLETE_CB(uint8_t itf);
|
||||
#endif
|
||||
|
||||
#if ADD_WEAK_FUNC_TUD_CDC_LINE_STATE_CB
|
||||
#define TUD_CDC_LINE_STATE_CB tud_cdc_line_state_cb
|
||||
#endif
|
||||
#ifndef TUD_CDC_LINE_STATE_CB
|
||||
#define TUD_CDC_LINE_STATE_CB NULL
|
||||
#else
|
||||
extern void TUD_CDC_LINE_STATE_CB(uint8_t itf, bool dtr, bool rts);
|
||||
#endif
|
||||
|
||||
#if ADD_WEAK_FUNC_TUD_CDC_LINE_CODING_CB
|
||||
#define TUD_CDC_LINE_CODING_CB tud_cdc_line_coding_cb
|
||||
#endif
|
||||
#ifndef TUD_CDC_LINE_CODING_CB
|
||||
#define TUD_CDC_LINE_CODING_CB NULL
|
||||
#else
|
||||
extern void TUD_CDC_LINE_CODING_CB(uint8_t itf, cdc_line_coding_t const* p_line_coding);
|
||||
#endif
|
||||
|
||||
#if ADD_WEAK_FUNC_TUD_CDC_SEND_BREAK_CB
|
||||
#define TUD_CDC_SEND_BREAK_CB tud_cdc_send_break_cb
|
||||
#endif
|
||||
#ifndef TUD_CDC_SEND_BREAK_CB
|
||||
#define TUD_CDC_SEND_BREAK_CB NULL
|
||||
#else
|
||||
extern void TUD_CDC_SEND_BREAK_CB(uint8_t itf, uint16_t duration_ms);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Inline Functions
|
||||
//--------------------------------------------------------------------+
|
||||
|
Reference in New Issue
Block a user