5#define LEVEL_DURATION_BIG
7#ifdef LEVEL_DURATION_BIG
9#define LEVEL_DURATION_RESET 0U
10#define LEVEL_DURATION_LEVEL_LOW 1U
11#define LEVEL_DURATION_LEVEL_HIGH 2U
12#define LEVEL_DURATION_WAIT 3U
13#define LEVEL_DURATION_RESERVED 0x800000U
16 uint32_t duration : 30;
20static inline LevelDuration level_duration_make(
bool level, uint32_t duration) {
22 level_duration.level = level ? LEVEL_DURATION_LEVEL_HIGH : LEVEL_DURATION_LEVEL_LOW;
23 level_duration.duration = duration;
24 return level_duration;
29 level_duration.level = LEVEL_DURATION_RESET;
30 return level_duration;
35 level_duration.level = LEVEL_DURATION_WAIT;
36 return level_duration;
39static inline bool level_duration_is_reset(
LevelDuration level_duration) {
40 return level_duration.level == LEVEL_DURATION_RESET;
43static inline bool level_duration_is_wait(
LevelDuration level_duration) {
44 return level_duration.level == LEVEL_DURATION_WAIT;
47static inline bool level_duration_get_level(
LevelDuration level_duration) {
48 return level_duration.level == LEVEL_DURATION_LEVEL_HIGH;
51static inline uint32_t level_duration_get_duration(
LevelDuration level_duration) {
52 return level_duration.duration;
57#define LEVEL_DURATION_RESET 0U
58#define LEVEL_DURATION_RESERVED 0x800000U
62static inline LevelDuration level_duration(
bool level, uint32_t duration) {
63 return level ? duration : -(int32_t)duration;
67 return LEVEL_DURATION_RESET;
70static inline bool level_duration_is_reset(
LevelDuration level_duration) {
71 return level_duration == LEVEL_DURATION_RESET;
74static inline bool level_duration_get_level(
LevelDuration level_duration) {
75 return level_duration > 0;
78static inline uint32_t level_duration_get_duration(
LevelDuration level_duration) {
79 return (level_duration >= 0) ? level_duration : -level_duration;
Definition level_duration.h:15