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

sys/isrpipe: Replace xtimer with ztimer_usec

This commit is contained in:
MrKevinWeiss 2023-05-22 13:27:44 +02:00
parent a28f6e5a41
commit 17ca5db1f5
No known key found for this signature in database
GPG Key ID: 4B69974722CBEEAE
3 changed files with 6 additions and 6 deletions

View File

@ -362,7 +362,7 @@ endif
ifneq (,$(filter isrpipe_read_timeout,$(USEMODULE)))
USEMODULE += isrpipe
USEMODULE += xtimer
USEMODULE += ztimer_usec
endif
ifneq (,$(filter md5sum sha1sum sha256sum,$(USEMODULE)))

View File

@ -15,4 +15,4 @@ menuconfig MODULE_ISRPIPE
config MODULE_ISRPIPE_READ_TIMEOUT
bool "ISR Pipe read with timeout"
depends on MODULE_ISRPIPE
select MODULE_XTIMER
select ZTIMER_USEC

View File

@ -20,7 +20,7 @@
#include <errno.h>
#include "isrpipe/read_timeout.h"
#include "xtimer.h"
#include "ztimer.h"
typedef struct {
mutex_t *mutex;
@ -41,9 +41,9 @@ int isrpipe_read_timeout(isrpipe_t *isrpipe, uint8_t *buffer, size_t count, uint
_isrpipe_timeout_t _timeout = { .mutex = &isrpipe->mutex, .flag = 0 };
xtimer_t timer = { .callback = _cb, .arg = &_timeout };
ztimer_t timer = { .callback = _cb, .arg = &_timeout };
xtimer_set(&timer, timeout);
ztimer_set(ZTIMER_USEC, &timer, timeout);
while (!(res = tsrb_get(&isrpipe->tsrb, buffer, count))) {
mutex_lock(&isrpipe->mutex);
if (_timeout.flag) {
@ -52,7 +52,7 @@ int isrpipe_read_timeout(isrpipe_t *isrpipe, uint8_t *buffer, size_t count, uint
}
}
xtimer_remove(&timer);
ztimer_remove(ZTIMER_USEC, &timer);
return res;
}