Compiler and Platform specific definitions and typedefs common to all platforms.
|
#define
|
MEMSET
(d, v, l) memset(d, v, l)
|
|
Friendly convenience macro pointing to the C Stdlib functions.
|
|
#define
|
MEMCOPY
(d, s, l) memcpy(d, s, l)
|
|
#define
|
MEMMOVE
(d, s, l) memmove(d, s, l)
|
|
#define
|
MEMPGMCOPY
(d, s, l) memcpy(d, s, l)
|
|
#define
|
MEMCOMPARE
(s0, s1, l) memcmp(s0, s1, l)
|
|
#define
|
MEMPGMCOMPARE
(s0, s1, l) memcmp(s0, s1, l)
|
|
#define
|
TRUE
1
|
|
An alias for one, used for clarity.
|
|
#define
|
FALSE
0
|
|
An alias for zero, used for clarity.
|
|
#define
|
NULL
((void *)0)
|
|
The null pointer.
|
|
#define
|
BIT
(x) (1U << (x))
|
|
Useful to reference a single bit of a byte.
|
|
#define
|
BIT32
(x) (((uint32_t) 1) << (x))
|
|
Useful to reference a single bit of an uint32_t type.
|
|
#define
|
SETBIT
(reg, bit) (reg) |=
BIT
(bit)
|
|
Sets
bit
in the
reg
register or byte.
|
|
#define
|
SETBITS
(reg, bits) (reg) |= (bits)
|
|
Sets the bits in the
reg
register or the byte as specified in the bitmask
bits
.
|
|
#define
|
CLEARBIT
(reg, bit) (reg) &= ~(
BIT
(bit))
|
|
Clears a bit in the
reg
register or byte.
|
|
#define
|
CLEARBITS
(reg, bits) (reg) &= ~(bits)
|
|
Clears the bits in the
reg
register or byte as specified in the bitmask
bits
.
|
|
#define
|
READBIT
(reg, bit) ((reg) & (
BIT
(bit)))
|
|
Returns the value of
bit
within the register or byte
reg
.
|
|
#define
|
READBITS
(reg, bits) ((reg) & (bits))
|
|
Returns the value of the bitmask
bits
within the register or byte
reg
.
|
|
#define
|
LOW_BYTE
(n) ((uint8_t)((n) & 0xFF))
|
|
Returns the low byte of the 16-bit value
n
as an
uint8_t
.
|
|
#define
|
HIGH_BYTE
(n) ((uint8_t)(
LOW_BYTE
((n) >> 8)))
|
|
Returns the high byte of the 16-bit value
n
as an
uint8_t
.
|
|
#define
|
HIGH_LOW_TO_INT
(high, low)
|
|
Returns the value built from the two
uint8_t
values
high
and
low
.
|
|
#define
|
INT8U_TO_INT32U
(byte3, byte2, byte1, byte0)
|
|
Returns the value built from the four
uint8_t
as an
uint32_t
.
|
|
#define
|
BYTE_0
(n) ((uint8_t)((n) & 0xFF))
|
|
Returns the low byte of the 32-bit value
n
as an
uint8_t
.
|
|
#define
|
BYTE_1
(n)
BYTE_0
((n) >> 8)
|
|
Returns the second byte of the 32-bit value
n
as an
uint8_t
.
|
|
#define
|
BYTE_2
(n)
BYTE_0
((n) >> 16)
|
|
Returns the third byte of the 32-bit value
n
as an
uint8_t
.
|
|
#define
|
BYTE_3
(n)
BYTE_0
((n) >> 24)
|
|
Returns the high byte of the 32-bit value
n
as an
uint8_t
.
|
|
#define
|
BYTE_4
(n)
BYTE_0
((n) >> 32)
|
|
Returns the fifth byte of the 64-bit value
n
as an
uint8_t
.
|
|
#define
|
BYTE_5
(n)
BYTE_0
((n) >> 40)
|
|
Returns the sixth byte of the 64-bit value
n
as an
uint8_t
.
|
|
#define
|
BYTE_6
(n)
BYTE_0
((n) >> 48)
|
|
Returns the seventh byte of the 64-bit value
n
as an
uint8_t
.
|
|
#define
|
BYTE_7
(n)
BYTE_0
((n) >> 56)
|
|
Returns the high byte of the 64-bit value
n
as an
uint8_t
.
|
|
#define
|
COUNTOF
(a) (sizeof(a) / sizeof(a[0]))
|
|
Returns the number of entries in an array.
|
|
#define
|
elapsedTimeInt8u
(oldTime, newTime) ((uint8_t) ((uint8_t)(newTime) - (uint8_t)(oldTime)))
|
|
Returns the elapsed time between two 8 bit values. Result may not be valid if the time samples differ by more than 127.
|
|
#define
|
elapsedTimeInt16u
(oldTime, newTime) ((uint16_t) ((uint16_t)(newTime) - (uint16_t)(oldTime)))
|
|
Returns the elapsed time between two 16 bit values. Result may not be valid if the time samples differ by more than 32767.
|
|
#define
|
elapsedTimeInt32u
(oldTime, newTime) ((uint32_t) ((uint32_t)(newTime) - (uint32_t)(oldTime)))
|
|
Returns the elapsed time between two 32 bit values. Result may not be valid if the time samples differ by more than 2147483647.
|
|
#define
|
MAX_INT8U_VALUE
(0xFF)
|
|
Returns true if t1 is greater than t2. Can only account for 1 wrap around of the variable before it is wrong.
|
|
#define
|
HALF_MAX_INT8U_VALUE
(0x80)
|
|
Returns the elapsed time between two 8 bit values. Result may not be valid if the time samples differ by more than 127.
|
|
#define
|
timeGTorEqualInt8u
(t1, t2) (
elapsedTimeInt8u
(t2, t1) <= (
HALF_MAX_INT8U_VALUE
))
|
|
Returns the elapsed time between two 8 bit values. Result may not be valid if the time samples differ by more than 127.
|
|
#define
|
MAX_INT16U_VALUE
(0xFFFF)
|
|
Returns true if t1 is greater than t2. Can only account for 1 wrap around of the variable before it is wrong.
|
|
#define
|
HALF_MAX_INT16U_VALUE
(0x8000)
|
|
Returns the elapsed time between two 8 bit values. Result may not be valid if the time samples differ by more than 127.
|
|
#define
|
timeGTorEqualInt16u
(t1, t2) (
elapsedTimeInt16u
(t2, t1) <= (
HALF_MAX_INT16U_VALUE
))
|
|
Returns the elapsed time between two 8 bit values. Result may not be valid if the time samples differ by more than 127.
|
|
#define
|
MAX_INT32U_VALUE
(0xFFFFFFFFUL)
|
|
Returns true if t1 is greater than t2. Can only account for 1 wrap around of the variable before it is wrong.
|
|
#define
|
HALF_MAX_INT32U_VALUE
(0x80000000UL)
|
|
Returns the elapsed time between two 8 bit values. Result may not be valid if the time samples differ by more than 127.
|
|
#define
|
timeGTorEqualInt32u
(t1, t2) (
elapsedTimeInt32u
(t2, t1) <= (
HALF_MAX_INT32U_VALUE
))
|
|
Returns the elapsed time between two 8 bit values. Result may not be valid if the time samples differ by more than 127.
|
|
#define
|
UNUSED_VAR
(x) (void)(x)
|
|
#define
|
DEBUG_LEVEL
BASIC_DEBUG
|
|
Set debug level based on whether DEBUG or DEBUG_STRIPPED are defined.
|
|
#define
|
STATIC_ASSERT
(__condition, __errorstr)
|
|
Disable static assertions on compilers that don't support them.
|
Compiler and Platform specific definitions and typedefs common to all platforms.
platform-common.h
provides PLATFORM_HEADER defaults and common definitions. This head should never be included directly, it should only be included by the specific PLATFORM_HEADER used by your platform.
See
platform-common.h
for source code.
◆
BIT
#define BIT
|
(
|
|
x
|
)
|
(1U << (x))
|
Useful to reference a single bit of a byte.
◆
BIT32
#define BIT32
|
(
|
|
x
|
)
|
(((uint32_t) 1) << (x))
|
Useful to reference a single bit of an uint32_t type.
◆
BYTE_0
#define BYTE_0
|
(
|
|
n
|
)
|
((uint8_t)((n) & 0xFF))
|
Returns the low byte of the 32-bit value
n
as an
uint8_t
.
◆
BYTE_1
#define BYTE_1
|
(
|
|
n
|
)
|
BYTE_0
((n) >> 8)
|
Returns the second byte of the 32-bit value
n
as an
uint8_t
.
◆
BYTE_2
#define BYTE_2
|
(
|
|
n
|
)
|
BYTE_0
((n) >> 16)
|
Returns the third byte of the 32-bit value
n
as an
uint8_t
.
◆
BYTE_3
#define BYTE_3
|
(
|
|
n
|
)
|
BYTE_0
((n) >> 24)
|
Returns the high byte of the 32-bit value
n
as an
uint8_t
.
◆
BYTE_4
#define BYTE_4
|
(
|
|
n
|
)
|
BYTE_0
((n) >> 32)
|
Returns the fifth byte of the 64-bit value
n
as an
uint8_t
.
◆
BYTE_5
#define BYTE_5
|
(
|
|
n
|
)
|
BYTE_0
((n) >> 40)
|
Returns the sixth byte of the 64-bit value
n
as an
uint8_t
.
◆
BYTE_6
#define BYTE_6
|
(
|
|
n
|
)
|
BYTE_0
((n) >> 48)
|
Returns the seventh byte of the 64-bit value
n
as an
uint8_t
.
◆
BYTE_7
#define BYTE_7
|
(
|
|
n
|
)
|
BYTE_0
((n) >> 56)
|
Returns the high byte of the 64-bit value
n
as an
uint8_t
.
◆
CLEARBIT
#define CLEARBIT
|
(
|
|
reg,
|
|
|
|
bit
|
|
)
|
|
(reg) &= ~(
BIT
(bit))
|
Clears a bit in the
reg
register or byte.
-
Note
-
Assuming
reg
is an IO register, some platforms (such as the AVR) can implement this in a single atomic operation.
◆
CLEARBITS
#define CLEARBITS
|
(
|
|
reg,
|
|
|
|
bits
|
|
)
|
|
(reg) &= ~(bits)
|
Clears the bits in the
reg
register or byte as specified in the bitmask
bits
.
-
Note
-
This is never a single atomic operation.
◆
COUNTOF
#define COUNTOF
|
(
|
|
a
|
)
|
(sizeof(a) / sizeof(a[0]))
|
Returns the number of entries in an array.
◆
DEBUG_LEVEL
Set debug level based on whether DEBUG or DEBUG_STRIPPED are defined.
◆
elapsedTimeInt16u
#define elapsedTimeInt16u
|
(
|
|
oldTime,
|
|
|
|
newTime
|
|
)
|
|
((uint16_t) ((uint16_t)(newTime) - (uint16_t)(oldTime)))
|
Returns the elapsed time between two 16 bit values. Result may not be valid if the time samples differ by more than 32767.
◆
elapsedTimeInt32u
#define elapsedTimeInt32u
|
(
|
|
oldTime,
|
|
|
|
newTime
|
|
)
|
|
((uint32_t) ((uint32_t)(newTime) - (uint32_t)(oldTime)))
|
Returns the elapsed time between two 32 bit values. Result may not be valid if the time samples differ by more than 2147483647.
◆
elapsedTimeInt8u
#define elapsedTimeInt8u
|
(
|
|
oldTime,
|
|
|
|
newTime
|
|
)
|
|
((uint8_t) ((uint8_t)(newTime) - (uint8_t)(oldTime)))
|
Returns the elapsed time between two 8 bit values. Result may not be valid if the time samples differ by more than 127.
◆
FALSE
An alias for zero, used for clarity.
◆
HALF_MAX_INT16U_VALUE
#define HALF_MAX_INT16U_VALUE (0x8000)
|
Returns the elapsed time between two 8 bit values. Result may not be valid if the time samples differ by more than 127.
◆
HALF_MAX_INT32U_VALUE
#define HALF_MAX_INT32U_VALUE (0x80000000UL)
|
Returns the elapsed time between two 8 bit values. Result may not be valid if the time samples differ by more than 127.
◆
HALF_MAX_INT8U_VALUE
#define HALF_MAX_INT8U_VALUE (0x80)
|
Returns the elapsed time between two 8 bit values. Result may not be valid if the time samples differ by more than 127.
◆
HIGH_BYTE
#define HIGH_BYTE
|
(
|
|
n
|
)
|
((uint8_t)(
LOW_BYTE
((n) >> 8)))
|
Returns the high byte of the 16-bit value
n
as an
uint8_t
.
◆
HIGH_LOW_TO_INT
#define HIGH_LOW_TO_INT
|
(
|
|
high,
|
|
|
|
low
|
|
)
|
|
|
Value:
( \
((uint16_t) (((uint16_t) (high)) << 8)) \
+ ((uint16_t) ((low) & 0xFF)) \
)
Returns the value built from the two
uint8_t
values
high
and
low
.
◆
INT8U_TO_INT32U
#define INT8U_TO_INT32U
|
(
|
|
byte3,
|
|
|
|
byte2,
|
|
|
|
byte1,
|
|
|
|
byte0
|
|
)
|
|
|
Value:
( \
(((uint32_t) (byte3)) << 24) \
+ (((uint32_t) (byte2)) << 16) \
+ (((uint32_t) (byte1)) << 8) \
+ ((uint32_t) ((byte0) & 0xFF)) \
)
Returns the value built from the four
uint8_t
as an
uint32_t
.
◆
LOW_BYTE
#define LOW_BYTE
|
(
|
|
n
|
)
|
((uint8_t)((n) & 0xFF))
|
Returns the low byte of the 16-bit value
n
as an
uint8_t
.
◆
MAX_INT16U_VALUE
#define MAX_INT16U_VALUE (0xFFFF)
|
Returns true if t1 is greater than t2. Can only account for 1 wrap around of the variable before it is wrong.
◆
MAX_INT32U_VALUE
#define MAX_INT32U_VALUE (0xFFFFFFFFUL)
|
Returns true if t1 is greater than t2. Can only account for 1 wrap around of the variable before it is wrong.
◆
MAX_INT8U_VALUE
#define MAX_INT8U_VALUE (0xFF)
|
Returns true if t1 is greater than t2. Can only account for 1 wrap around of the variable before it is wrong.
◆
MEMCOMPARE
#define MEMCOMPARE
|
(
|
|
s0,
|
|
|
|
s1,
|
|
|
|
l
|
|
)
|
|
memcmp(s0, s1, l)
|
◆
MEMCOPY
#define MEMCOPY
|
(
|
|
d,
|
|
|
|
s,
|
|
|
|
l
|
|
)
|
|
memcpy(d, s, l)
|
◆
MEMMOVE
#define MEMMOVE
|
(
|
|
d,
|
|
|
|
s,
|
|
|
|
l
|
|
)
|
|
memmove(d, s, l)
|
◆
MEMPGMCOMPARE
#define MEMPGMCOMPARE
|
(
|
|
s0,
|
|
|
|
s1,
|
|
|
|
l
|
|
)
|
|
memcmp(s0, s1, l)
|
◆
MEMPGMCOPY
#define MEMPGMCOPY
|
(
|
|
d,
|
|
|
|
s,
|
|
|
|
l
|
|
)
|
|
memcpy(d, s, l)
|
◆
MEMSET
#define MEMSET
|
(
|
|
d,
|
|
|
|
v,
|
|
|
|
l
|
|
)
|
|
memset(d, v, l)
|
Friendly convenience macro pointing to the C Stdlib functions.
◆
NULL
◆
READBIT
#define READBIT
|
(
|
|
reg,
|
|
|
|
bit
|
|
)
|
|
((reg) & (
BIT
(bit)))
|
Returns the value of
bit
within the register or byte
reg
.
◆
READBITS
#define READBITS
|
(
|
|
reg,
|
|
|
|
bits
|
|
)
|
|
((reg) & (bits))
|
Returns the value of the bitmask
bits
within the register or byte
reg
.
◆
SETBIT
#define SETBIT
|
(
|
|
reg,
|
|
|
|
bit
|
|
)
|
|
(reg) |=
BIT
(bit)
|
Sets
bit
in the
reg
register or byte.
-
Note
-
Assuming
reg
is an IO register, some platforms (such as the AVR) can implement this in a single atomic operation.
◆
SETBITS
#define SETBITS
|
(
|
|
reg,
|
|
|
|
bits
|
|
)
|
|
(reg) |= (bits)
|
Sets the bits in the
reg
register or the byte as specified in the bitmask
bits
.
-
Note
-
This is never a single atomic operation.
◆
STATIC_ASSERT
#define STATIC_ASSERT
|
(
|
|
__condition,
|
|
|
|
__errorstr
|
|
)
|
|
|
Disable static assertions on compilers that don't support them.
◆
timeGTorEqualInt16u
Returns the elapsed time between two 8 bit values. Result may not be valid if the time samples differ by more than 127.
◆
timeGTorEqualInt32u
Returns the elapsed time between two 8 bit values. Result may not be valid if the time samples differ by more than 127.
◆
timeGTorEqualInt8u
Returns the elapsed time between two 8 bit values. Result may not be valid if the time samples differ by more than 127.
◆
TRUE
An alias for one, used for clarity.
◆
UNUSED_VAR
#define UNUSED_VAR
|
(
|
|
x
|
)
|
(void)(x)
|
Useful macro for avoiding compiler warnings related to unused function arguments or unused variables.