#pragma once #include #include #include #ifdef __cplusplus extern "C" { #endif struct rt_event; uint32_t rt_event_clear(struct rt_event *, uint32_t); uint32_t rt_event_get(const struct rt_event *); uint32_t rt_event_set(struct rt_event *, uint32_t); uint32_t rt_event_set_from_task(struct rt_event *, uint32_t); uint32_t rt_event_set_from_interrupt(struct rt_event *, uint32_t); uint32_t rt_event_wait(struct rt_event *, uint32_t); uint32_t rt_event_trywait(struct rt_event *, uint32_t); uint32_t rt_event_timedwait(struct rt_event *, uint32_t, unsigned long ticks); bool rt_event_bits_match(uint32_t bits, uint32_t wait); static const uint32_t RT_EVENT_WAITED_MASK = UINT32_C(1) << 31; static const uint32_t RT_EVENT_WAIT_ALL = UINT32_C(1) << 30; static const uint32_t RT_EVENT_WAIT_NOCLEAR = UINT32_C(1) << 29; static const uint32_t RT_EVENT_WAIT_RESERVED = UINT32_C(7) << 29; struct rt_event { rt_atomic_uint32_t bits; struct rt_list wait_list; struct rt_syscall_record set_record; }; #define RT_EVENT_INIT(name) \ { \ .bits = UINT32_C(0), \ .wait_list = RT_LIST_INIT(name.wait_list), \ .set_record = \ { \ .next = NULL, \ .args = \ { \ .event_set = \ { \ .event = &name, \ }, \ }, \ .syscall = RT_SYSCALL_PENDABLE_EVENT_SET, \ .pending = RT_ATOMIC_FLAG_INIT, \ }, \ } #define RT_EVENT(name) struct rt_event name = RT_EVENT_INIT(name) #ifdef __cplusplus } #endif