Skip to content

Commit

Permalink
Use consistent __attribute__((packed))
Browse files Browse the repository at this point in the history
  • Loading branch information
GilesBathgate committed Nov 26, 2021
1 parent c1a0c6b commit 7fcb669
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions parts/I2CPeripheral.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class I2CPeripheral: public BasePeripheral
uint8_t writeRegAddr;
uint8_t isAddrRead :1; // Write bit on address. IDK if this is used given msgBits.isWrite.
uint8_t address :7;
}__attribute__ ((__packed__));
} __attribute__((packed));
};

using NativeI2CMsg_t = union NativeI2CMsg {
Expand All @@ -75,7 +75,7 @@ class I2CPeripheral: public BasePeripheral
uint8_t isWrite :1; // Write bit on address. IDK if this is used given msgBits.isWrite.
uint8_t address :7;
uint8_t data :8 ;
} __attribute__ ((__packed__));
} __attribute__((packed));
};

// I2C transaction handler.
Expand Down
4 changes: 2 additions & 2 deletions parts/components/MCP23S17.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ using mcp_reg_bank_1_t = struct mcp_reg_bank_1_t {
uint8_t SEQOP :1;
uint8_t MIRROR :1;
uint8_t BANK :1;
} __attribute__ ((__packed__)) IOCON;
} __attribute__((packed)) IOCON;
};
uint8_t GPPU; //0x06
uint8_t INTF; //0x07
Expand Down Expand Up @@ -119,7 +119,7 @@ class MCP23S17: public SPIPeripheral
uint8_t READ :1;
uint8_t HADDR :3;
uint8_t _FIXED :4;
} __attribute__ ((__packed__));
} __attribute__((packed));
} m_hdr = {0};

union {
Expand Down
4 changes: 2 additions & 2 deletions parts/components/SDCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class SDCard:public SPIPeripheral, public Scriptable, private IKeyClient
unsigned int address :32;
Command cmd :6;
unsigned char :2; // Start/position
} __attribute__ ((__packed__)) bits;
} __attribute__((packed)) bits;
uint8_t bytes[6];
} m_CmdIn {.all = 0};

Expand All @@ -161,7 +161,7 @@ class SDCard:public SPIPeripheral, public Scriptable, private IKeyClient
uint32_t function :4;
uint32_t mio :1;

} __attribute__ ((__packed__)) bits;
} __attribute__((packed)) bits;
};

struct {
Expand Down
14 changes: 7 additions & 7 deletions parts/components/TMC2130.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ class TMC2130: public SPIPeripheral, public Scriptable, public GLMotor
uint32_t data :32; // 32 bits of data
uint8_t address :7;
uint8_t RW :1;
} __attribute__ ((__packed__)) bitsIn;
} __attribute__((packed)) bitsIn;
struct {
uint32_t data :32; // 32 bits of data
uint8_t reset_flag :1;
uint8_t driver_error :1;
uint8_t sg2 :1;
uint8_t standstill :1;
uint8_t :4; // unused
} __attribute__ ((__packed__)) bitsOut;
} __attribute__((packed)) bitsOut;
uint8_t bytes[5] {0,0,0,0,0}; // Raw bytes as piped in/out by SPI.
};

Expand Down Expand Up @@ -152,14 +152,14 @@ class TMC2130: public SPIPeripheral, public Scriptable, public GLMotor
uint8_t stop_enable :1;
uint8_t direct_mode :1;
uint16_t :14;
} __attribute__ ((__packed__)) GCONF; // 0x00
} __attribute__((packed)) GCONF; // 0x00
struct // 0x01
{
uint8_t reset :1;
uint8_t drv_err :1;
uint8_t uv_cp :1;
uint32_t :29; // unused
} __attribute__ ((__packed__)) GSTAT;
} __attribute__((packed)) GSTAT;
uint32_t _unimplemented[2]; //0x02 - 0x03
struct // 0x04
{
Expand All @@ -168,7 +168,7 @@ class TMC2130: public SPIPeripheral, public Scriptable, public GLMotor
uint8_t :1; // unused
uint16_t :16; // unused
uint8_t version :8;
} __attribute__ ((__packed__)) IOIN;
} __attribute__((packed)) IOIN;
uint32_t _unimplemented2[103]; //0x05 - 0x6B
struct //0x6C
{
Expand All @@ -189,7 +189,7 @@ class TMC2130: public SPIPeripheral, public Scriptable, public GLMotor
uint32_t dedge :1;
uint32_t diss2g :1;
uint32_t :1;
} __attribute__ ((__packed__)) CHOPCONF;
} __attribute__((packed)) CHOPCONF;
uint32_t _unimplemented3[2]; //0x6D - 0x6E
struct //0x6F
{
Expand All @@ -206,7 +206,7 @@ class TMC2130: public SPIPeripheral, public Scriptable, public GLMotor
uint8_t ola :1;
uint8_t olb :1;
uint8_t stst :1;
} __attribute__ ((__packed__)) DRV_STATUS;
} __attribute__((packed)) DRV_STATUS;
}defs;
};

Expand Down
8 changes: 4 additions & 4 deletions parts/components/usb_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct usb_setup_pkt {
word wValue;
word wIndex;
word wLength;
} __attribute__((__packed__));
} __attribute__((packed));

#define USB_REQTYPE_DIR_DEV_TO_HOST 0x80
#define USB_REQTYPE_STD 0
Expand Down Expand Up @@ -62,7 +62,7 @@ struct usb_device_descriptor {
byte iProduct; // Index of String Descriptor describing the product.
byte iSerialNumber; // Index of String Descriptor with the device's serial number.
byte bNumConfigurations; // Number of possible configurations.
} __attribute__ ((__packed__));
} __attribute__((packed));

struct usb_configuration_descriptor
{
Expand All @@ -74,7 +74,7 @@ struct usb_configuration_descriptor
byte iConfiguration; // Index of String Descriptor describing the configuration.
byte bmAttributes; // Configuration characteristics.
byte bMaxPower; // Maximum power consumed by this configuration.
} __attribute__ ((__packed__));
} __attribute__((packed));


struct usb_interface_descriptor
Expand All @@ -88,4 +88,4 @@ struct usb_interface_descriptor
byte bInterfaceSubClass; // Subclass code (assigned by the USB-IF).
byte bInterfaceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific.
byte iInterface; // Index of String Descriptor describing the interface.
} __attribute__ ((__packed__));
} __attribute__((packed));
12 changes: 6 additions & 6 deletions parts/components/usbip_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ struct usbip_common_hdr {
uint32_t devid; // (busnum << 16) | devnum
uint32_t direction;
uint32_t ep;
} __attribute__ ((__packed__));
} __attribute__((packed));

#define USBIP_CMD_SUBMIT 0x0001
#define USBIP_CMD_UNLINK 0x0002
Expand All @@ -117,7 +117,7 @@ struct usbip_cmd_submit {
int32_t number_of_packets;
int32_t interval;
unsigned char setup[8];
} __attribute__ ((__packed__));
} __attribute__((packed));

/*
+ Allowed transfer_flags | value | control | interrupt | bulk | isochronous
Expand All @@ -139,7 +139,7 @@ struct usbip_ret_submit {
int32_t number_of_packets;
int32_t error_count;
long long setup;
} __attribute__ ((__packed__));
} __attribute__((packed));


struct usbip_cmd_unlink {
Expand All @@ -149,7 +149,7 @@ struct usbip_cmd_unlink {
int32_t pad3;
int32_t pad4;
long long pad5;
} __attribute__ ((__packed__));
} __attribute__((packed));


struct usbip_ret_unlink {
Expand All @@ -159,7 +159,7 @@ struct usbip_ret_unlink {
int32_t pad3;
int32_t pad4;
long long pad5;
} __attribute__ ((__packed__));
} __attribute__((packed));

struct usbip_header {
struct usbip_common_hdr hdr;
Expand All @@ -169,4 +169,4 @@ struct usbip_header {
struct usbip_cmd_unlink unlink;
struct usbip_ret_unlink retunlink;
} u;
} __attribute__ ((__packed__));
} __attribute__((packed));

0 comments on commit 7fcb669

Please sign in to comment.