cpu/lpc2387: use TIMER_CHANNEL_NUMOF

This commit is contained in:
Benjamin Valentin 2020-06-23 19:22:27 +02:00
parent 5da1a9e577
commit 3af4d38735
2 changed files with 8 additions and 8 deletions

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