Merge pull request #15317 from aabadie/pr/sys/arduino_ztimer

sys/arduino: replace xtimer by ztimer as high-level background timer
This commit is contained in:
Francisco 2021-06-17 15:56:04 +02:00 committed by GitHub
commit a012a0849f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View File

@ -9,7 +9,8 @@ ifneq (,$(filter arduino,$(USEMODULE)))
SKETCH_MODULE ?= arduino_sketches SKETCH_MODULE ?= arduino_sketches
USEMODULE += $(SKETCH_MODULE) USEMODULE += $(SKETCH_MODULE)
USEMODULE += fmt USEMODULE += fmt
USEMODULE += xtimer USEMODULE += ztimer_usec
USEMODULE += ztimer_msec
endif endif
ifneq (,$(filter arduino_pwm,$(FEATURES_USED))) ifneq (,$(filter arduino_pwm,$(FEATURES_USED)))

View File

@ -19,7 +19,8 @@
*/ */
extern "C" { extern "C" {
#include "xtimer.h" #include "assert.h"
#include "ztimer.h"
#include "periph/gpio.h" #include "periph/gpio.h"
#include "periph/adc.h" #include "periph/adc.h"
#include "periph/pwm.h" #include "periph/pwm.h"
@ -60,22 +61,22 @@ int digitalRead(int pin)
void delay(unsigned long msec) void delay(unsigned long msec)
{ {
xtimer_usleep(msec * US_PER_MS); ztimer_sleep(ZTIMER_MSEC, msec);
} }
void delayMicroseconds(unsigned long usec) void delayMicroseconds(unsigned long usec)
{ {
xtimer_usleep(usec); ztimer_sleep(ZTIMER_USEC, usec);
} }
unsigned long micros() unsigned long micros()
{ {
return xtimer_now_usec(); return ztimer_now(ZTIMER_USEC);
} }
unsigned long millis() unsigned long millis()
{ {
return xtimer_now_usec64() / US_PER_MS; return ztimer_now(ZTIMER_MSEC);
} }
#if MODULE_PERIPH_ADC #if MODULE_PERIPH_ADC

View File

@ -1,3 +1,6 @@
BOARD_INSUFFICIENT_MEMORY := \ BOARD_INSUFFICIENT_MEMORY := \
arduino-uno \
arduino-duemilanove \
arduino-nano \
nucleo-l011k4 \ nucleo-l011k4 \
# #