SLEEPTIMEREMDRV
Detailed Description
Low frequency timer utilities.
Utilities (timer, delays and time keeping).
Data Structures | |
struct | sl_sleeptimer_timer_handle |
struct | time_date |
Time and Date structure. | |
Macros | |
#define | ECODE_EMDRV_SLEEPTIMER_OK (ECODE_OK) |
A successful return value. | |
#define | ECODE_EMDRV_SLEEPTIMER_PARAM_ERROR (ECODE_EMDRV_SLEEPTIMER_BASE | 0x00000001) |
An illegal input parameter. | |
#define | ECODE_EMDRV_SLEEPTIMER_TIMER_NOT_RUNNING (ECODE_EMDRV_SLEEPTIMER_BASE | 0x00000002) |
A timer is not running. | |
#define | SLEEPTIMER_ENUM(name) typedef uint8_t name; enum name##_enum |
Typedefs | |
typedef struct time_date | sl_sleeptimer_date_t |
Time and Date structure. | |
typedef int32_t | sl_sleeptimer_time_zone_offset_t |
Time zone offset from UTC(second). | |
typedef void(* | sl_sleeptimer_timer_callback_t) (sl_sleeptimer_timer_handle_t *handle, void *data) |
typedef struct sl_sleeptimer_timer_handle | sl_sleeptimer_timer_handle_t |
typedef uint32_t | sl_sleeptimer_timestamp_t |
Timestamp, wall clock time in seconds. | |
Typedef Documentation
typedef void(* sl_sleeptimer_timer_callback_t) (sl_sleeptimer_timer_handle_t *handle, void *data) |
Typedef for the user supplied callback function which is called when a timer expires.
- Parameters
-
handle
The timer handle. data
An extra parameter for the user application.
Definition at line 64
of file sleeptimer.h
.
Function Documentation
void sl_sleeptimer_delay_millisecond | ( | uint16_t | time_ms | ) |
Active delay.
- Parameters
-
time_ms
Delay duration in milliseconds.
Definition at line 684
of file sleeptimer.c
.
References ECODE_EMDRV_SLEEPTIMER_OK, sl_sleeptimer_ms_to_tick(), and sl_sleeptimer_start_timer().
uint32_t sl_sleeptimer_get_tick_count | ( | void |
| ) |
Gets current 32 bits global tick count.
- Returns
- Current tick count.
Gets current 32 bits tick count.
Definition at line 301
of file sleeptimer.c
.
uint64_t sl_sleeptimer_get_tick_count64 | ( | void |
| ) |
Gets current 64 bits global tick count.
- Returns
- Current tick count.
Gets current 64 bits tick count.
Definition at line 309
of file sleeptimer.c
.
References CORE_DECLARE_IRQ_STATE, CORE_ENTER_ATOMIC, and CORE_EXIT_ATOMIC.
uint32_t sl_sleeptimer_get_timer_frequency | ( | void |
| ) |
Get timer frequency.
- Returns
- 0 if successful. Error code otherwise.
Get timer frequency.
Definition at line 324
of file sleeptimer.c
.
Ecode_t sl_sleeptimer_get_timer_time_remaining | ( | sl_sleeptimer_timer_handle_t * | handle, |
uint32_t * | time |
||
) |
Gets remaining time until timer expires.
- Parameters
-
handle
Pointer to handle to timer. time
Time left in timer ticks.
- Returns
- 0 if successful. Error code otherwise.
Gets a 32 bits timer's time remaining.
Definition at line 259
of file sleeptimer.c
.
References CORE_DECLARE_IRQ_STATE, CORE_ENTER_ATOMIC, CORE_EXIT_ATOMIC, sl_sleeptimer_timer_handle::delta, ECODE_EMDRV_SLEEPTIMER_OK, ECODE_EMDRV_SLEEPTIMER_PARAM_ERROR, ECODE_EMDRV_SLEEPTIMER_TIMER_NOT_RUNNING, and sl_sleeptimer_timer_handle::next.
Ecode_t sl_sleeptimer_init | ( | void |
| ) |
Initializes the Sleeptimer.
- Returns
- 0 if successful. Error code otherwise.
Initializes sleep timer.
Definition at line 126
of file sleeptimer.c
.
References CORE_DECLARE_IRQ_STATE, CORE_ENTER_ATOMIC, CORE_EXIT_ATOMIC, and ECODE_EMDRV_SLEEPTIMER_OK.
Ecode_t sl_sleeptimer_is_timer_running | ( | sl_sleeptimer_timer_handle_t * | handle, |
bool * | running |
||
) |
Gets the status of a timer.
- Parameters
-
handle
Pointer to handle to timer. running
Pointer to the status of the timer.
- Returns
- 0 if successful. Error code otherwise.
Gets the status of a timer.
Definition at line 232
of file sleeptimer.c
.
References CORE_DECLARE_IRQ_STATE, CORE_ENTER_ATOMIC, CORE_EXIT_ATOMIC, ECODE_EMDRV_SLEEPTIMER_OK, ECODE_EMDRV_SLEEPTIMER_PARAM_ERROR, and sl_sleeptimer_timer_handle::next.
Ecode_t sl_sleeptimer_ms32_to_tick | ( | uint32_t | time_ms, |
uint32_t * | tick |
||
) |
Converts 32-bits milliseconds in ticks.
- Parameters
-
time_ms
Number of milliseconds. tick
Pointer to the converted tick number.
- Returns
- 0 if successful. Error code otherwise.
- Note
- The result is "rounded" to the superior tick number. If possible the sl_sleeptimer_ms_to_tick() function should be used. The millisecond 32-bits range is not fully supported, depending on the timer frequency. The function will return an error if the converted number of ticks would overflow.
Definition at line 713
of file sleeptimer.c
.
References ECODE_EMDRV_SLEEPTIMER_OK, and ECODE_EMDRV_SLEEPTIMER_PARAM_ERROR.
uint32_t sl_sleeptimer_ms_to_tick | ( | uint16_t | time_ms | ) |
Converts milliseconds in ticks.
- Parameters
-
time_ms
Number of milliseconds.
- Returns
- Corresponding ticks number.
- Note
- The result is "rounded" to the superior tick number. This function is light and cannot fail so it should be privilegied to perform a millisecond to tick conversion.
Definition at line 705
of file sleeptimer.c
.
Referenced by sl_sleeptimer_delay_millisecond().
Ecode_t sl_sleeptimer_start_periodic_timer | ( | sl_sleeptimer_timer_handle_t * | handle, |
uint32_t | timeout, |
||
sl_sleeptimer_timer_callback_t | callback, |
||
void * | callback_data, |
||
uint8_t | priority |
||
) |
Starts a 32 bits periodic timer.
- Parameters
-
handle
Pointer to handle to timer. timeout
Timer periodic timeout, in timer ticks. callback
Callback function that will be called when initial/periodic timeout expires. callbackData
Pointer to user data that will be passed to callback. priority
Priority of callback. Useful in case multiple timer expire at the same time. 0 = highest priority.
- Returns
- 0 if successful. Error code otherwise.
Starts a 32 bits periodic timer.
Definition at line 175
of file sleeptimer.c
.
References ECODE_EMDRV_SLEEPTIMER_PARAM_ERROR.
Ecode_t sl_sleeptimer_start_timer | ( | sl_sleeptimer_timer_handle_t * | handle, |
uint32_t | timeout, |
||
sl_sleeptimer_timer_callback_t | callback, |
||
void * | callback_data, |
||
uint8_t | priority |
||
) |
Starts a 32 bits timer.
- Parameters
-
handle
Pointer to handle to timer. timeout
Timer timeout, in timer ticks. callback
Callback function that will be called when initial/periodic timeout expires. callbackData
Pointer to user data that will be passed to callback. priority
Priority of callback. Useful in case multiple timer expire at the same time. 0 = highest priority.
- Returns
- 0 if successful. Error code otherwise.
Starts a 32 bits timer.
Definition at line 154
of file sleeptimer.c
.
References ECODE_EMDRV_SLEEPTIMER_PARAM_ERROR.
Referenced by sl_sleeptimer_delay_millisecond().
Ecode_t sl_sleeptimer_stop_timer | ( | sl_sleeptimer_timer_handle_t * | handle | ) |
Stops a timer.
- Parameters
-
handle
Pointer to handle to timer.
- Returns
Stops a 32 bits timer.
Definition at line 196
of file sleeptimer.c
.
References CORE_DECLARE_IRQ_STATE, CORE_ENTER_ATOMIC, CORE_EXIT_ATOMIC, ECODE_EMDRV_SLEEPTIMER_OK, and ECODE_EMDRV_SLEEPTIMER_PARAM_ERROR.
Ecode_t sl_sleeptimer_tick64_to_ms | ( | uint64_t | tick, |
uint64_t * | ms |
||
) |
Converts 64-bit ticks in milliseconds.
- Parameters
-
tick
Number of tick. ms
Pointer to the converted milliseconds number.
- Returns
- 0 if successful. Error code otherwise.
- Note
- The result is rounded to the inferior millisecond.
Definition at line 739
of file sleeptimer.c
.
References ECODE_EMDRV_SLEEPTIMER_OK, and ECODE_EMDRV_SLEEPTIMER_PARAM_ERROR.
uint32_t sl_sleeptimer_tick_to_ms | ( | uint32_t | tick | ) |
Converts ticks in milliseconds.
- Parameters
-
tick
Number of tick.
- Returns
- Corresponding milliseconds number.
- Note
- The result is rounded to the inferior millisecond.
Definition at line 727
of file sleeptimer.c
.