XBee Firmware Library  1.6.0
Functions
Real Time Clock (RTC)

Functions

void delay_ticks (uint16_t delay)
 Performs a busy loop delay of delay system ticks. The watchdog is continuously refreshed during the delay. More...
 
void rtc_cancel_periodic_task (void)
 Cancels the execution of the periodic task setting to 0 the periodic task timer. More...
 
int rtc_config (void)
 Configures and initializes the RTC module, with the defualt settings. Its automatically called by sys_hw_init() More...
 
int rtc_get_date (tm_t *now)
 Reads the RTC time/date and saves it in now. More...
 
uint32_t rtc_get_ms_uptime (void)
 Returns the miliseconds counter, number of ms the system has been running without interruption (downtime) More...
 
uint32_t rtc_get_uptime (void)
 Returns the second counter, number of seconds the system has been running without interruption (downtime) More...
 
void rtc_isr (void)
 RTC interrupt service routine. More...
 
void rtc_periodic_task (void)
 Function called when the periodic timer expires. The periodic timer is rearmed automatically by the firmware. More...
 
int rtc_set_alarm (tm_t newalarm)
 Programs the alarm with newalarm time values. More...
 
int rtc_set_date (tm_t newdate)
 Sets date as RTC date. More...
 
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. More...
 
void rtc_set_timeout (uint16_t timeout)
 Programs the timeout variable, decremented each system tick. More...
 
bool_t rtc_timeout_expired (void)
 Returns a 1 if the programmed timeout expired. The timeout is programmed with rtc_set_timeout() More...
 

Detailed Description

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:

Function Documentation

void delay_ticks ( uint16_t  delay)

Performs a busy loop delay of delay system ticks. The watchdog is continuously refreshed during the delay.

Parameters
[in]delaythe 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
None
void rtc_cancel_periodic_task ( void  )

Cancels the execution of the periodic task setting to 0 the periodic task timer.

Parameters
[in]None
Return values
None
int rtc_config ( void  )

Configures and initializes the RTC module, with the defualt settings. Its automatically called by sys_hw_init()

Parameters
None
Return values
0on success
int rtc_get_date ( tm_t now)

Reads the RTC time/date and saves it in now.

Parameters
[out]nowstruct where the time/date is saved
Return values
0on success
EINVALinvalid parameter
uint32_t rtc_get_ms_uptime ( void  )

Returns the miliseconds counter, number of ms the system has been running without interruption (downtime)

Parameters
None
Return values
Numberof miliseconds the system has been up and running
uint32_t rtc_get_uptime ( void  )

Returns the second counter, number of seconds the system has been running without interruption (downtime)

Parameters
None
Return values
Numberof seconds the system has been up and running
void rtc_isr ( void  )

RTC interrupt service routine.

Parameters
None
Return values
None
void rtc_periodic_task ( void  )

Function called when the periodic timer expires. The periodic timer is rearmed automatically by the firmware.

Parameters
None
Return values
None
int rtc_set_alarm ( tm_t  newalarm)

Programs the alarm with newalarm time values.

Parameters
[in]newalarmtime/date value when the alarm will be triggered
Return values
0on success
int rtc_set_date ( tm_t  newdate)

Sets date as RTC date.

Parameters
[in]newdateDate to program in the RTC
Return values
0on 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]periodin system ticks, for the periodic task
Return values
0on success
void rtc_set_timeout ( uint16_t  timeout)

Programs the timeout variable, decremented each system tick.

Parameters
[in]timeoutexpressed as number of system ticks.
Return values
Nothing
bool_t rtc_timeout_expired ( void  )

Returns a 1 if the programmed timeout expired. The timeout is programmed with rtc_set_timeout()

Parameters
[in]None
Return values
1if the timeout expired, 0 otherwise