|
sarmfsw: SMFSW Toolbox (desinged for ARM / compatible with other 8b/16b/32b platforms) 4.0rc
SMFSW collection of miscellaneous functions \& macros (desinged for ARM / compatible with other 8b/16b/32b platforms)
|
ARM common macros. More...

Macros | |
| #define | Undefined (-1) |
| Undefined value. | |
| #define | Null (0) |
| Null Value. | |
| #define | pNull ((void *) 0) |
| Null pointer -> same as NULL in stdlib.h. | |
| #define | charNull ('\0') |
| Null Char. | |
| #define | True true |
True alias for true | |
| #define | False false |
False alias for false | |
| #define | TRUE true |
TRUE alias for true | |
| #define | FALSE false |
FALSE alias for false | |
| #define | UNUSED(X) |
Unused parameter X (to avoid gcc/g++ warnings) | |
| #define | UNUSED_RET (void) |
| Explicitly ignore function return (MISRA compliance) | |
| #define | _x_ UNUSED_RET |
| Short alias for UNUSED_RET. | |
| #define | GET_BITS(v, b) |
Get bits from mask b of variable v. | |
| #define | SET_BITS(v, b) |
Set bits b of variable v. | |
| #define | CLR_BITS(v, b) |
Clear bits b of variable v. | |
| #define | INV_BITS(v, b) |
Invert bits b of variable v. | |
| #define | SET_BITS_VAL(v, m, s) |
Set variable v to set value s with mask m. | |
| #define | TEST_BITS_SET(v, b) |
Test variable v with bits b (all set) | |
| #define | TEST_BITS_CLR(v, b) |
Test variable v with bits b (all cleared) | |
| #define | TEST_BITS_VAL(v, b) |
Test variable v with bits b (all set) | |
| #define | TEST_MASK_VAL(v, m, r) |
Test variable v with bits mask m is equal to r. | |
| #define | LSHIFT(v, n) |
Shift v n bits left. | |
| #define | RSHIFT(v, n) |
Shift v n bits right. | |
| #define | LSHIFT8(v, n) |
Shift v n bits left (up to 7b) | |
| #define | RSHIFT8(v, n) |
Shift v n bits right (up to 7b) | |
| #define | LSHIFT16(v, n) |
Shift v n bits left (up to 15b) | |
| #define | RSHIFT16(v, n) |
Shift v n bits right (up to 15b) | |
| #define | LSHIFT32(v, n) |
Shift v n bits left (up to 31b) | |
| #define | RSHIFT32(v, n) |
Shift v n bits right (up to 31b) | |
| #define | LSHIFT64(v, n) |
Shift v n bits left (up to 63b) | |
| #define | RSHIFT64(v, n) |
Shift v n bits right (up to 63b) | |
| #define | MAKEWORD(lsb, msb) |
Make WORD from lsb and msb. | |
| #define | MAKELONG(lsw, msw) |
Make LONG from lsw and msw. | |
| #define | LOBYTE(w) |
Get BYTE LSB from WORD w. | |
| #define | HIBYTE(w) |
Get BYTE MSB from WORD w. | |
| #define | LOWORD(l) |
Get WORD LSW from LONG l. | |
| #define | HIWORD(l) |
Get WORD MSW from LONG l. | |
| #define | SWAP_TYPE(a, b, typ) |
Swap two variable type typ a & b. | |
| #define | SWAP_BYTE(a, b) |
Swap two BYTE a & b. | |
| #define | SWAP_WORD(a, b) |
Swap two WORD a & b. | |
| #define | SWAP_DWORD(a, b) |
Swap two DWORD a & b. | |
| #define | SWAP_LWORD(a, b) |
Swap two LWORD a & b. | |
| #define | SWAP_FLOAT(a, b) |
Swap two float a & b. | |
| #define | SWAP_DOUBLE(a, b) |
Swap two double a & b. | |
| #define | VAL_AT(addr, typ) |
Get the type typ content of address addr. | |
| #define | SZ_ARRAY(arr) |
Computes the number of array elements in arr. | |
| #define | SZ_OBJ(obj, typ) |
Computes the number of elements in obj of type typ. | |
| #define | SZ_TYP_MBR(typ, mbr) |
Computes the size of member mbr in struct type typ. | |
| #define | TYP_MBR(typ, mbr) |
Get member mbr from a struct type typ. | |
| #define | TYP_MBR_TYP(typ, mbr) |
Get typeof member mbr from a struct type typ. | |
| #define | OFFSET_OF(typ, mbr) |
Computes the offset member mbr from struct type typ. | |
| #define | ROOT_OF(ptr, typ, mbr) |
Computes the address of parent struct typ of ptr from member mbr. | |
| #define | binEval(exp) |
boolean evaluation of expression exp | |
| #define | nbinEval(exp) |
complemented boolean evaluation of expression exp | |
| #define | isNull(p) |
Test is p is null. | |
| #define | isNotNull(p) |
Test is p is not null. | |
| #define | isOdd(v) |
Test is v is odd. | |
| #define | isEven(v) |
Test is v is even. | |
| #define | min MIN |
| #define | MIN(a, b) |
Returns min value between a and b. | |
| #define | max MAX |
| #define | MAX(a, b) |
Returns max value between a and b. | |
| #define | min3 MIN3 |
| #define | MIN3(a, b, c) |
Returns min value between a, b and c. | |
| #define | max3 MAX3 |
| #define | MAX3(a, b, c) |
Returns max value between a, b and c. | |
| #define | clamp CLAMP |
| #define | CLAMP(v, mn, mx) |
Returns the value between mn and mx from v. | |
| #define | SCALE_VAL(v, from_min, from_max, to_min, to_max) |
Scale value v from range from_min:from_max to range to_min:to_max. | |
| #define | SCALE_VAL_T(typ, v, from_min, from_max, to_min, to_max) |
Scale typed typ value v from range from_min:from_max to range to_min:to_max. | |
| #define | BYTE_TO_PERC(b) |
Converts a BYTE b (0-255) to percent (0-100) | |
| #define | PERC_TO_BYTE(p) |
Converts a p percentage (0-100) to BYTE (0-255) with max checking. | |
| #define | M_1_3 (1.0 / 3.0) |
| 1/3 constant approximation | |
| #define | M_2_3 (2.0 / 3.0) |
| 2/3 constant approximation | |
ARM common macros.
SINGLE_SHIFT_ONLY_OPCODE at project level (see LSHIFT & RSHIFT) #undef (misra-c2012-20.5)| #define _x_ UNUSED_RET |
Short alias for UNUSED_RET.
| #define binEval | ( | exp | ) |
boolean evaluation of expression exp
| #define BYTE_TO_PERC | ( | b | ) |
| #define charNull ('\0') |
Null Char.
| #define CLAMP | ( | v, | |
| mn, | |||
| mx ) |
| #define clamp CLAMP |
clamp alias for CLAMP
| #define CLR_BITS | ( | v, | |
| b ) |
Clear bits b of variable v.
| #define FALSE false |
FALSE alias for false
| #define False false |
False alias for false
| #define GET_BITS | ( | v, | |
| b ) |
Get bits from mask b of variable v.
| #define HIBYTE | ( | w | ) |
| #define HIWORD | ( | l | ) |
| #define INV_BITS | ( | v, | |
| b ) |
Invert bits b of variable v.
| #define isEven | ( | v | ) |
Test is v is even.
signed or unsigned use will produce the same result.| #define isNotNull | ( | p | ) |
| #define isNull | ( | p | ) |
Test is p is null.
| #define isOdd | ( | v | ) |
Test is v is odd.
signed or unsigned use will produce the same result.| #define LSHIFT | ( | v, | |
| n ) |
Shift v n bits left.
| #define LSHIFT64 | ( | v, | |
| n ) |
| #define M_1_3 (1.0 / 3.0) |
1/3 constant approximation
| #define M_2_3 (2.0 / 3.0) |
2/3 constant approximation
| #define MAKELONG | ( | lsw, | |
| msw ) |
| #define MAKEWORD | ( | lsb, | |
| msb ) |
| #define MAX | ( | a, | |
| b ) |
Returns max value between a and b.
| #define max MAX |
max alias for MAX
| #define MAX3 | ( | a, | |
| b, | |||
| c ) |
Returns max value between a, b and c.
| #define max3 MAX3 |
max3 alias for MAX3
| #define MIN | ( | a, | |
| b ) |
Returns min value between a and b.
| #define min MIN |
min alias for MIN
| #define MIN3 | ( | a, | |
| b, | |||
| c ) |
Returns min value between a, b and c.
| #define min3 MIN3 |
min3 alias for MIN3
| #define nbinEval | ( | exp | ) |
| #define Null (0) |
Null Value.
| #define OFFSET_OF | ( | typ, | |
| mbr ) |
Computes the offset member mbr from struct type typ.
typ parameter would be cast instead of type.mbr parameter shall be a structure member; will in any way raise an error in case not.| #define PERC_TO_BYTE | ( | p | ) |
| #define pNull ((void *) 0) |
Null pointer -> same as NULL in stdlib.h.
| #define ROOT_OF | ( | ptr, | |
| typ, | |||
| mbr ) |
Computes the address of parent struct typ of ptr from member mbr.
mbr parameter shall be a structure member; will in any way raise an error in case not.| #define RSHIFT | ( | v, | |
| n ) |
Shift v n bits right.
| #define SCALE_VAL | ( | v, | |
| from_min, | |||
| from_max, | |||
| to_min, | |||
| to_max ) |
Scale value v from range from_min:from_max to range to_min:to_max.
| #define SCALE_VAL_T | ( | typ, | |
| v, | |||
| from_min, | |||
| from_max, | |||
| to_min, | |||
| to_max ) |
Scale typed typ value v from range from_min:from_max to range to_min:to_max.
| #define SET_BITS | ( | v, | |
| b ) |
Set bits b of variable v.
| #define SET_BITS_VAL | ( | v, | |
| m, | |||
| s ) |
Set variable v to set value s with mask m.
| #define SWAP_BYTE | ( | a, | |
| b ) |
| #define SWAP_DOUBLE | ( | a, | |
| b ) |
Swap two double a & b.
| #define SWAP_FLOAT | ( | a, | |
| b ) |
Swap two float a & b.
| #define SWAP_TYPE | ( | a, | |
| b, | |||
| typ ) |
Swap two variable type typ a & b.
typ parameter would be cast instead of type declaration (thus raising error); other parameters shall be variable names, raising error otherwise is intended.| #define SZ_ARRAY | ( | arr | ) |
Computes the number of array elements in arr.
arr shall be an instance of type; raising error otherwise is intended.| #define SZ_OBJ | ( | obj, | |
| typ ) |
Computes the number of elements in obj of type typ.
obj parameter can be a type instead of an istance of type.typ parameter would be cast instead of type.| #define SZ_TYP_MBR | ( | typ, | |
| mbr ) |
Computes the size of member mbr in struct type typ.
typ parameter would be cast instead of type.mbr parameter shall be a structure member; will in any way raise an error in case not.| #define TEST_BITS_CLR | ( | v, | |
| b ) |
Test variable v with bits b (all cleared)
| #define TEST_BITS_SET | ( | v, | |
| b ) |
Test variable v with bits b (all set)
| #define TEST_BITS_VAL | ( | v, | |
| b ) |
Test variable v with bits b (all set)
| #define TEST_MASK_VAL | ( | v, | |
| m, | |||
| r ) |
Test variable v with bits mask m is equal to r.
| #define TRUE true |
TRUE alias for true
| #define True true |
True alias for true
| #define TYP_MBR | ( | typ, | |
| mbr ) |
Get member mbr from a struct type typ.
typ parameter would be cast instead of type.mbr parameter shall be a structure member; will in any way raise an error in case not.| #define TYP_MBR_TYP | ( | typ, | |
| mbr ) |
Get typeof member mbr from a struct type typ.
typeof C language extension should only be used to get a compiler native known type | #define Undefined (-1) |
Undefined value.
| #define UNUSED | ( | X | ) |
Unused parameter X (to avoid gcc/g++ warnings)
| #define UNUSED_RET (void) |
Explicitly ignore function return (MISRA compliance)
| #define VAL_AT | ( | addr, | |
| typ ) |
Get the type typ content of address addr.
typ parameter would be cast instead of type.