Contiki 2.6

Platform_common

Compiler and Platform specific definitions and typedefs common to all platforms. More...

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)   (1U << (x))
 Useful to reference a single bit of a byte.
#define BIT32(x)   (((int32u) 1) << (x))
 Useful to reference a single bit of an int32u 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.

Byte Manipulation Macros

#define LOW_BYTE(n)   ((int8u)((n) & 0xFF))
 Returns the low byte of the 16-bit value n as an int8u.
#define HIGH_BYTE(n)   ((int8u)(LOW_BYTE((n) >> 8)))
 Returns the high byte of the 16-bit value n as an int8u.
#define HIGH_LOW_TO_INT(high, low)
 Returns the value built from the two int8u values high and low.
#define BYTE_0(n)   ((int8u)((n) & 0xFF))
 Returns the low byte of the 32-bit value n as an int8u.
#define BYTE_1(n)   ((int8u)(BYTE_0((n) >> 8)))
 Returns the second byte of the 32-bit value n as an int8u.
#define BYTE_2(n)   ((int8u)(BYTE_0((n) >> 16)))
 Returns the third byte of the 32-bit value n as an int8u.
#define BYTE_3(n)   ((int8u)(BYTE_0((n) >> 24)))
 Returns the high byte of the 32-bit value n as an int8u.

Time Manipulation Macros

#define elapsedTimeInt8u(oldTime, newTime)   ((int8u) ((int8u)(newTime) - (int8u)(oldTime)))
 Returns the elapsed time between two 8 bit values.
#define elapsedTimeInt16u(oldTime, newTime)   ((int16u) ((int16u)(newTime) - (int16u)(oldTime)))
 Returns the elapsed time between two 16 bit values.
#define elapsedTimeInt32u(oldTime, newTime)   ((int32u) ((int32u)(newTime) - (int32u)(oldTime)))
 Returns the elapsed time between two 32 bit values.
#define MAX_INT8U_VALUE   0xFF
 Returns TRUE if t1 is greater than t2.
#define timeGTorEqualInt8u(t1, t2)   (elapsedTimeInt8u(t2, t1) <= ((MAX_INT8U_VALUE + 1) / 2))
#define MAX_INT16U_VALUE   0xFFFF
 Returns TRUE if t1 is greater than t2.
#define timeGTorEqualInt16u(t1, t2)   (elapsedTimeInt16u(t2, t1) <= ((MAX_INT16U_VALUE + 1) / 2))
#define MAX_INT32U_VALUE   0xFFFFFFFF
 Returns TRUE if t1 is greater than t2.
#define timeGTorEqualInt32u(t1, t2)   (elapsedTimeInt32u(t2, t1) <= ((MAX_INT32U_VALUE + 1) / 2))

Detailed Description

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.


Define Documentation

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

Definition at line 221 of file platform-common.h.

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

Definition at line 228 of file platform-common.h.

#define elapsedTimeInt16u (   oldTime,
  newTime 
)    ((int16u) ((int16u)(newTime) - (int16u)(oldTime)))

Returns the elapsed time between two 16 bit values.

Result may not be valid if the time samples differ by more than 32767

Definition at line 309 of file platform-common.h.

#define elapsedTimeInt32u (   oldTime,
  newTime 
)    ((int32u) ((int32u)(newTime) - (int32u)(oldTime)))

Returns the elapsed time between two 32 bit values.

Result may not be valid if the time samples differ by more than 2147483647

Definition at line 316 of file platform-common.h.

#define elapsedTimeInt8u (   oldTime,
  newTime 
)    ((int8u) ((int8u)(newTime) - (int8u)(oldTime)))

Returns the elapsed time between two 8 bit values.

Result may not be valid if the time samples differ by more than 127

Definition at line 302 of file platform-common.h.

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

Definition at line 331 of file platform-common.h.

#define MAX_INT32U_VALUE   0xFFFFFFFF

Returns TRUE if t1 is greater than t2.

Can only account for 1 wrap around of the variable before it is wrong.

Definition at line 339 of file platform-common.h.

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

Definition at line 323 of file platform-common.h.

#define SETBIT (   reg,
  bit 
)    reg |= BIT(bit)

Sets bit in the reg register or byte.

Note:
Assuming reg is an IO register, some platforms can implement this in a single atomic operation.

Definition at line 207 of file platform-common.h.

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

Definition at line 214 of file platform-common.h.