1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-29 08:21:18 +01:00

Merge pull request #14337 from benpicco/TIMER_CHANNEL_NUMOF

use TIMER_CHANNEL_NUMOF instead of TIMER_CHANNELS
This commit is contained in:
Bas Stottelaar 2020-06-24 01:19:17 +02:00 committed by GitHub
commit 6774f7e412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 38 additions and 38 deletions

View File

@ -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 */
/** @} */

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -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 */

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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);

View File

@ -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));
}