platform-common.h File Reference

See Platform_common for detailed documentation. More...

Go to the source code of this file.

Defines

Master Program Memory Declarations

These are a set of defines for simple declarations of program memory.



#define PGM   const
 Standard program memory delcaration.
#define PGM_P   const char *
 Char pointer to program memory declaration.
#define PGM_PU   const unsigned char *
 Unsigned char pointer to program memory declaration.
#define PGM_NO_CONST
 Sometimes a second PGM is needed in a declaration.
Divide and Modulus Operations

Some platforms can perform divide and modulus operations on 32 bit quantities more efficiently when the divisor is only a 16 bit quantity.

C compilers will always promote the divisor to 32 bits before performing the operation, so the following utility functions are instead required to take advantage of this optimisation.



#define halCommonUDiv32By16(x, y)   ((int16u) (((int32u) (x)) / ((int16u) (y))))
 Provide a portable name for the int32u by int16u division library function (which can perform the division with only a single assembly instruction on some platforms).
#define halCommonSDiv32By16(x, y)   ((int16s) (((int32s) (x)) / ((int16s) (y))))
 Provide a portable name for the int32s by int16s division library function (which can perform the division with only a single assembly instruction on some platforms).
#define halCommonUMod32By16(x, y)   ((int16u) (((int32u) (x)) % ((int16u) (y))))
 Provide a portable name for the int32u by int16u modulo library function (which can perform the division with only a single assembly instruction on some platforms).
#define halCommonSMod32By16(x, y)   ((int16s) (((int32s) (x)) % ((int16s) (y))))
 Provide a portable name for the int32s by int16s modulo library function (which can perform the division with only a single assembly instruction on some platforms).
Generic Types



#define TRUE   1
 An alias for one, used for clarity.
#define FALSE   0
 An alias for zero, used for clarity.
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))

C Standard Library Memory Utilities

These should be used in place of the standard library functions.

These functions have the same parameters and expected results as their C Standard Library equivalents but may take advantage of certain implementation optimizations.

Unless otherwise noted, these functions are utilized by the StStack and are therefore required to be implemented in the HAL. Additionally, unless otherwise noted, applications that find these functions useful may utilze them.



#define MEMSET(d, v, l)   halCommonMemSet(d,v,l)
 Friendly convenience macro pointing to the full HAL function.
#define MEMCOPY(d, s, l)   halCommonMemCopy(d,s,l)
#define MEMCOMPARE(s0, s1, l)   halCommonMemCompare(s0, s1, l)
#define MEMPGMCOMPARE(s0, s1, l)   halCommonMemPGMCompare(s0, s1, l)
void halCommonMemCopy (void *dest, const void *src, int8u bytes)
 Refer to the C stdlib memcpy().
void halCommonMemSet (void *dest, int8u val, int16u bytes)
 Refer to the C stdlib memset().
int8s halCommonMemCompare (const void *source0, const void *source1, int8u bytes)
 Refer to the C stdlib memcmp().

Detailed Description

See Platform_common for detailed documentation.

Definition in file platform-common.h.


Generated on Mon Apr 11 14:23:50 2011 for Contiki 2.5 by  doxygen 1.6.1