mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
tests/periph_gpio: Convert to ztimer
This commit is contained in:
parent
8c2f0dd2af
commit
f1feaa2063
@ -8,6 +8,7 @@ FEATURES_OPTIONAL += periph_gpio_tamper_wake
|
||||
USEMODULE += shell
|
||||
USEMODULE += shell_commands
|
||||
USEMODULE += benchmark
|
||||
USEMODULE += ztimer_usec
|
||||
|
||||
# disable native GPIOs for automatic test
|
||||
ifeq (native,$(BOARD))
|
||||
|
@ -5,5 +5,7 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
arduino-uno \
|
||||
atmega328p \
|
||||
atmega328p-xplained-mini \
|
||||
nucleo-l011k4 \
|
||||
samd10-xmini \
|
||||
stm32f030f4-demo \
|
||||
#
|
||||
|
@ -2,7 +2,8 @@
|
||||
# application configuration. This is only needed during migration.
|
||||
CONFIG_MODULE_PERIPH_GPIO=y
|
||||
|
||||
CONFIG_MODULE_BENCHMARK=y
|
||||
CONFIG_MODULE_SHELL=y
|
||||
CONFIG_MODULE_SHELL_COMMANDS=y
|
||||
CONFIG_MODULE_BENCHMARK=y
|
||||
CONFIG_MODULE_XTIMER=y
|
||||
CONFIG_MODULE_ZTIMER=y
|
||||
CONFIG_ZTIMER_USEC=y
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "shell.h"
|
||||
#include "benchmark.h"
|
||||
#include "periph/gpio.h"
|
||||
#include "ztimer.h"
|
||||
|
||||
#define BENCH_RUNS_DEFAULT (1000UL * 100)
|
||||
#define IRQ_TIMEOUT_US (1000UL)
|
||||
@ -302,13 +303,13 @@ static int cmd_auto_test(int argc, char **argv)
|
||||
}
|
||||
|
||||
gpio_set(pin_out);
|
||||
if (xtimer_mutex_lock_timeout(&lock, IRQ_TIMEOUT_US)) {
|
||||
if (ztimer_mutex_lock_timeout(ZTIMER_USEC, &lock, IRQ_TIMEOUT_US)) {
|
||||
puts("rising interrupt timeout");
|
||||
return -1;
|
||||
}
|
||||
|
||||
gpio_clear(pin_out);
|
||||
if (xtimer_mutex_lock_timeout(&lock, IRQ_TIMEOUT_US) == 0) {
|
||||
if (ztimer_mutex_lock_timeout(ZTIMER_USEC, &lock, IRQ_TIMEOUT_US) == 0) {
|
||||
puts("interrupt falsely generated on falling edge");
|
||||
return -1;
|
||||
}
|
||||
@ -320,13 +321,13 @@ static int cmd_auto_test(int argc, char **argv)
|
||||
}
|
||||
|
||||
gpio_set(pin_out);
|
||||
if (xtimer_mutex_lock_timeout(&lock, IRQ_TIMEOUT_US) == 0) {
|
||||
if (ztimer_mutex_lock_timeout(ZTIMER_USEC, &lock, IRQ_TIMEOUT_US) == 0) {
|
||||
puts("interrupt falsely generated on rising edge");
|
||||
return -1;
|
||||
}
|
||||
|
||||
gpio_clear(pin_out);
|
||||
if (xtimer_mutex_lock_timeout(&lock, IRQ_TIMEOUT_US)) {
|
||||
if (ztimer_mutex_lock_timeout(ZTIMER_USEC, &lock, IRQ_TIMEOUT_US)) {
|
||||
puts("rising interrupt timeout");
|
||||
return -1;
|
||||
}
|
||||
@ -335,13 +336,13 @@ static int cmd_auto_test(int argc, char **argv)
|
||||
gpio_irq_disable(pin_in);
|
||||
|
||||
gpio_set(pin_out);
|
||||
if (xtimer_mutex_lock_timeout(&lock, IRQ_TIMEOUT_US) == 0) {
|
||||
if (ztimer_mutex_lock_timeout(ZTIMER_USEC, &lock, IRQ_TIMEOUT_US) == 0) {
|
||||
puts("interrupt falsely generated on rising edge while disabled");
|
||||
return -1;
|
||||
}
|
||||
|
||||
gpio_clear(pin_out);
|
||||
if (xtimer_mutex_lock_timeout(&lock, IRQ_TIMEOUT_US) == 0) {
|
||||
if (ztimer_mutex_lock_timeout(ZTIMER_USEC, &lock, IRQ_TIMEOUT_US) == 0) {
|
||||
puts("interrupt falsely generated while disabled");
|
||||
return -1;
|
||||
}
|
||||
@ -349,19 +350,19 @@ static int cmd_auto_test(int argc, char **argv)
|
||||
/* test IRQ enable */
|
||||
|
||||
gpio_irq_enable(pin_in);
|
||||
if (xtimer_mutex_lock_timeout(&lock, IRQ_TIMEOUT_US) == 0) {
|
||||
if (ztimer_mutex_lock_timeout(ZTIMER_USEC, &lock, IRQ_TIMEOUT_US) == 0) {
|
||||
puts("interrupt falsely generated after being re-enabled");
|
||||
return -1;
|
||||
}
|
||||
|
||||
gpio_set(pin_out);
|
||||
if (xtimer_mutex_lock_timeout(&lock, IRQ_TIMEOUT_US) == 0) {
|
||||
if (ztimer_mutex_lock_timeout(ZTIMER_USEC, &lock, IRQ_TIMEOUT_US) == 0) {
|
||||
puts("interrupt falsely generated on rising edge after re-enabled");
|
||||
return -1;
|
||||
}
|
||||
|
||||
gpio_clear(pin_out);
|
||||
if (xtimer_mutex_lock_timeout(&lock, IRQ_TIMEOUT_US)) {
|
||||
if (ztimer_mutex_lock_timeout(ZTIMER_USEC, &lock, IRQ_TIMEOUT_US)) {
|
||||
puts("interrupt not re-enabled");
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user