Skip to content

Commit

Permalink
Merge pull request #12199 from smlng/fix_timer_returns
Browse files Browse the repository at this point in the history
periph/timer: Fix return codes of timer API
  • Loading branch information
benpicco authored Sep 17, 2019
2 parents 98482b6 + ddd9700 commit d5c272e
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cpu/atmega_common/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value)
*ctx[tim].flag &= ~(1 << (channel + OCF1A));
*ctx[tim].mask |= (1 << (channel + OCIE1A));

return 1;
return 0;
}

int timer_clear(tim_t tim, int channel)
Expand Down
4 changes: 2 additions & 2 deletions cpu/cc2538/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value)
}
dev(tim)->IMR |= chn_isr_cfg[channel].flag;

return 1;
return 0;
}

int timer_clear(tim_t tim, int channel)
Expand All @@ -190,7 +190,7 @@ int timer_clear(tim_t tim, int channel)
/* clear interupt flags */
dev(tim)->IMR &= ~(chn_isr_cfg[channel].flag);

return 1;
return 0;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion cpu/cc26x0/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value)
}
dev(tim)->IMR |= chn_isr_cfg[channel].flag;

return 1;
return 0;
}

int timer_clear(tim_t tim, int channel)
Expand Down
10 changes: 5 additions & 5 deletions cpu/kinetis/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ static inline int lptmr_set(uint8_t dev, uint16_t timeout)
lptmr_reload(dev, timeout);
}
irq_restore(mask);
return 1;
return 0;
}

static inline int lptmr_set_absolute(uint8_t dev, uint16_t target)
Expand Down Expand Up @@ -498,7 +498,7 @@ static inline int lptmr_set_absolute(uint8_t dev, uint16_t target)
lptmr_reload(dev, timeout);
}
irq_restore(mask);
return 1;
return 0;
}

static inline int lptmr_clear(uint8_t dev)
Expand All @@ -510,20 +510,20 @@ static inline int lptmr_clear(uint8_t dev)
if (!lptmr[dev].running) {
/* Already clear */
irq_restore(mask);
return 1;
return 0;
}
lptmr[dev].running = 0;
if (!(hw->CSR & LPTMR_CSR_TEN_MASK)) {
/* Timer is stopped */
irq_restore(mask);
return 1;
return 0;
}
/* Disable interrupt, enable timer */
hw->CSR = LPTMR_CSR_TEN_MASK | LPTMR_CSR_TFC_MASK;
/* Clear IRQ if it occurred during this function */
NVIC_ClearPendingIRQ(lptmr_config[dev].irqn);
irq_restore(mask);
return 1;
return 0;
}

static inline void lptmr_start(uint8_t dev)
Expand Down
6 changes: 3 additions & 3 deletions cpu/lm4f120/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int timer_init(tim_t dev, unsigned long freq, timer_cb_t cb, void *arg)
unsigned int timer_base;
unsigned int timer_side = TIMER_A;
unsigned int timer_cfg = TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC_UP | TIMER_TAMR_TAMIE;
unsigned int timer_max_val;
unsigned int timer_max_val = 0;
unsigned int timer_intbit = TIMER_TIMA_TIMEOUT | TIMER_TIMA_MATCH;

switch(dev){
Expand Down Expand Up @@ -163,7 +163,7 @@ int timer_set_absolute(tim_t dev, int channel, unsigned int value)
ROM_TimerMatchSet(timer_base, timer_side, (unsigned long) (scaledv & 0xFFFFFFFF));
ROM_TimerEnable(timer_base, timer_side);

return 1;
return 0;
}

int timer_clear(tim_t dev, int channel)
Expand Down Expand Up @@ -194,7 +194,7 @@ int timer_clear(tim_t dev, int channel)
}

ROM_TimerIntClear(timer_base, timer_intbit);
return 1;
return 0;
}

unsigned int timer_read(tim_t dev)
Expand Down
4 changes: 2 additions & 2 deletions cpu/lpc1768/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int timer_set_absolute(tim_t dev, int channel, unsigned int value)
return -1;
}
TIMER_0_DEV->MCR |= (1 << (channel * 3));
return 1;
return 0;
}
return -1;
}
Expand All @@ -92,7 +92,7 @@ int timer_clear(tim_t dev, int channel)
{
if (dev == TIMER_0 && channel >= 0 && channel < TIMER_0_CHANNELS) {
TIMER_0_DEV->MCR &= ~(1 << (channel * 3));
return 1;
return 0;
}
return -1;
}
Expand Down
6 changes: 3 additions & 3 deletions cpu/mips32r2_common/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ int timer_set(tim_t dev, int channel, unsigned int timeout)
compares[channel] = counter + timeout;
irq_restore(status);

return 1;
return 0;
}

int timer_set_absolute(tim_t dev, int channel, unsigned int value)
Expand All @@ -152,7 +152,7 @@ int timer_set_absolute(tim_t dev, int channel, unsigned int value)
compares[channel] = value;
irq_restore(status);

return 1;
return 0;
}

int timer_clear(tim_t dev, int channel)
Expand All @@ -166,7 +166,7 @@ int timer_clear(tim_t dev, int channel)
compares[channel] = 0;
irq_restore(status);

return 1;
return 0;
}

unsigned int timer_read(tim_t dev)
Expand Down
4 changes: 2 additions & 2 deletions cpu/native/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ int timer_set(tim_t dev, int channel, unsigned int offset)

do_timer_set(offset);

return 1;
return 0;
}

int timer_set_absolute(tim_t dev, int channel, unsigned int value)
Expand All @@ -157,7 +157,7 @@ int timer_clear(tim_t dev, int channel)

do_timer_set(0);

return 1;
return 0;
}

void timer_start(tim_t dev)
Expand Down
4 changes: 2 additions & 2 deletions cpu/nrf5x_common/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ int timer_set_absolute(tim_t tim, int chan, unsigned int value)
dev(tim)->CC[chan] = value;
dev(tim)->INTENSET = (TIMER_INTENSET_COMPARE0_Msk << chan);

return 1;
return 0;
}

int timer_clear(tim_t tim, int chan)
Expand All @@ -116,7 +116,7 @@ int timer_clear(tim_t tim, int chan)
dev(tim)->INTENCLR = (TIMER_INTENSET_COMPARE0_Msk << chan);
ctx[tim].flags &= ~(1 << chan);

return 1;
return 0;
}

unsigned int timer_read(tim_t tim)
Expand Down
4 changes: 2 additions & 2 deletions cpu/sam0_common/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value)
return -1;
}

return 1;
return 0;
}

int timer_clear(tim_t tim, int channel)
Expand All @@ -182,7 +182,7 @@ int timer_clear(tim_t tim, int channel)
return -1;
}

return 1;
return 0;
}

unsigned int timer_read(tim_t tim)
Expand Down
2 changes: 1 addition & 1 deletion cpu/sam3/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ int timer_clear(tim_t tim, int channel)

dev(tim)->TC_CHANNEL[0].TC_IDR = (TC_IDR_CPAS << channel);

return 1;
return 0;
}

unsigned int timer_read(tim_t tim)
Expand Down
6 changes: 3 additions & 3 deletions drivers/include/periph/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int timer_init(tim_t dev, unsigned long freq, timer_cb_t cb, void *arg);
* @param[in] timeout timeout in ticks after that the registered callback
* is executed
*
* @return 1 on success
* @return 0 on success
* @return -1 on error
*/
int timer_set(tim_t dev, int channel, unsigned int timeout);
Expand All @@ -121,7 +121,7 @@ int timer_set(tim_t dev, int channel, unsigned int timeout);
* @param[in] value the absolute compare value when the callback will be
* triggered
*
* @return 1 on success
* @return 0 on success
* @return -1 on error
*/
int timer_set_absolute(tim_t dev, int channel, unsigned int value);
Expand All @@ -132,7 +132,7 @@ int timer_set_absolute(tim_t dev, int channel, unsigned int value);
* @param[in] dev the timer device to clear
* @param[in] channel the channel on the given device to clear
*
* @return 1 on success
* @return 0 on success
* @return -1 on error
*/
int timer_clear(tim_t dev, int channel);
Expand Down

0 comments on commit d5c272e

Please sign in to comment.