mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/pir: migrate to ztimer64
This commit is contained in:
parent
d8126864ea
commit
c19a78765a
@ -12,7 +12,7 @@ config MODULE_PIR
|
||||
depends on TEST_KCONFIG
|
||||
select MODULE_PERIPH_GPIO
|
||||
select MODULE_PERIPH_GPIO_IRQ
|
||||
select MODULE_XTIMER
|
||||
select ZTIMER64_USEC
|
||||
|
||||
config HAVE_PIR
|
||||
bool
|
||||
|
@ -1,3 +1,3 @@
|
||||
FEATURES_REQUIRED += periph_gpio
|
||||
FEATURES_REQUIRED += periph_gpio_irq
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += ztimer64_usec
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "irq.h"
|
||||
#include "thread.h"
|
||||
#include "msg.h"
|
||||
#include "xtimer.h"
|
||||
#include "ztimer64.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
@ -50,7 +50,7 @@ int pir_init(pir_t *dev, const pir_params_t *params)
|
||||
dev->active = false;
|
||||
dev->accum_active_time = 0;
|
||||
dev->start_active_time = 0;
|
||||
dev->last_read_time = xtimer_now_usec64();
|
||||
dev->last_read_time = ztimer64_now(ZTIMER64_USEC);
|
||||
|
||||
gpio_mode_t gpio_mode;
|
||||
if (dev->p.active_high) {
|
||||
@ -74,7 +74,7 @@ pir_event_t pir_get_status(const pir_t *dev)
|
||||
|
||||
int pir_get_occupancy(pir_t *dev, int16_t *occup) {
|
||||
int irq_state = irq_disable();
|
||||
uint64_t now = xtimer_now_usec64();
|
||||
uint64_t now = ztimer64_now(ZTIMER64_USEC);
|
||||
uint64_t total_time = now - dev->last_read_time;
|
||||
if (total_time == 0) {
|
||||
irq_restore(irq_state);
|
||||
@ -145,7 +145,7 @@ static void pir_callback(void *arg)
|
||||
DEBUG("pir_callback: %p\n", arg);
|
||||
pir_t *dev = (pir_t*) arg;
|
||||
bool pin_now = gpio_read(dev->p.gpio);
|
||||
uint64_t now = xtimer_now_usec64();
|
||||
uint64_t now = ztimer64_now(ZTIMER64_USEC);
|
||||
|
||||
/* We were busy counting */
|
||||
if (dev->active) {
|
||||
|
@ -7,5 +7,6 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
atmega328p-xplained-mini \
|
||||
nucleo-f031k6 \
|
||||
nucleo-l011k4 \
|
||||
samd10-xmini \
|
||||
stm32f030f4-demo \
|
||||
#
|
||||
|
@ -23,7 +23,8 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "thread.h"
|
||||
#include "xtimer.h"
|
||||
#include "timex.h"
|
||||
#include "ztimer.h"
|
||||
#include "pir.h"
|
||||
#include "pir_params.h"
|
||||
|
||||
@ -76,7 +77,7 @@ int main(void)
|
||||
while (1) {
|
||||
printf("Status: %s\n", pir_get_status(&dev) == PIR_STATUS_INACTIVE ?
|
||||
"inactive" : "active");
|
||||
xtimer_usleep(1000 * 1000);
|
||||
ztimer_sleep(ZTIMER_USEC, 1 * US_PER_SEC);
|
||||
}
|
||||
#else
|
||||
thread_create(
|
||||
|
Loading…
Reference in New Issue
Block a user