Loading...
Searching...
No Matches
timer.h File Reference

Low-level timer peripheral driver interface definitions. More...

Detailed Description

Low-level timer peripheral driver interface definitions.

Author
Hauke Petersen hauke.nosp@m..pet.nosp@m.ersen.nosp@m.@fu-.nosp@m.berli.nosp@m.n.de

Definition in file timer.h.

#include <limits.h>
#include <stdint.h>
#include <stdbool.h>
#include "architecture.h"
#include "periph_cpu.h"
#include "periph_conf.h"
+ Include dependency graph for timer.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  timer_isr_ctx_t
 Default interrupt context entry holding callback and argument. More...
 

Macros

#define TIMER_DEV(x)   (x)
 Default timer definition macro.
 
#define TIMER_UNDEF   (UINT_FAST8_MAX)
 Default value for timer not defined.
 
#define TIM_FLAG_RESET_ON_SET   (0x01)
 Reset the timer when the set() function is called.
 
#define TIM_FLAG_RESET_ON_MATCH   (0x02)
 Reset the timer on match.
 
#define TIM_FLAG_SET_STOPPED   (0x04)
 Keep the timer stopped after setting alarm.
 

Typedefs

typedef uint_fast8_t tim_t
 Default timer type.
 
typedef void(* timer_cb_t) (void *arg, int channel)
 Signature of event callback functions triggered from interrupts.
 

Functions

int timer_init (tim_t dev, uint32_t freq, timer_cb_t cb, void *arg)
 Initialize the given timer.
 
int timer_set (tim_t dev, int channel, unsigned int timeout)
 Set a given timer channel for the given timer device.
 
int timer_set_absolute (tim_t dev, int channel, unsigned int value)
 Set an absolute timeout value for the given channel of the given timer.
 
int timer_set_periodic (tim_t dev, int channel, unsigned int value, uint8_t flags)
 Set an absolute timeout value for the given channel of the given timer.
 
int timer_clear (tim_t dev, int channel)
 Clear the given channel of the given timer device.
 
unsigned int timer_read (tim_t dev)
 Read the current value of the given timer device.
 
void timer_start (tim_t dev)
 Start the given timer.
 
void timer_stop (tim_t dev)
 Stop the given timer.
 
uword_t timer_query_freqs_numof (tim_t dev)
 Get the number of different frequencies supported by the given timer.
 
uword_t timer_query_channel_numof (tim_t dev)
 Get the number of timer channels for the given timer.
 
uint32_t timer_query_freqs (tim_t dev, uword_t index)
 Iterate over supported frequencies.
 
bool timer_poll_channel (tim_t dev, int channel)
 Check whether a compare channel has matched.