Skip to content

Commit

Permalink
drivers/ir_nec: move to ztimer
Browse files Browse the repository at this point in the history
  • Loading branch information
dp1 committed May 30, 2022
1 parent e32f4e9 commit eddf376
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion drivers/ir_nec/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ config MODULE_IR_NEC
depends on TEST_KCONFIG
select MODULE_ISRPIPE
select MODULE_PERIPH_GPIO_IRQ
select MODULE_XTIMER
select MODULE_ZTIMER
select MODULE_ZTIMER_USEC
2 changes: 1 addition & 1 deletion drivers/ir_nec/Makefile.dep
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
USEMODULE += isrpipe
USEMODULE += periph_gpio_irq
USEMODULE += xtimer
USEMODULE += ztimer_usec
6 changes: 3 additions & 3 deletions drivers/ir_nec/ir_nec.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "ir_nec_params.h"

#include <stdlib.h>
#include "xtimer.h"
#include "ztimer.h"

#include "ir_nec.h"

Expand All @@ -32,10 +32,10 @@ static void ir_nec_isr(void *arg)
ir_nec_t *ir = (ir_nec_t *)arg;

if (gpio_read(ir->pin) != 0) { // rising edge
ir->last_rising = xtimer_now_usec();
ir->last_rising = ztimer_now(ZTIMER_USEC);
}
else { // falling edge
int length = xtimer_now_usec() - ir->last_rising;
int length = ztimer_now(ZTIMER_USEC) - ir->last_rising;

if (abs(length - IR_NEC_START_US) <= IR_NEC_EPS_US) {
ir->data = 0;
Expand Down

0 comments on commit eddf376

Please sign in to comment.