Appiko
|
Common helpers used in C programs. More...
Macros | |
#define | MIN(a, b) ((a) < (b) ? (a) : (b)) |
#define | MAX(a, b) ((a) < (b) ? (b) : (a)) |
#define | CONCAT_2(p1, p2) CONCAT_2_(p1, p2) |
Concatenates or joins two parameters. More... | |
#define | CONCAT_2_(p1, p2) p1##p2 |
#define | CONCAT_3(p1, p2, p3) CONCAT_3_(p1, p2, p3) |
Concatenates or joins three parameters. More... | |
#define | CONCAT_3_(p1, p2, p3) p1##p2##p3 |
#define | ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) |
#define | ROUNDED_DIV(A, B) (((A) + ((B) / 2)) / (B)) |
Rounded integer division where the result is the integer closest to the answer instead of flooring the result. More... | |
#define | CEIL_DIV(A, B) (((A) + (B) - 1) / (B)) |
When the result of a division is not an integer, the result is rounded up to the next integer. More... | |
#define | IS_POWER_OF_TWO(A) ( ((A) != 0) && ((((A) - 1) & (A)) == 0) ) |
Checks if an integer is a power of two. More... | |
#define | MSEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000) / (RESOLUTION)) |
Macro for converting ms to ticks. More... | |
#define | SET_BIT_VAR(VAR, BIT_NO) (VAR | (1 << BIT_NO)) |
Macro to set particular bit in a given variable without affecting other bits. More... | |
#define | CLR_BIT_VAR(VAR, BIT_NO) (VAR & ~(1 << BIT_NO)) |
Macro to clear particular bit in a given variable without affecting other bits. More... | |
Enumerations | |
enum | { UNIT_0_625_MS = 625, UNIT_1_25_MS = 1250, UNIT_10_MS = 10000 } |
#define ARRAY_SIZE | ( | arr | ) | (sizeof(arr) / sizeof((arr)[0])) |
The number of elements inside a array
Definition at line 70 of file common_util.h.
#define CEIL_DIV | ( | A, | |
B | |||
) | (((A) + (B) - 1) / (B)) |
[in] | A | Numerator for the division. |
[in] | B | Denominator for the division. |
Definition at line 90 of file common_util.h.
#define CLR_BIT_VAR | ( | VAR, | |
BIT_NO | |||
) | (VAR & ~(1 << BIT_NO)) |
[in] | VAR | Variable from which bit is to be clear |
[in] | BIT_NO | Bit number which is be clear |
Definition at line 129 of file common_util.h.
#define CONCAT_2 | ( | p1, | |
p2 | |||
) | CONCAT_2_(p1, p2) |
Two level expansion are needed to make sure that the two parameters are fully expanded before joining them together.
p1 | First parameter for concatenating |
p2 | Second parameter for concatenating |
Definition at line 48 of file common_util.h.
#define CONCAT_2_ | ( | p1, | |
p2 | |||
) | p1##p2 |
Private macro used by CONCAT_2
Definition at line 50 of file common_util.h.
#define CONCAT_3 | ( | p1, | |
p2, | |||
p3 | |||
) | CONCAT_3_(p1, p2, p3) |
Two level expansion are needed to make sure that the three parameters are fully expanded before joining them together.
p1 | First parameter for concatenating |
p2 | Second parameter for concatenating |
p3 | Third parameter for concatenating |
Definition at line 65 of file common_util.h.
#define CONCAT_3_ | ( | p1, | |
p2, | |||
p3 | |||
) | p1##p2##p3 |
Private macro used by CONCAT_3
Definition at line 67 of file common_util.h.
#define IS_POWER_OF_TWO | ( | A | ) | ( ((A) != 0) && ((((A) - 1) & (A)) == 0) ) |
[in] | A | The number to be checked. |
Definition at line 99 of file common_util.h.
#define MAX | ( | a, | |
b | |||
) | ((a) < (b) ? (b) : (a)) |
The maximum of the two 32-bit arguments
Definition at line 34 of file common_util.h.
#define MIN | ( | a, | |
b | |||
) | ((a) < (b) ? (a) : (b)) |
The minimum of the two 32-bit arguments
Definition at line 32 of file common_util.h.
#define MSEC_TO_UNITS | ( | TIME, | |
RESOLUTION | |||
) | (((TIME) * 1000) / (RESOLUTION)) |
[in] | TIME | Number of ms to convert. |
[in] | RESOLUTION | Unit to be converted to in [us/ticks]. |
Definition at line 113 of file common_util.h.
#define ROUNDED_DIV | ( | A, | |
B | |||
) | (((A) + ((B) / 2)) / (B)) |
[in] | A | Numerator for the division. |
[in] | B | Denominator for the division. |
Definition at line 80 of file common_util.h.
#define SET_BIT_VAR | ( | VAR, | |
BIT_NO | |||
) | (VAR | (1 << BIT_NO)) |
[in] | VAR | Variable from which bit is to be set |
[in] | BIT_NO | Bit number which is be set |
Definition at line 121 of file common_util.h.
anonymous enum |
Enumerator | |
---|---|
UNIT_0_625_MS | Number of us in 0.625 ms. |
UNIT_1_25_MS | Number of us in 1.25 ms. |
UNIT_10_MS | Number of us in 10 ms. |
Definition at line 101 of file common_util.h.