cpu/atmega_common: use TIMER_CHANNEL_NUMOF
This commit is contained in:
parent
51135a50fc
commit
96273b4df0
@ -29,7 +29,7 @@ extern "C" {
|
|||||||
|
|
||||||
#ifndef TIMER_NUMOF
|
#ifndef TIMER_NUMOF
|
||||||
#define TIMER_NUMOF (2U)
|
#define TIMER_NUMOF (2U)
|
||||||
#define TIMER_CHANNELS (3)
|
#define TIMER_CHANNEL_NUMOF (3)
|
||||||
|
|
||||||
#define TIMER_0 MEGA_TIMER1
|
#define TIMER_0 MEGA_TIMER1
|
||||||
#define TIMER_0_MASK &TIMSK1
|
#define TIMER_0_MASK &TIMSK1
|
||||||
|
|||||||
@ -28,7 +28,7 @@ extern "C" {
|
|||||||
|
|
||||||
#ifndef TIMER_NUMOF
|
#ifndef TIMER_NUMOF
|
||||||
#define TIMER_NUMOF (2U)
|
#define TIMER_NUMOF (2U)
|
||||||
#define TIMER_CHANNELS (2)
|
#define TIMER_CHANNEL_NUMOF (2)
|
||||||
|
|
||||||
#define TIMER_0 MEGA_TIMER1
|
#define TIMER_0 MEGA_TIMER1
|
||||||
#define TIMER_0_MASK &TIMSK1
|
#define TIMER_0_MASK &TIMSK1
|
||||||
|
|||||||
@ -26,7 +26,7 @@ extern "C" {
|
|||||||
|
|
||||||
#ifndef TIMER_NUMOF
|
#ifndef TIMER_NUMOF
|
||||||
#define TIMER_NUMOF (3U)
|
#define TIMER_NUMOF (3U)
|
||||||
#define TIMER_CHANNELS (3)
|
#define TIMER_CHANNEL_NUMOF (3)
|
||||||
|
|
||||||
#define TIMER_0 MEGA_TIMER4
|
#define TIMER_0 MEGA_TIMER4
|
||||||
#define TIMER_0_MASK &TIMSK4
|
#define TIMER_0_MASK &TIMSK4
|
||||||
|
|||||||
@ -29,7 +29,7 @@ extern "C" {
|
|||||||
|
|
||||||
#ifndef TIMER_NUMOF
|
#ifndef TIMER_NUMOF
|
||||||
#define TIMER_NUMOF (2U)
|
#define TIMER_NUMOF (2U)
|
||||||
#define TIMER_CHANNELS (3)
|
#define TIMER_CHANNEL_NUMOF (3)
|
||||||
|
|
||||||
#define TIMER_0 MEGA_TIMER1
|
#define TIMER_0 MEGA_TIMER1
|
||||||
#define TIMER_0_MASK &TIMSK1
|
#define TIMER_0_MASK &TIMSK1
|
||||||
|
|||||||
@ -26,7 +26,7 @@ extern "C" {
|
|||||||
|
|
||||||
#ifndef TIMER_NUMOF
|
#ifndef TIMER_NUMOF
|
||||||
#define TIMER_NUMOF (3U)
|
#define TIMER_NUMOF (3U)
|
||||||
#define TIMER_CHANNELS (3)
|
#define TIMER_CHANNEL_NUMOF (3)
|
||||||
|
|
||||||
#define TIMER_0 MEGA_TIMER4
|
#define TIMER_0 MEGA_TIMER4
|
||||||
#define TIMER_0_MASK &TIMSK4
|
#define TIMER_0_MASK &TIMSK4
|
||||||
|
|||||||
@ -27,7 +27,7 @@ extern "C" {
|
|||||||
|
|
||||||
#ifndef TIMER_NUMOF
|
#ifndef TIMER_NUMOF
|
||||||
#define TIMER_NUMOF (1U)
|
#define TIMER_NUMOF (1U)
|
||||||
#define TIMER_CHANNELS (2)
|
#define TIMER_CHANNEL_NUMOF (2)
|
||||||
|
|
||||||
#define TIMER_0 MEGA_TIMER1
|
#define TIMER_0 MEGA_TIMER1
|
||||||
#define TIMER_0_MASK &TIMSK1
|
#define TIMER_0_MASK &TIMSK1
|
||||||
|
|||||||
@ -26,7 +26,7 @@ extern "C" {
|
|||||||
|
|
||||||
#ifndef TIMER_NUMOF
|
#ifndef TIMER_NUMOF
|
||||||
#define TIMER_NUMOF (2U)
|
#define TIMER_NUMOF (2U)
|
||||||
#define TIMER_CHANNELS (3)
|
#define TIMER_CHANNEL_NUMOF (3)
|
||||||
|
|
||||||
#define TIMER_0 MEGA_TIMER1
|
#define TIMER_0 MEGA_TIMER1
|
||||||
#define TIMER_0_MASK &TIMSK1
|
#define TIMER_0_MASK &TIMSK1
|
||||||
|
|||||||
@ -78,17 +78,17 @@ static unsigned _oneshot;
|
|||||||
|
|
||||||
static inline void set_oneshot(tim_t tim, int chan)
|
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)
|
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)
|
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)
|
int timer_set_absolute(tim_t tim, int channel, unsigned int value)
|
||||||
{
|
{
|
||||||
if (channel >= TIMER_CHANNELS) {
|
if (channel >= TIMER_CHANNEL_NUMOF) {
|
||||||
return -1;
|
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)
|
int timer_set(tim_t tim, int channel, unsigned int timeout)
|
||||||
{
|
{
|
||||||
if (channel >= TIMER_CHANNELS) {
|
if (channel >= TIMER_CHANNEL_NUMOF) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ int timer_set_periodic(tim_t tim, int channel, unsigned int value, uint8_t flags
|
|||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
if (channel >= TIMER_CHANNELS) {
|
if (channel >= TIMER_CHANNEL_NUMOF) {
|
||||||
return -1;
|
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)
|
int timer_clear(tim_t tim, int channel)
|
||||||
{
|
{
|
||||||
if (channel >= TIMER_CHANNELS) {
|
if (channel >= TIMER_CHANNEL_NUMOF) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user