Add ATTR_* macros in the newly created attributes.h and use them wherever possible for improved readability.
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
#include "config_globals.h"
|
||||
#include "attributes.h"
|
||||
|
||||
static uint8_t hardwareConfig[HARDWARE_CONFIG_SIZE];
|
||||
config_buffer_t HardwareConfigBuffer = {hardwareConfig};
|
||||
|
||||
static uint8_t userConfig1[USER_CONFIG_SIZE];
|
||||
static uint8_t __attribute__((section (".m_data_2"))) userConfig2[USER_CONFIG_SIZE];
|
||||
static uint8_t ATTR_DATA2 userConfig2[USER_CONFIG_SIZE];
|
||||
config_buffer_t ValidatedUserConfigBuffer = { userConfig1 };
|
||||
config_buffer_t StagingUserConfigBuffer = { userConfig2 };
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Includes:
|
||||
|
||||
#include <stdint.h>
|
||||
#include "attributes.h"
|
||||
#include "lufa/HIDClassCommon.h"
|
||||
#include "usb_composite_device.h"
|
||||
#include "main.h"
|
||||
@@ -69,24 +70,24 @@
|
||||
uint8_t longPressAction;
|
||||
uint8_t modifiers;
|
||||
uint16_t scancode;
|
||||
} __attribute__ ((packed)) keystroke;
|
||||
} ATTR_PACKED keystroke;
|
||||
struct {
|
||||
mouse_button_t buttonActions;
|
||||
mouse_scroll_t scrollActions;
|
||||
mouse_move_action_t moveActions;
|
||||
} __attribute__ ((packed)) mouse;
|
||||
} ATTR_PACKED mouse;
|
||||
struct {
|
||||
bool isToggle;
|
||||
uint8_t layer;
|
||||
} __attribute__ ((packed)) switchLayer;
|
||||
} ATTR_PACKED switchLayer;
|
||||
struct {
|
||||
uint8_t keymapId;
|
||||
} __attribute__ ((packed)) switchKeymap;
|
||||
} ATTR_PACKED switchKeymap;
|
||||
struct {
|
||||
uint8_t macroId;
|
||||
} __attribute__ ((packed)) playMacro;
|
||||
} ATTR_PACKED playMacro;
|
||||
};
|
||||
} __attribute__ ((packed)) key_action_t;
|
||||
} ATTR_PACKED key_action_t;
|
||||
|
||||
// Variables:
|
||||
|
||||
|
||||
@@ -41,29 +41,29 @@
|
||||
keystroke_type_t type;
|
||||
uint8_t scancode;
|
||||
uint8_t modifierMask;
|
||||
} __attribute__ ((packed)) key;
|
||||
} ATTR_PACKED key;
|
||||
struct {
|
||||
macro_sub_action_t action;
|
||||
uint8_t mouseButtonsMask;
|
||||
} __attribute__ ((packed)) mouseButton;
|
||||
} ATTR_PACKED mouseButton;
|
||||
struct {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
} __attribute__ ((packed)) moveMouse;
|
||||
} ATTR_PACKED moveMouse;
|
||||
struct {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
} __attribute__ ((packed)) scrollMouse;
|
||||
} ATTR_PACKED scrollMouse;
|
||||
struct {
|
||||
int16_t delay;
|
||||
} __attribute__ ((packed)) delay;
|
||||
} ATTR_PACKED delay;
|
||||
struct {
|
||||
const char *text;
|
||||
uint16_t textLen;
|
||||
} __attribute__ ((packed)) text;
|
||||
} ATTR_PACKED text;
|
||||
};
|
||||
macro_action_type_t type;
|
||||
} __attribute__ ((packed)) macro_action_t;
|
||||
} ATTR_PACKED macro_action_t;
|
||||
|
||||
// Variables:
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Includes:
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "attributes.h"
|
||||
#include "usb_api.h"
|
||||
#include "usb_descriptors/usb_descriptor_basic_keyboard_report.h"
|
||||
|
||||
@@ -26,7 +27,7 @@
|
||||
uint8_t modifiers;
|
||||
uint8_t reserved; // Always must be 0
|
||||
uint8_t scancodes[USB_BASIC_KEYBOARD_MAX_KEYS];
|
||||
} __attribute__ ((packed)) usb_basic_keyboard_report_t;
|
||||
} ATTR_PACKED usb_basic_keyboard_report_t;
|
||||
|
||||
// Variables:
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
typedef struct {
|
||||
uint16_t scancodes[USB_MEDIA_KEYBOARD_MAX_KEYS];
|
||||
} __attribute__ ((packed)) usb_media_keyboard_report_t;
|
||||
} ATTR_PACKED usb_media_keyboard_report_t;
|
||||
|
||||
// Variables:
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
int16_t y;
|
||||
int8_t wheelX;
|
||||
int8_t wheelY;
|
||||
} __attribute__ ((packed)) usb_mouse_report_t;
|
||||
} ATTR_PACKED usb_mouse_report_t;
|
||||
|
||||
// Variables:
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Includes:
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "attributes.h"
|
||||
#include "usb_api.h"
|
||||
#include "usb_descriptors/usb_descriptor_system_keyboard_report.h"
|
||||
|
||||
@@ -24,7 +25,7 @@
|
||||
|
||||
typedef struct {
|
||||
uint8_t scancodes[USB_SYSTEM_KEYBOARD_MAX_KEYS];
|
||||
} __attribute__ ((packed)) usb_system_keyboard_report_t;
|
||||
} ATTR_PACKED usb_system_keyboard_report_t;
|
||||
|
||||
// Variables:
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#include "wormhole.h"
|
||||
|
||||
wormhole_t Wormhole NO_INIT_GCC;
|
||||
wormhole_t ATTR_NO_INIT Wormhole;
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
// Includes:
|
||||
|
||||
#include <stdint.h>
|
||||
#include "attributes.h"
|
||||
|
||||
// Macros:
|
||||
|
||||
#define WORMHOLE_MAGIC_NUMBER 0x3b04cd9e94521f9a
|
||||
#define NO_INIT_GCC __attribute__ ((section (".noinit")))
|
||||
|
||||
// Typedefs:
|
||||
|
||||
@@ -26,6 +26,6 @@
|
||||
|
||||
// Variables:
|
||||
|
||||
extern wormhole_t Wormhole NO_INIT_GCC;
|
||||
extern wormhole_t ATTR_NO_INIT Wormhole;
|
||||
|
||||
#endif
|
||||
|
||||
11
shared/attributes.h
Normal file
11
shared/attributes.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef __ATTRIBUTES_H__
|
||||
#define __ATTRIBUTES_H__
|
||||
|
||||
// Macros:
|
||||
|
||||
#define ATTR_PACKED __attribute__ ((packed))
|
||||
#define ATTR_NO_INIT __attribute__ ((section (".noinit")))
|
||||
#define ATTR_DATA2 __attribute__((section (".m_data_2")))
|
||||
#define ATTR_BOOTLOADER_CONFIG __attribute__((used, section(".BootloaderConfig")))
|
||||
|
||||
#endif
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "attributes.h"
|
||||
#include "i2c_addresses.h"
|
||||
|
||||
// Macros:
|
||||
@@ -14,7 +15,7 @@
|
||||
#define CLOCK_FLAG_HIGH_SPEED_MODE 0x01
|
||||
|
||||
#define DEFINE_BOOTLOADER_CONFIG_AREA(address) \
|
||||
__attribute__((used, section(".BootloaderConfig"))) const bootloader_config_t BootloaderConfig = { \
|
||||
const ATTR_BOOTLOADER_CONFIG bootloader_config_t BootloaderConfig = { \
|
||||
.tag = BOOTLOADER_TAG, \
|
||||
.enabledPeripherals = EnabledBootloaderPeripherial_I2c, \
|
||||
.i2cSlaveAddress = address, \
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Includes:
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "attributes.h"
|
||||
|
||||
// Macros:
|
||||
|
||||
@@ -38,7 +39,7 @@
|
||||
uint8_t length;
|
||||
uint16_t crc;
|
||||
uint8_t data[I2C_MESSAGE_MAX_PAYLOAD_LENGTH];
|
||||
} __attribute__ ((packed)) i2c_message_t;
|
||||
} ATTR_PACKED i2c_message_t;
|
||||
|
||||
// Variables:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user