add TU_ prefix to compiler ATTR to prevent name conflict with application
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,6 +5,7 @@ test_old
|
|||||||
tests/build
|
tests/build
|
||||||
*.d
|
*.d
|
||||||
*.o
|
*.o
|
||||||
|
*.P
|
||||||
*.launch
|
*.launch
|
||||||
*.map
|
*.map
|
||||||
*.axf
|
*.axf
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4)
|
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4)
|
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4)
|
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4)
|
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4)
|
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X
|
#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X
|
||||||
#define CFG_TUSB_MEM_SECTION // LPC17xx USB DMA can access all address
|
#define CFG_TUSB_MEM_SECTION // LPC17xx USB DMA can access all address
|
||||||
#elif (CFG_TUSB_MCU == OPT_MCU_LPC43XX)
|
#elif (CFG_TUSB_MCU == OPT_MCU_LPC43XX)
|
||||||
#define CFG_TUSB_MEM_SECTION ATTR_SECTION(.data.$RAM3)
|
#define CFG_TUSB_MEM_SECTION TU_ATTR_SECTION(.data.$RAM3)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined __CC_ARM // Compiled with Keil armcc
|
#elif defined __CC_ARM // Compiled with Keil armcc
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ typedef enum
|
|||||||
// FUNCTIONAL DESCRIPTOR (COMMUNICATION INTERFACE)
|
// FUNCTIONAL DESCRIPTOR (COMMUNICATION INTERFACE)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
/// Header 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 bLength ; ///< Size of this descriptor in bytes.
|
||||||
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
||||||
@@ -221,7 +221,7 @@ typedef struct ATTR_PACKED
|
|||||||
}cdc_desc_func_header_t;
|
}cdc_desc_func_header_t;
|
||||||
|
|
||||||
/// Union Functional Descriptor (Communication Interface)
|
/// 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 bLength ; ///< Size of this descriptor in bytes.
|
||||||
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
||||||
@@ -231,7 +231,7 @@ typedef struct ATTR_PACKED
|
|||||||
}cdc_desc_func_union_t;
|
}cdc_desc_func_union_t;
|
||||||
|
|
||||||
#define cdc_desc_func_union_n_t(no_slave)\
|
#define cdc_desc_func_union_n_t(no_slave)\
|
||||||
struct ATTR_PACKED { \
|
struct TU_ATTR_PACKED { \
|
||||||
uint8_t bLength ;\
|
uint8_t bLength ;\
|
||||||
uint8_t bDescriptorType ;\
|
uint8_t bDescriptorType ;\
|
||||||
uint8_t bDescriptorSubType ;\
|
uint8_t bDescriptorSubType ;\
|
||||||
@@ -240,7 +240,7 @@ typedef struct ATTR_PACKED
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Country Selection Functional Descriptor (Communication Interface)
|
/// 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 bLength ; ///< Size of this descriptor in bytes.
|
||||||
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
||||||
@@ -250,7 +250,7 @@ typedef struct ATTR_PACKED
|
|||||||
}cdc_desc_func_country_selection_t;
|
}cdc_desc_func_country_selection_t;
|
||||||
|
|
||||||
#define cdc_desc_func_country_selection_n_t(no_country) \
|
#define cdc_desc_func_country_selection_n_t(no_country) \
|
||||||
struct ATTR_PACKED {\
|
struct TU_ATTR_PACKED {\
|
||||||
uint8_t bLength ;\
|
uint8_t bLength ;\
|
||||||
uint8_t bDescriptorType ;\
|
uint8_t bDescriptorType ;\
|
||||||
uint8_t bDescriptorSubType ;\
|
uint8_t bDescriptorSubType ;\
|
||||||
@@ -264,7 +264,7 @@ typedef struct ATTR_PACKED
|
|||||||
|
|
||||||
/// \brief Call Management Functional Descriptor
|
/// \brief Call Management Functional Descriptor
|
||||||
/// \details This functional descriptor describes the processing of calls for the Communications Class interface.
|
/// \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 bLength ; ///< Size of this descriptor in bytes.
|
||||||
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
||||||
@@ -280,7 +280,7 @@ typedef struct ATTR_PACKED
|
|||||||
}cdc_desc_func_call_management_t;
|
}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_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_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
|
/// \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
|
/// \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 bLength ; ///< Size of this descriptor in bytes.
|
||||||
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
||||||
@@ -303,7 +303,7 @@ typedef struct ATTR_PACKED
|
|||||||
|
|
||||||
/// \brief Direct Line Management Functional Descriptor
|
/// \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
|
/// \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 bLength ; ///< Size of this descriptor in bytes.
|
||||||
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
||||||
@@ -319,7 +319,7 @@ typedef struct ATTR_PACKED
|
|||||||
/// \brief Telephone Ringer Functional Descriptor
|
/// \brief Telephone Ringer Functional Descriptor
|
||||||
/// \details The Telephone Ringer functional descriptor describes the ringer capabilities supported by the Communications Class interface,
|
/// \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
|
/// 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 bLength ; ///< Size of this descriptor in bytes.
|
||||||
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
||||||
@@ -331,7 +331,7 @@ typedef struct ATTR_PACKED
|
|||||||
/// \brief Telephone Operational Modes Functional Descriptor
|
/// \brief Telephone Operational Modes Functional Descriptor
|
||||||
/// \details The Telephone Operational Modes functional descriptor describes the operational modes supported by
|
/// \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
|
/// 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 bLength ; ///< Size of this descriptor in bytes.
|
||||||
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
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
|
/// \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
|
/// \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.
|
/// 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 bLength ; ///< Size of this descriptor in bytes.
|
||||||
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
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
|
// Requests
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint32_t bit_rate;
|
uint32_t bit_rate;
|
||||||
uint8_t stop_bits; ///< 0: 1 stop bit - 1: 1.5 stop bits - 2: 2 stop bits
|
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");
|
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 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;
|
uint16_t half_duplex_carrier_control : 1;
|
||||||
|
|||||||
@@ -91,16 +91,16 @@ static inline bool tud_cdc_write_flush (void)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// Invoked when received new data
|
// 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`
|
// 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
|
// 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
|
// 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);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
#define RNDIS_MSG_PAYLOAD_MAX (1024*4)
|
#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 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];
|
static rndish_data_t rndish_data[CFG_TUSB_HOST_DEVICE_MAX];
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
* @{ */
|
* @{ */
|
||||||
|
|
||||||
/// USB HID Descriptor
|
/// USB HID Descriptor
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t bLength; /**< Numeric expression that is the total size of the HID descriptor */
|
uint8_t bLength; /**< Numeric expression that is the total size of the HID descriptor */
|
||||||
uint8_t bDescriptorType; /**< Constant name specifying type of HID descriptor. */
|
uint8_t bDescriptorType; /**< Constant name specifying type of HID descriptor. */
|
||||||
@@ -150,7 +150,7 @@ typedef enum
|
|||||||
* @{ */
|
* @{ */
|
||||||
|
|
||||||
/// Standard HID Boot Protocol Mouse Report.
|
/// Standard HID Boot Protocol Mouse Report.
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t buttons; /**< buttons mask for currently pressed buttons in the mouse. */
|
uint8_t buttons; /**< buttons mask for currently pressed buttons in the mouse. */
|
||||||
int8_t x; /**< Current delta x movement of the mouse. */
|
int8_t x; /**< Current delta x movement of the mouse. */
|
||||||
@@ -178,7 +178,7 @@ typedef enum
|
|||||||
* @{ */
|
* @{ */
|
||||||
|
|
||||||
/// Standard HID Boot Protocol Keyboard Report.
|
/// Standard HID Boot Protocol Keyboard Report.
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t modifier; /**< Keyboard modifier (KEYBOARD_MODIFER_* masks). */
|
uint8_t modifier; /**< Keyboard modifier (KEYBOARD_MODIFER_* masks). */
|
||||||
uint8_t reserved; /**< Reserved for OEM use, always set to 0. */
|
uint8_t reserved; /**< Reserved for OEM use, always set to 0. */
|
||||||
|
|||||||
@@ -82,12 +82,12 @@ uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type,
|
|||||||
void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
|
void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
|
||||||
|
|
||||||
// Invoked when received SET_PROTOCOL request ( mode switch Boot <-> Report )
|
// Invoked when received SET_PROTOCOL request ( mode switch Boot <-> Report )
|
||||||
ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode);
|
TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode);
|
||||||
|
|
||||||
// Invoked when received SET_IDLE request. return false will stall the request
|
// Invoked when received SET_IDLE request. return false will stall the request
|
||||||
// - Idle Rate = 0 : only send report if there is changes, i.e skip duplication
|
// - Idle Rate = 0 : only send report if there is changes, i.e skip duplication
|
||||||
// - Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms).
|
// - Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms).
|
||||||
ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t idle_rate);
|
TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t idle_rate);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------+
|
/* --------------------------------------------------------------------+
|
||||||
* HID Report Descriptor Template
|
* HID Report Descriptor Template
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
// FUNCTIONAL DESCRIPTOR (COMMUNICATION INTERFACE)
|
// FUNCTIONAL DESCRIPTOR (COMMUNICATION INTERFACE)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
/// Header 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 bLength ; ///< Size of this descriptor in bytes.
|
||||||
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
||||||
@@ -52,7 +52,7 @@ typedef struct ATTR_PACKED
|
|||||||
}midi_desc_func_header_t;
|
}midi_desc_func_header_t;
|
||||||
|
|
||||||
/// Union Functional Descriptor (Communication Interface)
|
/// 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 bLength ; ///< Size of this descriptor in bytes.
|
||||||
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ static inline bool tud_midi_write_flush (void)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// APPLICATION CALLBACK API (WEAK is optional)
|
// APPLICATION CALLBACK API (WEAK is optional)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
ATTR_WEAK void tud_midi_rx_cb(uint8_t itf);
|
TU_ATTR_WEAK void tud_midi_rx_cb(uint8_t itf);
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Internal Class Driver API
|
// Internal Class Driver API
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ typedef enum
|
|||||||
}msc_csw_status_t;
|
}msc_csw_status_t;
|
||||||
|
|
||||||
/// Command Block Wrapper
|
/// Command Block Wrapper
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint32_t signature; ///< Signature that helps identify this data packet as a CBW. The signature field shall contain the value 43425355h (little endian), indicating a CBW.
|
uint32_t signature; ///< Signature that helps identify this data packet as a CBW. The signature field shall contain the value 43425355h (little endian), indicating a CBW.
|
||||||
uint32_t tag; ///< Tag sent by the host. The device shall echo the contents of this field back to the host in the dCSWTagfield of the associated CSW. The dCSWTagpositively associates a CSW with the corresponding CBW.
|
uint32_t tag; ///< Tag sent by the host. The device shall echo the contents of this field back to the host in the dCSWTagfield of the associated CSW. The dCSWTagpositively associates a CSW with the corresponding CBW.
|
||||||
@@ -100,7 +100,7 @@ typedef struct ATTR_PACKED
|
|||||||
TU_VERIFY_STATIC(sizeof(msc_cbw_t) == 31, "size is not correct");
|
TU_VERIFY_STATIC(sizeof(msc_cbw_t) == 31, "size is not correct");
|
||||||
|
|
||||||
/// Command Status Wrapper
|
/// Command Status Wrapper
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint32_t signature ; ///< Signature that helps identify this data packet as a CSW. The signature field shall contain the value 53425355h (little endian), indicating CSW.
|
uint32_t signature ; ///< Signature that helps identify this data packet as a CSW. The signature field shall contain the value 53425355h (little endian), indicating CSW.
|
||||||
uint32_t tag ; ///< The device shall set this field to the value received in the dCBWTag of the associated CBW.
|
uint32_t tag ; ///< The device shall set this field to the value received in the dCBWTag of the associated CBW.
|
||||||
@@ -153,7 +153,7 @@ typedef enum
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
/// SCSI Test Unit Ready Command
|
/// SCSI Test Unit Ready Command
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t cmd_code ; ///< SCSI OpCode for \ref SCSI_CMD_TEST_UNIT_READY
|
uint8_t cmd_code ; ///< SCSI OpCode for \ref SCSI_CMD_TEST_UNIT_READY
|
||||||
uint8_t lun ; ///< Logical Unit
|
uint8_t lun ; ///< Logical Unit
|
||||||
@@ -164,7 +164,7 @@ typedef struct ATTR_PACKED
|
|||||||
TU_VERIFY_STATIC(sizeof(scsi_test_unit_ready_t) == 6, "size is not correct");
|
TU_VERIFY_STATIC(sizeof(scsi_test_unit_ready_t) == 6, "size is not correct");
|
||||||
|
|
||||||
/// SCSI Inquiry Command
|
/// SCSI Inquiry Command
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t cmd_code ; ///< SCSI OpCode for \ref SCSI_CMD_INQUIRY
|
uint8_t cmd_code ; ///< SCSI OpCode for \ref SCSI_CMD_INQUIRY
|
||||||
uint8_t reserved1 ;
|
uint8_t reserved1 ;
|
||||||
@@ -177,7 +177,7 @@ typedef struct ATTR_PACKED
|
|||||||
TU_VERIFY_STATIC(sizeof(scsi_inquiry_t) == 6, "size is not correct");
|
TU_VERIFY_STATIC(sizeof(scsi_inquiry_t) == 6, "size is not correct");
|
||||||
|
|
||||||
/// SCSI Inquiry Response Data
|
/// SCSI Inquiry Response Data
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t peripheral_device_type : 5;
|
uint8_t peripheral_device_type : 5;
|
||||||
uint8_t peripheral_qualifier : 3;
|
uint8_t peripheral_qualifier : 3;
|
||||||
@@ -223,7 +223,7 @@ typedef struct ATTR_PACKED
|
|||||||
TU_VERIFY_STATIC(sizeof(scsi_inquiry_resp_t) == 36, "size is not correct");
|
TU_VERIFY_STATIC(sizeof(scsi_inquiry_resp_t) == 36, "size is not correct");
|
||||||
|
|
||||||
|
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t response_code : 7; ///< 70h - current errors, Fixed Format 71h - deferred errors, Fixed Format
|
uint8_t response_code : 7; ///< 70h - current errors, Fixed Format 71h - deferred errors, Fixed Format
|
||||||
uint8_t valid : 1;
|
uint8_t valid : 1;
|
||||||
@@ -249,7 +249,7 @@ typedef struct ATTR_PACKED
|
|||||||
|
|
||||||
TU_VERIFY_STATIC(sizeof(scsi_sense_fixed_resp_t) == 18, "size is not correct");
|
TU_VERIFY_STATIC(sizeof(scsi_sense_fixed_resp_t) == 18, "size is not correct");
|
||||||
|
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t cmd_code ; ///< SCSI OpCode for \ref SCSI_CMD_MODE_SENSE_6
|
uint8_t cmd_code ; ///< SCSI OpCode for \ref SCSI_CMD_MODE_SENSE_6
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ typedef struct ATTR_PACKED
|
|||||||
TU_VERIFY_STATIC( sizeof(scsi_mode_sense6_t) == 6, "size is not correct");
|
TU_VERIFY_STATIC( sizeof(scsi_mode_sense6_t) == 6, "size is not correct");
|
||||||
|
|
||||||
// This is only a Mode parameter header(6).
|
// This is only a Mode parameter header(6).
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t data_len;
|
uint8_t data_len;
|
||||||
uint8_t medium_type;
|
uint8_t medium_type;
|
||||||
@@ -281,7 +281,7 @@ typedef struct ATTR_PACKED
|
|||||||
|
|
||||||
TU_VERIFY_STATIC( sizeof(scsi_mode_sense6_resp_t) == 4, "size is not correct");
|
TU_VERIFY_STATIC( sizeof(scsi_mode_sense6_resp_t) == 4, "size is not correct");
|
||||||
|
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t cmd_code; ///< SCSI OpCode for \ref SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL
|
uint8_t cmd_code; ///< SCSI OpCode for \ref SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL
|
||||||
uint8_t reserved[3];
|
uint8_t reserved[3];
|
||||||
@@ -291,7 +291,7 @@ typedef struct ATTR_PACKED
|
|||||||
|
|
||||||
TU_VERIFY_STATIC( sizeof(scsi_prevent_allow_medium_removal_t) == 6, "size is not correct");
|
TU_VERIFY_STATIC( sizeof(scsi_prevent_allow_medium_removal_t) == 6, "size is not correct");
|
||||||
|
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t cmd_code;
|
uint8_t cmd_code;
|
||||||
|
|
||||||
@@ -318,7 +318,7 @@ TU_VERIFY_STATIC( sizeof(scsi_start_stop_unit_t) == 6, "size is not correct");
|
|||||||
// SCSI MMC
|
// SCSI MMC
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
/// SCSI Read Format Capacity: Write Capacity
|
/// SCSI Read Format Capacity: Write Capacity
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t cmd_code;
|
uint8_t cmd_code;
|
||||||
uint8_t reserved[6];
|
uint8_t reserved[6];
|
||||||
@@ -328,7 +328,7 @@ typedef struct ATTR_PACKED
|
|||||||
|
|
||||||
TU_VERIFY_STATIC( sizeof(scsi_read_format_capacity_t) == 10, "size is not correct");
|
TU_VERIFY_STATIC( sizeof(scsi_read_format_capacity_t) == 10, "size is not correct");
|
||||||
|
|
||||||
typedef struct ATTR_PACKED{
|
typedef struct TU_ATTR_PACKED{
|
||||||
uint8_t reserved[3];
|
uint8_t reserved[3];
|
||||||
uint8_t list_length; /// must be 8*n, length in bytes of formattable capacity descriptor followed it.
|
uint8_t list_length; /// must be 8*n, length in bytes of formattable capacity descriptor followed it.
|
||||||
|
|
||||||
@@ -348,7 +348,7 @@ TU_VERIFY_STATIC( sizeof(scsi_read_format_capacity_data_t) == 12, "size is not c
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
/// SCSI Read Capacity 10 Command: Read Capacity
|
/// SCSI Read Capacity 10 Command: Read Capacity
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t cmd_code ; ///< SCSI OpCode for \ref SCSI_CMD_READ_CAPACITY_10
|
uint8_t cmd_code ; ///< SCSI OpCode for \ref SCSI_CMD_READ_CAPACITY_10
|
||||||
uint8_t reserved1 ;
|
uint8_t reserved1 ;
|
||||||
@@ -369,7 +369,7 @@ typedef struct {
|
|||||||
TU_VERIFY_STATIC(sizeof(scsi_read_capacity10_resp_t) == 8, "size is not correct");
|
TU_VERIFY_STATIC(sizeof(scsi_read_capacity10_resp_t) == 8, "size is not correct");
|
||||||
|
|
||||||
/// SCSI Read 10 Command
|
/// SCSI Read 10 Command
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t cmd_code ; ///< SCSI OpCode
|
uint8_t cmd_code ; ///< SCSI OpCode
|
||||||
uint8_t reserved ; // has LUN according to wiki
|
uint8_t reserved ; // has LUN according to wiki
|
||||||
|
|||||||
@@ -126,24 +126,24 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
|
|||||||
/*------------- Optional callbacks -------------*/
|
/*------------- Optional callbacks -------------*/
|
||||||
|
|
||||||
// Invoked when received GET_MAX_LUN request, required for multiple LUNs implementation
|
// Invoked when received GET_MAX_LUN request, required for multiple LUNs implementation
|
||||||
ATTR_WEAK uint8_t tud_msc_get_maxlun_cb(void);
|
TU_ATTR_WEAK uint8_t tud_msc_get_maxlun_cb(void);
|
||||||
|
|
||||||
// Invoked when received Start Stop Unit command
|
// Invoked when received Start Stop Unit command
|
||||||
// - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage
|
// - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage
|
||||||
// - Start = 1 : active mode, if load_eject = 1 : load disk storage
|
// - Start = 1 : active mode, if load_eject = 1 : load disk storage
|
||||||
ATTR_WEAK void tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject);
|
TU_ATTR_WEAK void tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject);
|
||||||
|
|
||||||
// Invoked when Read10 command is complete
|
// Invoked when Read10 command is complete
|
||||||
ATTR_WEAK void tud_msc_read10_complete_cb(uint8_t lun);
|
TU_ATTR_WEAK void tud_msc_read10_complete_cb(uint8_t lun);
|
||||||
|
|
||||||
// Invoke when Write10 command is complete, can be used to flush flash caching
|
// Invoke when Write10 command is complete, can be used to flush flash caching
|
||||||
ATTR_WEAK void tud_msc_write10_complete_cb(uint8_t lun);
|
TU_ATTR_WEAK void tud_msc_write10_complete_cb(uint8_t lun);
|
||||||
|
|
||||||
// Invoked when command in tud_msc_scsi_cb is complete
|
// Invoked when command in tud_msc_scsi_cb is complete
|
||||||
ATTR_WEAK void tud_msc_scsi_complete_cb(uint8_t lun, uint8_t const scsi_cmd[16]);
|
TU_ATTR_WEAK void tud_msc_scsi_complete_cb(uint8_t lun, uint8_t const scsi_cmd[16]);
|
||||||
|
|
||||||
// Hook to make a mass storage device read-only. TODO remove
|
// Hook to make a mass storage device read-only. TODO remove
|
||||||
ATTR_WEAK bool tud_msc_is_writable_cb(uint8_t lun);
|
TU_ATTR_WEAK bool tud_msc_is_writable_cb(uint8_t lun);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ static osal_semaphore_def_t msch_sem_def;
|
|||||||
static osal_semaphore_t msch_sem_hdl;
|
static osal_semaphore_t msch_sem_hdl;
|
||||||
|
|
||||||
// buffer used to read scsi information when mounted, largest response data currently is inquiry
|
// buffer used to read scsi information when mounted, largest response data currently is inquiry
|
||||||
CFG_TUSB_MEM_SECTION ATTR_ALIGNED(4) static uint8_t msch_buffer[sizeof(scsi_inquiry_resp_t)];
|
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4) static uint8_t msch_buffer[sizeof(scsi_inquiry_resp_t)];
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||||
|
|||||||
@@ -57,9 +57,6 @@
|
|||||||
|
|
||||||
#define TU_BIT(n) (1U << (n))
|
#define TU_BIT(n) (1U << (n))
|
||||||
|
|
||||||
// for declaration of reserved field, make use of _TU_COUNTER_
|
|
||||||
#define TU_RESERVED XSTRING_CONCAT_(reserved, _TU_COUNTER_)
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|||||||
@@ -32,10 +32,10 @@
|
|||||||
#ifndef _TUSB_COMPILER_H_
|
#ifndef _TUSB_COMPILER_H_
|
||||||
#define _TUSB_COMPILER_H_
|
#define _TUSB_COMPILER_H_
|
||||||
|
|
||||||
#define STRING_(x) #x ///< stringify without expand
|
#define TU_STRING(x) #x ///< stringify without expand
|
||||||
#define XSTRING_(x) STRING_(x) ///< expand then stringify
|
#define TU_XSTRING(x) TU_STRING(x) ///< expand then stringify
|
||||||
#define STRING_CONCAT_(a, b) a##b ///< concat without expand
|
#define TU_STRCAT(a, b) a##b ///< concat without expand
|
||||||
#define XSTRING_CONCAT_(a, b) STRING_CONCAT_(a, b) ///< expand then concat
|
#define TU_XSTRCAT(a, b) TU_STRCAT(a, b) ///< expand then concat
|
||||||
|
|
||||||
#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
|
#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
|
||||||
#define _TU_COUNTER_ __COUNTER__
|
#define _TU_COUNTER_ __COUNTER__
|
||||||
@@ -47,20 +47,23 @@
|
|||||||
#if __STDC_VERSION__ >= 201112L
|
#if __STDC_VERSION__ >= 201112L
|
||||||
#define TU_VERIFY_STATIC _Static_assert
|
#define TU_VERIFY_STATIC _Static_assert
|
||||||
#else
|
#else
|
||||||
#define TU_VERIFY_STATIC(const_expr, _mess) enum { XSTRING_CONCAT_(_verify_static_, _TU_COUNTER_) = 1/(!!(const_expr)) }
|
#define TU_VERIFY_STATIC(const_expr, _mess) enum { TU_XSTRCAT(_verify_static_, _TU_COUNTER_) = 1/(!!(const_expr)) }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// for declaration of reserved field, make use of _TU_COUNTER_
|
||||||
|
#define TU_RESERVED TU_XSTRCAT(reserved, _TU_COUNTER_)
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Compiler porting with Attribute and Endian
|
// Compiler porting with Attribute and Endian
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
#define ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
|
#define TU_ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
|
||||||
#define ATTR_SECTION(sec_name) __attribute__ ((section(#sec_name)))
|
#define TU_ATTR_SECTION(sec_name) __attribute__ ((section(#sec_name)))
|
||||||
#define ATTR_PACKED __attribute__ ((packed))
|
#define TU_ATTR_PACKED __attribute__ ((packed))
|
||||||
#define ATTR_PREPACKED
|
#define TU_ATTR_PREPACKED
|
||||||
#define ATTR_WEAK __attribute__ ((weak))
|
#define TU_ATTR_WEAK __attribute__ ((weak))
|
||||||
#define ATTR_DEPRECATED(mess) __attribute__ ((deprecated(mess))) // warn if function with this attribute is used
|
#define TU_ATTR_DEPRECATED(mess) __attribute__ ((deprecated(mess))) // warn if function with this attribute is used
|
||||||
#define ATTR_UNUSED __attribute__ ((unused)) // Function/Variable is meant to be possibly unused
|
#define TU_ATTR_UNUSED __attribute__ ((unused)) // Function/Variable is meant to be possibly unused
|
||||||
|
|
||||||
// Endian conversion use well-known host to network (big endian) naming
|
// Endian conversion use well-known host to network (big endian) naming
|
||||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ enum
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
/// USB Standard Device Descriptor (section 9.6.1, table 9-8)
|
/// USB Standard Device Descriptor (section 9.6.1, table 9-8)
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t bLength ; ///< Size of this descriptor in bytes.
|
uint8_t bLength ; ///< Size of this descriptor in bytes.
|
||||||
uint8_t bDescriptorType ; ///< DEVICE Descriptor Type.
|
uint8_t bDescriptorType ; ///< DEVICE Descriptor Type.
|
||||||
@@ -222,7 +222,7 @@ typedef struct ATTR_PACKED
|
|||||||
} tusb_desc_device_t;
|
} tusb_desc_device_t;
|
||||||
|
|
||||||
/// USB Standard Configuration Descriptor (section 9.6.1 table 9-10) */
|
/// USB Standard Configuration Descriptor (section 9.6.1 table 9-10) */
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t bLength ; ///< Size of this descriptor in bytes
|
uint8_t bLength ; ///< Size of this descriptor in bytes
|
||||||
uint8_t bDescriptorType ; ///< CONFIGURATION Descriptor Type
|
uint8_t bDescriptorType ; ///< CONFIGURATION Descriptor Type
|
||||||
@@ -236,7 +236,7 @@ typedef struct ATTR_PACKED
|
|||||||
} tusb_desc_configuration_t;
|
} tusb_desc_configuration_t;
|
||||||
|
|
||||||
/// USB Standard Interface Descriptor (section 9.6.1 table 9-12)
|
/// USB Standard Interface Descriptor (section 9.6.1 table 9-12)
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t bLength ; ///< Size of this descriptor in bytes
|
uint8_t bLength ; ///< Size of this descriptor in bytes
|
||||||
uint8_t bDescriptorType ; ///< INTERFACE Descriptor Type
|
uint8_t bDescriptorType ; ///< INTERFACE Descriptor Type
|
||||||
@@ -251,21 +251,21 @@ typedef struct ATTR_PACKED
|
|||||||
} tusb_desc_interface_t;
|
} tusb_desc_interface_t;
|
||||||
|
|
||||||
/// USB Standard Endpoint Descriptor (section 9.6.1 table 9-13)
|
/// USB Standard Endpoint Descriptor (section 9.6.1 table 9-13)
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t bLength ; ///< Size of this descriptor in bytes
|
uint8_t bLength ; ///< Size of this descriptor in bytes
|
||||||
uint8_t bDescriptorType ; ///< ENDPOINT Descriptor Type
|
uint8_t bDescriptorType ; ///< ENDPOINT Descriptor Type
|
||||||
|
|
||||||
uint8_t bEndpointAddress ; ///< The address of the endpoint on the USB device described by this descriptor. The address is encoded as follows: \n Bit 3...0: The endpoint number \n Bit 6...4: Reserved, reset to zero \n Bit 7: Direction, ignored for control endpoints 0 = OUT endpoint 1 = IN endpoint.
|
uint8_t bEndpointAddress ; ///< The address of the endpoint on the USB device described by this descriptor. The address is encoded as follows: \n Bit 3...0: The endpoint number \n Bit 6...4: Reserved, reset to zero \n Bit 7: Direction, ignored for control endpoints 0 = OUT endpoint 1 = IN endpoint.
|
||||||
|
|
||||||
struct ATTR_PACKED {
|
struct TU_ATTR_PACKED {
|
||||||
uint8_t xfer : 2;
|
uint8_t xfer : 2;
|
||||||
uint8_t sync : 2;
|
uint8_t sync : 2;
|
||||||
uint8_t usage : 2;
|
uint8_t usage : 2;
|
||||||
uint8_t : 2;
|
uint8_t : 2;
|
||||||
} bmAttributes ; ///< This field describes the endpoint's attributes when it is configured using the bConfigurationValue. \n Bits 1..0: Transfer Type \n- 00 = Control \n- 01 = Isochronous \n- 10 = Bulk \n- 11 = Interrupt \n If not an isochronous endpoint, bits 5..2 are reserved and must be set to zero. If isochronous, they are defined as follows: \n Bits 3..2: Synchronization Type \n- 00 = No Synchronization \n- 01 = Asynchronous \n- 10 = Adaptive \n- 11 = Synchronous \n Bits 5..4: Usage Type \n- 00 = Data endpoint \n- 01 = Feedback endpoint \n- 10 = Implicit feedback Data endpoint \n- 11 = Reserved \n Refer to Chapter 5 of USB 2.0 specification for more information. \n All other bits are reserved and must be reset to zero. Reserved bits must be ignored by the host.
|
} bmAttributes ; ///< This field describes the endpoint's attributes when it is configured using the bConfigurationValue. \n Bits 1..0: Transfer Type \n- 00 = Control \n- 01 = Isochronous \n- 10 = Bulk \n- 11 = Interrupt \n If not an isochronous endpoint, bits 5..2 are reserved and must be set to zero. If isochronous, they are defined as follows: \n Bits 3..2: Synchronization Type \n- 00 = No Synchronization \n- 01 = Asynchronous \n- 10 = Adaptive \n- 11 = Synchronous \n Bits 5..4: Usage Type \n- 00 = Data endpoint \n- 01 = Feedback endpoint \n- 10 = Implicit feedback Data endpoint \n- 11 = Reserved \n Refer to Chapter 5 of USB 2.0 specification for more information. \n All other bits are reserved and must be reset to zero. Reserved bits must be ignored by the host.
|
||||||
|
|
||||||
struct ATTR_PACKED {
|
struct TU_ATTR_PACKED {
|
||||||
uint16_t size : 11; ///< Maximum packet size this endpoint is capable of sending or receiving when this configuration is selected. \n For isochronous endpoints, this value is used to reserve the bus time in the schedule, required for the per-(micro)frame data payloads. The pipe may, on an ongoing basis, actually use less bandwidth than that reserved. The device reports, if necessary, the actual bandwidth used via its normal, non-USB defined mechanisms. \n For all endpoints, bits 10..0 specify the maximum packet size (in bytes). \n For high-speed isochronous and interrupt endpoints: \n Bits 12..11 specify the number of additional transaction opportunities per microframe: \n- 00 = None (1 transaction per microframe) \n- 01 = 1 additional (2 per microframe) \n- 10 = 2 additional (3 per microframe) \n- 11 = Reserved \n Bits 15..13 are reserved and must be set to zero.
|
uint16_t size : 11; ///< Maximum packet size this endpoint is capable of sending or receiving when this configuration is selected. \n For isochronous endpoints, this value is used to reserve the bus time in the schedule, required for the per-(micro)frame data payloads. The pipe may, on an ongoing basis, actually use less bandwidth than that reserved. The device reports, if necessary, the actual bandwidth used via its normal, non-USB defined mechanisms. \n For all endpoints, bits 10..0 specify the maximum packet size (in bytes). \n For high-speed isochronous and interrupt endpoints: \n Bits 12..11 specify the number of additional transaction opportunities per microframe: \n- 00 = None (1 transaction per microframe) \n- 01 = 1 additional (2 per microframe) \n- 10 = 2 additional (3 per microframe) \n- 11 = Reserved \n Bits 15..13 are reserved and must be set to zero.
|
||||||
uint16_t hs_period_mult : 2;
|
uint16_t hs_period_mult : 2;
|
||||||
uint16_t : 0;
|
uint16_t : 0;
|
||||||
@@ -275,7 +275,7 @@ typedef struct ATTR_PACKED
|
|||||||
} tusb_desc_endpoint_t;
|
} tusb_desc_endpoint_t;
|
||||||
|
|
||||||
/// USB Other Speed Configuration Descriptor (section 9.6.1 table 9-11)
|
/// USB Other Speed Configuration Descriptor (section 9.6.1 table 9-11)
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t bLength ; ///< Size of descriptor
|
uint8_t bLength ; ///< Size of descriptor
|
||||||
uint8_t bDescriptorType ; ///< Other_speed_Configuration Type
|
uint8_t bDescriptorType ; ///< Other_speed_Configuration Type
|
||||||
@@ -289,7 +289,7 @@ typedef struct ATTR_PACKED
|
|||||||
} tusb_desc_other_speed_t;
|
} tusb_desc_other_speed_t;
|
||||||
|
|
||||||
/// USB Device Qualifier Descriptor (section 9.6.1 table 9-9)
|
/// USB Device Qualifier Descriptor (section 9.6.1 table 9-9)
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t bLength ; ///< Size of descriptor
|
uint8_t bLength ; ///< Size of descriptor
|
||||||
uint8_t bDescriptorType ; ///< Device Qualifier Type
|
uint8_t bDescriptorType ; ///< Device Qualifier Type
|
||||||
@@ -304,7 +304,7 @@ typedef struct ATTR_PACKED
|
|||||||
} tusb_desc_device_qualifier_t;
|
} tusb_desc_device_qualifier_t;
|
||||||
|
|
||||||
/// USB Interface Association Descriptor (IAD ECN)
|
/// USB Interface Association Descriptor (IAD ECN)
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t bLength ; ///< Size of descriptor
|
uint8_t bLength ; ///< Size of descriptor
|
||||||
uint8_t bDescriptorType ; ///< Other_speed_Configuration Type
|
uint8_t bDescriptorType ; ///< Other_speed_Configuration Type
|
||||||
@@ -320,13 +320,13 @@ typedef struct ATTR_PACKED
|
|||||||
} tusb_desc_interface_assoc_t;
|
} tusb_desc_interface_assoc_t;
|
||||||
|
|
||||||
/// USB Header Descriptor
|
/// USB Header Descriptor
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t bLength ; ///< Size of this descriptor in bytes
|
uint8_t bLength ; ///< Size of this descriptor in bytes
|
||||||
uint8_t bDescriptorType ; ///< Descriptor Type
|
uint8_t bDescriptorType ; ///< Descriptor Type
|
||||||
} tusb_desc_header_t;
|
} tusb_desc_header_t;
|
||||||
|
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
uint8_t bLength ; ///< Size of this descriptor in bytes
|
uint8_t bLength ; ///< Size of this descriptor in bytes
|
||||||
uint8_t bDescriptorType ; ///< Descriptor Type
|
uint8_t bDescriptorType ; ///< Descriptor Type
|
||||||
@@ -337,9 +337,9 @@ typedef struct ATTR_PACKED
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Types
|
/* Types
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
typedef struct ATTR_PACKED{
|
typedef struct TU_ATTR_PACKED{
|
||||||
union {
|
union {
|
||||||
struct ATTR_PACKED {
|
struct TU_ATTR_PACKED {
|
||||||
uint8_t recipient : 5; ///< Recipient type tusb_request_recipient_t.
|
uint8_t recipient : 5; ///< Recipient type tusb_request_recipient_t.
|
||||||
uint8_t type : 2; ///< Request type tusb_request_type_t.
|
uint8_t type : 2; ///< Request type tusb_request_type_t.
|
||||||
uint8_t direction : 1; ///< Direction type. tusb_dir_t
|
uint8_t direction : 1; ///< Direction type. tusb_dir_t
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ typedef enum
|
|||||||
USBD_EVENT_FUNC_CALL
|
USBD_EVENT_FUNC_CALL
|
||||||
} dcd_eventid_t;
|
} dcd_eventid_t;
|
||||||
|
|
||||||
typedef struct ATTR_ALIGNED(4)
|
typedef struct TU_ATTR_ALIGNED(4)
|
||||||
{
|
{
|
||||||
uint8_t rhport;
|
uint8_t rhport;
|
||||||
uint8_t event_id;
|
uint8_t event_id;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
// Device Data
|
// Device Data
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct ATTR_PACKED
|
struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
volatile uint8_t connected : 1;
|
volatile uint8_t connected : 1;
|
||||||
volatile uint8_t configured : 1;
|
volatile uint8_t configured : 1;
|
||||||
|
|||||||
@@ -76,17 +76,17 @@ uint8_t const * tud_descriptor_configuration_cb(uint8_t index);
|
|||||||
uint16_t const* tud_descriptor_string_cb(uint8_t index);
|
uint16_t const* tud_descriptor_string_cb(uint8_t index);
|
||||||
|
|
||||||
// Invoked when device is mounted (configured)
|
// Invoked when device is mounted (configured)
|
||||||
ATTR_WEAK void tud_mount_cb(void);
|
TU_ATTR_WEAK void tud_mount_cb(void);
|
||||||
|
|
||||||
// Invoked when device is unmounted
|
// Invoked when device is unmounted
|
||||||
ATTR_WEAK void tud_umount_cb(void);
|
TU_ATTR_WEAK void tud_umount_cb(void);
|
||||||
|
|
||||||
// Invoked when usb bus is suspended
|
// Invoked when usb bus is suspended
|
||||||
// Within 7ms, device must draw an average of current less than 2.5 mA from bus
|
// Within 7ms, device must draw an average of current less than 2.5 mA from bus
|
||||||
ATTR_WEAK void tud_suspend_cb(bool remote_wakeup_en);
|
TU_ATTR_WEAK void tud_suspend_cb(bool remote_wakeup_en);
|
||||||
|
|
||||||
// Invoked when usb bus is resumed
|
// Invoked when usb bus is resumed
|
||||||
ATTR_WEAK void tud_resume_cb(void);
|
TU_ATTR_WEAK void tud_resume_cb(void);
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Interface Descriptor Template
|
// Interface Descriptor Template
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Periodic frame list must be 4K alignment
|
// Periodic frame list must be 4K alignment
|
||||||
CFG_TUSB_MEM_SECTION ATTR_ALIGNED(4096) static ehci_data_t ehci_data;
|
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4096) static ehci_data_t ehci_data;
|
||||||
|
|
||||||
// EHCI portable
|
// EHCI portable
|
||||||
uint32_t hcd_ehci_register_addr(uint8_t rhport);
|
uint32_t hcd_ehci_register_addr(uint8_t rhport);
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ typedef union {
|
|||||||
}ehci_link_t;
|
}ehci_link_t;
|
||||||
|
|
||||||
/// Queue Element Transfer Descriptor
|
/// Queue Element Transfer Descriptor
|
||||||
/// Qtd is used to declare overlay in ehci_qhd_t -> cannot be declared with ATTR_ALIGNED(32)
|
/// Qtd is used to declare overlay in ehci_qhd_t -> cannot be declared with TU_ATTR_ALIGNED(32)
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
// Word 0: Next QTD Pointer
|
// Word 0: Next QTD Pointer
|
||||||
@@ -137,7 +137,7 @@ typedef struct
|
|||||||
TU_VERIFY_STATIC( sizeof(ehci_qtd_t) == 32, "size is not correct" );
|
TU_VERIFY_STATIC( sizeof(ehci_qtd_t) == 32, "size is not correct" );
|
||||||
|
|
||||||
/// Queue Head
|
/// Queue Head
|
||||||
typedef struct ATTR_ALIGNED(32)
|
typedef struct TU_ATTR_ALIGNED(32)
|
||||||
{
|
{
|
||||||
// Word 0: Next QHD
|
// Word 0: Next QHD
|
||||||
ehci_link_t next;
|
ehci_link_t next;
|
||||||
@@ -185,7 +185,7 @@ typedef struct ATTR_ALIGNED(32)
|
|||||||
TU_VERIFY_STATIC( sizeof(ehci_qhd_t) == 64, "size is not correct" );
|
TU_VERIFY_STATIC( sizeof(ehci_qhd_t) == 64, "size is not correct" );
|
||||||
|
|
||||||
/// Highspeed Isochronous Transfer Descriptor (section 3.3)
|
/// Highspeed Isochronous Transfer Descriptor (section 3.3)
|
||||||
typedef struct ATTR_ALIGNED(32) {
|
typedef struct TU_ATTR_ALIGNED(32) {
|
||||||
// Word 0: Next Link Pointer
|
// Word 0: Next Link Pointer
|
||||||
ehci_link_t next;
|
ehci_link_t next;
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ typedef struct ATTR_ALIGNED(32) {
|
|||||||
TU_VERIFY_STATIC( sizeof(ehci_itd_t) == 64, "size is not correct" );
|
TU_VERIFY_STATIC( sizeof(ehci_itd_t) == 64, "size is not correct" );
|
||||||
|
|
||||||
/// Split (Full-Speed) Isochronous Transfer Descriptor
|
/// Split (Full-Speed) Isochronous Transfer Descriptor
|
||||||
typedef struct ATTR_ALIGNED(32)
|
typedef struct TU_ATTR_ALIGNED(32)
|
||||||
{
|
{
|
||||||
// Word 0: Next Link Pointer
|
// Word 0: Next Link Pointer
|
||||||
ehci_link_t next;
|
ehci_link_t next;
|
||||||
@@ -442,7 +442,7 @@ typedef struct
|
|||||||
}control[CFG_TUSB_HOST_DEVICE_MAX+1];
|
}control[CFG_TUSB_HOST_DEVICE_MAX+1];
|
||||||
|
|
||||||
ehci_qhd_t qhd_pool[HCD_MAX_ENDPOINT];
|
ehci_qhd_t qhd_pool[HCD_MAX_ENDPOINT];
|
||||||
ehci_qtd_t qtd_pool[HCD_MAX_XFER] ATTR_ALIGNED(32);
|
ehci_qtd_t qtd_pool[HCD_MAX_XFER] TU_ATTR_ALIGNED(32);
|
||||||
|
|
||||||
ehci_registers_t* regs;
|
ehci_registers_t* regs;
|
||||||
}ehci_data_t;
|
}ehci_data_t;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ typedef struct
|
|||||||
}usbh_hub_t;
|
}usbh_hub_t;
|
||||||
|
|
||||||
CFG_TUSB_MEM_SECTION static usbh_hub_t hub_data[CFG_TUSB_HOST_DEVICE_MAX];
|
CFG_TUSB_MEM_SECTION static usbh_hub_t hub_data[CFG_TUSB_HOST_DEVICE_MAX];
|
||||||
ATTR_ALIGNED(4) CFG_TUSB_MEM_SECTION static uint8_t hub_enum_buffer[sizeof(descriptor_hub_desc_t)];
|
TU_ATTR_ALIGNED(4) CFG_TUSB_MEM_SECTION static uint8_t hub_enum_buffer[sizeof(descriptor_hub_desc_t)];
|
||||||
|
|
||||||
//OSAL_SEM_DEF(hub_enum_semaphore);
|
//OSAL_SEM_DEF(hub_enum_semaphore);
|
||||||
//static osal_semaphore_handle_t hub_enum_sem_hdl;
|
//static osal_semaphore_handle_t hub_enum_sem_hdl;
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
//indicators. See Section 11.5.3.
|
//indicators. See Section 11.5.3.
|
||||||
//D15...D8: Reserved
|
//D15...D8: Reserved
|
||||||
|
|
||||||
typedef struct ATTR_PACKED{
|
typedef struct TU_ATTR_PACKED{
|
||||||
uint8_t bLength ; ///< Size of descriptor
|
uint8_t bLength ; ///< Size of descriptor
|
||||||
uint8_t bDescriptorType ; ///< Other_speed_Configuration Type
|
uint8_t bDescriptorType ; ///< Other_speed_Configuration Type
|
||||||
uint8_t bNbrPorts;
|
uint8_t bNbrPorts;
|
||||||
@@ -135,7 +135,7 @@ enum{
|
|||||||
// data in response of HUB_REQUEST_GET_STATUS, wIndex = 0 (hub)
|
// data in response of HUB_REQUEST_GET_STATUS, wIndex = 0 (hub)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
union{
|
union{
|
||||||
struct ATTR_PACKED {
|
struct TU_ATTR_PACKED {
|
||||||
uint16_t local_power_source : 1;
|
uint16_t local_power_source : 1;
|
||||||
uint16_t over_current : 1;
|
uint16_t over_current : 1;
|
||||||
uint16_t : 14;
|
uint16_t : 14;
|
||||||
@@ -150,7 +150,7 @@ TU_VERIFY_STATIC( sizeof(hub_status_response_t) == 4, "size is not correct");
|
|||||||
// data in response of HUB_REQUEST_GET_STATUS, wIndex = Port num
|
// data in response of HUB_REQUEST_GET_STATUS, wIndex = Port num
|
||||||
typedef struct {
|
typedef struct {
|
||||||
union {
|
union {
|
||||||
struct ATTR_PACKED {
|
struct TU_ATTR_PACKED {
|
||||||
uint16_t connect_status : 1;
|
uint16_t connect_status : 1;
|
||||||
uint16_t port_enable : 1;
|
uint16_t port_enable : 1;
|
||||||
uint16_t suspend : 1;
|
uint16_t suspend : 1;
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ enum {
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
CFG_TUSB_MEM_SECTION ATTR_ALIGNED(256) static ohci_data_t ohci_data;
|
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(256) static ohci_data_t ohci_data;
|
||||||
|
|
||||||
static ohci_ed_t * const p_ed_head[] =
|
static ohci_ed_t * const p_ed_head[] =
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ typedef struct {
|
|||||||
volatile uint16_t frame_pad;
|
volatile uint16_t frame_pad;
|
||||||
volatile uint32_t done_head;
|
volatile uint32_t done_head;
|
||||||
uint8_t reserved[116+4]; // TODO try to make use of this area if possible, extra 4 byte to make the whole struct size = 256
|
uint8_t reserved[116+4]; // TODO try to make use of this area if possible, extra 4 byte to make the whole struct size = 256
|
||||||
}ohci_hcca_t; // ATTR_ALIGNED(256)
|
}ohci_hcca_t; // TU_ATTR_ALIGNED(256)
|
||||||
|
|
||||||
TU_VERIFY_STATIC( sizeof(ohci_hcca_t) == 256, "size is not correct" );
|
TU_VERIFY_STATIC( sizeof(ohci_hcca_t) == 256, "size is not correct" );
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ typedef struct {
|
|||||||
}ohci_td_item_t;
|
}ohci_td_item_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct ATTR_ALIGNED(16)
|
typedef struct TU_ATTR_ALIGNED(16)
|
||||||
{
|
{
|
||||||
// Word 0
|
// Word 0
|
||||||
uint32_t used : 1;
|
uint32_t used : 1;
|
||||||
@@ -102,7 +102,7 @@ typedef struct ATTR_ALIGNED(16)
|
|||||||
|
|
||||||
TU_VERIFY_STATIC( sizeof(ohci_gtd_t) == 16, "size is not correct" );
|
TU_VERIFY_STATIC( sizeof(ohci_gtd_t) == 16, "size is not correct" );
|
||||||
|
|
||||||
typedef struct ATTR_ALIGNED(16)
|
typedef struct TU_ATTR_ALIGNED(16)
|
||||||
{
|
{
|
||||||
// Word 0
|
// Word 0
|
||||||
uint32_t dev_addr : 7;
|
uint32_t dev_addr : 7;
|
||||||
@@ -137,7 +137,7 @@ typedef struct ATTR_ALIGNED(16)
|
|||||||
|
|
||||||
TU_VERIFY_STATIC( sizeof(ohci_ed_t) == 16, "size is not correct" );
|
TU_VERIFY_STATIC( sizeof(ohci_ed_t) == 16, "size is not correct" );
|
||||||
|
|
||||||
typedef struct ATTR_ALIGNED(32)
|
typedef struct TU_ATTR_ALIGNED(32)
|
||||||
{
|
{
|
||||||
/*---------- Word 1 ----------*/
|
/*---------- Word 1 ----------*/
|
||||||
uint32_t starting_frame : 16;
|
uint32_t starting_frame : 16;
|
||||||
@@ -163,7 +163,7 @@ typedef struct ATTR_ALIGNED(32)
|
|||||||
TU_VERIFY_STATIC( sizeof(ochi_itd_t) == 32, "size is not correct" );
|
TU_VERIFY_STATIC( sizeof(ochi_itd_t) == 32, "size is not correct" );
|
||||||
|
|
||||||
// structure with member alignment required from large to small
|
// structure with member alignment required from large to small
|
||||||
typedef struct ATTR_ALIGNED(256)
|
typedef struct TU_ATTR_ALIGNED(256)
|
||||||
{
|
{
|
||||||
ohci_hcca_t hcca;
|
ohci_hcca_t hcca;
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ CFG_TUSB_MEM_SECTION usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
|
|||||||
OSAL_QUEUE_DEF(OPT_MODE_HOST, _usbh_qdef, CFG_TUH_TASK_QUEUE_SZ, hcd_event_t);
|
OSAL_QUEUE_DEF(OPT_MODE_HOST, _usbh_qdef, CFG_TUH_TASK_QUEUE_SZ, hcd_event_t);
|
||||||
static osal_queue_t _usbh_q;
|
static osal_queue_t _usbh_q;
|
||||||
|
|
||||||
CFG_TUSB_MEM_SECTION ATTR_ALIGNED(4) static uint8_t _usbh_ctrl_buf[CFG_TUSB_HOST_ENUM_BUFFER_SIZE];
|
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4) static uint8_t _usbh_ctrl_buf[CFG_TUSB_HOST_ENUM_BUFFER_SIZE];
|
||||||
|
|
||||||
//------------- Reporter Task Data -------------//
|
//------------- Reporter Task Data -------------//
|
||||||
|
|
||||||
|
|||||||
@@ -77,13 +77,13 @@ static inline bool tuh_device_is_configured(uint8_t dev_addr)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// APPLICATION CALLBACK
|
// APPLICATION CALLBACK
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
ATTR_WEAK uint8_t tuh_device_attached_cb (tusb_desc_device_t const *p_desc_device);
|
TU_ATTR_WEAK uint8_t tuh_device_attached_cb (tusb_desc_device_t const *p_desc_device);
|
||||||
|
|
||||||
/** Callback invoked when device is mounted (configured) */
|
/** Callback invoked when device is mounted (configured) */
|
||||||
ATTR_WEAK void tuh_mount_cb (uint8_t dev_addr);
|
TU_ATTR_WEAK void tuh_mount_cb (uint8_t dev_addr);
|
||||||
|
|
||||||
/** Callback invoked when device is unmounted (bus reset/unplugged) */
|
/** Callback invoked when device is unmounted (bus reset/unplugged) */
|
||||||
ATTR_WEAK void tuh_umount_cb(uint8_t dev_addr);
|
TU_ATTR_WEAK void tuh_umount_cb(uint8_t dev_addr);
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// CLASS-USBH & INTERNAL API
|
// CLASS-USBH & INTERNAL API
|
||||||
|
|||||||
@@ -34,8 +34,8 @@
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* MACRO TYPEDEF CONSTANT ENUM
|
/* MACRO TYPEDEF CONSTANT ENUM
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
static ATTR_ALIGNED(4) UsbDeviceDescBank sram_registers[8][2];
|
static TU_ATTR_ALIGNED(4) UsbDeviceDescBank sram_registers[8][2];
|
||||||
static ATTR_ALIGNED(4) uint8_t _setup_packet[8];
|
static TU_ATTR_ALIGNED(4) uint8_t _setup_packet[8];
|
||||||
|
|
||||||
// Setup the control endpoint 0.
|
// Setup the control endpoint 0.
|
||||||
static void bus_reset(void)
|
static void bus_reset(void)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
/* MACRO TYPEDEF CONSTANT ENUM
|
/* MACRO TYPEDEF CONSTANT ENUM
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
static UsbDeviceDescBank sram_registers[8][2];
|
static UsbDeviceDescBank sram_registers[8][2];
|
||||||
static ATTR_ALIGNED(4) uint8_t _setup_packet[8];
|
static TU_ATTR_ALIGNED(4) uint8_t _setup_packet[8];
|
||||||
|
|
||||||
// Setup the control endpoint 0.
|
// Setup the control endpoint 0.
|
||||||
static void bus_reset(void)
|
static void bus_reset(void)
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ enum {
|
|||||||
CMDSTAT_VBUS_DEBOUNCED_MASK = TU_BIT(28),
|
CMDSTAT_VBUS_DEBOUNCED_MASK = TU_BIT(28),
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct ATTR_PACKED
|
typedef struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
// Bits 21:6 (aligned 64) used in conjunction with bit 31:22 of DATABUFSTART
|
// Bits 21:6 (aligned 64) used in conjunction with bit 31:22 of DATABUFSTART
|
||||||
volatile uint16_t buffer_offset;
|
volatile uint16_t buffer_offset;
|
||||||
@@ -101,7 +101,7 @@ typedef struct
|
|||||||
|
|
||||||
xfer_dma_t dma[EP_COUNT];
|
xfer_dma_t dma[EP_COUNT];
|
||||||
|
|
||||||
ATTR_ALIGNED(64) uint8_t setup_packet[8];
|
TU_ATTR_ALIGNED(64) uint8_t setup_packet[8];
|
||||||
}dcd_data_t;
|
}dcd_data_t;
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
@@ -109,7 +109,7 @@ typedef struct
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// EP list must be 256-byte aligned
|
// EP list must be 256-byte aligned
|
||||||
CFG_TUSB_MEM_SECTION ATTR_ALIGNED(256) static dcd_data_t _dcd;
|
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(256) static dcd_data_t _dcd;
|
||||||
|
|
||||||
static inline uint16_t get_buf_offset(void const * buffer)
|
static inline uint16_t get_buf_offset(void const * buffer)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#define DCD_ENDPOINT_MAX 32
|
#define DCD_ENDPOINT_MAX 32
|
||||||
|
|
||||||
typedef struct ATTR_ALIGNED(4)
|
typedef struct TU_ATTR_ALIGNED(4)
|
||||||
{
|
{
|
||||||
//------------- Word 0 -------------//
|
//------------- Word 0 -------------//
|
||||||
uint32_t next;
|
uint32_t next;
|
||||||
@@ -91,7 +91,7 @@ typedef struct
|
|||||||
|
|
||||||
} dcd_data_t;
|
} dcd_data_t;
|
||||||
|
|
||||||
CFG_TUSB_MEM_SECTION ATTR_ALIGNED(128) static dcd_data_t _dcd;
|
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(128) static dcd_data_t _dcd;
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|||||||
@@ -46,16 +46,16 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// Must be at 2K alignment
|
// Must be at 2K alignment
|
||||||
dcd_qhd_t qhd[QHD_MAX] ATTR_ALIGNED(64);
|
dcd_qhd_t qhd[QHD_MAX] TU_ATTR_ALIGNED(64);
|
||||||
dcd_qtd_t qtd[QHD_MAX] ATTR_ALIGNED(32);
|
dcd_qtd_t qtd[QHD_MAX] TU_ATTR_ALIGNED(32);
|
||||||
}dcd_data_t;
|
}dcd_data_t;
|
||||||
|
|
||||||
#if (CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE)
|
#if (CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE)
|
||||||
CFG_TUSB_MEM_SECTION ATTR_ALIGNED(2048) static dcd_data_t dcd_data0;
|
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(2048) static dcd_data_t dcd_data0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE)
|
#if (CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE)
|
||||||
CFG_TUSB_MEM_SECTION ATTR_ALIGNED(2048) static dcd_data_t dcd_data1;
|
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(2048) static dcd_data_t dcd_data1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static LPC_USBHS_T * const LPC_USB[2] = { LPC_USB0, LPC_USB1 };
|
static LPC_USBHS_T * const LPC_USB[2] = { LPC_USB0, LPC_USB1 };
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
#define IN_EP_BASE (USB_OTG_INEndpointTypeDef *) (USB_OTG_FS_PERIPH_BASE + USB_OTG_IN_ENDPOINT_BASE)
|
#define IN_EP_BASE (USB_OTG_INEndpointTypeDef *) (USB_OTG_FS_PERIPH_BASE + USB_OTG_IN_ENDPOINT_BASE)
|
||||||
#define FIFO_BASE(_x) (uint32_t *) (USB_OTG_FS_PERIPH_BASE + USB_OTG_FIFO_BASE + (_x) * USB_OTG_FIFO_SIZE)
|
#define FIFO_BASE(_x) (uint32_t *) (USB_OTG_FS_PERIPH_BASE + USB_OTG_FIFO_BASE + (_x) * USB_OTG_FIFO_SIZE)
|
||||||
|
|
||||||
static ATTR_ALIGNED(4) uint32_t _setup_packet[6];
|
static TU_ATTR_ALIGNED(4) uint32_t _setup_packet[6];
|
||||||
static uint8_t _setup_offs; // We store up to 3 setup packets.
|
static uint8_t _setup_offs; // We store up to 3 setup packets.
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
@@ -131,7 +131,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4)
|
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ void tearDown(void)
|
|||||||
void test_struct_alignment(void)
|
void test_struct_alignment(void)
|
||||||
{
|
{
|
||||||
TEST_ASSERT_EQUAL( 32, __alignof__(ehci_qhd_t) );
|
TEST_ASSERT_EQUAL( 32, __alignof__(ehci_qhd_t) );
|
||||||
// TEST_ASSERT_EQUAL( 32, __alignof__(ehci_qtd_t) ); ehci_qtd_t is used to declare overlay variable in qhd --> cannot declare with ATTR_ALIGNED(32)
|
// TEST_ASSERT_EQUAL( 32, __alignof__(ehci_qtd_t) ); ehci_qtd_t is used to declare overlay variable in qhd --> cannot declare with TU_ATTR_ALIGNED(32)
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL( 32, __alignof__(ehci_itd_t) );
|
TEST_ASSERT_EQUAL( 32, __alignof__(ehci_itd_t) );
|
||||||
TEST_ASSERT_EQUAL( 32, __alignof__(ehci_sitd_t) );
|
TEST_ASSERT_EQUAL( 32, __alignof__(ehci_sitd_t) );
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include "tusb_option.h"
|
#include "tusb_option.h"
|
||||||
#include "descriptor_test.h"
|
#include "descriptor_test.h"
|
||||||
|
|
||||||
CFG_TUSB_MEM_SECTION ATTR_ALIGNED(4)
|
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4)
|
||||||
const uint8_t keyboard_report_descriptor[] = {
|
const uint8_t keyboard_report_descriptor[] = {
|
||||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
|
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
|
||||||
HID_USAGE ( HID_USAGE_DESKTOP_KEYBOARD ),
|
HID_USAGE ( HID_USAGE_DESKTOP_KEYBOARD ),
|
||||||
@@ -69,7 +69,7 @@ const uint8_t keyboard_report_descriptor[] = {
|
|||||||
HID_COLLECTION_END
|
HID_COLLECTION_END
|
||||||
};
|
};
|
||||||
|
|
||||||
CFG_TUSB_MEM_SECTION ATTR_ALIGNED(4)
|
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4)
|
||||||
const uint8_t mouse_report_descriptor[] = {
|
const uint8_t mouse_report_descriptor[] = {
|
||||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
|
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
|
||||||
HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ),
|
HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ),
|
||||||
@@ -106,7 +106,7 @@ const uint8_t mouse_report_descriptor[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
CFG_TUSB_MEM_SECTION ATTR_ALIGNED(4)
|
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4)
|
||||||
tusb_desc_device_t const desc_device =
|
tusb_desc_device_t const desc_device =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(tusb_desc_device_t),
|
.bLength = sizeof(tusb_desc_device_t),
|
||||||
@@ -130,7 +130,7 @@ tusb_desc_device_t const desc_device =
|
|||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
CFG_TUSB_MEM_SECTION ATTR_ALIGNED(4)
|
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4)
|
||||||
const app_configuration_desc_t desc_configuration =
|
const app_configuration_desc_t desc_configuration =
|
||||||
{
|
{
|
||||||
.configuration =
|
.configuration =
|
||||||
|
|||||||
@@ -48,9 +48,9 @@
|
|||||||
#include "usbh.h"
|
#include "usbh.h"
|
||||||
|
|
||||||
//------------- core -------------//
|
//------------- core -------------//
|
||||||
uint8_t tusbh_device_attached_cb (tusb_desc_device_t const *p_desc_device) ATTR_WEAK;
|
uint8_t tusbh_device_attached_cb (tusb_desc_device_t const *p_desc_device) TU_ATTR_WEAK;
|
||||||
void tusbh_device_mount_succeed_cb (uint8_t dev_addr) ATTR_WEAK;
|
void tusbh_device_mount_succeed_cb (uint8_t dev_addr) TU_ATTR_WEAK;
|
||||||
void tusbh_device_mount_failed_cb(tusb_error_t error, tusb_desc_device_t const *p_desc_device) ATTR_WEAK;
|
void tusbh_device_mount_failed_cb(tusb_error_t error, tusb_desc_device_t const *p_desc_device) TU_ATTR_WEAK;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user