|
PebbleOS
|
Ticks, timeouts and thread priorities shared by every kernel object. More...
Data Structures | |
| struct | pbl_timeout_t |
| Timeout of a blocking call. More... | |
Macros | |
| #define | PBL_TICK_HZ CONFIG_KERNEL_TICK_HZ |
Tick rate in Hz, from CONFIG_KERNEL_TICK_HZ. | |
| #define | PBL_TICK_FOREVER UINT32_MAX |
| Tick count that stands for an infinite timeout. | |
| #define | PBL_NO_WAIT ((pbl_timeout_t){.ticks = 0}) |
Do not wait: fail with -EBUSY if the call would block. | |
| #define | PBL_FOREVER ((pbl_timeout_t){.ticks = PBL_TICK_FOREVER}) |
| Wait without a time limit. | |
| #define | PBL_TICKS(t) ((pbl_timeout_t){.ticks = (t)}) |
| Timeout in ticks. | |
| #define | PBL_MSEC(ms) ((pbl_timeout_t){.ticks = pbl_ms_to_ticks(ms)}) |
| Timeout in milliseconds, rounded down to whole ticks. | |
| #define | PBL_SEC(s) PBL_MSEC((s) * 1000U) |
| Timeout in seconds. | |
| #define | PBL_PRIO_IDLE ((pbl_prio_t)0) |
| Lowest priority, the one of the idle thread. | |
| #define | PBL_PRIO_MAX ((pbl_prio_t)(CONFIG_KERNEL_NUM_PRIORITIES - 1)) |
Highest priority, CONFIG_KERNEL_NUM_PRIORITIES - 1. | |
Typedefs | |
| typedef uint32_t | pbl_tick_t |
| Kernel tick count. | |
| typedef uint8_t | pbl_prio_t |
| Thread priority. | |
Functions | |
| pbl_tick_t | pbl_ms_to_ticks (uint32_t ms) |
| Convert milliseconds to ticks, rounding down. | |
| uint32_t | pbl_ticks_to_ms (pbl_tick_t ticks) |
| Convert ticks to milliseconds, rounding down. | |
| static bool | pbl_timeout_is_forever (pbl_timeout_t t) |
| Check whether a timeout is PBL_FOREVER. | |
| static bool | pbl_timeout_is_no_wait (pbl_timeout_t t) |
| Check whether a timeout is PBL_NO_WAIT. | |
Ticks, timeouts and thread priorities shared by every kernel object.
Blocking calls take a pbl_timeout_t built with one of the timeout macros, so ticks and milliseconds cannot be mixed up:
| struct pbl_timeout_t |
Timeout of a blocking call.
A distinct type so ticks and milliseconds cannot be mixed; build it with PBL_NO_WAIT, PBL_FOREVER, PBL_TICKS, PBL_MSEC or PBL_SEC.
| Data Fields | ||
|---|---|---|
| pbl_tick_t | ticks | Ticks to wait, 0 for no wait or PBL_TICK_FOREVER for no limit. |
| #define PBL_FOREVER ((pbl_timeout_t){.ticks = PBL_TICK_FOREVER}) |
Wait without a time limit.
| #define PBL_MSEC | ( | ms | ) | ((pbl_timeout_t){.ticks = pbl_ms_to_ticks(ms)}) |
Timeout in milliseconds, rounded down to whole ticks.
| ms | Number of milliseconds. |
| #define PBL_NO_WAIT ((pbl_timeout_t){.ticks = 0}) |
Do not wait: fail with -EBUSY if the call would block.
| #define PBL_PRIO_IDLE ((pbl_prio_t)0) |
Lowest priority, the one of the idle thread.
| #define PBL_PRIO_MAX ((pbl_prio_t)(CONFIG_KERNEL_NUM_PRIORITIES - 1)) |
Highest priority, CONFIG_KERNEL_NUM_PRIORITIES - 1.
| #define PBL_SEC | ( | s | ) | PBL_MSEC((s) * 1000U) |
Timeout in seconds.
| s | Number of seconds. |
| #define PBL_TICK_FOREVER UINT32_MAX |
Tick count that stands for an infinite timeout.
| #define PBL_TICK_HZ CONFIG_KERNEL_TICK_HZ |
Tick rate in Hz, from CONFIG_KERNEL_TICK_HZ.
Matches the RTC tick rate.
| #define PBL_TICKS | ( | t | ) | ((pbl_timeout_t){.ticks = (t)}) |
Timeout in ticks.
| t | Number of ticks. |
| typedef uint8_t pbl_prio_t |
Thread priority.
Higher value = more urgent.
| typedef uint32_t pbl_tick_t |
Kernel tick count.
Wraps around; compare differences, not absolute values.
| pbl_tick_t pbl_ms_to_ticks | ( | uint32_t | ms | ) |
Convert milliseconds to ticks, rounding down.
| ms | Milliseconds. |
| uint32_t pbl_ticks_to_ms | ( | pbl_tick_t | ticks | ) |
Convert ticks to milliseconds, rounding down.
| ticks | Ticks. |
|
inlinestatic |
Check whether a timeout is PBL_FOREVER.
| t | Timeout. |
t never expires. References PBL_TICK_FOREVER, and pbl_timeout_t::ticks.
|
inlinestatic |
Check whether a timeout is PBL_NO_WAIT.
| t | Timeout. |
t does not wait. References pbl_timeout_t::ticks.