1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/periph/timer: add timer_set_periodic()

This commit is contained in:
Benjamin Valentin 2020-04-18 01:26:32 +02:00 committed by Benjamin Valentin
parent 7c11ae9dcc
commit cd107be976
2 changed files with 40 additions and 0 deletions

View File

@ -1050,6 +1050,10 @@ ifneq (,$(filter periph_gpio_irq,$(USEMODULE)))
FEATURES_REQUIRED += periph_gpio
endif
ifneq (,$(filter periph_timer_periodic,$(USEMODULE)))
FEATURES_REQUIRED += periph_timer
endif
ifneq (,$(filter devfs_hwrng,$(USEMODULE)))
FEATURES_REQUIRED += periph_hwrng
endif

View File

@ -34,6 +34,7 @@
#define PERIPH_TIMER_H
#include <limits.h>
#include <stdint.h>
#include "periph_cpu.h"
/** @todo remove dev_enums.h include once all platforms are ported to the updated periph interface */
@ -69,6 +70,26 @@ extern "C" {
typedef unsigned int tim_t;
#endif
/**
* @brief Reset the timer when the set() function is called
*
* When set, calling the timer_set_periodic() function resets the timer count value.
*/
#ifndef TIM_FLAG_RESET_ON_SET
#define TIM_FLAG_RESET_ON_SET (0x01)
#endif
/**
* @brief Reset the timer on match
*
* When set, a match on this channel will reset the timer count value.
* When set on multiple channels, only the channel with the lowest match value
* will be reached.
*/
#ifndef TIM_FLAG_RESET_ON_MATCH
#define TIM_FLAG_RESET_ON_MATCH (0x02)
#endif
/**
* @brief Signature of event callback functions triggered from interrupts
*
@ -138,6 +159,21 @@ int timer_set(tim_t dev, int channel, unsigned int timeout);
*/
int timer_set_absolute(tim_t dev, int channel, unsigned int value);
/**
* @brief Set an absolute timeout value for the given channel of the given timer
* The timeout will be called periodically for each iteration
*
* @param[in] dev the timer device to set
* @param[in] channel the channel to set
* @param[in] value the absolute compare value when the callback will be
* triggered
* @param[in] flags options
*
* @return 0 on success
* @return -1 on error
*/
int timer_set_periodic(tim_t dev, int channel, unsigned int value, uint8_t flags);
/**
* @brief Clear the given channel of the given timer device
*