Common PLATFORM_HEADER Configuration#

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.

Generic Types#

#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.

Bit Manipulation Macros#

#define
BIT (x)

Useful to reference a single bit of a byte.

#define
BIT32 (x)

Useful to reference a single bit of an uint32_t type.

#define
SETBIT (reg, bit)

Sets bit in the reg register or byte.

#define
SETBITS (reg, bits)

Sets the bits in the reg register or the byte as specified in the bitmask bits.

#define
CLEARBIT (reg, bit)

Clears a bit in the reg register or byte.

#define
CLEARBITS (reg, bits)

Clears the bits in the reg register or byte as specified in the bitmask bits.

#define
READBIT (reg, bit)

Returns the value of bit within the register or byte reg.

#define
READBITS (reg, bits)

Returns the value of the bitmask bits within the register or byte reg.

Byte Manipulation Macros#

#define
LOW_BYTE (n)

Returns the low byte of the 16-bit value n as an uint8_t.

#define
HIGH_BYTE (n)

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)

Returns the low byte of the 32-bit value n as an uint8_t.

#define
BYTE_1 (n)

Returns the second byte of the 32-bit value n as an uint8_t.

#define
BYTE_2 (n)

Returns the third byte of the 32-bit value n as an uint8_t.

#define
BYTE_3 (n)

Returns the high byte of the 32-bit value n as an uint8_t.

#define
BYTE_4 (n)

Returns the fifth byte of the 64-bit value n as an uint8_t.

#define
BYTE_5 (n)

Returns the sixth byte of the 64-bit value n as an uint8_t.

#define
BYTE_6 (n)

Returns the seventh byte of the 64-bit value n as an uint8_t.

#define
BYTE_7 (n)

Returns the high byte of the 64-bit value n as an uint8_t.

#define
COUNTOF (a)

Returns the number of entries in an array.

Time Manipulation Macros#

#define
elapsedTimeInt8u (oldTime, newTime)

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)

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)

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)

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)

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)

Returns the elapsed time between two 8 bit values. Result may not be valid if the time samples differ by more than 127.

Miscellaneous Macros#

#define
UNUSED_VAR (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.

Macros#

#define
MEMSET (d, v, l)

Friendly convenience macro pointing to the C Stdlib functions.

#define
MEMCOPY (d, s, l)
#define
MEMMOVE (d, s, l)
#define
MEMPGMCOPY (d, s, l)
#define
MEMCOMPARE (s0, s1, l)
#define
MEMPGMCOMPARE (s0, s1, l)

Generic Types Documentation#

Bit Manipulation Macros Documentation#

Byte Manipulation Macros Documentation#

Time Manipulation Macros Documentation#

Miscellaneous Macros Documentation#