diff --git a/.gitignore b/.gitignore index c2fa0f161..6d306198d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ test_old tests/build *.d *.o +*.P *.launch *.map *.axf diff --git a/examples/device/cdc_msc_hid/src/tusb_config.h b/examples/device/cdc_msc_hid/src/tusb_config.h index 8981077d3..6b1f0700b 100644 --- a/examples/device/cdc_msc_hid/src/tusb_config.h +++ b/examples/device/cdc_msc_hid/src/tusb_config.h @@ -62,7 +62,7 @@ #endif #ifndef CFG_TUSB_MEM_ALIGN -#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4) +#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4) #endif //-------------------------------------------------------------------- diff --git a/examples/device/cdc_msc_hid_freertos/src/tusb_config.h b/examples/device/cdc_msc_hid_freertos/src/tusb_config.h index dfa8be629..b4e18de92 100644 --- a/examples/device/cdc_msc_hid_freertos/src/tusb_config.h +++ b/examples/device/cdc_msc_hid_freertos/src/tusb_config.h @@ -62,7 +62,7 @@ #endif #ifndef CFG_TUSB_MEM_ALIGN -#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4) +#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4) #endif //-------------------------------------------------------------------- diff --git a/examples/device/hid_generic_inout/src/tusb_config.h b/examples/device/hid_generic_inout/src/tusb_config.h index acd23f954..dc7d98812 100644 --- a/examples/device/hid_generic_inout/src/tusb_config.h +++ b/examples/device/hid_generic_inout/src/tusb_config.h @@ -62,7 +62,7 @@ #endif #ifndef CFG_TUSB_MEM_ALIGN -#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4) +#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4) #endif //-------------------------------------------------------------------- diff --git a/examples/device/msc_dual_lun/src/tusb_config.h b/examples/device/msc_dual_lun/src/tusb_config.h index fe30fbf20..ae57b4d60 100644 --- a/examples/device/msc_dual_lun/src/tusb_config.h +++ b/examples/device/msc_dual_lun/src/tusb_config.h @@ -62,7 +62,7 @@ #endif #ifndef CFG_TUSB_MEM_ALIGN -#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4) +#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4) #endif //-------------------------------------------------------------------- diff --git a/examples/host/cdc_msc_hid/src/tusb_config.h b/examples/host/cdc_msc_hid/src/tusb_config.h index 144efa519..9662223b1 100644 --- a/examples/host/cdc_msc_hid/src/tusb_config.h +++ b/examples/host/cdc_msc_hid/src/tusb_config.h @@ -63,7 +63,7 @@ #endif #ifndef CFG_TUSB_MEM_ALIGN -#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4) +#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4) #endif //-------------------------------------------------------------------- diff --git a/examples/obsolete/host/src/tusb_config.h b/examples/obsolete/host/src/tusb_config.h index d88da4bb4..a025e9091 100644 --- a/examples/obsolete/host/src/tusb_config.h +++ b/examples/obsolete/host/src/tusb_config.h @@ -67,7 +67,7 @@ #if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X #define CFG_TUSB_MEM_SECTION // LPC17xx USB DMA can access all address #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 #elif defined __CC_ARM // Compiled with Keil armcc 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.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]; diff --git a/src/class/hid/hid.h b/src/class/hid/hid.h index 902c01ef5..04b255ea8 100644 --- a/src/class/hid/hid.h +++ b/src/class/hid/hid.h @@ -44,7 +44,7 @@ * @{ */ /// 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 bDescriptorType; /**< Constant name specifying type of HID descriptor. */ @@ -150,7 +150,7 @@ typedef enum * @{ */ /// 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. */ int8_t x; /**< Current delta x movement of the mouse. */ @@ -178,7 +178,7 @@ typedef enum * @{ */ /// 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 reserved; /**< Reserved for OEM use, always set to 0. */ diff --git a/src/class/hid/hid_device.h b/src/class/hid/hid_device.h index be7999770..75cc0969d 100644 --- a/src/class/hid/hid_device.h +++ b/src/class/hid/hid_device.h @@ -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); // 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 // - 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). -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 diff --git a/src/class/midi/midi.h b/src/class/midi/midi.h index ee318f788..50f2be679 100644 --- a/src/class/midi/midi.h +++ b/src/class/midi/midi.h @@ -42,7 +42,7 @@ // 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 @@ -52,7 +52,7 @@ typedef struct ATTR_PACKED }midi_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 diff --git a/src/class/midi/midi_device.h b/src/class/midi/midi_device.h index 84f4c57bd..45e009010 100644 --- a/src/class/midi/midi_device.h +++ b/src/class/midi/midi_device.h @@ -82,7 +82,7 @@ static inline bool tud_midi_write_flush (void) //--------------------------------------------------------------------+ // 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 diff --git a/src/class/msc/msc.h b/src/class/msc/msc.h index 95fac6598..d461513fc 100644 --- a/src/class/msc/msc.h +++ b/src/class/msc/msc.h @@ -86,7 +86,7 @@ typedef enum }msc_csw_status_t; /// 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 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"); /// 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 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 -typedef struct ATTR_PACKED +typedef struct TU_ATTR_PACKED { uint8_t cmd_code ; ///< SCSI OpCode for \ref SCSI_CMD_TEST_UNIT_READY 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"); /// 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 reserved1 ; @@ -177,7 +177,7 @@ typedef struct ATTR_PACKED TU_VERIFY_STATIC(sizeof(scsi_inquiry_t) == 6, "size is not correct"); /// SCSI Inquiry Response Data -typedef struct ATTR_PACKED +typedef struct TU_ATTR_PACKED { uint8_t peripheral_device_type : 5; 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"); -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 valid : 1; @@ -249,7 +249,7 @@ typedef struct ATTR_PACKED 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 @@ -268,7 +268,7 @@ typedef struct ATTR_PACKED TU_VERIFY_STATIC( sizeof(scsi_mode_sense6_t) == 6, "size is not correct"); // This is only a Mode parameter header(6). -typedef struct ATTR_PACKED +typedef struct TU_ATTR_PACKED { uint8_t data_len; 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"); -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 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"); -typedef struct ATTR_PACKED +typedef struct TU_ATTR_PACKED { 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 Read Format Capacity: Write Capacity -typedef struct ATTR_PACKED +typedef struct TU_ATTR_PACKED { uint8_t cmd_code; 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"); -typedef struct ATTR_PACKED{ +typedef struct TU_ATTR_PACKED{ uint8_t reserved[3]; 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 -typedef struct ATTR_PACKED +typedef struct TU_ATTR_PACKED { uint8_t cmd_code ; ///< SCSI OpCode for \ref SCSI_CMD_READ_CAPACITY_10 uint8_t reserved1 ; @@ -369,7 +369,7 @@ typedef struct { TU_VERIFY_STATIC(sizeof(scsi_read_capacity10_resp_t) == 8, "size is not correct"); /// SCSI Read 10 Command -typedef struct ATTR_PACKED +typedef struct TU_ATTR_PACKED { uint8_t cmd_code ; ///< SCSI OpCode uint8_t reserved ; // has LUN according to wiki diff --git a/src/class/msc/msc_device.h b/src/class/msc/msc_device.h index cf228dad9..03a4afadb 100644 --- a/src/class/msc/msc_device.h +++ b/src/class/msc/msc_device.h @@ -126,24 +126,24 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, /*------------- Optional callbacks -------------*/ // 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 // - Start = 0 : stopped power mode, if load_eject = 1 : unload 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 -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 -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 -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 -ATTR_WEAK bool tud_msc_is_writable_cb(uint8_t lun); +TU_ATTR_WEAK bool tud_msc_is_writable_cb(uint8_t lun); /** @} */ /** @} */ diff --git a/src/class/msc/msc_host.c b/src/class/msc/msc_host.c index d2a1a00f7..0507c5f6d 100644 --- a/src/class/msc/msc_host.c +++ b/src/class/msc/msc_host.c @@ -44,7 +44,7 @@ static osal_semaphore_def_t msch_sem_def; static osal_semaphore_t msch_sem_hdl; // 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 diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h index 4b74bcfc0..c77be2a9f 100644 --- a/src/common/tusb_common.h +++ b/src/common/tusb_common.h @@ -57,9 +57,6 @@ #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 //--------------------------------------------------------------------+ diff --git a/src/common/tusb_compiler.h b/src/common/tusb_compiler.h index 0978d1c0f..09768ef88 100644 --- a/src/common/tusb_compiler.h +++ b/src/common/tusb_compiler.h @@ -32,10 +32,10 @@ #ifndef _TUSB_COMPILER_H_ #define _TUSB_COMPILER_H_ -#define STRING_(x) #x ///< stringify without expand -#define XSTRING_(x) STRING_(x) ///< expand then stringify -#define STRING_CONCAT_(a, b) a##b ///< concat without expand -#define XSTRING_CONCAT_(a, b) STRING_CONCAT_(a, b) ///< expand then concat +#define TU_STRING(x) #x ///< stringify without expand +#define TU_XSTRING(x) TU_STRING(x) ///< expand then stringify +#define TU_STRCAT(a, b) a##b ///< concat without expand +#define TU_XSTRCAT(a, b) TU_STRCAT(a, b) ///< expand then concat #if defined __COUNTER__ && __COUNTER__ != __COUNTER__ #define _TU_COUNTER_ __COUNTER__ @@ -47,20 +47,23 @@ #if __STDC_VERSION__ >= 201112L #define TU_VERIFY_STATIC _Static_assert #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 +// for declaration of reserved field, make use of _TU_COUNTER_ +#define TU_RESERVED TU_XSTRCAT(reserved, _TU_COUNTER_) + //--------------------------------------------------------------------+ // Compiler porting with Attribute and Endian //--------------------------------------------------------------------+ #if defined(__GNUC__) - #define ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes))) - #define ATTR_SECTION(sec_name) __attribute__ ((section(#sec_name))) - #define ATTR_PACKED __attribute__ ((packed)) - #define ATTR_PREPACKED - #define ATTR_WEAK __attribute__ ((weak)) - #define 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_ALIGNED(Bytes) __attribute__ ((aligned(Bytes))) + #define TU_ATTR_SECTION(sec_name) __attribute__ ((section(#sec_name))) + #define TU_ATTR_PACKED __attribute__ ((packed)) + #define TU_ATTR_PREPACKED + #define TU_ATTR_WEAK __attribute__ ((weak)) + #define TU_ATTR_DEPRECATED(mess) __attribute__ ((deprecated(mess))) // warn if function with this attribute is used + #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 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ diff --git a/src/common/tusb_types.h b/src/common/tusb_types.h index 786533849..34ad26f15 100644 --- a/src/common/tusb_types.h +++ b/src/common/tusb_types.h @@ -200,7 +200,7 @@ enum //--------------------------------------------------------------------+ /// 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 bDescriptorType ; ///< DEVICE Descriptor Type. @@ -222,7 +222,7 @@ typedef struct ATTR_PACKED } tusb_desc_device_t; /// 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 bDescriptorType ; ///< CONFIGURATION Descriptor Type @@ -236,7 +236,7 @@ typedef struct ATTR_PACKED } tusb_desc_configuration_t; /// 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 bDescriptorType ; ///< INTERFACE Descriptor Type @@ -251,21 +251,21 @@ typedef struct ATTR_PACKED } tusb_desc_interface_t; /// 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 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. - struct ATTR_PACKED { + struct TU_ATTR_PACKED { uint8_t xfer : 2; uint8_t sync : 2; uint8_t usage : 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. - 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 hs_period_mult : 2; uint16_t : 0; @@ -275,7 +275,7 @@ typedef struct ATTR_PACKED } tusb_desc_endpoint_t; /// 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 bDescriptorType ; ///< Other_speed_Configuration Type @@ -289,7 +289,7 @@ typedef struct ATTR_PACKED } tusb_desc_other_speed_t; /// 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 bDescriptorType ; ///< Device Qualifier Type @@ -304,7 +304,7 @@ typedef struct ATTR_PACKED } tusb_desc_device_qualifier_t; /// USB Interface Association Descriptor (IAD ECN) -typedef struct ATTR_PACKED +typedef struct TU_ATTR_PACKED { uint8_t bLength ; ///< Size of descriptor uint8_t bDescriptorType ; ///< Other_speed_Configuration Type @@ -320,13 +320,13 @@ typedef struct ATTR_PACKED } tusb_desc_interface_assoc_t; /// USB Header Descriptor -typedef struct ATTR_PACKED +typedef struct TU_ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes uint8_t bDescriptorType ; ///< Descriptor Type } tusb_desc_header_t; -typedef struct ATTR_PACKED +typedef struct TU_ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes uint8_t bDescriptorType ; ///< Descriptor Type @@ -337,9 +337,9 @@ typedef struct ATTR_PACKED /*------------------------------------------------------------------*/ /* Types *------------------------------------------------------------------*/ -typedef struct ATTR_PACKED{ +typedef struct TU_ATTR_PACKED{ union { - struct ATTR_PACKED { + struct TU_ATTR_PACKED { uint8_t recipient : 5; ///< Recipient type tusb_request_recipient_t. uint8_t type : 2; ///< Request type tusb_request_type_t. uint8_t direction : 1; ///< Direction type. tusb_dir_t diff --git a/src/device/dcd.h b/src/device/dcd.h index bd7088fe4..0ed4a77d9 100644 --- a/src/device/dcd.h +++ b/src/device/dcd.h @@ -52,7 +52,7 @@ typedef enum USBD_EVENT_FUNC_CALL } dcd_eventid_t; -typedef struct ATTR_ALIGNED(4) +typedef struct TU_ATTR_ALIGNED(4) { uint8_t rhport; uint8_t event_id; diff --git a/src/device/usbd.c b/src/device/usbd.c index e22de4728..38838b61f 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -40,7 +40,7 @@ // Device Data //--------------------------------------------------------------------+ typedef struct { - struct ATTR_PACKED + struct TU_ATTR_PACKED { volatile uint8_t connected : 1; volatile uint8_t configured : 1; diff --git a/src/device/usbd.h b/src/device/usbd.h index 46143a215..4b10f1a0e 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -76,17 +76,17 @@ uint8_t const * tud_descriptor_configuration_cb(uint8_t index); uint16_t const* tud_descriptor_string_cb(uint8_t index); // 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 -ATTR_WEAK void tud_umount_cb(void); +TU_ATTR_WEAK void tud_umount_cb(void); // Invoked when usb bus is suspended // 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 -ATTR_WEAK void tud_resume_cb(void); +TU_ATTR_WEAK void tud_resume_cb(void); //--------------------------------------------------------------------+ // Interface Descriptor Template diff --git a/src/host/ehci/ehci.c b/src/host/ehci/ehci.c index 2973c6895..63e87dd54 100644 --- a/src/host/ehci/ehci.c +++ b/src/host/ehci/ehci.c @@ -44,7 +44,7 @@ // INTERNAL OBJECT & FUNCTION DECLARATION //--------------------------------------------------------------------+ // 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 uint32_t hcd_ehci_register_addr(uint8_t rhport); diff --git a/src/host/ehci/ehci.h b/src/host/ehci/ehci.h index f64c58a0c..ce2f56771 100644 --- a/src/host/ehci/ehci.h +++ b/src/host/ehci/ehci.h @@ -95,7 +95,7 @@ typedef union { }ehci_link_t; /// 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 { // Word 0: Next QTD Pointer @@ -137,7 +137,7 @@ typedef struct TU_VERIFY_STATIC( sizeof(ehci_qtd_t) == 32, "size is not correct" ); /// Queue Head -typedef struct ATTR_ALIGNED(32) +typedef struct TU_ATTR_ALIGNED(32) { // Word 0: Next QHD 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" ); /// Highspeed Isochronous Transfer Descriptor (section 3.3) -typedef struct ATTR_ALIGNED(32) { +typedef struct TU_ATTR_ALIGNED(32) { // Word 0: Next Link Pointer 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" ); /// Split (Full-Speed) Isochronous Transfer Descriptor -typedef struct ATTR_ALIGNED(32) +typedef struct TU_ATTR_ALIGNED(32) { // Word 0: Next Link Pointer ehci_link_t next; @@ -442,7 +442,7 @@ typedef struct }control[CFG_TUSB_HOST_DEVICE_MAX+1]; 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_data_t; diff --git a/src/host/hub.c b/src/host/hub.c index cc440086f..a2d4e8429 100644 --- a/src/host/hub.c +++ b/src/host/hub.c @@ -45,7 +45,7 @@ typedef struct }usbh_hub_t; 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); //static osal_semaphore_handle_t hub_enum_sem_hdl; diff --git a/src/host/hub.h b/src/host/hub.h index 0182337b1..51d33d4e5 100644 --- a/src/host/hub.h +++ b/src/host/hub.h @@ -81,7 +81,7 @@ //indicators. See Section 11.5.3. //D15...D8: Reserved -typedef struct ATTR_PACKED{ +typedef struct TU_ATTR_PACKED{ uint8_t bLength ; ///< Size of descriptor uint8_t bDescriptorType ; ///< Other_speed_Configuration Type uint8_t bNbrPorts; @@ -135,7 +135,7 @@ enum{ // data in response of HUB_REQUEST_GET_STATUS, wIndex = 0 (hub) typedef struct { union{ - struct ATTR_PACKED { + struct TU_ATTR_PACKED { uint16_t local_power_source : 1; uint16_t over_current : 1; 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 typedef struct { union { - struct ATTR_PACKED { + struct TU_ATTR_PACKED { uint16_t connect_status : 1; uint16_t port_enable : 1; uint16_t suspend : 1; diff --git a/src/host/ohci/ohci.c b/src/host/ohci/ohci.c index e22f04f9b..ea553baa2 100644 --- a/src/host/ohci/ohci.c +++ b/src/host/ohci/ohci.c @@ -124,7 +124,7 @@ enum { //--------------------------------------------------------------------+ // 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[] = { diff --git a/src/host/ohci/ohci.h b/src/host/ohci/ohci.h index ec35edf19..a8aae251b 100644 --- a/src/host/ohci/ohci.h +++ b/src/host/ohci/ohci.h @@ -65,7 +65,7 @@ typedef struct { volatile uint16_t frame_pad; 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 -}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" ); @@ -76,7 +76,7 @@ typedef struct { }ohci_td_item_t; -typedef struct ATTR_ALIGNED(16) +typedef struct TU_ATTR_ALIGNED(16) { // Word 0 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" ); -typedef struct ATTR_ALIGNED(16) +typedef struct TU_ATTR_ALIGNED(16) { // Word 0 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" ); -typedef struct ATTR_ALIGNED(32) +typedef struct TU_ATTR_ALIGNED(32) { /*---------- Word 1 ----------*/ 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" ); // structure with member alignment required from large to small -typedef struct ATTR_ALIGNED(256) +typedef struct TU_ATTR_ALIGNED(256) { ohci_hcca_t hcca; diff --git a/src/host/usbh.c b/src/host/usbh.c index f370b62f4..655e3dd4b 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -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); 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 -------------// diff --git a/src/host/usbh.h b/src/host/usbh.h index a0955e9f9..311b2514d 100644 --- a/src/host/usbh.h +++ b/src/host/usbh.h @@ -77,13 +77,13 @@ static inline bool tuh_device_is_configured(uint8_t dev_addr) //--------------------------------------------------------------------+ // 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) */ -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) */ -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 diff --git a/src/portable/microchip/samd21/dcd_samd21.c b/src/portable/microchip/samd21/dcd_samd21.c index 9a9964505..fedfa2ec9 100644 --- a/src/portable/microchip/samd21/dcd_samd21.c +++ b/src/portable/microchip/samd21/dcd_samd21.c @@ -34,8 +34,8 @@ /*------------------------------------------------------------------*/ /* MACRO TYPEDEF CONSTANT ENUM *------------------------------------------------------------------*/ -static ATTR_ALIGNED(4) UsbDeviceDescBank sram_registers[8][2]; -static ATTR_ALIGNED(4) uint8_t _setup_packet[8]; +static TU_ATTR_ALIGNED(4) UsbDeviceDescBank sram_registers[8][2]; +static TU_ATTR_ALIGNED(4) uint8_t _setup_packet[8]; // Setup the control endpoint 0. static void bus_reset(void) diff --git a/src/portable/microchip/samd51/dcd_samd51.c b/src/portable/microchip/samd51/dcd_samd51.c index 6a4bd0e63..a43609b9e 100644 --- a/src/portable/microchip/samd51/dcd_samd51.c +++ b/src/portable/microchip/samd51/dcd_samd51.c @@ -35,7 +35,7 @@ /* MACRO TYPEDEF CONSTANT ENUM *------------------------------------------------------------------*/ 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. static void bus_reset(void) diff --git a/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c b/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c index b63bf1feb..0dab2caf7 100644 --- a/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c +++ b/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c @@ -67,7 +67,7 @@ enum { 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 volatile uint16_t buffer_offset; @@ -101,7 +101,7 @@ typedef struct 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; //--------------------------------------------------------------------+ @@ -109,7 +109,7 @@ typedef struct //--------------------------------------------------------------------+ // 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) { diff --git a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c index a14d20e30..cdc4d58db 100644 --- a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c +++ b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c @@ -37,7 +37,7 @@ //--------------------------------------------------------------------+ #define DCD_ENDPOINT_MAX 32 -typedef struct ATTR_ALIGNED(4) +typedef struct TU_ATTR_ALIGNED(4) { //------------- Word 0 -------------// uint32_t next; @@ -91,7 +91,7 @@ typedef struct } 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; //--------------------------------------------------------------------+ diff --git a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c index 89dc98ce4..049624d92 100644 --- a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c +++ b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c @@ -46,16 +46,16 @@ typedef struct { // Must be at 2K alignment - dcd_qhd_t qhd[QHD_MAX] ATTR_ALIGNED(64); - dcd_qtd_t qtd[QHD_MAX] ATTR_ALIGNED(32); + dcd_qhd_t qhd[QHD_MAX] TU_ATTR_ALIGNED(64); + dcd_qtd_t qtd[QHD_MAX] TU_ATTR_ALIGNED(32); }dcd_data_t; #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 #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 static LPC_USBHS_T * const LPC_USB[2] = { LPC_USB0, LPC_USB1 }; diff --git a/src/portable/st/stm32f4/dcd_stm32f4.c b/src/portable/st/stm32f4/dcd_stm32f4.c index f7128344d..996950ab0 100644 --- a/src/portable/st/stm32f4/dcd_stm32f4.c +++ b/src/portable/st/stm32f4/dcd_stm32f4.c @@ -39,7 +39,7 @@ #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) -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. typedef struct { diff --git a/src/tusb_option.h b/src/tusb_option.h index 694191406..9415992a7 100644 --- a/src/tusb_option.h +++ b/src/tusb_option.h @@ -131,7 +131,7 @@ #endif #ifndef CFG_TUSB_MEM_ALIGN -#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4) +#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4) #endif #ifndef CFG_TUSB_OS diff --git a/tests/lpc18xx_43xx/test/host/ehci/test_ehci_structure.c b/tests/lpc18xx_43xx/test/host/ehci/test_ehci_structure.c index ce6371054..e63fa850c 100644 --- a/tests/lpc18xx_43xx/test/host/ehci/test_ehci_structure.c +++ b/tests/lpc18xx_43xx/test/host/ehci/test_ehci_structure.c @@ -59,7 +59,7 @@ void tearDown(void) void test_struct_alignment(void) { 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_sitd_t) ); diff --git a/tests/support/descriptor_test.c b/tests/support/descriptor_test.c index b51c81711..0796e5b57 100644 --- a/tests/support/descriptor_test.c +++ b/tests/support/descriptor_test.c @@ -27,7 +27,7 @@ #include "tusb_option.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[] = { HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ), HID_USAGE ( HID_USAGE_DESKTOP_KEYBOARD ), @@ -69,7 +69,7 @@ const uint8_t keyboard_report_descriptor[] = { HID_COLLECTION_END }; -CFG_TUSB_MEM_SECTION ATTR_ALIGNED(4) +CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4) const uint8_t mouse_report_descriptor[] = { HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ), 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 = { .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 = { .configuration = diff --git a/tests/support/tusb_callback.h b/tests/support/tusb_callback.h index 3e793dd9e..456c5d2b6 100644 --- a/tests/support/tusb_callback.h +++ b/tests/support/tusb_callback.h @@ -48,9 +48,9 @@ #include "usbh.h" //------------- core -------------// -uint8_t tusbh_device_attached_cb (tusb_desc_device_t const *p_desc_device) ATTR_WEAK; -void tusbh_device_mount_succeed_cb (uint8_t dev_addr) ATTR_WEAK; -void tusbh_device_mount_failed_cb(tusb_error_t error, 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) TU_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 }