Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/tinydtls: migrate to ztimer64_msec #17564

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/tinydtls/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ USEMODULE += hashes
USEMODULE += random
USEMODULE += tinydtls_aes
USEMODULE += tinydtls_ecc
USEMODULE += xtimer
USEMODULE += ztimer64_msec

# TinyDTLS only has support for 32-bit architectures ATM
FEATURES_REQUIRED += arch_32bit
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
From 4408e8bd0c67efe6e08606568f8642f33e2fffdf Mon Sep 17 00:00:00 2001
From: Francisco Molina <[email protected]>
Date: Mon, 24 Jan 2022 17:54:46 +0100
Subject: [PATCH] dtls_time: migrate to ztimer64_usec

---
dtls_time.c | 4 ++--
dtls_time.h | 5 +++--
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/dtls_time.c b/dtls_time.c
index 5d353b4..4ae4414 100644
--- a/dtls_time.c
+++ b/dtls_time.c
@@ -43,12 +43,12 @@ dtls_tick_t dtls_clock_offset;

void
dtls_clock_init(void) {
- dtls_clock_offset = xtimer_now64().ticks64;
+ dtls_clock_offset = ztimer64_now(ZTIMER64_MSEC);
}

void
dtls_ticks(dtls_tick_t *t) {
- *t = xtimer_now64().ticks64 -dtls_clock_offset;
+ *t = ztimer64_now(ZTIMER64_MSEC) - dtls_clock_offset;
}

#endif /* RIOT_VERSION */
diff --git a/dtls_time.h b/dtls_time.h
index f16b2d0..4cae153 100644
--- a/dtls_time.h
+++ b/dtls_time.h
@@ -39,12 +39,13 @@

#elif defined(RIOT_VERSION)

-#include <xtimer.h>
+#include "ztimer64.h"
+#include "timex.h"

/* this macro is already present on FreeBSD
which causes a redefine error otherwise */
#ifndef CLOCK_SECOND
-#define CLOCK_SECOND (xtimer_ticks_from_usec64(1000000UL).ticks64)
+#define CLOCK_SECOND (MS_PER_SEC)
#endif

typedef uint64_t clock_time_t;
--
2.30.2