nRF51 SDK - S110 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Simple timer module. More...

Typedefs

typedef void(* app_simple_timer_timeout_handler_t )(void *p_context)
 Timer time-out handler type.
 

Enumerations

enum  app_simple_timer_mode_t {
  APP_SIMPLE_TIMER_MODE_SINGLE_SHOT,
  APP_SIMPLE_TIMER_MODE_REPEATED
}
 Timer modes. More...
 

Functions

uint32_t app_simple_timer_init (void)
 Function for configuring and setting up the timer hardware. More...
 
uint32_t app_simple_timer_start (app_simple_timer_mode_t mode, app_simple_timer_timeout_handler_t timeout_handler, uint16_t timeout_ticks, void *p_context)
 Function for starting a timer. More...
 
uint32_t app_simple_timer_stop (void)
 Function for stopping the timer. More...
 
uint32_t app_simple_timer_uninit (void)
 Function for uninitializing the timer. Should be called also when the timer is not used anymore to reach lowest power consumption in system. More...
 

Detailed Description

Simple timer module.

Supported features and limitations:

Enumeration Type Documentation

Timer modes.

Enumerator
APP_SIMPLE_TIMER_MODE_SINGLE_SHOT 

The timer will expire only once.

APP_SIMPLE_TIMER_MODE_REPEATED 

The timer will restart each time it expires.

Function Documentation

uint32_t app_simple_timer_init ( void  )

Function for configuring and setting up the timer hardware.

Note
Configuration parameters should be set in nrf_drv_config.h file. The TIMER1_CONFIG_MODE has to be set to NRF_TIMER_MODE_TIMER value. The TIMER1_CONFIG_BIT_WIDTH has to be set to NRF_TIMER_BIT_WIDTH_16 value.
Return values
NRF_SUCCESSIf the operation is successful.
NRF_ERROR_INVALID_STATEIf the operation fails because the timer is already initialized.
NRF_ERROR_INVALID_PARAMIf the operation fails because some configuration parameter is not valid.
uint32_t app_simple_timer_start ( app_simple_timer_mode_t  mode,
app_simple_timer_timeout_handler_t  timeout_handler,
uint16_t  timeout_ticks,
void *  p_context 
)

Function for starting a timer.

Note
If this function is called for a timer that is already running, the currently running timer is stopped before starting the new one.
Parameters
[in]modeTimer mode (see app_simple_timer_mode_t).
[in]timeout_handlerFunction to be executed when the timer expires (see app_simple_timer_timeout_handler_t).
[in]timeout_ticksNumber of timer ticks to time-out event.
[in]p_contextGeneral purpose pointer. Will be passed to the time-out handler when the timer expires.
Return values
NRF_SUCCESSIf the operation is successful.
NRF_ERROR_INVALID_STATEIf the operation fails because app_simple_timer_init has not been called and the operation is not allowed in this state.
NRF_ERROR_NULLIf the operation fails because timeout_handler is NULL.
NRF_ERROR_INVALID_PARAMIf the operation fails because "mode" parameter is not valid.
uint32_t app_simple_timer_stop ( void  )

Function for stopping the timer.

Return values
NRF_SUCCESSIf the operation is successful.
uint32_t app_simple_timer_uninit ( void  )

Function for uninitializing the timer. Should be called also when the timer is not used anymore to reach lowest power consumption in system.

Note
The function switches off the internal core of the timer to reach lowest power consumption in system. The startup time from this state may be longer compared to starting the timer from the stopped state.
Return values
NRF_SUCCESSIf the operation is successful.