Skip to content

Commit

Permalink
Merge pull request #6360 from OlegHahm/periph_timer_remove_irq
Browse files Browse the repository at this point in the history
periph timer: remove timer_irq_(en|dis)able
  • Loading branch information
haukepetersen authored Jan 18, 2017
2 parents 7c04f05 + d0316fa commit a35709b
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 265 deletions.
11 changes: 0 additions & 11 deletions cpu/atmega_common/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,6 @@ void timer_start(tim_t tim)
ctx[tim].dev->CRB = ctx[tim].mode;
}

void timer_irq_enable(tim_t tim)
{
*ctx[tim].mask = ctx[tim].isrs;
}

void timer_irq_disable(tim_t tim)
{
ctx[tim].isrs = *(ctx[tim].mask);
*ctx[tim].mask = 0;
}

#ifdef TIMER_NUMOF
static inline void _isr(tim_t tim, int chan)
{
Expand Down
23 changes: 5 additions & 18 deletions cpu/cc2538/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ static const int IRQn_lut[GPTIMER_NUMOF] = {
GPTIMER_3A_IRQn
};

/* enable timer interrupts */
static inline void _irq_enable(tim_t dev);

/**
* @brief Setup the given timer
*
Expand Down Expand Up @@ -142,7 +145,7 @@ int timer_init(tim_t dev, unsigned long freq, timer_cb_t cb, void *arg)
}

/* Enable interrupts for given timer: */
timer_irq_enable(dev);
_irq_enable(dev);

return 0;
}
Expand Down Expand Up @@ -274,7 +277,7 @@ void timer_start(tim_t dev)
}
}

void timer_irq_enable(tim_t dev)
static inline void _irq_enable(tim_t dev)
{
DEBUG("%s(%u)\n", __FUNCTION__, dev);

Expand All @@ -292,22 +295,6 @@ void timer_irq_enable(tim_t dev)
}
}

void timer_irq_disable(tim_t dev)
{
DEBUG("%s(%u)\n", __FUNCTION__, dev);

if (dev < TIMER_NUMOF) {
IRQn_Type irqn = IRQn_lut[GPTIMER_GET_NUM(timer_config[dev].dev)];

NVIC_DisableIRQ(irqn);

if (timer_config[dev].channels == 2) {
irqn++;
NVIC_DisableIRQ(irqn);
}
}
}

static cc2538_gptimer_t* GPTIMER = GPTIMER0;

static void irq_handler_a(int n) {
Expand Down
12 changes: 1 addition & 11 deletions cpu/cc26x0/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int timer_init(tim_t tim, unsigned long freq, timer_cb_t cb, void *arg)
/* set the timer speed */
dev(tim)->TAPR = (RCOSC48M_FREQ / freq) - 1;
/* enable global timer interrupt and start the timer */
timer_irq_enable(tim);
NVIC_EnableIRQ(GPTIMER_0A_IRQN + (2 * timer_config[tim].num));
dev(tim)->CTL = GPT_CTL_TAEN;

return 0;
Expand Down Expand Up @@ -117,16 +117,6 @@ void timer_start(tim_t tim)
dev(tim)->CTL = GPT_CTL_TAEN;
}

void timer_irq_enable(tim_t tim)
{
NVIC_EnableIRQ(GPTIMER_0A_IRQN + (2 * timer_config[tim].num));
}

void timer_irq_disable(tim_t tim)
{
NVIC_DisableIRQ(GPTIMER_0A_IRQN + (2 * timer_config[tim].num));
}

/**
* @brief handle interrupt for a timer
*
Expand Down
17 changes: 0 additions & 17 deletions cpu/cc430/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,6 @@ void timer_stop(tim_t dev)
TIMER_BASE->CTL &= ~(CTL_MC_MASK);
}

void timer_irq_enable(tim_t dev)
{

/* TODO: not supported, yet
*
* Problem here: there is no means, of globally disabling timer interrupts.
* We could just enable the interrupts for all CC channels, but this would
* mean, that we might enable interrupts for channels, that are not active.
* I guess we need to remember the interrupt state of all channels before
* disabling and then restore this state when enabling again?! */
}

void timer_irq_disable(tim_t dev)
{
/* TODO: not supported, yet */
}

ISR(TIMER_ISR_CC0, isr_timer_a_cc0)
{
__enter_isr();
Expand Down
10 changes: 0 additions & 10 deletions cpu/ezr32wg/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,6 @@ void timer_start(tim_t dev)
timer_config[dev].timer->CMD = TIMER_CMD_START;
}

void timer_irq_enable(tim_t dev)
{
NVIC_EnableIRQ(timer_config[dev].irqn);
}

void timer_irq_disable(tim_t dev)
{
NVIC_DisableIRQ(timer_config[dev].irqn);
}

void timer_reset(tim_t dev)
{
timer_config[dev].timer->CNT = 0;
Expand Down
38 changes: 5 additions & 33 deletions cpu/lm4f120/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ static timer_conf_t config[TIMER_NUMOF];

#include "hw_timer.h"

/* enable timer interrupts */
static inline void _irq_enable(tim_t dev);

/* Missing from driverlib */
static inline unsigned long
PRIV_TimerPrescaleSnapshotGet(unsigned long ulbase, unsigned long ultimer) {
Expand Down Expand Up @@ -115,7 +118,7 @@ int timer_init(tim_t dev, unsigned long freq, timer_cb_t cb, void *arg)

ROM_TimerIntEnable(timer_base, timer_intbit);

timer_irq_enable(dev);
_irq_enable(dev);
timer_start(dev);

return 0;
Expand Down Expand Up @@ -305,7 +308,7 @@ void timer_stop(tim_t dev)
ROM_TimerDisable(timer_base, timer_side);
}

void timer_irq_enable(tim_t dev)
static inline void _irq_enable(tim_t dev)
{
unsigned int timer_intbase;

Expand All @@ -332,37 +335,6 @@ void timer_irq_enable(tim_t dev)
ROM_IntEnable(timer_intbase);
}

void timer_irq_disable(tim_t dev)
{
unsigned int timer_base;
unsigned int timer_intbit = TIMER_TIMA_TIMEOUT;
unsigned int timer_intbase;

if (dev >= TIMER_NUMOF){
return;
}

switch(dev){
#if TIMER_0_EN
case TIMER_0:
timer_base = WTIMER0_BASE;
timer_intbase = INT_WTIMER0A;
break;
#endif
#if TIMER_1_EN
case TIMER_1:
timer_base = WTIMER1_BASE;
timer_intbase = INT_WTIMER1A;
break;
#endif
default:
return; /* unreachable */
}

ROM_IntEnable(timer_intbase);
ROM_TimerIntDisable(timer_base, timer_intbit);
}

#if TIMER_0_EN
void isr_wtimer0a(void)
{
Expand Down
14 changes: 0 additions & 14 deletions cpu/lpc11u34/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,6 @@ void timer_stop(tim_t dev)
}
}

void timer_irq_enable(tim_t dev)
{
if (dev == TIMER_0) {
NVIC_EnableIRQ(TIMER_0_IRQ);
}
}

void timer_irq_disable(tim_t dev)
{
if (dev == TIMER_0) {
NVIC_DisableIRQ(TIMER_0_IRQ);
}
}

void TIMER_0_ISR(void)
{
if (TIMER_0_DEV->IR & MR0_FLAG) {
Expand Down
14 changes: 0 additions & 14 deletions cpu/lpc1768/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,6 @@ void timer_stop(tim_t dev)
}
}

void timer_irq_enable(tim_t dev)
{
if (dev == TIMER_0) {
NVIC_EnableIRQ(TIMER_0_IRQ);
}
}

void timer_irq_disable(tim_t dev)
{
if (dev == TIMER_0) {
NVIC_DisableIRQ(TIMER_0_IRQ);
}
}

#if TIMER_0_EN
void TIMER_0_ISR(void)
{
Expand Down
12 changes: 0 additions & 12 deletions cpu/lpc2387/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,6 @@ void timer_stop(tim_t tim)
get_dev(tim)->TCR = 0;
}

void timer_irq_enable(tim_t tim)
{
(void) tim;
/* TODO */
}

void timer_irq_disable(tim_t tim)
{
(void) tim;
/* TODO */
}

static inline void isr_handler(lpc23xx_timer_t *dev, int tim_num)
{
for (unsigned i = 0; i < TIMER_CHAN_NUMOF; i++) {
Expand Down
17 changes: 0 additions & 17 deletions cpu/msp430fxyz/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,6 @@ void timer_stop(tim_t dev)
TIMER_BASE->CTL &= ~(TIMER_CTL_MC_MASK);
}

void timer_irq_enable(tim_t dev)
{

/* TODO: not supported, yet
*
* Problem here: there is no means, of globally disabling timer interrupts.
* We could just enable the interrupts for all CC channels, but this would
* mean, that we might enable interrupts for channels, that are not active.
* I guess we need to remember the interrupt state of all channels before
* disabling and then restore this state when enabling again?! */
}

void timer_irq_disable(tim_t dev)
{
/* TODO: not supported, yet */
}

ISR(TIMER_ISR_CC0, isr_timer_a_cc0)
{
__enter_isr();
Expand Down
29 changes: 3 additions & 26 deletions cpu/native/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ int timer_init(tim_t dev, unsigned long freq, timer_cb_t cb, void *arg)
time_null = 0;
time_null = timer_read(0);

timer_irq_disable(dev);
_callback = cb;
_cb_arg = arg;
timer_irq_enable(dev);
if (register_interrupt(SIGALRM, native_isr_timer) != 0) {
DEBUG("darn!\n\n");
}

return 0;
}
Expand Down Expand Up @@ -155,30 +156,6 @@ int timer_clear(tim_t dev, int channel)
return 1;
}

void timer_irq_enable(tim_t dev)
{
(void)dev;
DEBUG("%s\n", __func__);

if (register_interrupt(SIGALRM, native_isr_timer) != 0) {
DEBUG("darn!\n\n");
}

return;
}

void timer_irq_disable(tim_t dev)
{
(void)dev;
DEBUG("%s\n", __func__);

if (unregister_interrupt(SIGALRM) != 0) {
DEBUG("darn!\n\n");
}

return;
}

void timer_start(tim_t dev)
{
(void)dev;
Expand Down
12 changes: 1 addition & 11 deletions cpu/nrf5x_common/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int timer_init(tim_t tim, unsigned long freq, timer_cb_t cb, void *arg)
dev(tim)->EVENTS_COMPARE[2] = 0;

/* enable interrupts */
timer_irq_enable(tim);
NVIC_EnableIRQ(timer_config[tim].irqn);
/* start the timer */
dev(tim)->TASKS_START = 1;

Expand Down Expand Up @@ -140,16 +140,6 @@ void timer_stop(tim_t tim)
dev(tim)->TASKS_STOP = 1;
}

void timer_irq_enable(tim_t tim)
{
NVIC_EnableIRQ(timer_config[tim].irqn);
}

void timer_irq_disable(tim_t tim)
{
NVIC_DisableIRQ(timer_config[tim].irqn);
}

static inline void irq_handler(int num)
{
for (unsigned i = 0; i < timer_config[num].channels; i++) {
Expand Down
12 changes: 1 addition & 11 deletions cpu/sam3/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int timer_init(tim_t tim, unsigned long freq, timer_cb_t cb, void *arg)
dev(tim)->TC_CHANNEL[1].TC_CCR = (TC_CCR_CLKEN | TC_CCR_SWTRG);

/* enable global interrupts for given timer */
timer_irq_enable(tim);
NVIC_EnableIRQ(timer_config[tim].id_ch0);

return 0;
}
Expand Down Expand Up @@ -164,16 +164,6 @@ void timer_stop(tim_t tim)
dev(tim)->TC_CHANNEL[1].TC_CCR = TC_CCR_CLKDIS;
}

void timer_irq_enable(tim_t tim)
{
NVIC_EnableIRQ(timer_config[tim].id_ch0);
}

void timer_irq_disable(tim_t tim)
{
NVIC_DisableIRQ(timer_config[tim].id_ch0);
}

static inline void isr_handler(tim_t tim)
{
uint32_t status = dev(tim)->TC_CHANNEL[0].TC_SR;
Expand Down
Loading

0 comments on commit a35709b

Please sign in to comment.