mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:32:45 +01:00
Merge pull request #17567 from fjmolinas/pr_test_uart_non_blocking_to_ztimer
tests/periph_uart_nonblocking: migrate to ztimer
This commit is contained in:
commit
fca7ed3943
@ -1,6 +1,6 @@
|
||||
include ../Makefile.tests_common
|
||||
|
||||
FEATURES_REQUIRED += periph_uart_nonblocking
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += ztimer_usec
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
@ -2,4 +2,4 @@
|
||||
# application configuration. This is only needed during migration.
|
||||
CONFIG_MODULE_PERIPH_UART=y
|
||||
CONFIG_MODULE_PERIPH_UART_NONBLOCKING=y
|
||||
CONFIG_MODULE_XTIMER=y
|
||||
CONFIG_ZTIMER_USEC=y
|
||||
|
@ -19,14 +19,15 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <xtimer.h>
|
||||
#include "ztimer.h"
|
||||
#include "periph_conf.h"
|
||||
|
||||
#define LINE_DELAY_MS 100
|
||||
|
||||
static inline uint32_t puts_delay(const char* str)
|
||||
{
|
||||
puts(str);
|
||||
xtimer_usleep(LINE_DELAY_MS * 1000);
|
||||
ztimer_sleep(ZTIMER_USEC, LINE_DELAY_MS * 1000);
|
||||
return LINE_DELAY_MS * 1000;
|
||||
}
|
||||
|
||||
@ -46,7 +47,7 @@ int main(void)
|
||||
_irq_disabled_print();
|
||||
|
||||
uint32_t total_us = 0;
|
||||
xtimer_ticks32_t counter = xtimer_now();
|
||||
uint32_t counter = ztimer_now(ZTIMER_USEC);
|
||||
|
||||
/* Richard Stallman and the Free Software Foundation
|
||||
claim no copyright on this song. */
|
||||
@ -72,9 +73,9 @@ int main(void)
|
||||
total_us += puts_delay("You'll be free, hackers, you'll be free.");
|
||||
total_us += puts_delay("");
|
||||
|
||||
counter.ticks32 = xtimer_now().ticks32 - counter.ticks32;
|
||||
counter = ztimer_now(ZTIMER_USEC) - counter;
|
||||
|
||||
printf("== printed in %" PRIu32 "/%" PRIu32 " µs ==\n", xtimer_usec_from_ticks(counter), total_us);
|
||||
printf("== printed in %" PRIu32 "/%" PRIu32 " µs ==\n", counter, total_us);
|
||||
|
||||
puts("[SUCCESS]");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user