Skip to content

Commit 32ff86d

Browse files
Adjust to new interface in etl::chrono
1 parent 984d426 commit 32ff86d

File tree

2 files changed

+36
-3
lines changed
  • executables/referenceApp/platforms/s32k148evb/bspConfiguration/src/bsp/SystemTimer
  • platforms/posix/bsp/bspSystemTime/src/bsp/time

2 files changed

+36
-3
lines changed

executables/referenceApp/platforms/s32k148evb/bspConfiguration/src/bsp/SystemTimer/SystemTimer.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "interrupts/SuspendResumeAllInterruptsScopedLock.h"
1111
#include "mcu/mcu.h"
1212

13+
#include <etl/chrono.h>
14+
1315
namespace
1416
{
1517
uint32_t const DWT_FREQ_MHZ_RUN = 80U;
@@ -79,14 +81,27 @@ uint32_t getSystemTicks32Bit(void) { return static_cast<uint32_t>(updateTicks())
7981

8082
uint64_t getSystemTimeNs(void) { return updateTicks() * 1000U / TICK_FREQ_MHZ; }
8183

82-
extern "C" uint64_t etl_get_system_time_nanosec() { return getSystemTimeNs(); }
83-
8484
uint64_t getSystemTimeUs(void) { return updateTicks() / TICK_FREQ_MHZ; }
8585

8686
uint32_t getSystemTimeUs32Bit(void) { return static_cast<uint32_t>(updateTicks() / TICK_FREQ_MHZ); }
8787

8888
uint64_t getSystemTimeMs(void) { return updateTicks() / TICK_FREQ_MHZ / 1000U; }
8989

90+
etl::chrono::high_resolution_clock::rep etl_get_high_resolution_clock()
91+
{
92+
return etl::chrono::high_resolution_clock::rep{static_cast<int64_t>(getSystemTimeNs())};
93+
}
94+
95+
etl::chrono::system_clock::rep etl_get_system_clock()
96+
{
97+
return etl::chrono::system_clock::rep(static_cast<int64_t>(getSystemTimeMs()));
98+
}
99+
100+
etl::chrono::steady_clock::rep etl_get_steady_clock()
101+
{
102+
return etl::chrono::steady_clock::rep(static_cast<int64_t>(getSystemTimeMs() / 1000));
103+
}
104+
90105
uint32_t getSystemTimeMs32Bit(void)
91106
{
92107
return static_cast<uint32_t>(updateTicks() / TICK_FREQ_MHZ / 1000U);

platforms/posix/bsp/bspSystemTime/src/bsp/time/systemTimer.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright 2024 Accenture.
22

33
#include <bsp/timer/SystemTimer.h>
4+
#include <etl/chrono.h>
45

56
#include <chrono>
67

@@ -12,7 +13,24 @@ uint64_t getSystemTimeNs()
1213
return duration_cast<nanoseconds>(duration).count();
1314
}
1415

15-
extern "C" uint64_t etl_get_system_time_nanosec() { return getSystemTimeNs(); }
16+
extern "C"
17+
{
18+
etl::chrono::high_resolution_clock::rep etl_get_high_resolution_clock()
19+
{
20+
return etl::chrono::high_resolution_clock::rep{static_cast<int64_t>(getSystemTimeNs())};
21+
}
22+
23+
etl::chrono::system_clock::rep etl_get_system_clock()
24+
{
25+
return etl::chrono::system_clock::rep(static_cast<int64_t>(getSystemTimeNs() / 1000 / 1000));
26+
}
27+
28+
etl::chrono::steady_clock::rep etl_get_steady_clock()
29+
{
30+
return etl::chrono::steady_clock::rep(
31+
static_cast<int64_t>(getSystemTimeNs() / 1000 / 1000 / 1000));
32+
}
33+
}
1634

1735
uint32_t getSystemTimeUs32Bit(void) { return getSystemTimeNs() / 1000; }
1836

0 commit comments

Comments
 (0)