1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:32:45 +01:00

cpu/gd32v: move TIMER_CHANNEL macros to header file

This commit is contained in:
Gunar Schorcht 2023-01-28 17:39:06 +01:00
parent 2c6e527339
commit 596d762806
2 changed files with 14 additions and 10 deletions

View File

@ -165,6 +165,16 @@ typedef enum {
GPIO_AF_OUT_OD = 0xf, /**< alternate function output - open-drain */
} gpio_af_t;
/**
* @brief GD32V timers have 4 capture-compare channels
*/
#define TIMER_CHANNEL_NUMOF (4U)
/**
* @brief Macro for accessing the capture/compare register of a timer channel
*/
#define TIMER_CHANNEL(tim, chan) *(&dev(tim)->CH0CV + (chan * 2))
/**
* @brief Timer configuration
*/

View File

@ -25,12 +25,6 @@
#define ENABLE_DEBUG 0
#include "debug.h"
/**
* @brief Define a macro for accessing a timer channel
*/
#define TIM_CHAN(tim, chan) *(&dev(tim)->CH0CV + chan)
#define TIMER_CHANNEL_NUMOF (4)
static void _timer_isr(unsigned irq);
/**
@ -143,10 +137,10 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value)
set_oneshot(tim, channel);
TIM_CHAN(tim, channel) = (value & timer_config[tim].max);
TIMER_CHANNEL(tim, channel) = (value & timer_config[tim].max);
#ifdef MODULE_PERIPH_TIMER_PERIODIC
if (dev(tim)->CAR == TIM_CHAN(tim, channel)) {
if (dev(tim)->CAR == TIMER_CHANNEL(tim, channel)) {
dev(tim)->CAR = timer_config[tim].max;
}
#endif
@ -207,7 +201,7 @@ int timer_clear(tim_t tim, int channel)
dev(tim)->DMAINTEN &= ~(TIMER0_DMAINTEN_CH0IE_Msk << channel);
#ifdef MODULE_PERIPH_TIMER_PERIODIC
if (dev(tim)->CAR == TIM_CHAN(tim, channel)) {
if (dev(tim)->CAR == TIMER_CHANNEL(tim, channel)) {
dev(tim)->CAR = timer_config[tim].max;
}
#endif
@ -247,7 +241,7 @@ static void _irq_handler(tim_t tim)
status &= ~msk;
/* interrupt flag gets set for all channels > ARR */
if (TIM_CHAN(tim, i) > top) {
if (TIMER_CHANNEL(tim, i) > top) {
continue;
}