mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
Simplify timer definitions
This commit is contained in:
parent
3e56bb75cf
commit
3171fa27ce
2 changed files with 519 additions and 643 deletions
|
@ -27,6 +27,9 @@
|
|||
|
||||
#define CONCAT_HELPER(x,y) x ## y
|
||||
#define CONCAT(x,y) CONCAT_HELPER(x, y)
|
||||
#define CONCAT2(_1,_2) CONCAT(_1, _2)
|
||||
#define CONCAT3(_1,_2,_3) CONCAT(CONCAT(_1, _2), _3)
|
||||
#define CONCAT4(_1,_2,_3,_4) CONCAT(CONCAT3(_1, _2, _3), _4)
|
||||
|
||||
#define STR_HELPER(x) #x
|
||||
#define STR(x) STR_HELPER(x)
|
||||
|
@ -34,6 +37,18 @@
|
|||
#define EXPAND_I(x) x
|
||||
#define EXPAND(x) EXPAND_I(x)
|
||||
|
||||
// expand to t if bit is 1, f when bit is 0. Other bit values are not supported
|
||||
#define PP_IIF(bit, t, f) PP_IIF_I(bit, t, f)
|
||||
#define PP_IIF_I(bit, t, f) PP_IIF_ ## bit(t, f)
|
||||
#define PP_IIF_0(t, f) f
|
||||
#define PP_IIF_1(t, f) t
|
||||
|
||||
// Expand all argumens and call macro with them. When expansion of some argument contains ',', it will be passed as multiple arguments
|
||||
// #define TAKE3(_1,_2,_3) CONCAT3(_1,_2,_3)
|
||||
// #define MULTI2 A,B
|
||||
// PP_CALL(TAKE3, MULTI2, C) expands to ABC
|
||||
#define PP_CALL(macro, ...) macro(__VA_ARGS__)
|
||||
|
||||
#if !defined(UNUSED)
|
||||
#define UNUSED(x) (void)(x)
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue