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"
132#pragma GCC diagnostic push
133#if defined(__clang__)
134#elif defined(__GNUC__)
135#pragma GCC diagnostic ignored "-Wunused-parameter"
166#if defined(OS_TRACE_RTOS_EVFLAGS)
167 trace::printf (
"%s() @%p %s\n", __func__,
this, this->name ());
173#if !defined(OS_USE_RTOS_PORT_EVENT_FLAGS)
174 clock_ = attr.clock !=
nullptr ? attr.clock : &
sysclock;
177#if defined(OS_USE_RTOS_PORT_EVENT_FLAGS)
179 port::event_flags::create (
this);
187#pragma GCC diagnostic pop
204#if defined(OS_TRACE_RTOS_EVFLAGS)
208#if defined(OS_USE_RTOS_PORT_EVENT_FLAGS)
210 port::event_flags::destroy (
this);
215 assert(list_.empty ());
245#if defined(OS_TRACE_RTOS_EVFLAGS)
246 trace::printf (
"%s(0x%X,%u) @%p %s <0x%X\n", __func__, mask, mode,
this,
247 name (), event_flags_.mask ());
255#if defined(OS_USE_RTOS_PORT_EVENT_FLAGS)
257 return port::event_flags::wait (
this, mask, oflags, mode);
265 if (event_flags_.check_raised (mask, oflags, mode))
267#if defined(OS_TRACE_RTOS_EVFLAGS)
268 trace::printf (
"%s(0x%X,%u) @%p %s >0x%X\n", __func__, mask, mode,
269 this,
name (), event_flags_.mask ());
290 if (event_flags_.check_raised (mask, oflags, mode))
292#if defined(OS_TRACE_RTOS_EVFLAGS)
294 mode,
this,
name (), event_flags_.mask ());
300 scheduler::internal_link_node (list_, node);
313 scheduler::internal_unlink_node (node);
319#if defined(OS_TRACE_RTOS_EVFLAGS)
320 trace::printf (
"%s(0x%X,%u) EINTR @%p %s\n", __func__, mask, mode,
328 return ENOTRECOVERABLE;
348#if defined(OS_TRACE_RTOS_EVFLAGS)
349 trace::printf (
"%s(0x%X,%u) @%p %s <0x%X\n", __func__, mask, mode,
this,
350 name (), event_flags_.mask ());
353#if defined(OS_USE_RTOS_PORT_EVENT_FLAGS)
355 return port::event_flags::try_wait (
this, mask, oflags, mode);
360 assert(port::interrupts::is_priority_valid ());
366 if (event_flags_.check_raised (mask, oflags, mode))
368#if defined(OS_TRACE_RTOS_EVFLAGS)
369 trace::printf (
"%s(0x%X,%u) @%p %s >0x%X\n", __func__, mask, mode,
370 this,
name (), event_flags_.mask ());
376#if defined(OS_TRACE_RTOS_EVFLAGS)
377 trace::printf (
"%s(0x%X,%u) EWOULDBLOCK @%p %s \n", __func__,
378 mask, mode,
this,
name ());
430#if defined(OS_TRACE_RTOS_EVFLAGS)
431 trace::printf (
"%s(0x%X,%u,%u) @%p %s <0x%X\n", __func__, mask, timeout,
432 mode,
this,
name (), event_flags_.mask ());
440#if defined(OS_USE_RTOS_PORT_EVENT_FLAGS)
442 return port::event_flags::timed_wait (
this, mask, timeout, oflags, mode);
452 if (event_flags_.check_raised (mask, oflags, mode))
454#if defined(OS_TRACE_RTOS_EVFLAGS)
455 trace::printf (
"%s(0x%X,%u,%u) @%p %s >0x%X\n", __func__, mask,
456 timeout, mode,
this,
name (),
457 event_flags_.mask ());
477 { timeout_timestamp, crt_thread };
485 if (event_flags_.check_raised (mask, oflags, mode))
487#if defined(OS_TRACE_RTOS_EVFLAGS)
489 mask, timeout, mode,
this,
name (),
490 event_flags_.mask ());
497 scheduler::internal_link_node (list_, node, clock_list,
508 scheduler::internal_unlink_node (node, timeout_node);
512#if defined(OS_TRACE_RTOS_EVFLAGS)
513 trace::printf (
"%s(0x%X,%u,%u) EINTR @%p %s 0x%X \n", __func__,
514 mask, timeout, mode,
this,
name ());
519 if (clock_->steady_now () >= timeout_timestamp)
521#if defined(OS_TRACE_RTOS_EVFLAGS)
523 __func__, mask, timeout, mode,
this,
name ());
530 return ENOTRECOVERABLE;
546#if defined(OS_TRACE_RTOS_EVFLAGS)
548 event_flags_.mask ());
551#if defined(OS_USE_RTOS_PORT_EVENT_FLAGS)
555 return port::event_flags::raise (
this, mask, oflags);
559 result_t res = event_flags_.raise (mask, oflags);
566#if defined(OS_TRACE_RTOS_EVFLAGS)
568 event_flags_.mask ());
581#if defined(OS_TRACE_RTOS_EVFLAGS)
583 event_flags_.mask ());
586#if defined(OS_USE_RTOS_PORT_EVENT_FLAGS)
590 return port::event_flags::clear (
this, mask, oflags);
594 result_t res = event_flags_.clear (mask, oflags);
596#if defined(OS_TRACE_RTOS_EVFLAGS)
598 event_flags_.mask ());
620#if defined(OS_TRACE_RTOS_EVFLAGS)
624#if defined(OS_USE_RTOS_PORT_EVENT_FLAGS)
626 return port::event_flags::get (
this, mask, mode);
632#if defined(OS_TRACE_RTOS_EVFLAGS)
634 event_flags_.mask (),
this,
name ());
648#if defined(OS_TRACE_RTOS_EVFLAGS)
652#if defined(OS_USE_RTOS_PORT_EVENT_FLAGS)
654 return port::event_flags::waiting (
this);
659 assert(port::interrupts::is_priority_valid ());
665 return !list_.empty ();
Synchronised event flags.
result_t wait(flags::mask_t mask, flags::mask_t *oflags, flags::mode_t mode=flags::mode::all|flags::mode::clear)
Wait for event flags.
result_t timed_wait(flags::mask_t mask, clock::duration_t timeout, flags::mask_t *oflags=nullptr, flags::mode_t mode=flags::mode::all|flags::mode::clear)
Timed wait for event flags.
~event_flags()
Destruct the event flags object instance.
event_flags(const attributes &attr=initializer)
Construct an event flags object instance.
bool waiting(void)
Check if there are threads waiting.
flags::mask_t get(flags::mask_t mask, flags::mode_t mode=flags::mode::clear)
Get (and possibly clear) event flags.
result_t try_wait(flags::mask_t mask, flags::mask_t *oflags=nullptr, flags::mode_t mode=flags::mode::all|flags::mode::clear)
Try to wait for event flags.
result_t raise(flags::mask_t mask, flags::mask_t *oflags=nullptr)
Raise event flags.
result_t clear(flags::mask_t mask, flags::mask_t *oflags=nullptr)
Clear event flags.
Ordered list of time stamp nodes.
const char * name(void) const
Get object name.
Double linked list node, with time stamp and thread.
Double linked list node, with thread reference.
Interrupts critical section RAII helper.
POSIX compliant thread, using the default RTOS allocator.
bool interrupted(void)
Check if interrupted.
int printf(const char *format,...)
Write a formatted string to the trace device.
port::clock::duration_t duration_t
Type of variables holding clock durations.
port::clock::timestamp_t timestamp_t
Type of variables holding clock time stamps.
clock_systick sysclock
The system clock object instance.
static const attributes initializer
Default event flags initialiser.
uint32_t mode_t
Type of variables holding flags modes.
uint32_t mask_t
Type of variables holding flags masks.
bool in_handler_mode(void)
Check if the CPU is in handler mode.
@ ok
Function completed; no errors or events occurred.
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_throw(__e, __er)
Assert or throw a system error exception.
#define os_assert_err(__e, __er)
Assert or return an error.
Single file µOS++ RTOS definitions.