diff --git a/boards/common/esp8266/include/periph_conf_common.h b/boards/common/esp8266/include/periph_conf_common.h index a2b030dea8..7f90e018d5 100644 --- a/boards/common/esp8266/include/periph_conf_common.h +++ b/boards/common/esp8266/include/periph_conf_common.h @@ -193,13 +193,13 @@ static const spi_conf_t spi_config[] = { /* software timer */ #define TIMER_NUMOF (1U) /**< number of timer devices */ -#define TIMER_CHANNELS (10U) /**< number of channels per timer device */ +#define TIMER_CHANNEL_NUMOF (10U) /**< number of channels per timer device */ #else /* MODULE_ESP_SW_TIMER */ /* hardware timer */ #define TIMER_NUMOF (1U) /**< number of timer devices */ -#define TIMER_CHANNELS (1U) /**< number of channels per timer device */ +#define TIMER_CHANNEL_NUMOF (1U) /**< number of channels per timer device */ #endif /* MODULE_ESP_SW_TIMER */ /** @} */ diff --git a/cpu/atmega1281/include/default_timer_config.h b/cpu/atmega1281/include/default_timer_config.h index 41fb5f7857..5cb1aaadf2 100644 --- a/cpu/atmega1281/include/default_timer_config.h +++ b/cpu/atmega1281/include/default_timer_config.h @@ -29,7 +29,7 @@ extern "C" { #ifndef TIMER_NUMOF #define TIMER_NUMOF (2U) -#define TIMER_CHANNELS (3) +#define TIMER_CHANNEL_NUMOF (3) #define TIMER_0 MEGA_TIMER1 #define TIMER_0_MASK &TIMSK1 diff --git a/cpu/atmega1284p/include/default_timer_config.h b/cpu/atmega1284p/include/default_timer_config.h index 56eac636de..62fbdb2afb 100644 --- a/cpu/atmega1284p/include/default_timer_config.h +++ b/cpu/atmega1284p/include/default_timer_config.h @@ -28,7 +28,7 @@ extern "C" { #ifndef TIMER_NUMOF #define TIMER_NUMOF (2U) -#define TIMER_CHANNELS (2) +#define TIMER_CHANNEL_NUMOF (2) #define TIMER_0 MEGA_TIMER1 #define TIMER_0_MASK &TIMSK1 diff --git a/cpu/atmega128rfa1/include/default_timer_config.h b/cpu/atmega128rfa1/include/default_timer_config.h index e3a7901e04..3f193cee61 100644 --- a/cpu/atmega128rfa1/include/default_timer_config.h +++ b/cpu/atmega128rfa1/include/default_timer_config.h @@ -26,7 +26,7 @@ extern "C" { #ifndef TIMER_NUMOF #define TIMER_NUMOF (3U) -#define TIMER_CHANNELS (3) +#define TIMER_CHANNEL_NUMOF (3) #define TIMER_0 MEGA_TIMER4 #define TIMER_0_MASK &TIMSK4 diff --git a/cpu/atmega2560/include/default_timer_config.h b/cpu/atmega2560/include/default_timer_config.h index b38e8fe312..b3d850a259 100644 --- a/cpu/atmega2560/include/default_timer_config.h +++ b/cpu/atmega2560/include/default_timer_config.h @@ -29,7 +29,7 @@ extern "C" { #ifndef TIMER_NUMOF #define TIMER_NUMOF (2U) -#define TIMER_CHANNELS (3) +#define TIMER_CHANNEL_NUMOF (3) #define TIMER_0 MEGA_TIMER1 #define TIMER_0_MASK &TIMSK1 diff --git a/cpu/atmega256rfr2/include/default_timer_config.h b/cpu/atmega256rfr2/include/default_timer_config.h index 8670c66553..a96cdde2cb 100644 --- a/cpu/atmega256rfr2/include/default_timer_config.h +++ b/cpu/atmega256rfr2/include/default_timer_config.h @@ -26,7 +26,7 @@ extern "C" { #ifndef TIMER_NUMOF #define TIMER_NUMOF (3U) -#define TIMER_CHANNELS (3) +#define TIMER_CHANNEL_NUMOF (3) #define TIMER_0 MEGA_TIMER4 #define TIMER_0_MASK &TIMSK4 diff --git a/cpu/atmega328p/include/default_timer_config.h b/cpu/atmega328p/include/default_timer_config.h index b1d39ecc93..08e3ffebeb 100644 --- a/cpu/atmega328p/include/default_timer_config.h +++ b/cpu/atmega328p/include/default_timer_config.h @@ -27,7 +27,7 @@ extern "C" { #ifndef TIMER_NUMOF #define TIMER_NUMOF (1U) -#define TIMER_CHANNELS (2) +#define TIMER_CHANNEL_NUMOF (2) #define TIMER_0 MEGA_TIMER1 #define TIMER_0_MASK &TIMSK1 diff --git a/cpu/atmega32u4/include/default_timer_config.h b/cpu/atmega32u4/include/default_timer_config.h index b0d89240a1..fe454f8435 100644 --- a/cpu/atmega32u4/include/default_timer_config.h +++ b/cpu/atmega32u4/include/default_timer_config.h @@ -26,7 +26,7 @@ extern "C" { #ifndef TIMER_NUMOF #define TIMER_NUMOF (2U) -#define TIMER_CHANNELS (3) +#define TIMER_CHANNEL_NUMOF (3) #define TIMER_0 MEGA_TIMER1 #define TIMER_0_MASK &TIMSK1 diff --git a/cpu/atmega_common/periph/timer.c b/cpu/atmega_common/periph/timer.c index 45229de5f7..eadfc4ddc5 100644 --- a/cpu/atmega_common/periph/timer.c +++ b/cpu/atmega_common/periph/timer.c @@ -78,17 +78,17 @@ static unsigned _oneshot; static inline void set_oneshot(tim_t tim, int chan) { - _oneshot |= (1 << chan) << (TIMER_CHANNELS * tim); + _oneshot |= (1 << chan) << (TIMER_CHANNEL_NUMOF * tim); } static inline void clear_oneshot(tim_t tim, int chan) { - _oneshot &= ~((1 << chan) << (TIMER_CHANNELS * tim)); + _oneshot &= ~((1 << chan) << (TIMER_CHANNEL_NUMOF * tim)); } static inline bool is_oneshot(tim_t tim, int chan) { - return _oneshot & ((1 << chan) << (TIMER_CHANNELS * tim)); + return _oneshot & ((1 << chan) << (TIMER_CHANNEL_NUMOF * tim)); } /** @@ -150,7 +150,7 @@ int timer_init(tim_t tim, unsigned long freq, timer_cb_t cb, void *arg) int timer_set_absolute(tim_t tim, int channel, unsigned int value) { - if (channel >= TIMER_CHANNELS) { + if (channel >= TIMER_CHANNEL_NUMOF) { return -1; } @@ -168,7 +168,7 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value) int timer_set(tim_t tim, int channel, unsigned int timeout) { - if (channel >= TIMER_CHANNELS) { + if (channel >= TIMER_CHANNEL_NUMOF) { return -1; } @@ -197,7 +197,7 @@ int timer_set_periodic(tim_t tim, int channel, unsigned int value, uint8_t flags { int res = 0; - if (channel >= TIMER_CHANNELS) { + if (channel >= TIMER_CHANNEL_NUMOF) { return -1; } @@ -235,7 +235,7 @@ int timer_set_periodic(tim_t tim, int channel, unsigned int value, uint8_t flags int timer_clear(tim_t tim, int channel) { - if (channel >= TIMER_CHANNELS) { + if (channel >= TIMER_CHANNEL_NUMOF) { return -1; } diff --git a/cpu/esp32/include/periph_cpu.h b/cpu/esp32/include/periph_cpu.h index b70c2ace93..a690eed7b5 100644 --- a/cpu/esp32/include/periph_cpu.h +++ b/cpu/esp32/include/periph_cpu.h @@ -506,12 +506,12 @@ typedef struct { */ #ifdef MODULE_ESP_HW_COUNTER /** hardware ccount/ccompare registers are used for timer implementation */ -#define TIMER_NUMOF (2) -#define TIMER_CHANNELS (1) +#define TIMER_NUMOF (2) +#define TIMER_CHANNEL_NUMOF (1) #else /** hardware timer modules are used for timer implementation (default) */ -#define TIMER_NUMOF (3) -#define TIMER_CHANNELS (1) +#define TIMER_NUMOF (3) +#define TIMER_CHANNEL_NUMOF (1) #endif /** Timer used for system time */ diff --git a/cpu/lpc2387/include/periph_cpu.h b/cpu/lpc2387/include/periph_cpu.h index bf1db82f7f..95f4cceac3 100644 --- a/cpu/lpc2387/include/periph_cpu.h +++ b/cpu/lpc2387/include/periph_cpu.h @@ -126,7 +126,7 @@ typedef struct { /** * @brief Number of available timer channels */ -#define TIMER_CHANNELS (4U) +#define TIMER_CHANNEL_NUMOF (4U) /** * @brief Declare needed generic SPI functions diff --git a/cpu/lpc2387/periph/timer.c b/cpu/lpc2387/periph/timer.c index bf1c7caeb8..6a409287bc 100644 --- a/cpu/lpc2387/periph/timer.c +++ b/cpu/lpc2387/periph/timer.c @@ -42,17 +42,17 @@ static uint32_t _oneshot; static inline void set_oneshot(tim_t tim, int chan) { - _oneshot |= (1 << chan) << (TIMER_CHANNELS * tim); + _oneshot |= (1 << chan) << (TIMER_CHANNEL_NUMOF * tim); } static inline void clear_oneshot(tim_t tim, int chan) { - _oneshot &= ~((1 << chan) << (TIMER_CHANNELS * tim)); + _oneshot &= ~((1 << chan) << (TIMER_CHANNEL_NUMOF * tim)); } static inline bool is_oneshot(tim_t tim, int chan) { - return _oneshot & ((1 << chan) << (TIMER_CHANNELS * tim)); + return _oneshot & ((1 << chan) << (TIMER_CHANNEL_NUMOF * tim)); } /** @@ -156,7 +156,7 @@ int timer_init(tim_t tim, unsigned long freq, timer_cb_t cb, void *arg) int timer_set_absolute(tim_t tim, int channel, unsigned int value) { - if (((unsigned) tim >= TIMER_NUMOF) || ((unsigned) channel >= TIMER_CHANNELS)) { + if (((unsigned) tim >= TIMER_NUMOF) || ((unsigned) channel >= TIMER_CHANNEL_NUMOF)) { return -1; } @@ -172,7 +172,7 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value) int timer_set_periodic(tim_t tim, int channel, unsigned int value, uint8_t flags) { - if (((unsigned) tim >= TIMER_NUMOF) || ((unsigned) channel >= TIMER_CHANNELS)) { + if (((unsigned) tim >= TIMER_NUMOF) || ((unsigned) channel >= TIMER_CHANNEL_NUMOF)) { return -1; } @@ -202,7 +202,7 @@ int timer_set_periodic(tim_t tim, int channel, unsigned int value, uint8_t flags int timer_clear(tim_t tim, int channel) { - if (((unsigned) tim >= TIMER_NUMOF) || ((unsigned) channel >= TIMER_CHANNELS)) { + if (((unsigned) tim >= TIMER_NUMOF) || ((unsigned) channel >= TIMER_CHANNEL_NUMOF)) { return -1; } get_dev(tim)->MCR &= ~(1 << (channel * 3)); @@ -242,7 +242,7 @@ static inline void chan_handler(lpc23xx_timer_t *dev, unsigned tim_num, unsigned static inline void isr_handler(lpc23xx_timer_t *dev, int tim_num) { - for (unsigned i = 0; i < TIMER_CHANNELS; ++i) { + for (unsigned i = 0; i < TIMER_CHANNEL_NUMOF; ++i) { chan_handler(dev, tim_num, i); } diff --git a/cpu/sam0_common/include/periph_cpu_common.h b/cpu/sam0_common/include/periph_cpu_common.h index 9796867d6d..225fe539a9 100644 --- a/cpu/sam0_common/include/periph_cpu_common.h +++ b/cpu/sam0_common/include/periph_cpu_common.h @@ -353,7 +353,7 @@ typedef struct { /** * @brief Number of available timer channels */ -#define TIMER_CHANNELS (2) +#define TIMER_CHANNEL_NUMOF (2) /** * @brief Set up alternate function (PMUX setting) for a PORT pin diff --git a/cpu/sam0_common/periph/timer.c b/cpu/sam0_common/periph/timer.c index 6e86a8ff9e..261a85e43b 100644 --- a/cpu/sam0_common/periph/timer.c +++ b/cpu/sam0_common/periph/timer.c @@ -41,17 +41,17 @@ static uint32_t _oneshot; static inline void set_oneshot(tim_t tim, int chan) { - _oneshot |= (1 << chan) << (TIMER_CHANNELS * tim); + _oneshot |= (1 << chan) << (TIMER_CHANNEL_NUMOF * tim); } static inline void clear_oneshot(tim_t tim, int chan) { - _oneshot &= ~((1 << chan) << (TIMER_CHANNELS * tim)); + _oneshot &= ~((1 << chan) << (TIMER_CHANNEL_NUMOF * tim)); } static inline bool is_oneshot(tim_t tim, int chan) { - return _oneshot & ((1 << chan) << (TIMER_CHANNELS * tim)); + return _oneshot & ((1 << chan) << (TIMER_CHANNEL_NUMOF * tim)); } static inline TcCount32 *dev(tim_t tim) diff --git a/cpu/sam3/include/periph_cpu.h b/cpu/sam3/include/periph_cpu.h index ae2e8bedf3..da7d987605 100644 --- a/cpu/sam3/include/periph_cpu.h +++ b/cpu/sam3/include/periph_cpu.h @@ -68,7 +68,7 @@ typedef uint32_t gpio_t; /** * @brief We use 3 channels for each defined timer */ -#define TIMER_CHANNELS (3) +#define TIMER_CHANNEL_NUMOF (3) /** * @brief The RTT width is fixed to 32-bit diff --git a/cpu/sam3/periph/timer.c b/cpu/sam3/periph/timer.c index 93cdcd43d8..b0ba1ceeed 100644 --- a/cpu/sam3/periph/timer.c +++ b/cpu/sam3/periph/timer.c @@ -124,7 +124,7 @@ int timer_init(tim_t tim, unsigned long freq, timer_cb_t cb, void *arg) int timer_set_absolute(tim_t tim, int channel, unsigned int value) { - if (channel >= TIMER_CHANNELS) { + if (channel >= TIMER_CHANNEL_NUMOF) { return -1; } (&dev(tim)->TC_CHANNEL[0].TC_RA)[channel] = value; @@ -135,7 +135,7 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value) int timer_clear(tim_t tim, int channel) { - if (channel >= TIMER_CHANNELS) { + if (channel >= TIMER_CHANNEL_NUMOF) { return -1; } @@ -163,7 +163,7 @@ static inline void isr_handler(tim_t tim) { uint32_t status = dev(tim)->TC_CHANNEL[0].TC_SR; - for (int i = 0; i < TIMER_CHANNELS; i++) { + for (int i = 0; i < TIMER_CHANNEL_NUMOF; i++) { if (status & (TC_SR_CPAS << i)) { dev(tim)->TC_CHANNEL[0].TC_IDR = (TC_IDR_CPAS << i); isr_ctx[tim].cb(isr_ctx[tim].arg, i); diff --git a/tests/periph_timer_periodic/main.c b/tests/periph_timer_periodic/main.c index 5aeaee17cb..cab5fba69a 100644 --- a/tests/periph_timer_periodic/main.c +++ b/tests/periph_timer_periodic/main.c @@ -41,7 +41,7 @@ #define CYCLE_MS 100UL #define CYCLES_MAX 10 -static unsigned count[TIMER_CHANNELS]; +static unsigned count[TIMER_CHANNEL_NUMOF]; static void cb(void *arg, int chan) { @@ -93,7 +93,7 @@ int main(void) puts("\nCycles:"); bool succeeded = true; - for (unsigned i = 0; i < TIMER_CHANNELS; ++i) { + for (unsigned i = 0; i < TIMER_CHANNEL_NUMOF; ++i) { printf("channel %u = %02u\t[%s]\n", i, count[i], _print_ok(i, &succeeded)); }