From 3f2fbc6e75b9a0e326fa8f5ea0b268c1541a5bfa Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 6 Jun 2019 11:12:40 +0700 Subject: [PATCH] update tinyusb --- .../tinyusb/src/class/cdc/cdc.h | 28 +++++++++---------- .../tinyusb/src/class/cdc/cdc_device.h | 8 +++--- .../tinyusb/src/class/hid/hid.h | 6 ++-- .../tinyusb/src/class/hid/hid_device.h | 10 +++---- .../tinyusb/src/class/midi/midi.h | 4 +-- .../tinyusb/src/class/midi/midi_device.h | 2 +- .../tinyusb/src/class/msc/msc.h | 28 +++++++++---------- .../tinyusb/src/class/msc/msc_device.h | 24 ++++++++-------- .../tinyusb/src/common/tusb_common.h | 3 -- .../tinyusb/src/common/tusb_compiler.h | 27 ++++++++++-------- .../tinyusb/src/common/tusb_types.h | 26 ++++++++--------- .../tinyusb/src/device/dcd.h | 2 +- .../tinyusb/src/device/usbd.c | 2 +- .../tinyusb/src/device/usbd.h | 8 +++--- .../tinyusb/src/tusb_option.h | 2 +- .../nRF5/Adafruit_TinyUSB_Core/tusb_config.h | 2 +- 16 files changed, 91 insertions(+), 91 deletions(-) diff --git a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/cdc/cdc.h b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/cdc/cdc.h index 200f6eaa..2e865bdb 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/cdc/cdc.h +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/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/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/cdc/cdc_device.h b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/cdc/cdc_device.h index 9e108763..3c1af9db 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/cdc/cdc_device.h +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/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/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/hid/hid.h b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/hid/hid.h index 902c01ef..04b255ea 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/hid/hid.h +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/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/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/hid/hid_device.h b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/hid/hid_device.h index aa1f2b83..947dbb75 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/hid/hid_device.h +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/hid/hid_device.h @@ -70,24 +70,24 @@ bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8_t x, int8_t y // Invoked when received GET HID REPORT DESCRIPTOR request // Application return pointer to descriptor, whose contents must exist long enough for transfer to complete -ATTR_WEAK uint8_t const * tud_hid_descriptor_report_cb(void); +TU_ATTR_WEAK uint8_t const * tud_hid_descriptor_report_cb(void); // Invoked when received GET_REPORT control request // Application must fill buffer report's content and return its length. // Return zero will cause the stack to STALL request -ATTR_WEAK uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen); +TU_ATTR_WEAK uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen); // Invoked when received SET_REPORT control request or // received data on OUT endpoint ( Report ID = 0, Type = 0 ) -ATTR_WEAK void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize); +TU_ATTR_WEAK 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/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/midi/midi.h b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/midi/midi.h index ee318f78..50f2be67 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/midi/midi.h +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/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/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/midi/midi_device.h b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/midi/midi_device.h index 84f4c57b..45e00901 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/midi/midi_device.h +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/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/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/msc/msc.h b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/msc/msc.h index 95fac659..d461513f 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/msc/msc.h +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/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/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/msc/msc_device.h b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/msc/msc_device.h index b2cd7e89..d6699485 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/msc/msc_device.h +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/msc/msc_device.h @@ -72,7 +72,7 @@ bool tud_msc_set_sense(uint8_t lun, uint8_t sense_key, uint8_t add_sense_code, u * \retval negative Indicate error e.g reading disk I/O. tinyusb will \b STALL the corresponding * endpoint and return failed status in command status wrapper phase. */ -ATTR_WEAK int32_t tud_msc_read10_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize); +TU_ATTR_WEAK int32_t tud_msc_read10_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize); /** * Invoked when received \ref SCSI_CMD_WRITE_10 command @@ -91,19 +91,19 @@ ATTR_WEAK int32_t tud_msc_read10_cb (uint8_t lun, uint32_t lba, uint32_t offset, * \retval negative Indicate error writing disk I/O. Tinyusb will \b STALL the corresponding * endpoint and return failed status in command status wrapper phase. */ -ATTR_WEAK int32_t tud_msc_write10_cb (uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize); +TU_ATTR_WEAK int32_t tud_msc_write10_cb (uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize); // Invoked when received SCSI_CMD_INQUIRY // Application fill vendor id, product id and revision with string up to 8, 16, 4 characters respectively -ATTR_WEAK void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4]); +TU_ATTR_WEAK void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4]); // Invoked when received Test Unit Ready command. // return true allowing host to read/write this LUN e.g SD card inserted -ATTR_WEAK bool tud_msc_test_unit_ready_cb(uint8_t lun); +TU_ATTR_WEAK bool tud_msc_test_unit_ready_cb(uint8_t lun); // Invoked when received SCSI_CMD_READ_CAPACITY_10 and SCSI_CMD_READ_FORMAT_CAPACITY to determine the disk size // Application update block count and block size -ATTR_WEAK void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size); +TU_ATTR_WEAK void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size); /** * Invoked when received an SCSI command not in built-in list below. @@ -121,29 +121,29 @@ ATTR_WEAK void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* * \retval negative Indicate error e.g unsupported command, tinyusb will \b STALL the corresponding * endpoint and return failed status in command status wrapper phase. */ -ATTR_WEAK int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize); +TU_ATTR_WEAK int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize); /*------------- 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/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/common/tusb_common.h b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/common/tusb_common.h index 4b74bcfc..c77be2a9 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/common/tusb_common.h +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/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/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/common/tusb_compiler.h b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/common/tusb_compiler.h index 0978d1c0..09768ef8 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/common/tusb_compiler.h +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/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/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/common/tusb_types.h b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/common/tusb_types.h index 78653384..34ad26f1 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/common/tusb_types.h +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/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/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/device/dcd.h b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/device/dcd.h index bd7088fe..0ed4a77d 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/device/dcd.h +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/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/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.c b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.c index e22de472..38838b61 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.c +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/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/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.h b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.h index 46143a21..4b10f1a0 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.h +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/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/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/tusb_option.h b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/tusb_option.h index 69419140..9415992a 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/tusb_option.h +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/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/cores/nRF5/Adafruit_TinyUSB_Core/tusb_config.h b/cores/nRF5/Adafruit_TinyUSB_Core/tusb_config.h index f117108b..2448c838 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tusb_config.h +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tusb_config.h @@ -42,7 +42,7 @@ #define CFG_TUSB_OS OPT_OS_FREERTOS #define CFG_TUSB_MEM_SECTION -#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4) +#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4) //-------------------------------------------------------------------- // DEVICE CONFIGURATION