replace ATTR_PACKED_STRUCT by simply ATTR_PACKED (drop IAR support)

remove "primitive_types.h" by simply include stdbool.h, stdint.h
This commit is contained in:
hathach
2015-05-01 18:34:08 +07:00
parent 6dbd580b53
commit 9218d1e8bb
12 changed files with 60 additions and 106 deletions

View File

@@ -50,7 +50,8 @@ extern "C"
#endif
#include "tusb_option.h"
#include "primitive_types.h"
#include <stdbool.h>
#include <stdint.h>
#include "compiler/compiler.h"
#include "hal/hal.h" // TODO find a way to break hal dependency

View File

@@ -47,7 +47,8 @@
extern "C" {
#endif
#include "primitive_types.h"
#include <stdbool.h>
#include <stdint.h>
#include "compiler/compiler.h"
//------------- Bit manipulation -------------//

View File

@@ -52,7 +52,8 @@
//--------------------------------------------------------------------+
//------------- Standard Header -------------//
#include "primitive_types.h"
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>

View File

@@ -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 <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_PRIMITIVE_TYPES_H_ */

View File

@@ -50,14 +50,15 @@
#endif
#include "tusb_option.h"
#include "primitive_types.h"
#include <stdbool.h>
#include <stdint.h>
#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

View File

@@ -47,12 +47,13 @@
#endif
#include "tusb_option.h"
#include "primitive_types.h"
#include <stdbool.h>
#include <stdint.h>
#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