1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests/driver_ltc4150: migrate to ztimer_usec

This commit is contained in:
Francisco Molina 2021-12-09 12:49:08 +01:00
parent a1fe17c698
commit d8126864ea
2 changed files with 6 additions and 5 deletions

View File

@ -4,6 +4,7 @@ BOARD ?= msba2
USEMODULE += fmt_table
USEMODULE += ltc4150
USEMODULE += ztimer_usec
include $(RIOTBASE)/Makefile.include

View File

@ -25,7 +25,8 @@
#include "led.h"
#include "ltc4150.h"
#include "thread.h"
#include "xtimer.h"
#include "ztimer.h"
#include "timex.h"
typedef struct {
uint64_t last_usec;
@ -96,8 +97,7 @@ static void pulse_cb(ltc4150_dev_t *dev, ltc4150_dir_t dir, uint64_t now_usec,
*/
static void spin(uint32_t seconds)
{
uint32_t till = xtimer_now_usec() + US_PER_SEC * seconds;
while (xtimer_now_usec() < till) { }
ztimer_spin(ZTIMER_USEC, US_PER_SEC * seconds);
}
/**
@ -110,14 +110,14 @@ static void *busy_thread(void *arg)
/* one minute of ~0% CPU usage */
LED0_OFF;
LED1_OFF;
xtimer_sleep(60);
ztimer_sleep(ZTIMER_USEC, 60 * US_PER_SEC);
change_of_load_level = 1;
/* one minute of ~50% CPU usage */
for (unsigned i = 0; i < 30; i++) {
LED0_OFF;
LED1_OFF;
xtimer_sleep(1);
ztimer_sleep(ZTIMER_USEC, 1 * US_PER_SEC);
LED0_ON;
LED1_ON;
spin(1);