13#if defined(OS_USE_OS_APP_CONFIG_H)
14#include <cmsis-plus/os-app-config.h>
22#pragma clang diagnostic ignored "-Wc++98-compat"
41#if defined(OS_USE_RTOS_PORT_SCHEDULER)
49#if defined(OS_TRACE_RTOS_SYSCLOCK_TICK)
51#elif defined(OS_TRACE_RTOS_SYSCLOCK_TICK_BRACES)
59 sysclock.internal_increment_count ();
63 sysclock.internal_check_timestamps ();
64 hrclock.internal_check_timestamps ();
66#if !defined(OS_INCLUDE_RTOS_REALTIME_CLOCK_DRIVER)
80#if !defined(OS_USE_RTOS_PORT_SCHEDULER)
86#if defined(OS_TRACE_RTOS_SYSCLOCK_TICK_BRACES)
99#if defined(OS_USE_RTOS_PORT_SCHEDULER)
107#if defined(OS_TRACE_RTOS_RTC_TICK)
115 rtclock.internal_increment_count ();
168 return steady_count_;
182 return steady_count_;
192#if defined(OS_TRACE_RTOS_CLOCKS)
194#pragma GCC diagnostic push
195#if defined(__clang__)
196#elif defined(__GNUC__)
197#pragma GCC diagnostic ignored "-Wuseless-cast"
200 static_cast<unsigned int> (duration),
202#pragma GCC diagnostic pop
215 res = internal_wait_until_ (timestamp, steady_list_);
233 return ENOTRECOVERABLE;
242#if defined(OS_TRACE_RTOS_CLOCKS)
254 res = internal_wait_until_ (timestamp, steady_list_);
272 return ENOTRECOVERABLE;
281#if defined(OS_TRACE_RTOS_CLOCKS)
283#pragma GCC diagnostic push
284#if defined(__clang__)
285#elif defined(__GNUC__)
286#pragma GCC diagnostic ignored "-Wuseless-cast"
288 trace::printf (
"%s(%u)\n", __func__,
static_cast<unsigned int> (timeout));
289#pragma GCC diagnostic pop
301 res = internal_wait_until_ (timestamp, steady_list_);
334#pragma GCC diagnostic push
335#if defined(__clang__)
336#pragma clang diagnostic ignored "-Wdeprecated-volatile"
337#elif defined(__GNUC__)
338#pragma GCC diagnostic ignored "-Wvolatile"
340 steady_count_ += duration;
341#pragma GCC diagnostic pop
343 internal_check_timestamps ();
344 return steady_count_;
359 clock::offset (offset_t offset __attribute__((unused)))
364#pragma GCC diagnostic push
365#if defined(__clang__)
366#elif defined(__GNUC__)
367#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
368#pragma GCC diagnostic ignored "-Wsuggest-final-types"
371 clock::internal_wait_until_ (timestamp_t timestamp,
380 { timestamp, crt_thread };
391 crt_thread.clock_node_ = &node;
404 crt_thread.clock_node_ =
nullptr;
411#pragma GCC diagnostic pop
428#pragma GCC diagnostic push
429#if defined(__clang__)
430#elif defined(__GNUC__)
431#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
440#pragma GCC diagnostic push
441#if defined(__clang__)
442#pragma clang diagnostic ignored "-Wsign-conversion"
443#elif defined(__GNUC__)
444#pragma GCC diagnostic ignored "-Wsign-conversion"
446 return steady_count_ + offset_;
447#pragma GCC diagnostic pop
450#pragma GCC diagnostic pop
458#if defined(OS_TRACE_RTOS_CLOCKS)
470 res = internal_wait_until_ (timestamp, adjusted_list_);
488 return ENOTRECOVERABLE;
557#pragma GCC diagnostic push
558#if defined(__clang__)
559#pragma clang diagnostic ignored "-Wglobal-constructors"
560#pragma clang diagnostic ignored "-Wexit-time-destructors"
566#pragma GCC diagnostic pop
592#if defined(OS_TRACE_RTOS_CLOCKS)
600#if defined(OS_USE_RTOS_PORT_CLOCK_SYSTICK_WAIT_FOR)
603 clock_systick::internal_wait_until_ (timestamp_t timestamp,
658#pragma GCC diagnostic push
659#if defined(__clang__)
660#pragma clang diagnostic ignored "-Wglobal-constructors"
661#pragma clang diagnostic ignored "-Wexit-time-destructors"
667#pragma GCC diagnostic pop
698#if defined(OS_TRACE_RTOS_CLOCKS)
709#pragma GCC diagnostic push
710#if defined(__clang__)
711#pragma clang diagnostic ignored "-Wglobal-constructors"
712#pragma clang diagnostic ignored "-Wexit-time-destructors"
718#pragma GCC diagnostic pop
744#if defined(OS_TRACE_RTOS_CLOCKS)
Adjustable (non-steady) clock.
virtual ~adjustable_clock() override
Destruct the clock object instance.
virtual timestamp_t now(void) override
Tell the current time adjusted for epoch.
virtual result_t sleep_until(timestamp_t timestamp) override
Sleep until an absolute timestamp.
virtual offset_t offset(void) override
Get adjustment offset.
void internal_check_timestamps(void)
High Resolution derived clock.
void internal_increment_count(void)
virtual ~clock_highres() override
Destruct the SysTick clock object instance.
virtual void start(void) override
clock_highres()
Construct a SysTick clock object instance.
virtual timestamp_t now(void) override
Tell the current time.
virtual void start(void) override
Initialise and make the RTC tick.
virtual ~clock_rtc() override
Destruct the real time clock object instance.
clock_rtc()
Construct a real time clock object instance.
static constexpr uint32_t frequency_hz
SysTick frequency in Hz.
virtual ~clock_systick() override
Destruct the SysTick clock object instance.
clock_systick()
Construct a SysTick clock object instance.
virtual void start(void) override
result_t wait_for(duration_t timeout)
Timed wait for an event.
virtual result_t sleep_until(timestamp_t timestamp)
Sleep until an absolute timestamp.
timestamp_t update_for_slept_time(duration_t duration)
Increase the internal count after a deep sleep.
timestamp_t steady_now(void)
Tell the current time since startup.
virtual timestamp_t now(void)
Tell the current time, possibly adjusted for epoch.
virtual void start(void)=0
Start the clock.
virtual ~clock()
Destruct the clock object instance.
result_t sleep_for(duration_t duration)
Sleep for a relative duration.
Ordered list of time stamp nodes.
void link(timestamp_node &node)
Add a new thread node to the list.
const char * name(void) const
Get object name.
Double linked list node, with time stamp and thread.
Interrupts critical section RAII helper.
static uint32_t cycles_since_tick(void)
static void internal_interrupt_service_routine(void)
RTC implementation hook.
static result_t wait_for(clock::duration_t ticks)
static void internal_interrupt_service_routine(void)
SysTick implementation hook.
int printf(const char *format,...)
Write a formatted string to the trace device.
int putchar(int c)
Write the single character to the trace device.
void os_systick_handler(void)
SysTick interrupt handler.
void os_rtc_handler(void)
RTC interrupt handler.
port::clock::duration_t duration_t
Type of variables holding clock durations.
clock_highres hrclock
The high resolution clock object instance.
clock_rtc rtclock
The real time clock object instance.
port::clock::timestamp_t timestamp_t
Type of variables holding clock time stamps.
clock_systick sysclock
The system clock object instance.
port::clock::offset_t offset_t
Type of variables holding clock offsets.
bool in_handler_mode(void)
Check if the CPU is in handler mode.
void prepare_suspend(void)
@ ok
Function completed; no errors or events occurred.
bool started(void)
Check if the scheduler was started.
bool locked(void)
Check if the scheduler is locked.
thread & thread(void)
Get the current running thread.
uint32_t result_t
Type of values returned by RTOS functions.
#define os_assert_err(__e, __er)
Assert or return an error.
Single file µOS++ RTOS definitions.
@ suspended
Not present in the READY list, waiting for an event.