ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
ruuvi_interface_timer.h
Go to the documentation of this file.
1 #ifndef RUUVI_INTERFACE_TIMER_H
2 #define RUUVI_INTERFACE_TIMER_H
63 #include "ruuvi_driver_error.h"
65 #include <stdbool.h>
66 
68 #if RI_TIMER_ENABLED
69 #define RUUVI_NRF5_SDK15_TIMER_ENABLED RUUVI_NRF5_SDK15_ENABLED
70 #endif
71 
73 typedef enum
74 {
78 
79 typedef void * ri_timer_id_t;
80 
86 typedef void (*ruuvi_timer_timeout_handler_t) (void * const p_context);
87 
88 /* @brief Calls initialization as required by application timers.
89  *
90  * After initialization, timers can be created, started and stopped.
91  *
92  * @retval RD_SUCCESS on success.
93  * @retval RD_ERROR_INVALID_STATE if timers are already initialized.
94  */
96 
97 /* @brief Calls uninitialization as required by application timers
98  *
99  * Deletes state of timers and stops hardware timers if possible.
100  *
101  **/
103 
110 bool ri_timer_is_init (void);
111 
112 /* @brief Function for creating a timer instance.
113  *
114  * Timers may be statically or dynamically allocated, if statically allocated this will
115  * only return a handle to instance. If dynamically, this will allocate memory for new
116  * instance.
117  *
118  * @param[out] p_timer_id pointer to timer id, outputs ID which can be used to control the timer
119  * @param[in] mode mode of the timer, single shot or repeated
120  * @param[in] timeout_handler function which gets called
121  * @return RD_SUCCESS if timer was created
122  * @return RD_ERROR_RESOURCES if no more timers can be allocated
123  * @return RD_ERROR_INVALID_STATE if timers have not been initialized
124  * @return error code from stack on other error
125  */
127  ri_timer_mode_t mode,
128  ruuvi_timer_timeout_handler_t timeout_handler);
129 
142  uint32_t ms,
143  void * const context);
144 
153 #endif
uint32_t rd_status_t
bitfield for representing errors
bool ri_timer_is_init(void)
Check if timer is initialized.
rd_status_t ri_timer_uninit(void)
rd_status_t ri_timer_start(ri_timer_id_t timer_id, uint32_t ms, void *const context)
Start given timer at a mode defined in ri_timer_create.
rd_status_t ri_timer_create(ri_timer_id_t *p_timer_id, ri_timer_mode_t mode, ruuvi_timer_timeout_handler_t timeout_handler)
void(* ruuvi_timer_timeout_handler_t)(void *const p_context)
Function to be called when timer times out.
rd_status_t ri_timer_init(void)
ri_timer_mode_t
Enable implementation selected by application.
rd_status_t ri_timer_stop(ri_timer_id_t timer_id)
void * ri_timer_id_t
Pointer to timer data.
@ RI_TIMER_MODE_REPEATED
@ RI_TIMER_MODE_SINGLE_SHOT
Header to enable and disable module compilation.
Ruuvi error codes and error check function.