Sleep Timer#

Sleep Timer can be used for creating timers which are tightly integrated with power management. The Power Manager requires precision timing to have all clocks ready on time, so that wakeup happens a little bit earlier to prepare the system to be ready at the right time. Sleep Timer uses one Hardware Timer and creates multiple software timer instances. It is important to note that when sleeptimer is used with WTIMER/TIMER, the MCU cannot go to EM2 energy mode because WTIMER/TIMER uses a high frequency clock source which is not retained in low energy mode.

The sleeptimer.c and sleeptimer.h source files for the SLEEPTIMER device driver library are in the service/sleeptimer folder.


Introduction#

The Sleeptimer driver provides software timers, delays, timekeeping and date functionalities using a low-frequency real-time clock peripheral.

All Silicon Labs microcontrollers equipped with a supported real-time clock peripheral (RTCC, SYSRTC, or BURTC) are currently supported. Only one instance of this driver can be initialized by the application.


Functionalities overview#


Software Timers#

This functionality allows the user to create periodic and one shot timers. A user callback can be associated with a timer and is called when the timer expires.

Timer structures must be allocated by the user. The function is called from within an interrupt handler with interrupts enabled.

As sleeptimer callback functions are executed in ISR, they should be kept simple and short. For periodic timers, the sleeptimer's callbacks need to be shorter than the timer's period to allow the application to exit the interrupt context.


Timekeeping#

A 64-bits tick counter is accessible through the

The SL_SLEEPTIMER_WALLCLOCK_CONFIG configuration enables a UNIX timestamp (seconds count since January 1, 1970, 00:00:00).

This timestamp can be retrieved/modified using the following API:

Convenience conversion functions are provided to convert UNIX timestamp to/from NTP and Zigbee cluster format :


Date#

The previously described internal timestamp can also be retrieved/modified in a date format sl_sleeptimer_date_t.


API :


Frequency Setup and Tick Count#

This driver works with a configurable time unit called tick.

The frequency of the ticks is based on the clock source and the internal frequency divider.

WTIMER/TIMER peripherals uses high frequency oscillator. To have a reasonable tick frequency, divider is set to maximum value (1024).

One of the following clock sources must be configured before initializing the sleeptimer:

  • LFXO: external crystal oscillator. Typically running at 32.768 kHz.

  • LFRCO: internal oscillator running at 32.768 kHz

  • ULFRCO: Ultra low-frequency oscillator running at 1.000 kHz

  • HFXO: High Frequency Crystal Oscillator at 39 Mhz. HFXO is only needed when Sleeptimer runs on TIMER or WTIMER.

The frequency divider is selected with the SL_SLEEPTIMER_FREQ_DIVIDER configuration. Its value must be a power of two within the range of 1 to 32. The number of ticks per second (sleeptimer frequency) is dictated by the following formula:

Tick (seconds) = 1 / (clock_frequency / frequency_divider)

The highest resolution for a tick is 30.5 us. It is achieved with a 32.768 kHz clock and a divider of 1.


Getting Started#


Clock Selection#

The sleeptimer relies on the hardware timer to operate. The hardware timer peripheral must be properly clocked from the application. Selecting the appropriate timer is crucial for design considerations. Each timer can potentially be used as a sleeptimer and is also available to the user. However, note that if a timer is used by the sleeptimer, it can't be used by the application and vice versa.

For WTIMER/TIMER peripherals, the user must select the appropriate oscillator if it is not the default wanted clock source.

When WTIMER/TIMER is selected, sleeptimer uses channel 0 and it is not possible to use other channels of the same instance for other purposes.

When SYSRTC is chosen, the Peripheral Reflex System (PRS) channel 1 and 2 will be used by sleeptimer and become unavailable. PRS_GetFreeChannel() can be used to retrieve an unallocated channel.


Clock Source Selection with the Clock Manager#

The clock source feeding the hardware timer used by Sleeptimer can be configured at compile time through the Clock Manager service. The Clock Manager configures the oscillators and routes them to the correct clock branch during system initialization, before Sleeptimer is initialized.

Each hardware timer peripheral that Sleeptimer can be backed by is fed by a dedicated Clock Manager clock branch. To pick the oscillator used by Sleeptimer, set the corresponding SL_CLOCK_MANAGER_<branch>CLK_SOURCE define in sl_clock_manager_tree_config.h. The available oscillators must also be configured in sl_clock_manager_oscillator_config.h (for example SL_CLOCK_MANAGER_LFXO_EN or SL_CLOCK_MANAGER_HFXO_EN).

// sl_clock_manager_tree_config.h - route SYSRTC to LFXO
#define SL_CLOCK_MANAGER_SYSRTCCLK_SOURCE    CMU_SYSRTC0CLKCTRL_CLKSEL_LFXO

When a low-frequency branch is left at SL_CLOCK_MANAGER_DEFAULT_LF_CLOCK_SOURCE, it follows the device-wide default selected by SL_CLOCK_MANAGER_DEFAULT_LF_CLOCK_SOURCE (LFXO, LFRCO, or ULFRCO). High-frequency branches behave the same way with SL_CLOCK_MANAGER_DEFAULT_HF_CLOCK_SOURCE.


Clock Sources#

Sleeptimer's hardware timers can be sourced from one of the following oscillators, depending on whether a low-frequency timer (RTCC, SYSRTC, BURTC) or a high-frequency timer (TIMER, WTIMER) is selected. The exact set of supported sources depends on the device.

Low-frequency sources (RTCC, SYSRTC, BURTC):

Clock

Description

Frequency

LFXO

Low-frequency crystal oscillator

32.768 kHz

LFRCO

Low-frequency RC oscillator

32.768 kHz

ULFRCO

Ultra low-frequency RC oscillator

1 kHz

High-frequency sources (TIMER, WTIMER):

Clock

Description

Frequency

HFXO

High-frequency crystal oscillator

up to 40 MHz

HFRCODPLL

High-frequency RC oscillator (DPLL)

device-dependent

FSRCO

Fixed-speed RC oscillator

20 MHz

Because Sleeptimer divides the timer clock down with SL_SLEEPTIMER_FREQ_DIVIDER (up to 1024), running Sleeptimer on a high-frequency timer requires a fast source to keep the resulting tick period usable.


Sleeptimer Peripheral Clock Branches#

The table below maps each hardware timer that Sleeptimer can use to the Clock Manager clock branch and configuration define that controls its source. Set the listed define to select which oscillator feeds the Sleeptimer hardware timer.

Peripheral

Clock branch

Configuration define

RTCC

RTCCCLK

SL_CLOCK_MANAGER_RTCCCLK_SOURCE

SYSRTC

SYSRTCCLK

SL_CLOCK_MANAGER_SYSRTCCLK_SOURCE

BURTC

EM4GRPACLK

SL_CLOCK_MANAGER_EM4GRPACLK_SOURCE

TIMER, WTIMER

EM01GRPACLK

SL_CLOCK_MANAGER_EM01GRPACLK_SOURCE


BURTC and EM4 limitations#

Warnings

  • Do not use Sleeptimer on BURTC if the application needs EM4 timekeeping, EM4 wake on BURTC, or continuity of Sleeptimer state across an EM4 reset.

The BURTC peripheral can run in EM4 and can be an EM4 wake source in hardware, but when SL_SLEEPTIMER_PERIPHERAL_BURTC is selected, the Sleeptimer HAL does not configure it that way.

If the firmware needs EM4 wake or EM4 timekeeping on BURTC, reserve BURTC for the application or stack and keep SL_SLEEPTIMER_PERIPHERAL on SL_SLEEPTIMER_PERIPHERAL_DEFAULT so Sleeptimer is backed by another timer (RTCC or SYSRTC, depending on what is available on the device).

#define SL_SLEEPTIMER_PERIPHERAL  SL_SLEEPTIMER_PERIPHERAL_DEFAULT


Configuration Options#

SL_SLEEPTIMER_PERIPHERAL can be set to one of the following values:

Config

Description

SL_SLEEPTIMER_PERIPHERAL_DEFAULT

Selects RTCC or SYSRTC, depending on what is available on the platform.

SL_SLEEPTIMER_PERIPHERAL_RTCC

Selects RTCC

SL_SLEEPTIMER_PERIPHERAL_SYSRTC

Selects SYSRTC

SL_SLEEPTIMER_PERIPHERAL_PRORTC

Selects Internal radio RTC. Available only on EFR32XG13, EFR32XG14, EFR32XG21, EFR32XG22, EFR32XG27 and EFR32XG29 families.

SL_SLEEPTIMER_PERIPHERAL_BURTC

Selects BURTC. See BURTC and EM4 limitations.

Note

  • SL_SLEEPTIMER_PERIPHERAL_PRORTC must not be used as the underlying peripheral for sleeptimer when RAIL is present in the project. Select a different peripheral via SL_SLEEPTIMER_PERIPHERAL in that case.

SL_SLEEPTIMER_WALLCLOCK_CONFIG must be set to 1 to enable timestamp and date functionnalities.

SL_SLEEPTIMER_FREQ_DIVIDER must be a power of 2 within the range 1 to 32. When SL_SLEEPTIMER_PERIPHERAL is set to SL_SLEEPTIMER_PERIPHERAL_PRORTC, SL_SLEEPTIMER_FREQ_DIVIDER must be set to 1.

SL_SLEEPTIMER_PRORTC_HAL_OWNS_IRQ_HANDLER is only meaningful when SL_SLEEPTIMER_PERIPHERAL is set to SL_SLEEPTIMER_PERIPHERAL_PRORTC. Set to 1 if no communication stack is used in your project. Otherwise, must be set to 0.


The API#

This section contains brief descriptions of the API functions. For more information about input and output parameters and return values, click on the hyperlinked function names. Most functions return an error code, SL_STATUS_OK is returned on success, see sl_status.h for other error codes.

The application code must include the sl_sleeptimer.h header file.

All API functions can be called from within interrupt handlers.

sl_sleeptimer_init()
These functions initialize the sleeptimer driver. Typically, sl_sleeptimer_init() is called once in the startup code.

sl_sleeptimer_start_timer()
Start a one shot 32 bits timer. When a timer expires, a user-supplied callback function is called. A pointer to this function is passed to sl_sleeptimer_start_timer(). See sl_sleeptimer_timer_callback_t for details of the callback prototype.

sl_sleeptimer_restart_timer()
Restart a one shot 32 bits timer. When a timer expires, a user-supplied callback function is called. A pointer to this function is passed to sl_sleeptimer_start_timer(). See sl_sleeptimer_timer_callback_t for details of the callback prototype.

sl_sleeptimer_start_periodic_timer()
Start a periodic 32 bits timer. When a timer expires, a user-supplied callback function is called. A pointer to this function is passed to sl_sleeptimer_start_timer(). See sl_sleeptimer_timer_callback_t for details of the callback prototype.

sl_sleeptimer_restart_periodic_timer()
Restart a periodic 32 bits timer. When a timer expires, a user-supplied callback function is called. A pointer to this function is passed to sl_sleeptimer_start_timer(). See sl_sleeptimer_timer_callback_t for details of the callback prototype.

sl_sleeptimer_stop_timer()
Stop a timer.

sl_sleeptimer_get_timer_time_remaining()
Get the time remaining before the timer expires.

sl_sleeptimer_delay_millisecond()
Delay for the given number of milliseconds. This is an "active wait" delay function.

sl_sleeptimer_is_timer_running()
Check if a timer is running.

sl_sleeptimer_get_time(), sl_sleeptimer_set_time()
Get or set wallclock time.

sl_sleeptimer_ms_to_tick(), sl_sleeptimer_ms32_to_tick(), sl_sleeptimer_tick_to_ms(), sl_sleeptimer_tick64_to_ms()
Convert between milliseconds and the configured timer peripheral ticks.


 The timer expiry callback function:
The callback function, prototyped as sl_sleeptimer_timer_callback_t(), is called from within the configured timer peripheral interrupt handler on timer expiration. sl_sleeptimer_timer_callback_t(sl_sleeptimer_timer_handle_t *handle, void *data)


Example#

#include "sl_sleeptimer.h"

void my_timer_callback(sl_sleeptimer_timer_handle_t *handle, void *data)
{
  //Code executed when the timer expire.
}

int start_timer(void)
{
  sl_status_t status;
  sl_sleeptimer_timer_handle_t my_timer;
  uint32_t timer_timeout = 300;

  // We assume the sleeptimer is initialized properly

  status = sl_sleeptimer_start_timer(&my_timer,
                                     timer_timeout,
                                     my_timer_callback,
                                     (void *)NULL,
                                     0,
                                     0);
  if(status != SL_STATUS_OK) {
    return -1;
  }
  return 1;
}

Modules#

sl_sleeptimer_timer_handle

sl_sleeptimer_date_t

Typedefs#

typedef uint32_t

Timestamp, wall clock time in seconds.

typedef uint64_t

sl sleeptimer timestamp 64 t

typedef int32_t

Time zone offset from UTC(second).

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.

Functions#

SLEEPTIMER_ENUM(sl_sleeptimer_month_t)

Month enum.

SLEEPTIMER_ENUM(sl_sleeptimer_weekDay_t)

Week Day enum.

sl_status_t

Initializes the Sleeptimer.

sl_status_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, uint16_t option_flags)

Starts a 32 bits timer.

sl_status_t
sl_sleeptimer_restart_timer(sl_sleeptimer_timer_handle_t *handle, uint32_t timeout, sl_sleeptimer_timer_callback_t callback, void *callback_data, uint8_t priority, uint16_t option_flags)

Restarts a 32 bits timer.

sl_status_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, uint16_t option_flags)

Starts a 32 bits periodic timer.

sl_status_t
sl_sleeptimer_restart_periodic_timer(sl_sleeptimer_timer_handle_t *handle, uint32_t timeout, sl_sleeptimer_timer_callback_t callback, void *callback_data, uint8_t priority, uint16_t option_flags)

Restarts a 32 bits periodic timer.

sl_status_t
sl_sleeptimer_stop_timer(sl_sleeptimer_timer_handle_t *handle)

Stops a timer.

sl_status_t
sl_sleeptimer_is_timer_running(const sl_sleeptimer_timer_handle_t *handle, bool *running)

Gets the status of a timer.

sl_status_t
sl_sleeptimer_get_timer_time_remaining(const sl_sleeptimer_timer_handle_t *handle, uint32_t *time)

Gets remaining time until timer expires.

sl_status_t
sl_sleeptimer_get_remaining_time_of_first_timer(uint16_t option_flags, uint32_t *time_remaining)

Gets the time remaining until the first timer with the matching set of flags expires.

uint32_t

Gets current 32 bits global tick count.

uint64_t

Gets current 64 bits global tick count.

uint32_t

Get timer frequency.

sl_status_t
sl_sleeptimer_convert_time_to_date(sl_sleeptimer_timestamp_t time, sl_sleeptimer_time_zone_offset_t time_zone, sl_sleeptimer_date_t *date)

Converts a Unix timestamp into a date.

sl_status_t
sl_sleeptimer_convert_time_to_date_64(sl_sleeptimer_timestamp_64_t time, sl_sleeptimer_time_zone_offset_t time_zone, sl_sleeptimer_date_t *date)

Converts a 64 bit Unix timestamp into a date.

sl_status_t
sl_sleeptimer_convert_date_to_time(sl_sleeptimer_date_t *date, sl_sleeptimer_timestamp_t *time)

Converts a date into a Unix timestamp.

sl_status_t
sl_sleeptimer_convert_date_to_time_64(sl_sleeptimer_date_t *date, sl_sleeptimer_timestamp_64_t *time)

Converts a date into a 64 bit timestamp.

uint32_t
sl_sleeptimer_convert_date_to_str(char *str, size_t size, const uint8_t *format, sl_sleeptimer_date_t *date)

Convert date to string.

void
sl_sleeptimer_set_tz(sl_sleeptimer_time_zone_offset_t offset)

Sets time zone offset.

Retrieves current 32 bit time.

Retrieves current 64 bit time.

sl_status_t
sl_sleeptimer_set_time(sl_sleeptimer_timestamp_t time)

Sets current time.

sl_status_t
sl_sleeptimer_set_time_64(sl_sleeptimer_timestamp_64_t time)

Sets current time.

sl_status_t
sl_sleeptimer_get_datetime(sl_sleeptimer_date_t *date)

Gets current date.

sl_status_t
sl_sleeptimer_set_datetime(sl_sleeptimer_date_t *date)

Sets current time, in date format.

sl_status_t
sl_sleeptimer_build_datetime(sl_sleeptimer_date_t *date, uint16_t year, sl_sleeptimer_month_t month, uint8_t month_day, uint8_t hour, uint8_t min, uint8_t sec, sl_sleeptimer_time_zone_offset_t tzOffset)

Builds a date time structure based on the provided parameters, where the maximum supported date is 10:14:07 PM 01/18/2038.

sl_status_t
sl_sleeptimer_build_datetime_64(sl_sleeptimer_date_t *date, uint16_t year, sl_sleeptimer_month_t month, uint8_t month_day, uint8_t hour, uint8_t min, uint8_t sec, sl_sleeptimer_time_zone_offset_t tzOffset)

Builds a date time structure based on the provided parameters, where the maximum supported date is 11:59:59 PM 12/31/11899.

sl_status_t
sl_sleeptimer_convert_unix_time_to_ntp(sl_sleeptimer_timestamp_t time, uint32_t *ntp_time)

Converts Unix timestamp into NTP timestamp.

sl_status_t
sl_sleeptimer_convert_ntp_time_to_unix(uint32_t ntp_time, sl_sleeptimer_timestamp_t *time)

Converts NTP timestamp into Unix timestamp.

sl_status_t
sl_sleeptimer_convert_unix_time_to_zigbee(sl_sleeptimer_timestamp_t time, uint32_t *zigbee_time)

Converts Unix timestamp into Zigbee timestamp.

sl_status_t
sl_sleeptimer_convert_zigbee_time_to_unix(uint32_t zigbee_time, sl_sleeptimer_timestamp_t *time)

Converts Zigbee timestamp into Unix timestamp.

sl_sleeptimer_set_tz_ahead_utc(uint8_t hours, uint8_t minutes)

Calculates offset for time zone after UTC-0.

sl_sleeptimer_set_tz_behind_utc(uint8_t hours, uint8_t minutes)

Calculates offset for time zone before UTC-0.

void

Active delay.

uint32_t
sl_sleeptimer_ms_to_tick(uint16_t time_ms)

Converts milliseconds in ticks.

sl_status_t
sl_sleeptimer_ms32_to_tick(uint32_t time_ms, uint32_t *tick)

Converts 32-bits milliseconds in ticks.

uint32_t

Gets the maximum value that can be passed to the functions that have a 32-bits time or timeout argument expressed in milliseconds.

uint32_t

Converts ticks in milliseconds.

sl_status_t
sl_sleeptimer_tick64_to_ms(uint64_t tick, uint64_t *ms)

Converts 64-bit ticks in milliseconds.

sl_status_t
sl_sleeptimer_start_timer_ms(sl_sleeptimer_timer_handle_t *handle, uint32_t timeout_ms, sl_sleeptimer_timer_callback_t callback, void *callback_data, uint8_t priority, uint16_t option_flags)

Starts a 32 bits timer.

sl_status_t
sl_sleeptimer_restart_timer_ms(sl_sleeptimer_timer_handle_t *handle, uint32_t timeout_ms, sl_sleeptimer_timer_callback_t callback, void *callback_data, uint8_t priority, uint16_t option_flags)

Restarts a 32 bits timer.

sl_status_t
sl_sleeptimer_start_periodic_timer_ms(sl_sleeptimer_timer_handle_t *handle, uint32_t timeout_ms, sl_sleeptimer_timer_callback_t callback, void *callback_data, uint8_t priority, uint16_t option_flags)

Starts a 32 bits periodic timer.

sl_status_t
sl_sleeptimer_restart_periodic_timer_ms(sl_sleeptimer_timer_handle_t *handle, uint32_t timeout_ms, sl_sleeptimer_timer_callback_t callback, void *callback_data, uint8_t priority, uint16_t option_flags)

Restarts a 32 bits periodic timer.

uint16_t

Gets the precision (in PPM) of the sleeptimer's clock.

Typedef Documentation#

sl_sleeptimer_timestamp_t#

typedef uint32_t sl_sleeptimer_timestamp_t

Timestamp, wall clock time in seconds.


sl_sleeptimer_timestamp_64_t#

typedef uint64_t sl_sleeptimer_timestamp_64_t

sl sleeptimer timestamp 64 t


sl_sleeptimer_time_zone_offset_t#

typedef int32_t sl_sleeptimer_time_zone_offset_t

Time zone offset from UTC(second).


sl_sleeptimer_timer_callback_t#

typedef void(* sl_sleeptimer_timer_callback_t) (sl_sleeptimer_timer_handle_t *handle, void *data) )(sl_sleeptimer_timer_handle_t *handle, void *data)

Typedef for the user supplied callback function which is called when a timer expires.

Parameters
TypeDirectionArgument NameDescription
N/Ahandle

The timer handle.

N/Adata

An extra parameter for the user application.


Function Documentation#

SLEEPTIMER_ENUM#

SLEEPTIMER_ENUM (sl_sleeptimer_month_t )

Month enum.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_month_tN/A

SLEEPTIMER_ENUM#

SLEEPTIMER_ENUM (sl_sleeptimer_weekDay_t )

Week Day enum.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_weekDay_tN/A

sl_sleeptimer_init#

sl_status_t sl_sleeptimer_init (void )

Initializes the Sleeptimer.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_start_timer#

sl_status_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, uint16_t option_flags)

Starts a 32 bits timer.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_timer_handle_t *N/Ahandle

Pointer to handle to timer.

uint32_tN/Atimeout

Timer timeout, in timer ticks.

sl_sleeptimer_timer_callback_tN/Acallback

Callback function that will be called when initial/periodic timeout expires.

void *N/Acallback_data

Pointer to user data that will be passed to callback.

uint8_tN/Apriority

Priority of callback. Useful in case multiple timer expire at the same time. 0 = highest priority.

uint16_tN/Aoption_flags

Bit array of option flags for the timer. Valid bit-wise OR of one or more of the following:

  • SL_SLEEPTIMER_NO_HIGH_PRECISION_HF_CLOCKS_REQUIRED_FLAG or 0 for not flags.

Note

  • This function cannot be called from an interrupt with a higher priority than BASEPRI.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_restart_timer#

sl_status_t sl_sleeptimer_restart_timer (sl_sleeptimer_timer_handle_t * handle, uint32_t timeout, sl_sleeptimer_timer_callback_t callback, void * callback_data, uint8_t priority, uint16_t option_flags)

Restarts a 32 bits timer.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_timer_handle_t *N/Ahandle

Pointer to handle to timer.

uint32_tN/Atimeout

Timer timeout, in timer ticks.

sl_sleeptimer_timer_callback_tN/Acallback

Callback function that will be called when initial/periodic timeout expires.

void *N/Acallback_data

Pointer to user data that will be passed to callback.

uint8_tN/Apriority

Priority of callback. Useful in case multiple timer expire at the same time. 0 = highest priority.

uint16_tN/Aoption_flags

Bit array of option flags for the timer. Valid bit-wise OR of one or more of the following:

  • SL_SLEEPTIMER_NO_HIGH_PRECISION_HF_CLOCKS_REQUIRED_FLAG or 0 for not flags.

Note

  • This function cannot be called from an interrupt with a higher priority than BASEPRI.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_start_periodic_timer#

sl_status_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, uint16_t option_flags)

Starts a 32 bits periodic timer.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_timer_handle_t *N/Ahandle

Pointer to handle to timer.

uint32_tN/Atimeout

Timer periodic timeout, in timer ticks.

sl_sleeptimer_timer_callback_tN/Acallback

Callback function that will be called when initial/periodic timeout expires.

void *N/Acallback_data

Pointer to user data that will be passed to callback.

uint8_tN/Apriority

Priority of callback. Useful in case multiple timer expire at the same time. 0 = highest priority.

uint16_tN/Aoption_flags

Bit array of option flags for the timer. Valid bit-wise OR of one or more of the following:

  • SL_SLEEPTIMER_NO_HIGH_PRECISION_HF_CLOCKS_REQUIRED_FLAG or 0 for not flags.

Note

  • This function cannot be called from an interrupt with a higher priority than BASEPRI.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_restart_periodic_timer#

sl_status_t sl_sleeptimer_restart_periodic_timer (sl_sleeptimer_timer_handle_t * handle, uint32_t timeout, sl_sleeptimer_timer_callback_t callback, void * callback_data, uint8_t priority, uint16_t option_flags)

Restarts a 32 bits periodic timer.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_timer_handle_t *N/Ahandle

Pointer to handle to timer.

uint32_tN/Atimeout

Timer periodic timeout, in timer ticks.

sl_sleeptimer_timer_callback_tN/Acallback

Callback function that will be called when initial/periodic timeout expires.

void *N/Acallback_data

Pointer to user data that will be passed to callback.

uint8_tN/Apriority

Priority of callback. Useful in case multiple timer expire at the same time. 0 = highest priority.

uint16_tN/Aoption_flags

Bit array of option flags for the timer. Valid bit-wise OR of one or more of the following:

  • SL_SLEEPTIMER_NO_HIGH_PRECISION_HF_CLOCKS_REQUIRED_FLAG or 0 for not flags.

Note

  • This function cannot be called from an interrupt with a higher priority than BASEPRI.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_stop_timer#

sl_status_t sl_sleeptimer_stop_timer (sl_sleeptimer_timer_handle_t * handle)

Stops a timer.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_timer_handle_t *N/Ahandle

Pointer to handle to timer.

Note

  • This function cannot be called from an interrupt with a higher priority than BASEPRI.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_is_timer_running#

sl_status_t sl_sleeptimer_is_timer_running (const sl_sleeptimer_timer_handle_t * handle, bool * running)

Gets the status of a timer.

Parameters
TypeDirectionArgument NameDescription
const sl_sleeptimer_timer_handle_t *N/Ahandle

Pointer to handle to timer.

bool *N/Arunning

Pointer to the status of the timer.

Note

  • A non periodic timer is considered not running during its callback.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_get_timer_time_remaining#

sl_status_t sl_sleeptimer_get_timer_time_remaining (const sl_sleeptimer_timer_handle_t * handle, uint32_t * time)

Gets remaining time until timer expires.

Parameters
TypeDirectionArgument NameDescription
const sl_sleeptimer_timer_handle_t *N/Ahandle

Pointer to handle to timer.

uint32_t *N/Atime

Time left in timer ticks.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_get_remaining_time_of_first_timer#

sl_status_t sl_sleeptimer_get_remaining_time_of_first_timer (uint16_t option_flags, uint32_t * time_remaining)

Gets the time remaining until the first timer with the matching set of flags expires.

Parameters
TypeDirectionArgument NameDescription
uint16_tN/Aoption_flags

Set of flags to match:

  • SL_SLEEPTIMER_ANY_TIMER_FLAG

  • SL_SLEEPTIMER_NO_HIGH_PRECISION_HF_CLOCKS_REQUIRED_FLAG

uint32_t *N/Atime_remaining

Time left in timer ticks.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_get_tick_count#

uint32_t sl_sleeptimer_get_tick_count (void )

Gets current 32 bits global tick count.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • Current tick count.


sl_sleeptimer_get_tick_count64#

uint64_t sl_sleeptimer_get_tick_count64 (void )

Gets current 64 bits global tick count.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • Current tick count.


sl_sleeptimer_get_timer_frequency#

uint32_t sl_sleeptimer_get_timer_frequency (void )

Get timer frequency.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • Timer frequency in hertz.


sl_sleeptimer_convert_time_to_date#

sl_status_t sl_sleeptimer_convert_time_to_date (sl_sleeptimer_timestamp_t time, sl_sleeptimer_time_zone_offset_t time_zone, sl_sleeptimer_date_t * date)

Converts a Unix timestamp into a date.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_timestamp_tN/Atime

32 bit Unix timestamp to convert.

sl_sleeptimer_time_zone_offset_tN/Atime_zone

Offset from UTC in second.

sl_sleeptimer_date_t *N/Adate

Pointer to converted date.

Note

  • Time is in Standard Time.

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_convert_time_to_date_64#

sl_status_t sl_sleeptimer_convert_time_to_date_64 (sl_sleeptimer_timestamp_64_t time, sl_sleeptimer_time_zone_offset_t time_zone, sl_sleeptimer_date_t * date)

Converts a 64 bit Unix timestamp into a date.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_timestamp_64_tN/Atime

64 bit Unix timestamp to convert.

sl_sleeptimer_time_zone_offset_tN/Atime_zone

Offset from UTC in second.

sl_sleeptimer_date_t *N/Adate

Pointer to converted date.

Note

  • Time is in Standard Time.

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_convert_date_to_time#

sl_status_t sl_sleeptimer_convert_date_to_time (sl_sleeptimer_date_t * date, sl_sleeptimer_timestamp_t * time)

Converts a date into a Unix timestamp.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_date_t *N/Adate

Pointer to date to convert.

sl_sleeptimer_timestamp_t *N/Atime

Pointer to converted 32 bit Unix timestamp.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.

Note

  • Dates are based on the Unix time representation. Range of dates supported :

    • January 1, 1970, 00:00:00 to January 19, 2038, 03:14:00

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.


sl_sleeptimer_convert_date_to_time_64#

sl_status_t sl_sleeptimer_convert_date_to_time_64 (sl_sleeptimer_date_t * date, sl_sleeptimer_timestamp_64_t * time)

Converts a date into a 64 bit timestamp.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_date_t *N/Adate

Pointer to date to convert.

sl_sleeptimer_timestamp_64_t *N/Atime

Pointer to converted 64 bit Unix timestamp.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.

Note

  • Dates are based on the 64 bit Unix time representation. Range of dates supported :

    • January 1, 1900, 00:00:00 to December 31, 11899 23:59:59.

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.


sl_sleeptimer_convert_date_to_str#

uint32_t sl_sleeptimer_convert_date_to_str (char * str, size_t size, const uint8_t * format, sl_sleeptimer_date_t * date)

Convert date to string.

Parameters
TypeDirectionArgument NameDescription
char *N/Astr

Output string.

size_tN/Asize

Size of the input array.

const uint8_t *N/Aformat

The format specification character.

sl_sleeptimer_date_t *N/Adate

Pointer to date structure.

Returns

  • 0 if error. Number of character in the output string.

Note


sl_sleeptimer_set_tz#

void sl_sleeptimer_set_tz (sl_sleeptimer_time_zone_offset_t offset)

Sets time zone offset.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_time_zone_offset_tN/Aoffset

Time zone offset, in seconds.

Note

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.


sl_sleeptimer_get_tz#

sl_sleeptimer_time_zone_offset_t sl_sleeptimer_get_tz (void )

Gets time zone offset.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • Time zone offset, in seconds.


sl_sleeptimer_get_time#

sl_sleeptimer_timestamp_t sl_sleeptimer_get_time (void )

Retrieves current 32 bit time.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Note

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.

Returns

  • Current timestamps in Unix format.


sl_sleeptimer_get_time_64#

sl_sleeptimer_timestamp_64_t sl_sleeptimer_get_time_64 (void )

Retrieves current 64 bit time.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Note

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.

Returns

  • Current timestamps in Unix format.


sl_sleeptimer_set_time#

sl_status_t sl_sleeptimer_set_time (sl_sleeptimer_timestamp_t time)

Sets current time.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_timestamp_tN/Atime

timestamp structure to set.

Note

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_set_time_64#

sl_status_t sl_sleeptimer_set_time_64 (sl_sleeptimer_timestamp_64_t time)

Sets current time.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_timestamp_64_tN/Atime

timestamp structure to set.

Note

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_get_datetime#

sl_status_t sl_sleeptimer_get_datetime (sl_sleeptimer_date_t * date)

Gets current date.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_date_t *N/Adate

Pointer to a sl_sleeptimer_date_t structure.

Note

  • Time is in Standard Time.

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_set_datetime#

sl_status_t sl_sleeptimer_set_datetime (sl_sleeptimer_date_t * date)

Sets current time, in date format.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_date_t *N/Adate

Pointer to current date.

Note

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_build_datetime#

sl_status_t sl_sleeptimer_build_datetime (sl_sleeptimer_date_t * date, uint16_t year, sl_sleeptimer_month_t month, uint8_t month_day, uint8_t hour, uint8_t min, uint8_t sec, sl_sleeptimer_time_zone_offset_t tzOffset)

Builds a date time structure based on the provided parameters, where the maximum supported date is 10:14:07 PM 01/18/2038.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_date_t *N/Adate

Pointer to the structure to be populated.

uint16_tN/Ayear

Current year. May be provided based on a 0 Epoch or a 1900 Epoch.

sl_sleeptimer_month_tN/Amonth

Months since January. Expected value: 0-11.

uint8_tN/Amonth_day

Day of the month. Expected value: 1-31.

uint8_tN/Ahour

Hours since midnight. Expected value: 0-23.

uint8_tN/Amin

Minutes after the hour. Expected value: 0-59.

uint8_tN/Asec

Seconds after the minute. Expected value: 0-59.

sl_sleeptimer_time_zone_offset_tN/AtzOffset

Offset, in seconds, from UTC.

Note

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_build_datetime_64#

sl_status_t sl_sleeptimer_build_datetime_64 (sl_sleeptimer_date_t * date, uint16_t year, sl_sleeptimer_month_t month, uint8_t month_day, uint8_t hour, uint8_t min, uint8_t sec, sl_sleeptimer_time_zone_offset_t tzOffset)

Builds a date time structure based on the provided parameters, where the maximum supported date is 11:59:59 PM 12/31/11899.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_date_t *N/Adate

Pointer to the structure to be populated.

uint16_tN/Ayear

Current year based on 0 Epoch.

sl_sleeptimer_month_tN/Amonth

Months since January. Expected value: 0-11.

uint8_tN/Amonth_day

Day of the month. Expected value: 1-31.

uint8_tN/Ahour

Hours since midnight. Expected value: 0-23.

uint8_tN/Amin

Minutes after the hour. Expected value: 0-59.

uint8_tN/Asec

Seconds after the minute. Expected value: 0-59.

sl_sleeptimer_time_zone_offset_tN/AtzOffset

Offset, in seconds, from UTC.

Note

  • Resulting date structure's year will be based on 1900 epoch

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_convert_unix_time_to_ntp#

sl_status_t sl_sleeptimer_convert_unix_time_to_ntp (sl_sleeptimer_timestamp_t time, uint32_t * ntp_time)

Converts Unix timestamp into NTP timestamp.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_timestamp_tN/Atime

Unix timestamp.

uint32_t *N/Antp_time

Pointer to NTP Timestamp.

Note

  • Unix timestamp range supported : 0x0 to 0x7C55 817F ie. January 1, 1970, 00:00:00 to February 07, 2036, 06:28:15

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_convert_ntp_time_to_unix#

sl_status_t sl_sleeptimer_convert_ntp_time_to_unix (uint32_t ntp_time, sl_sleeptimer_timestamp_t * time)

Converts NTP timestamp into Unix timestamp.

Parameters
TypeDirectionArgument NameDescription
uint32_tN/Antp_time

NTP Timestamp.

sl_sleeptimer_timestamp_t *N/Atime

Pointer to Unix timestamp.

Note

  • NTP timestamp range supported : 0x83AA 7E80 to 0xFFFF FFFF ie. January 1, 1970, 00:00:00 to February 07, 2036, 06:28:15

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_convert_unix_time_to_zigbee#

sl_status_t sl_sleeptimer_convert_unix_time_to_zigbee (sl_sleeptimer_timestamp_t time, uint32_t * zigbee_time)

Converts Unix timestamp into Zigbee timestamp.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_timestamp_tN/Atime

Unix timestamp.

uint32_t *N/Azigbee_time

Pointer to NTP Timestamp.

Note

  • Unix timestamp range supported : 0x386D 4380 to 0x7FFF FFFF ie. January 1, 2000, 00:00:0 to January 19, 2038, 03:14:00

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_convert_zigbee_time_to_unix#

sl_status_t sl_sleeptimer_convert_zigbee_time_to_unix (uint32_t zigbee_time, sl_sleeptimer_timestamp_t * time)

Converts Zigbee timestamp into Unix timestamp.

Parameters
TypeDirectionArgument NameDescription
uint32_tN/Azigbee_time

NTP Timestamp.

sl_sleeptimer_timestamp_t *N/Atime

Pointer to Unix timestamp.

Note

  • ZIGBEE timestamp range supported : 0x0 to 0x4792 BC7F ie. January 1, 2000, 00:00:00 to January 19, 2038, 03:14:00

  • Function definition is accessible only when SL_SLEEPTIMER_WALLCLOCK_CONFIG is set to 1.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


sl_sleeptimer_set_tz_ahead_utc#

sl_sleeptimer_time_zone_offset_t sl_sleeptimer_set_tz_ahead_utc (uint8_t hours, uint8_t minutes)

Calculates offset for time zone after UTC-0.

Parameters
TypeDirectionArgument NameDescription
uint8_tN/Ahours

Number of hours from UTC-0.

uint8_tN/Aminutes

Number of minutes from UTC-0.

Returns

  • The time zone offset in seconds.


sl_sleeptimer_set_tz_behind_utc#

sl_sleeptimer_time_zone_offset_t sl_sleeptimer_set_tz_behind_utc (uint8_t hours, uint8_t minutes)

Calculates offset for time zone before UTC-0.

Parameters
TypeDirectionArgument NameDescription
uint8_tN/Ahours

Number of hours to UTC-0.

uint8_tN/Aminutes

Number of minutes to UTC-0.

Returns

  • The time zone offset in seconds.


sl_sleeptimer_delay_millisecond#

void sl_sleeptimer_delay_millisecond (uint16_t time_ms)

Active delay.

Parameters
TypeDirectionArgument NameDescription
uint16_tN/Atime_ms

Delay duration in milliseconds.


sl_sleeptimer_ms_to_tick#

uint32_t sl_sleeptimer_ms_to_tick (uint16_t time_ms)

Converts milliseconds in ticks.

Parameters
TypeDirectionArgument NameDescription
uint16_tN/Atime_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.


sl_sleeptimer_ms32_to_tick#

sl_status_t sl_sleeptimer_ms32_to_tick (uint32_t time_ms, uint32_t * tick)

Converts 32-bits milliseconds in ticks.

Parameters
TypeDirectionArgument NameDescription
uint32_tN/Atime_ms

Number of milliseconds.

uint32_t *N/Atick

Pointer to the converted tick number.

Returns

  • SL_STATUS_OK 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.

  • This function converts the delay expressed in milliseconds to timer ticks (represented on 32 bits). This means that the value that can be passed to the argument 'time_ms' is limited. The maximum timeout value that can be passed to this function can be retrieved by calling sl_sleeptimer_get_max_ms32_conversion(). If the value passed to 'time_ms' is too large, SL_STATUS_INVALID_PARAMETER will be returned.


sl_sleeptimer_get_max_ms32_conversion#

uint32_t sl_sleeptimer_get_max_ms32_conversion (void )

Gets the maximum value that can be passed to the functions that have a 32-bits time or timeout argument expressed in milliseconds.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • Maximum time or timeout value in milliseconds.


sl_sleeptimer_tick_to_ms#

uint32_t sl_sleeptimer_tick_to_ms (uint32_t tick)

Converts ticks in milliseconds.

Parameters
TypeDirectionArgument NameDescription
uint32_tN/Atick

Number of tick.

Returns

  • Corresponding milliseconds number.

Note

  • The result is rounded to the inferior millisecond.


sl_sleeptimer_tick64_to_ms#

sl_status_t sl_sleeptimer_tick64_to_ms (uint64_t tick, uint64_t * ms)

Converts 64-bit ticks in milliseconds.

Parameters
TypeDirectionArgument NameDescription
uint64_tN/Atick

Number of tick.

uint64_t *N/Ams

Pointer to the converted milliseconds number.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.

Note

  • The result is rounded to the inferior millisecond.


sl_sleeptimer_is_power_manager_early_restore_timer_latest_to_expire#

bool sl_sleeptimer_is_power_manager_early_restore_timer_latest_to_expire (void )

Allow sleep after ISR exit.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • true if sleep is allowed after ISR exit. False otherwise.


sl_sleeptimer_start_timer_ms#

sl_status_t sl_sleeptimer_start_timer_ms (sl_sleeptimer_timer_handle_t * handle, uint32_t timeout_ms, sl_sleeptimer_timer_callback_t callback, void * callback_data, uint8_t priority, uint16_t option_flags)

Starts a 32 bits timer.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_timer_handle_t *N/Ahandle

Pointer to handle to timer.

uint32_tN/Atimeout_ms

Timer timeout, in milliseconds.

sl_sleeptimer_timer_callback_tN/Acallback

Callback function that will be called when initial/periodic timeout expires.

void *N/Acallback_data

Pointer to user data that will be passed to callback.

uint8_tN/Apriority

Priority of callback. Useful in case multiple timer expire at the same time. 0 = highest priority.

uint16_tN/Aoption_flags

Bit array of option flags for the timer. Valid bit-wise OR of one or more of the following:

  • SL_SLEEPTIMER_NO_HIGH_PRECISION_HF_CLOCKS_REQUIRED_FLAG or 0 for not flags.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.

Note

  • This function converts the delay expressed in milliseconds to timer ticks (represented on 32 bits). This means that the value that can be passed to the argument 'timeout_ms' is limited. The maximum timeout value that can be passed to this function can be retrieved by calling sl_sleeptimer_get_max_ms32_conversion(). If the value passed to 'timeout_ms' is too large, SL_STATUS_INVALID_PARAMETER will be returned.

  • This function cannot be called from an interrupt with a higher priority than BASEPRI.


sl_sleeptimer_restart_timer_ms#

sl_status_t sl_sleeptimer_restart_timer_ms (sl_sleeptimer_timer_handle_t * handle, uint32_t timeout_ms, sl_sleeptimer_timer_callback_t callback, void * callback_data, uint8_t priority, uint16_t option_flags)

Restarts a 32 bits timer.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_timer_handle_t *N/Ahandle

Pointer to handle to timer.

uint32_tN/Atimeout_ms

Timer timeout, in milliseconds.

sl_sleeptimer_timer_callback_tN/Acallback

Callback function that will be called when initial/periodic timeout expires.

void *N/Acallback_data

Pointer to user data that will be passed to callback.

uint8_tN/Apriority

Priority of callback. Useful in case multiple timer expire at the same time. 0 = highest priority.

uint16_tN/Aoption_flags

Bit array of option flags for the timer. Valid bit-wise OR of one or more of the following:

  • SL_SLEEPTIMER_NO_HIGH_PRECISION_HF_CLOCKS_REQUIRED_FLAG or 0 for not flags.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.

Note

  • This function converts the delay expressed in milliseconds to timer ticks (represented on 32 bits). This means that the value that can be passed to the argument 'timeout_ms' is limited. The maximum timeout value that can be passed to this function can be retrieved by calling sl_sleeptimer_get_max_ms32_conversion(). If the value passed to 'timeout_ms' is too large, SL_STATUS_INVALID_PARAMETER will be returned.

  • This function cannot be called from an interrupt with a higher priority than BASEPRI.


sl_sleeptimer_start_periodic_timer_ms#

sl_status_t sl_sleeptimer_start_periodic_timer_ms (sl_sleeptimer_timer_handle_t * handle, uint32_t timeout_ms, sl_sleeptimer_timer_callback_t callback, void * callback_data, uint8_t priority, uint16_t option_flags)

Starts a 32 bits periodic timer.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_timer_handle_t *N/Ahandle

Pointer to handle to timer.

uint32_tN/Atimeout_ms

Timer periodic timeout, in milliseconds.

sl_sleeptimer_timer_callback_tN/Acallback

Callback function that will be called when initial/periodic timeout expires.

void *N/Acallback_data

Pointer to user data that will be passed to callback.

uint8_tN/Apriority

Priority of callback. Useful in case multiple timer expire at the same time. 0 = highest priority.

uint16_tN/Aoption_flags

Bit array of option flags for the timer. Valid bit-wise OR of one or more of the following:

  • SL_SLEEPTIMER_NO_HIGH_PRECISION_HF_CLOCKS_REQUIRED_FLAG or 0 for not flags.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.

Note

  • This function converts the delay expressed in milliseconds to timer ticks (represented on 32 bits). This means that the value that can be passed to the argument 'timeout_ms' is limited. The maximum timeout value that can be passed to this function can be retrieved by calling sl_sleeptimer_get_max_ms32_conversion(). If the value passed to 'timeout_ms' is too large, SL_STATUS_INVALID_PARAMETER will be returned.

  • This function cannot be called from an interrupt with a higher priority than BASEPRI.


sl_sleeptimer_restart_periodic_timer_ms#

sl_status_t sl_sleeptimer_restart_periodic_timer_ms (sl_sleeptimer_timer_handle_t * handle, uint32_t timeout_ms, sl_sleeptimer_timer_callback_t callback, void * callback_data, uint8_t priority, uint16_t option_flags)

Restarts a 32 bits periodic timer.

Parameters
TypeDirectionArgument NameDescription
sl_sleeptimer_timer_handle_t *N/Ahandle

Pointer to handle to timer.

uint32_tN/Atimeout_ms

Timer periodic timeout, in milliseconds.

sl_sleeptimer_timer_callback_tN/Acallback

Callback function that will be called when initial/periodic timeout expires.

void *N/Acallback_data

Pointer to user data that will be passed to callback.

uint8_tN/Apriority

Priority of callback. Useful in case multiple timer expire at the same time. 0 = highest priority.

uint16_tN/Aoption_flags

Bit array of option flags for the timer. Valid bit-wise OR of one or more of the following:

  • SL_SLEEPTIMER_NO_HIGH_PRECISION_HF_CLOCKS_REQUIRED_FLAG or 0 for not flags.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.

Note

  • This function converts the delay expressed in milliseconds to timer ticks (represented on 32 bits). This means that the value that can be passed to the argument 'timeout_ms' is limited. The maximum timeout value that can be passed to this function can be retrieved by calling sl_sleeptimer_get_max_ms32_conversion(). If the value passed to 'timeout_ms' is too large, SL_STATUS_INVALID_PARAMETER will be returned.

  • This function cannot be called from an interrupt with a higher priority than BASEPRI.


sl_sleeptimer_get_clock_accuracy#

uint16_t sl_sleeptimer_get_clock_accuracy (void )

Gets the precision (in PPM) of the sleeptimer's clock.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • Clock accuracy, in PPM.