1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-16 10:03:50 +01:00

tests/periph_gpio: Convert to ztimer

This commit is contained in:
Koen Zandberg 2021-11-10 10:29:57 +01:00
parent 8c2f0dd2af
commit f1feaa2063
No known key found for this signature in database
GPG Key ID: BA1718B37D79F51C
4 changed files with 16 additions and 11 deletions

View File

@ -8,6 +8,7 @@ FEATURES_OPTIONAL += periph_gpio_tamper_wake
USEMODULE += shell USEMODULE += shell
USEMODULE += shell_commands USEMODULE += shell_commands
USEMODULE += benchmark USEMODULE += benchmark
USEMODULE += ztimer_usec
# disable native GPIOs for automatic test # disable native GPIOs for automatic test
ifeq (native,$(BOARD)) ifeq (native,$(BOARD))

View File

@ -5,5 +5,7 @@ BOARD_INSUFFICIENT_MEMORY := \
arduino-uno \ arduino-uno \
atmega328p \ atmega328p \
atmega328p-xplained-mini \ atmega328p-xplained-mini \
nucleo-l011k4 \
samd10-xmini \
stm32f030f4-demo \ stm32f030f4-demo \
# #

View File

@ -2,7 +2,8 @@
# application configuration. This is only needed during migration. # application configuration. This is only needed during migration.
CONFIG_MODULE_PERIPH_GPIO=y CONFIG_MODULE_PERIPH_GPIO=y
CONFIG_MODULE_BENCHMARK=y
CONFIG_MODULE_SHELL=y CONFIG_MODULE_SHELL=y
CONFIG_MODULE_SHELL_COMMANDS=y CONFIG_MODULE_SHELL_COMMANDS=y
CONFIG_MODULE_BENCHMARK=y CONFIG_MODULE_ZTIMER=y
CONFIG_MODULE_XTIMER=y CONFIG_ZTIMER_USEC=y

View File

@ -25,6 +25,7 @@
#include "shell.h" #include "shell.h"
#include "benchmark.h" #include "benchmark.h"
#include "periph/gpio.h" #include "periph/gpio.h"
#include "ztimer.h"
#define BENCH_RUNS_DEFAULT (1000UL * 100) #define BENCH_RUNS_DEFAULT (1000UL * 100)
#define IRQ_TIMEOUT_US (1000UL) #define IRQ_TIMEOUT_US (1000UL)
@ -302,13 +303,13 @@ static int cmd_auto_test(int argc, char **argv)
} }
gpio_set(pin_out); 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"); puts("rising interrupt timeout");
return -1; return -1;
} }
gpio_clear(pin_out); 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"); puts("interrupt falsely generated on falling edge");
return -1; return -1;
} }
@ -320,13 +321,13 @@ static int cmd_auto_test(int argc, char **argv)
} }
gpio_set(pin_out); 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"); puts("interrupt falsely generated on rising edge");
return -1; return -1;
} }
gpio_clear(pin_out); 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"); puts("rising interrupt timeout");
return -1; return -1;
} }
@ -335,13 +336,13 @@ static int cmd_auto_test(int argc, char **argv)
gpio_irq_disable(pin_in); gpio_irq_disable(pin_in);
gpio_set(pin_out); 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"); puts("interrupt falsely generated on rising edge while disabled");
return -1; return -1;
} }
gpio_clear(pin_out); 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"); puts("interrupt falsely generated while disabled");
return -1; return -1;
} }
@ -349,19 +350,19 @@ static int cmd_auto_test(int argc, char **argv)
/* test IRQ enable */ /* test IRQ enable */
gpio_irq_enable(pin_in); 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"); puts("interrupt falsely generated after being re-enabled");
return -1; return -1;
} }
gpio_set(pin_out); 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"); puts("interrupt falsely generated on rising edge after re-enabled");
return -1; return -1;
} }
gpio_clear(pin_out); 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"); puts("interrupt not re-enabled");
return -1; return -1;
} }