Timer API Overview
This API contains the functions to configure and control the High
Resolution Timer component on programmable XBee devices.
- Timer interrupt request functions:
- timer_config()
- timer_set_timeout()
- timer_get_timeout()
- timer_set_mode()
- timer_get_mode()
- timer_irq_enable()
- timer_enable()
Timer API Configuration Macros
The timer_config function needs a parameter to state the timer type. The two different options are defined in the following macros:
- Input Capture active-edge macros:
- ONE_SHOT : to set the timer as one shot.
- PERIODIC : to set timer as periodic.
Function that configures the settings of the timer component.
- Parameters
-
[in] | timer | timer to configure (use the name of the component defined by the config.xml) |
[in] | enable | TRUE for enabling, FALSE for disabling the timer. |
[in] | mode | desired mode for the timer (use defined macros). |
[in] | timeout | desired time for the timer to timeout |
- Return values
-
0 | On success. |
-EINVAL | If timer is not a valid timer. |
-EOVERFLOW | If u_secs is not in supported ranges. |
Function that enables/disables the timer module.
- Parameters
-
[in] | timer | timer to enable IRQ (use the name of the component defined by config.xml). |
[in] | enable | TRUE for enabling, FALSE for disabling module. |
- Return values
-
Function that returns timer's mode configuration.
- Parameters
-
[in] | timer | timer to get mode (use the name of the component defined by config.xml). |
- Return values
-
timermode_t | Timer mode: ONE_SHOT or PERIODIC. This determines how many times the interrupt will be entered. NO_VALID if bad timer is passed as argument. |
Function that returns the timeout of the timer interrupt if it is configured as One-Shot timer or the period if it is configured as a periodic timer.
- Parameters
-
[in] | timer | timer to get timeout (use the name of the component defined by config.xml). |
- Return values
-
uint32_t | configured timeout (in microseconds). |
Function that enables timer interrupt.
- Parameters
-
[in] | timer | timer to enable IRQ (use the name of the component defined by config.xml). |
[in] | enable | TRUE to enable, FALSE to disable IRQ. |
- Return values
-
0 | on success. |
-EINVAL | If timer is not a valid timer. |
Function that sets timer's mode.
- Parameters
-
[in] | timer | timer to set mode (use the name of the component defined by the config.xml). |
[in] | mode | Timer mode: ONE_SHOT or PERIODIC. This determines how many times the interrupt will be entered. |
- Return values
-
-EINVAL | If timer is not a valid timer. |
-ERANGE | out of range. |
Function that sets the timeout of the timer interrupt if it is configured as One-Shot timer or the period if it is configured as a periodic timer.
- Parameters
-
[in] | timer | timer to set timeout (use the name of the component defined by config.xml). |
[in] | u_secs | Timeout of interrupt in microseconds. |
- Return values
-
0 | On success. |
-EINVAL | If timer is not a valid timer. |
-EOVERFLOW | If u_secs is not in supported ranges. |