See System Timer Control for documentation.

License#

Copyright 2018 Silicon Laboratories Inc. www.silabs.com

The licensor of this software is Silicon Laboratories Inc. Your use of this software is governed by the terms of Silicon Labs Master Software License Agreement (MSLA) available at www.silabs.com/about-us/legal/master-software-license-agreement. This software is distributed to you in Source Code format and is governed by the sections of the MSLA applicable to Source Code.

/***************************************************************************/
#ifndef __SYSTEM_TIMER_H__
#define __SYSTEM_TIMER_H__

#ifndef DOXYGEN_SHOULD_SKIP_THIS

#if defined(EMBER_TEST)
  #include "unix/simulation/system-timer-sim.h"
#endif

#endif // DOXYGEN_SHOULD_SKIP_THIS

uint16_t halInternalStartSystemTimer(void);

uint16_t halCommonGetInt16uMillisecondTick(void);

uint32_t halCommonGetInt32uMillisecondTick(void);

uint64_t halCommonGetInt64uMillisecondTick(void);

uint16_t halCommonGetInt16uQuarterSecondTick(void);

EmberStatus halSleepForQuarterSeconds(uint32_t *duration);

EmberStatus halSleepForMilliseconds(uint32_t *duration);

EmberStatus halCommonIdleForMilliseconds(uint32_t *duration);

// Maintain the previous API for backwards compatibility
#define halIdleForMilliseconds(duration) halCommonIdleForMilliseconds((duration))

#endif //__SYSTEM_TIMER_H__

Macros#

#define

Functions#

uint16_t

Initializes the system tick.

uint16_t

Returns the current system time in system ticks, as a 16-bit value.

uint32_t

Returns the current system time in system ticks, as a 32-bit value.

uint64_t

Returns the current system time in system ticks, as a 64-bit value.

uint16_t

Returns the current system time in quarter second ticks, as a 16-bit value.

halSleepForQuarterSeconds(uint32_t *duration)

Uses the system timer to enter SLEEPMODE_WAKETIMER for approximately the specified amount of time (provided in quarter seconds).

halSleepForMilliseconds(uint32_t *duration)

Uses the system timer to enter SLEEPMODE_WAKETIMER for approximately the specified amount of time (provided in milliseconds). Note that since the system timer ticks at a rate of 1024Hz, a second is comprised of 1024 milliseconds in this function.

halCommonIdleForMilliseconds(uint32_t *duration)

Uses the system timer to enter SLEEPMODE_IDLE for approximately the specified amount of time (provided in milliseconds).

Macro Definition Documentation#

halIdleForMilliseconds#

#define halIdleForMilliseconds
Value:
(duration)

Definition at line 211 of file /mnt/raid/workspaces/ws.tfWcRzYcf/overlay/gsdk/platform/base/hal/micro/system-timer.h

Function Documentation#

halInternalStartSystemTimer#

uint16_t halInternalStartSystemTimer (void )

Initializes the system tick.

Parameters
N/A

Returns

  • Time to update the async registers after RTC is started (units of 100 microseconds).


Definition at line 57 of file /mnt/raid/workspaces/ws.tfWcRzYcf/overlay/gsdk/platform/base/hal/micro/system-timer.h

halCommonGetInt16uMillisecondTick#

uint16_t halCommonGetInt16uMillisecondTick (void )

Returns the current system time in system ticks, as a 16-bit value.

Parameters
N/A

Returns

  • The least significant 16 bits of the current system time, in system ticks.


Definition at line 66 of file /mnt/raid/workspaces/ws.tfWcRzYcf/overlay/gsdk/platform/base/hal/micro/system-timer.h

halCommonGetInt32uMillisecondTick#

uint32_t halCommonGetInt32uMillisecondTick (void )

Returns the current system time in system ticks, as a 32-bit value.

Parameters
N/A
  • EmberStack Usage:\n Unused, implementation optional.#

Returns

  • The least significant 32 bits of the current system time, in system ticks.


Definition at line 77 of file /mnt/raid/workspaces/ws.tfWcRzYcf/overlay/gsdk/platform/base/hal/micro/system-timer.h

halCommonGetInt64uMillisecondTick#

uint64_t halCommonGetInt64uMillisecondTick (void )

Returns the current system time in system ticks, as a 64-bit value.

Parameters
N/A
  • EmberStack Usage:\n Unused, implementation optional.#

Returns

  • 64 bits containing the current system time, in system ticks.


Definition at line 87 of file /mnt/raid/workspaces/ws.tfWcRzYcf/overlay/gsdk/platform/base/hal/micro/system-timer.h

halCommonGetInt16uQuarterSecondTick#

uint16_t halCommonGetInt16uQuarterSecondTick (void )

Returns the current system time in quarter second ticks, as a 16-bit value.

Parameters
N/A
  • EmberStack Usage:\n Unused, implementation optional.#

Returns

  • The least significant 16 bits of the current system time, in system ticks multiplied by 256.


Definition at line 98 of file /mnt/raid/workspaces/ws.tfWcRzYcf/overlay/gsdk/platform/base/hal/micro/system-timer.h

halSleepForQuarterSeconds#

EmberStatus halSleepForQuarterSeconds (uint32_t * duration)

Uses the system timer to enter SLEEPMODE_WAKETIMER for approximately the specified amount of time (provided in quarter seconds).

Parameters
N/Aduration

The amount of time, expressed in quarter seconds, that the micro should be placed into SLEEPMODE_WAKETIMER. When the function returns, this parameter provides the amount of time remaining out of the original sleep time request (normally the return value will be 0).

This function returns EMBER_SUCCESS and the duration parameter is decremented to 0 after sleeping for the specified amount of time. If an interrupt occurs that brings the chip out of sleep, the function returns EMBER_SLEEP_INTERRUPTED and the duration parameter reports the amount of time remaining out of the original request.

Note

  • This routine always enables interrupts.

  • The maximum sleep time of the hardware is limited on AVR-based platforms to 8 seconds, on EM2XX-based platforms to 64 seconds, and on EM35x platforms to 48.5 days. Any sleep duration greater than this limit will wake up briefly (e.g. 16 microseconds) to reenable another sleep cycle.

The EM2xx has a 16 bit sleep timer, which normally runs at 1024Hz. In order to support long sleep durations, the chip will periodically wake up to manage a larger timer in software. This periodic wakeup is normally triggered once every 32 seconds. However, this period can be extended to once every 2.275 hours by building with ENABLE_LONG_SLEEP_CYCLES defined. This definition enables the use of a prescaler when sleeping for more than 63 seconds at a time. However, this define also imposes the following limitations:

  1. The chip may only wake up from the sleep timer. (External GPIO wake events may not be used)

  2. Each time a sleep cycle is performed, a loss of accuracy up to +/-750ms will be observed in the system timer.

  • EmberStack Usage:\n Unused, implementation optional.#

Returns

  • An EmberStatus value indicating the success or failure of the command.


Definition at line 141 of file /mnt/raid/workspaces/ws.tfWcRzYcf/overlay/gsdk/platform/base/hal/micro/system-timer.h

halSleepForMilliseconds#

EmberStatus halSleepForMilliseconds (uint32_t * duration)

Uses the system timer to enter SLEEPMODE_WAKETIMER for approximately the specified amount of time (provided in milliseconds). Note that since the system timer ticks at a rate of 1024Hz, a second is comprised of 1024 milliseconds in this function.

Parameters
N/Aduration

The amount of time, expressed in milliseconds (1024 milliseconds = 1 second), that the micro should be placed into SLEEPMODE_WAKETIMER. When the function returns, this parameter provides the amount of time remaining out of the original sleep time request (normally the return value will be 0).

This function returns EMBER_SUCCESS and the duration parameter is decremented to 0 after sleeping for the specified amount of time. If an interrupt occurs that brings the chip out of sleep, the function returns EMBER_SLEEP_INTERRUPTED and the duration parameter reports the amount of time remaining out of the original request.

Note

  • This routine always enables interrupts.

  • This function is not implemented on AVR-based platforms.

  • Sleep durations less than 3 milliseconds are not allowed on on EM2XX-based platforms. Any attempt to sleep for less than 3 milliseconds on EM2XX-based platforms will cause the function to immediately exit without sleeping and return EMBER_SLEEP_INTERRUPTED.

  • The maximum sleep time of the hardware is limited on EM2XX-based platforms to 32 seconds. Any sleep duration greater than this limit will wake up briefly (e.g. 16 microseconds) to reenable another sleep cycle. Due to this limitation, this function should not be used with durations within 3 milliseconds of a multiple 32 seconds. The short sleep cycle that results from such durations is not handled reliably by the system timer on EM2XX-based platforms. If a sleep duration within 3 milliseconds of a multiple of 32 seconds is desired, halSleepForQuarterSeconds should be used.

  • EmberStack Usage:\n Unused, implementation optional.#

Returns

  • An EmberStatus value indicating the success or failure of the command.


Definition at line 184 of file /mnt/raid/workspaces/ws.tfWcRzYcf/overlay/gsdk/platform/base/hal/micro/system-timer.h

halCommonIdleForMilliseconds#

EmberStatus halCommonIdleForMilliseconds (uint32_t * duration)

Uses the system timer to enter SLEEPMODE_IDLE for approximately the specified amount of time (provided in milliseconds).

Parameters
N/Aduration

The amount of time, expressed in milliseconds, that the micro should be placed into SLEEPMODE_IDLE. When the function returns, this parameter provides the amount of time remaining out of the original idle time request (normally the return value will be 0).

This function returns EMBER_SUCCESS and the duration parameter is decremented to 0 after idling for the specified amount of time. If an interrupt occurs that brings the chip out of idle, the function returns EMBER_SLEEP_INTERRUPTED and the duration parameter reports the amount of time remaining out of the original request.

Note

  • This routine always enables interrupts.

  • EmberStack Usage:\n Unused, implementation optional.#

Returns

  • An EmberStatus value indicating the success or failure of the command.


Definition at line 208 of file /mnt/raid/workspaces/ws.tfWcRzYcf/overlay/gsdk/platform/base/hal/micro/system-timer.h