Add ATTR_* macros in the newly created attributes.h and use them wherever possible for improved readability.

This commit is contained in:
László Monda
2017-10-04 22:26:48 +02:00
parent f348aec97a
commit 4295793fb9
12 changed files with 40 additions and 23 deletions

11
shared/attributes.h Normal file
View 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

View File

@@ -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, \

View File

@@ -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: