From 9218d1e8bb9fd6cb37358c9e08f6ff9849c6110c Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 1 May 2015 18:34:08 +0700 Subject: [PATCH] replace ATTR_PACKED_STRUCT by simply ATTR_PACKED (drop IAR support) remove "primitive_types.h" by simply include stdbool.h, stdint.h --- tinyusb/class/cdc.h | 28 +++++++-------- tinyusb/class/hid.h | 6 ++-- tinyusb/class/msc.h | 26 +++++++------- tinyusb/common/assertion.h | 3 +- tinyusb/common/binary.h | 3 +- tinyusb/common/common.h | 3 +- tinyusb/common/primitive_types.h | 53 ---------------------------- tinyusb/common/std_descriptors.h | 25 ++++++------- tinyusb/common/std_request.h | 7 ++-- tinyusb/device/dcd_lpc_11uxx_13uxx.c | 2 +- tinyusb/hal/hal.h | 4 ++- tinyusb/host/hub.h | 6 ++-- 12 files changed, 60 insertions(+), 106 deletions(-) delete mode 100644 tinyusb/common/primitive_types.h diff --git a/tinyusb/class/cdc.h b/tinyusb/class/cdc.h index 8253e9c7..617803be 100644 --- a/tinyusb/class/cdc.h +++ b/tinyusb/class/cdc.h @@ -217,7 +217,7 @@ typedef enum { // FUNCTIONAL DESCRIPTOR (COMMUNICATION INTERFACE) //--------------------------------------------------------------------+ /// Header Functional Descriptor (Communication Interface) -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ @@ -225,7 +225,7 @@ typedef ATTR_PACKED_STRUCT(struct) { }cdc_desc_func_header_t; /// Union Functional Descriptor (Communication Interface) -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ @@ -234,7 +234,7 @@ typedef ATTR_PACKED_STRUCT(struct) { }cdc_desc_func_union_t; #define cdc_desc_func_union_n_t(no_slave)\ - ATTR_PACKED_STRUCT(struct) { \ + struct ATTR_PACKED { \ uint8_t bLength ;\ uint8_t bDescriptorType ;\ uint8_t bDescriptorSubType ;\ @@ -243,7 +243,7 @@ typedef ATTR_PACKED_STRUCT(struct) { } /// Country Selection Functional Descriptor (Communication Interface) -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ @@ -252,7 +252,7 @@ typedef ATTR_PACKED_STRUCT(struct) { }cdc_desc_func_country_selection_t; #define cdc_desc_func_country_selection_n_t(no_country) \ - ATTR_PACKED_STRUCT(struct) {\ + struct ATTR_PACKED {\ uint8_t bLength ;\ uint8_t bDescriptorType ;\ uint8_t bDescriptorSubType ;\ @@ -266,7 +266,7 @@ typedef ATTR_PACKED_STRUCT(struct) { /// \brief Call Management Functional Descriptor /// \details This functional descriptor describes the processing of calls for the Communications Class interface. -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ @@ -281,7 +281,7 @@ typedef ATTR_PACKED_STRUCT(struct) { }cdc_desc_func_call_management_t; -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct 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. uint8_t support_send_break : 1; ///< Device supports the request Send_Break @@ -293,7 +293,7 @@ STATIC_ASSERT(sizeof(cdc_acm_capability_t) == 1, "mostly problem with compiler") /// \brief Abstract Control Management Functional Descriptor /// \details This functional descriptor describes the commands supported by by the Communications Class interface with SubClass code of \ref CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ @@ -302,7 +302,7 @@ typedef ATTR_PACKED_STRUCT(struct) { /// \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 ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ @@ -317,7 +317,7 @@ typedef ATTR_PACKED_STRUCT(struct) { /// \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 ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ @@ -328,7 +328,7 @@ typedef ATTR_PACKED_STRUCT(struct) { /// \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 ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ @@ -343,7 +343,7 @@ typedef ATTR_PACKED_STRUCT(struct) { /// \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 ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ @@ -367,7 +367,7 @@ static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc) //--------------------------------------------------------------------+ // Requests //--------------------------------------------------------------------+ -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint32_t bit_rate; uint8_t stop_bits; ///< 0: 1 stop bit - 1: 1.5 stop bits - 2: 2 stop bits uint8_t parity; ///< 0: None - 1: Odd - 2: Even - 3: Mark - 4: Space @@ -376,7 +376,7 @@ typedef ATTR_PACKED_STRUCT(struct) { STATIC_ASSERT(sizeof(cdc_line_coding_t) == 7, "size is not correct"); -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct 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; uint16_t : 14; diff --git a/tinyusb/class/hid.h b/tinyusb/class/hid.h index c95cfa24..2a94bc9d 100644 --- a/tinyusb/class/hid.h +++ b/tinyusb/class/hid.h @@ -93,7 +93,7 @@ typedef enum { }hid_request_type_t; /// USB HID Descriptor -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct 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. */ @@ -155,7 +155,7 @@ typedef enum * @{ */ /// Standard HID Boot Protocol Mouse Report. -typedef ATTR_PACKED_STRUCT(struct) +typedef struct ATTR_PACKED { uint8_t buttons; /**< buttons mask for currently pressed buttons in the mouse. */ int8_t x; /**< Current delta x movement of the mouse. */ @@ -179,7 +179,7 @@ typedef enum { * @{ */ /// Standard HID Boot Protocol Keyboard Report. -typedef ATTR_PACKED_STRUCT(struct) +typedef struct ATTR_PACKED { uint8_t modifier; /**< Keyboard modifier byte, indicating pressed modifier keys (a combination of HID_KEYBOARD_MODIFER_* masks). */ uint8_t reserved; /**< Reserved for OEM use, always set to 0. */ diff --git a/tinyusb/class/msc.h b/tinyusb/class/msc.h index 727dd038..df80efe7 100644 --- a/tinyusb/class/msc.h +++ b/tinyusb/class/msc.h @@ -94,7 +94,7 @@ typedef enum { }msc_csw_status_t; /// Command Block Wrapper -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct 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. uint32_t xfer_bytes ; ///< The number of bytes of data that the host expects to transfer on the Bulk-In or Bulk-Out endpoint (as indicated by the Directionbit) during the execution of this command. If this field is zero, the device and the host shall transfer no data between the CBW and the associated CSW, and the device shall ignore the value of the Directionbit in bmCBWFlags. @@ -107,7 +107,7 @@ typedef ATTR_PACKED_STRUCT(struct) { STATIC_ASSERT(sizeof(msc_cmd_block_wrapper_t) == 31, "size is not correct"); /// Command Status Wrapper -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct 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. uint32_t data_residue ; ///< For Data-Out the device shall report in the dCSWDataResiduethe difference between the amount of data expected as stated in the dCBWDataTransferLength, and the actual amount of data processed by the device. For Data-In the device shall report in the dCSWDataResiduethe difference between the amount of data expected as stated in the dCBWDataTransferLengthand the actual amount of relevant data sent by the device @@ -156,7 +156,7 @@ typedef enum { //--------------------------------------------------------------------+ /// SCSI Test Unit Ready Command -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t cmd_code ; ///< SCSI OpCode for \ref SCSI_CMD_TEST_UNIT_READY uint8_t lun ; ///< Logical Unit uint8_t reserved[3] ; @@ -166,7 +166,7 @@ typedef ATTR_PACKED_STRUCT(struct) { STATIC_ASSERT(sizeof(scsi_test_unit_ready_t) == 6, "size is not correct"); /// SCSI Inquiry Command -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t cmd_code ; ///< SCSI OpCode for \ref SCSI_CMD_INQUIRY uint8_t reserved1 ; uint8_t page_code ; @@ -178,7 +178,7 @@ typedef ATTR_PACKED_STRUCT(struct) { STATIC_ASSERT(sizeof(scsi_inquiry_t) == 6, "size is not correct"); /// SCSI Inquiry Response Data -typedef ATTR_PACKED_STRUCT(struct) +typedef struct ATTR_PACKED { uint8_t peripheral_device_type : 5; uint8_t peripheral_qualifier : 3; @@ -224,7 +224,7 @@ typedef ATTR_PACKED_STRUCT(struct) STATIC_ASSERT(sizeof(scsi_inquiry_data_t) == 36, "size is not correct"); -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct 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 ATTR_PACKED_STRUCT(struct) { STATIC_ASSERT(sizeof(scsi_sense_fixed_data_t) == 18, "size is not correct"); -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t cmd_code ; ///< SCSI OpCode for \ref SCSI_CMD_MODE_SENSE_6 uint8_t : 3; @@ -266,7 +266,7 @@ typedef ATTR_PACKED_STRUCT(struct) { STATIC_ASSERT( sizeof(scsi_mode_sense_6_t) == 6, "size is not correct"); -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t mode_data_length; uint8_t medium_type; uint8_t device_specific_para; @@ -275,7 +275,7 @@ typedef ATTR_PACKED_STRUCT(struct) { STATIC_ASSERT( sizeof(scsi_mode_parameters_t) == 4, "size is not correct"); -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t cmd_code; ///< SCSI OpCode for \ref SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL uint8_t reserved[3]; uint8_t prohibit_removal; @@ -288,7 +288,7 @@ STATIC_ASSERT( sizeof(scsi_prevent_allow_medium_removal_t) == 6, "size is not co // SCSI MMC //--------------------------------------------------------------------+ /// SCSI Read Format Capacity: Write Capacity -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t cmd_code; uint8_t reserved[6]; uint16_t alloc_length; @@ -297,7 +297,7 @@ typedef ATTR_PACKED_STRUCT(struct) { STATIC_ASSERT( sizeof(scsi_read_format_capacity_t) == 10, "size is not correct"); -typedef ATTR_PACKED_STRUCT(struct){ +typedef struct ATTR_PACKED{ uint8_t reserved[3]; uint8_t list_length; /// must be 8*n, length in bytes of formattable capacity descriptor followed it. @@ -317,7 +317,7 @@ STATIC_ASSERT( sizeof(scsi_read_format_capacity_data_t) == 12, "size is not corr //--------------------------------------------------------------------+ /// SCSI Read Capacity 10 Command: Read Capacity -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t cmd_code ; ///< SCSI OpCode for \ref SCSI_CMD_READ_CAPACITY_10 uint8_t reserved1 ; uint32_t lba ; ///< The first Logical Block Address (LBA) accessed by this command @@ -337,7 +337,7 @@ typedef struct { STATIC_ASSERT(sizeof(scsi_read_capacity10_data_t) == 8, "size is not correct"); /// SCSI Read 10 Command -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t cmd_code ; ///< SCSI OpCode uint8_t reserved ; // has LUN according to wiki uint32_t lba ; ///< The first Logical Block Address (LBA) accessed by this command diff --git a/tinyusb/common/assertion.h b/tinyusb/common/assertion.h index dd2fbdc6..5d78dcce 100644 --- a/tinyusb/common/assertion.h +++ b/tinyusb/common/assertion.h @@ -50,7 +50,8 @@ extern "C" #endif #include "tusb_option.h" -#include "primitive_types.h" +#include +#include #include "compiler/compiler.h" #include "hal/hal.h" // TODO find a way to break hal dependency diff --git a/tinyusb/common/binary.h b/tinyusb/common/binary.h index 6860295d..ed7eecb2 100644 --- a/tinyusb/common/binary.h +++ b/tinyusb/common/binary.h @@ -47,7 +47,8 @@ extern "C" { #endif -#include "primitive_types.h" +#include +#include #include "compiler/compiler.h" //------------- Bit manipulation -------------// diff --git a/tinyusb/common/common.h b/tinyusb/common/common.h index 6bd12c39..4007d608 100644 --- a/tinyusb/common/common.h +++ b/tinyusb/common/common.h @@ -52,7 +52,8 @@ //--------------------------------------------------------------------+ //------------- Standard Header -------------// -#include "primitive_types.h" +#include +#include #include #include #include diff --git a/tinyusb/common/primitive_types.h b/tinyusb/common/primitive_types.h deleted file mode 100644 index f85e0299..00000000 --- a/tinyusb/common/primitive_types.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************/ -/*! - @file primitive_types.h - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -#ifndef _TUSB_PRIMITIVE_TYPES_H_ -#define _TUSB_PRIMITIVE_TYPES_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -#include -#include - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_PRIMITIVE_TYPES_H_ */ diff --git a/tinyusb/common/std_descriptors.h b/tinyusb/common/std_descriptors.h index 8b8da9c0..fdc736c9 100644 --- a/tinyusb/common/std_descriptors.h +++ b/tinyusb/common/std_descriptors.h @@ -50,14 +50,15 @@ #endif #include "tusb_option.h" -#include "primitive_types.h" +#include +#include #include "compiler/compiler.h" //--------------------------------------------------------------------+ // STANDARD DESCRIPTORS //--------------------------------------------------------------------+ /// USB Standard Device Descriptor (section 9.6.1, table 9-8) -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bDescriptorType ; ///< DEVICE Descriptor Type. uint16_t bcdUSB ; ///< BUSB Specification Release Number in Binary-Coded Decimal (i.e., 2.10 is 210H). This field identifies the release of the USB Specification with which the device and its descriptors are compliant. @@ -78,7 +79,7 @@ typedef ATTR_PACKED_STRUCT(struct) { } tusb_descriptor_device_t; /// USB Standard Configuration Descriptor (section 9.6.1 table 9-10) */ -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes uint8_t bDescriptorType ; ///< CONFIGURATION Descriptor Type uint16_t wTotalLength ; ///< Total length of data returned for this configuration. Includes the combined length of all descriptors (configuration, interface, endpoint, and class- or vendor-specific) returned for this configuration. @@ -91,7 +92,7 @@ typedef ATTR_PACKED_STRUCT(struct) { } tusb_descriptor_configuration_t; /// USB Standard Interface Descriptor (section 9.6.1 table 9-12) -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes uint8_t bDescriptorType ; ///< INTERFACE Descriptor Type @@ -105,20 +106,20 @@ typedef ATTR_PACKED_STRUCT(struct) { } tusb_descriptor_interface_t; /// USB Standard Endpoint Descriptor (section 9.6.1 table 9-13) -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct 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. - ATTR_PACKED_STRUCT(struct) { + struct 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. - ATTR_PACKED_STRUCT(struct) { + struct 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; @@ -128,7 +129,7 @@ typedef ATTR_PACKED_STRUCT(struct) { } tusb_descriptor_endpoint_t; /// USB Other Speed Configuration Descriptor (section 9.6.1 table 9-11) -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of descriptor uint8_t bDescriptorType ; ///< Other_speed_Configuration Type uint16_t wTotalLength ; ///< Total length of data returned @@ -141,7 +142,7 @@ typedef ATTR_PACKED_STRUCT(struct) { } tusb_descriptor_other_speed_t; /// USB Device Qualifier Descriptor (section 9.6.1 table 9-9) -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of descriptor uint8_t bDescriptorType ; ///< Device Qualifier Type uint16_t bcdUSB ; ///< USB specification version number (e.g., 0200H for V2.00) @@ -155,7 +156,7 @@ typedef ATTR_PACKED_STRUCT(struct) { } tusb_descriptor_device_qualifier_t; /// USB Interface Association Descriptor (IAD ECN) -typedef ATTR_PACKED_STRUCT(struct) +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of descriptor uint8_t bDescriptorType ; ///< Other_speed_Configuration Type @@ -171,13 +172,13 @@ typedef ATTR_PACKED_STRUCT(struct) } tusb_descriptor_interface_association_t; /// USB Header Descriptor -typedef ATTR_PACKED_STRUCT(struct) +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes uint8_t bDescriptorType ; ///< Descriptor Type } tusb_descriptor_header_t; -typedef ATTR_PACKED_STRUCT(struct) +typedef struct ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes uint8_t bDescriptorType ; ///< Descriptor Type diff --git a/tinyusb/common/std_request.h b/tinyusb/common/std_request.h index 46ce76c4..fc37a9c2 100644 --- a/tinyusb/common/std_request.h +++ b/tinyusb/common/std_request.h @@ -47,12 +47,13 @@ #endif #include "tusb_option.h" -#include "primitive_types.h" +#include +#include #include "compiler/compiler.h" -typedef ATTR_PACKED_STRUCT(struct){ +typedef struct ATTR_PACKED{ union { - ATTR_PACKED_STRUCT(struct) { + struct ATTR_PACKED { uint8_t recipient : 5; ///< Recipient type tusb_std_request_recipient_t. uint8_t type : 2; ///< Request type tusb_control_request_type_t. uint8_t direction : 1; ///< Direction type. tusb_direction_t diff --git a/tinyusb/device/dcd_lpc_11uxx_13uxx.c b/tinyusb/device/dcd_lpc_11uxx_13uxx.c index b50041f0..ddfea85c 100644 --- a/tinyusb/device/dcd_lpc_11uxx_13uxx.c +++ b/tinyusb/device/dcd_lpc_11uxx_13uxx.c @@ -92,7 +92,7 @@ enum { }; // buffer input must be 64 byte alignment -typedef ATTR_PACKED_STRUCT(struct) { +typedef struct ATTR_PACKED { volatile uint16_t buff_addr_offset ; ///< The address offset is updated by hardware after each successful reception/transmission of a packet. Hardware increments the original value with the integer value when the packet size is divided by 64. volatile uint16_t nbytes : 10 ; ///< For OUT endpoints this is the number of bytes that can be received in this buffer. For IN endpoints this is the number of bytes that must be transmitted. HW decrements this value with the packet size every time when a packet is successfully transferred. Note: If a short packet is received on an OUT endpoint, the active bit will be cleared and the NBytes value indicates the remaining buffer space that is not used. Software calculates the received number of bytes by subtracting the remaining NBytes from the programmed value. diff --git a/tinyusb/hal/hal.h b/tinyusb/hal/hal.h index da7ef63c..24e39289 100644 --- a/tinyusb/hal/hal.h +++ b/tinyusb/hal/hal.h @@ -43,7 +43,9 @@ // INCLUDES //--------------------------------------------------------------------+ #include "tusb_option.h" -#include "common/primitive_types.h" +#include +#include + #include "common/tusb_errors.h" #include "common/compiler/compiler.h" diff --git a/tinyusb/host/hub.h b/tinyusb/host/hub.h index 6ecba96f..665765a2 100644 --- a/tinyusb/host/hub.h +++ b/tinyusb/host/hub.h @@ -93,7 +93,7 @@ //indicators. See Section 11.5.3. //D15...D8: Reserved -typedef ATTR_PACKED_STRUCT(struct){ +typedef struct ATTR_PACKED{ uint8_t bLength ; ///< Size of descriptor uint8_t bDescriptorType ; ///< Other_speed_Configuration Type uint8_t bNbrPorts; @@ -147,7 +147,7 @@ enum{ // data in response of HUB_REQUEST_GET_STATUS, wIndex = 0 (hub) typedef struct { union{ - ATTR_PACKED_STRUCT(struct) { + struct ATTR_PACKED { uint16_t local_power_source : 1; uint16_t over_current : 1; uint16_t : 14; @@ -162,7 +162,7 @@ STATIC_ASSERT( sizeof(hub_status_response_t) == 4, "size is not correct"); // data in response of HUB_REQUEST_GET_STATUS, wIndex = Port num typedef struct { union { - ATTR_PACKED_STRUCT(struct) { + struct ATTR_PACKED { uint16_t connect_status : 1; uint16_t port_enable : 1; uint16_t suspend : 1;