Platform-specific layer provides a consistent RTC API to upper layers of the driver.
XBee RTC API Overview
This API contains the functions to configure and control the RTC module of
the Programmable XBee devices. The RTC provides the system time through second an millisecond counters, support to trigger a periodic task, calendar (date/time), one programmable alarm (with alarm function) and several functions to perform delays.
- RTC configuration functions:
- rtc_config()
- rtc_set_alarm()
- rtc_set_periodic_task_period()
- rtc_set_timeout()
- rtc_set_date()
- RTC functions to read/get status and RTC values:
- rtc_get_date()
- rtc_get_uptime()
- rtc_get_ms_uptime()
- rtc_timeout_expired()
- Miscellaneous RTC functions:
- delay_ticks()
Platform-specific layer provides a consistent UART API to upper layers of the driver.
RTC Macros
The delay_ticks() function of the RTC module needs as parameter the
number of system ticks for the delay. 1 system tick is 4 milliseconds,
but there is a macro that helps for some operations:
- \b HZ : This macro represents a value of 250. When used in the
delay_ticks() function, it will wait for 1 second.
Usage examples:
Performs a busy loop delay of delay system ticks. The watchdog is continuously refreshed during the delay.
- Parameters
-
[in] | delay | the number of system ticks of the delay, 1 tick is 4ms. You can also use the HZ macro. See the RTC Macros for more information. |
- Return values
-
void rtc_cancel_periodic_task |
( |
void |
| ) |
|
Cancels the execution of the periodic task setting to 0 the periodic task timer.
- Parameters
-
- Return values
-
Configures and initializes the RTC module, with the defualt settings. Its automatically called by sys_hw_init()
- Parameters
-
- Return values
-
int rtc_get_date |
( |
tm_t * |
now | ) |
|
Reads the RTC time/date and saves it in now.
- Parameters
-
[out] | now | struct where the time/date is saved |
- Return values
-
0 | on success |
EINVAL | invalid parameter |
Returns the miliseconds counter, number of ms the system has been running without interruption (downtime)
- Parameters
-
- Return values
-
Number | of miliseconds the system has been up and running |
Returns the second counter, number of seconds the system has been running without interruption (downtime)
- Parameters
-
- Return values
-
Number | of seconds the system has been up and running |
RTC interrupt service routine.
- Parameters
-
- Return values
-
void rtc_periodic_task |
( |
void |
| ) |
|
Function called when the periodic timer expires. The periodic timer is rearmed automatically by the firmware.
- Parameters
-
- Return values
-
int rtc_set_alarm |
( |
tm_t |
newalarm | ) |
|
Programs the alarm with newalarm time values.
- Parameters
-
[in] | newalarm | time/date value when the alarm will be triggered |
- Return values
-
int rtc_set_date |
( |
tm_t |
newdate | ) |
|
Sets date as RTC date.
- Parameters
-
[in] | newdate | Date to program in the RTC |
- Return values
-
0 | on success, error code otherwise |
int rtc_set_periodic_task_period |
( |
uint32_t |
period | ) |
|
Configures the period
(expressed as number of system ticks) of execution of the periodic task. A call to this function resets/restarts the periodic task timer.
- Parameters
-
[in] | period | in system ticks, for the periodic task |
- Return values
-
void rtc_set_timeout |
( |
uint16_t |
timeout | ) |
|
Programs the timeout variable, decremented each system tick.
- Parameters
-
[in] | timeout | expressed as number of system ticks. |
- Return values
-
bool_t rtc_timeout_expired |
( |
void |
| ) |
|
Returns a 1 if the programmed timeout expired. The timeout is programmed with rtc_set_timeout()
- Parameters
-
- Return values
-
1 | if the timeout expired, 0 otherwise |