![]() |
EVE 1.0
|
![]() |
Data Structures | |
struct | mwork_t |
Macros | |
#define | MWORK_COUNTER_WIDTH (24) |
#define | MWORK_GUARD_WIDTH (2) |
#define | MWORK_EFFECTIVE_WIDTH (MWORK_COUNTER_WIDTH - MWORK_GUARD_WIDTH) |
#define | MWORK_TIME_MASK ((1 << MWORK_EFFECTIVE_WIDTH) - 1) |
#define | MWORK_ROUND_TIME(tick) ((tick) & MWORK_TIME_MASK) |
#define | MWORK_TIME_SPAN_IS_NEGATIVE(span) (((span) & (1 << (MWORK_EFFECTIVE_WIDTH - 1))) != 0) |
#define | MWORK_MSEC(ms) MS_TO_TICKS(ms) |
#define | MWORK_INIT(x, callback) |
#define | MWORK_INIT_TYPED(x, callback) (struct mwork_t) MWORK_INIT(x, callback) |
#define | DECLARE_MWORK(x, callback) struct mwork_t x = MWORK_INIT(x, callback) |
Typedefs | |
typedef uint32_t | mwork_time_t |
typedef void(* | mwork_cb_t) (struct mwork_t *work) |
Functions | |
static mwork_time_t | mwork_now () |
void | mwork_schedule (struct mwork_t *work) |
void | mwork_cancel (struct mwork_t *work) |
static bool | mwork_pending (struct mwork_t *work) |
void | mwork_timer (void) |
#define MWORK_COUNTER_WIDTH (24) |
#define MWORK_GUARD_WIDTH (2) |
Amount of counter register LSB bits, reserved as synchronization quard
Definition at line 64 of file mwork.h.
Referenced by mwork_now().
#define MWORK_EFFECTIVE_WIDTH (MWORK_COUNTER_WIDTH - MWORK_GUARD_WIDTH) |
#define MWORK_TIME_MASK ((1 << MWORK_EFFECTIVE_WIDTH) - 1) |
#define MWORK_ROUND_TIME | ( | tick | ) | ((tick) & MWORK_TIME_MASK) |
#define MWORK_TIME_SPAN_IS_NEGATIVE | ( | span | ) | (((span) & (1 << (MWORK_EFFECTIVE_WIDTH - 1))) != 0) |
#define MWORK_MSEC | ( | ms | ) | MS_TO_TICKS(ms) |
#define MWORK_INIT | ( | x, | |
callback | |||
) |
Initializes a milliwork structure.
The macro is used to initialize a millisecond-scale work (milliwork) structure instance.
x | milliwork structure |
callback | milliwork callback |
Usage:
#define MWORK_INIT_TYPED | ( | x, | |
callback | |||
) | (struct mwork_t) MWORK_INIT(x, callback) |
Initializes a milliwork structure. Typed version of MWORK_INIT
#define DECLARE_MWORK | ( | x, | |
callback | |||
) | struct mwork_t x = MWORK_INIT(x, callback) |
Instantiates a milliwork structure.
The macro is used to instantiate a work structure.
x | name of the milliwork structure |
callback | the milliwork callback |
Usage:
typedef uint32_t mwork_time_t |
Milliwork time type.
Only MWORK_EFFECTIVE_WIDTH LSB bits are used, while MSB of them becomes a sign bit, and the rest of the uint32_t is ignored by the framework. So, the max interval for the milliwork is 2^(24-2-1)-1 = 2097151 ticks, or ~34 min. Please use OS etimer for longer intervals.
typedef void(* mwork_cb_t) (struct mwork_t *work) |
|
inlinestatic |
Returns the current timestamp, which can be used as a time reference in struct mwork_t::at
Usage:
Definition at line 200 of file mwork.h.
References mwork_cancel(), MWORK_GUARD_WIDTH, mwork_schedule(), and mwork_t::work.
Referenced by app_timer_start().
void mwork_schedule | ( | struct mwork_t * | work | ) |
Schedules a milliwork.
The function schedules a milliwork for execution at the specified point in time. The milliwork will be executed at the software interrupt level, like a work item. It is allowed to schedule a milliwork in the past. In this case it is triggered for execution immediately.
If two or more milliworks are scheduled for the same tick, they will be executed in the same order as thay were scheduled. Due to non-preemptive execution of work items and milliworks at the software interrupt level, the actual time when the milliwork execution starts can vary.
If the milliwork structure, pointed by the work
parameter is already scheduled for execution, then it is re-scheduled at the new time.
A scheduled milliwork holds system at PM_LEVEL_LOWPWR power level.
work | pointer to the milliwork structure |
Referenced by app_timer_start(), and mwork_now().
void mwork_cancel | ( | struct mwork_t * | work | ) |
Cancels a scheduled milliwork.
The function cancels a previously scheduled work.
work | pointer to the milliwork structure |
Referenced by app_timer_stop(), and mwork_now().
|
inlinestatic |
Checks if the milliwork is scheduled and pending execution.
The function checks if the milliwork is scheduled for execution.
work | pointer to the milliwork structure |
Definition at line 249 of file mwork.h.
References dlist_is_empty(), work_t::link, mwork_timer(), and mwork_t::work.
void mwork_timer | ( | void | ) |
Milliwork timer
Referenced by mwork_pending().