|
Embedded Artistry Framework
Embedded Systems C++ Framework
|
Classes | |
| class | os::freertos::EventFlag |
| FreeRTOS Event Flag Implementation. More... | |
| class | os::freertos::Mutex |
| FreeRTOS Mutex Implementation. More... | |
| class | os::freertos::Semaphore |
| Create a FreeRTOS semaphore (OSX variant) More... | |
| class | os::freertos::Thread |
| Create a FreeRTOS thread. More... | |
| class | os::freertos::Heap |
| class | os::freertos::freertosOSFactory_impl |
| Implementation of the FreeRTOS OS Factory For API documentation, see embvm::embvm::VirtualOSFactory. More... | |
Typedefs | |
| using | os::freertos::thread_exit_t = void(*)(void *) |
Functions | |
| void | os::freertos::register_threadexit_func (thread_exit_t atexit) noexcept |
| void | os::freertos::startScheduler () noexcept |
| Call this function to start the FreeRTOS scheduler. More... | |
Variables | |
| static constexpr size_t | os::freertos::FREERTOS_STACK_MIN = (1 * 1024) |
| class os::freertos::EventFlag |
FreeRTOS Event Flag Implementation.

Public Member Functions | |
| EventFlag () noexcept | |
| Create an event flag group. More... | |
| ~EventFlag () noexcept | |
| Default destructor which cleans up the event flag group. More... | |
| embvm::eventflag::flag_t | get (embvm::eventflag::flag_t bits_wait, embvm::eventflag::option opt=embvm::eventflag::option::OR, bool clearOnExit=true, const embvm::os_timeout_t &timeout=embvm::OS_WAIT_FOREVER) noexcept final |
| Get (or wait for) event flags. More... | |
| void | set (embvm::eventflag::flag_t bits) noexcept final |
| Set event flags. More... | |
| void | setFromISR (embvm::eventflag::flag_t bits) noexcept final |
| Set event flags from an ISR. More... | |
| void | clear () noexcept final |
| Clear all event flag bits. More... | |
| embvm::eventflag::handle_t | native_handle () const noexcept final |
| Get the native handle for the event flags group object. More... | |
Private Attributes | |
| embvm::eventflag::handle_t | handle_ |
|
explicitnoexcept |
Create an event flag group.
References assert, buf, handle_, and static_event_pool_.
|
noexcept |
Default destructor which cleans up the event flag group.
References handle_, and static_event_pool_.
|
finalvirtualnoexcept |
Clear all event flag bits.
Implements embvm::VirtualEventFlag.
References handle_.
|
finalvirtualnoexcept |
Get (or wait for) event flags.
Get the event flag bits. If the required event flags are not set, this function will block the calling thread until the flags are set or the timeout expires.
To see all bits currently set, set bits_wait to ~0 and timeout_t to the minimal value (timeout_t(1)).
| bits_wait | A bitmask of bits to wait for in the event flags group. |
| opt | The wait option, which is combined with bits_wait to control the behavior of get(). embvm::eventflag::option::OR will return once any of the bits specified in bits_wait are set in the event flag group. embvm::eventflag::option::AND will only return once ALL of the bits specified in bits_wait are set in the event flag group. |
| clearOnExit | If true, all event flags that were specified in bits_wait and set in the event flag group will be set to 0. If false, event flag bits will not be modified. |
| timeout | Specify a timeout for the get operation. If OS_WAIT_FOREVER is supplied, this call will block until the event flags are set. Otherwise, the function will timeout after the elapsed time if flags are not set. |
Implements embvm::VirtualEventFlag.
References embvm::eventflag::AND, assert, and os::freertos::frameworkTimeoutToTicks().
|
inlinefinalvirtualnoexcept |
Get the native handle for the event flags group object.
Implements embvm::VirtualEventFlag.
References handle_.
|
finalvirtualnoexcept |
Set event flags.
Set event flags from a threaded context. Threads waiting on event flags (via get()) will be notified.
| bits | A bitmask representing the bits to set in the event flag group. |
Implements embvm::VirtualEventFlag.
References assert.
|
finalvirtualnoexcept |
Set event flags from an ISR.
Set event flags from an interrupt context. This call must not use a lock. Threads waiting on event flags (via get()) will be notified.
| bits | A bitmask representing the bits to set in the event flag group. |
Implements embvm::VirtualEventFlag.
References assert, portYIELD_FROM_ISR, and r.
|
private |
Referenced by clear(), EventFlag(), native_handle(), and ~EventFlag().
| class os::freertos::MessageQueue |
FreeRTOS Message Queue implementation for OSX.
| TType | The type of data to be stored in the message queue |

Public Member Functions | |
| MessageQueue (size_t queue_length) noexcept | |
| Construct a message queue. More... | |
| ~MessageQueue () noexcept | |
| Default destructor, cleans up the message queue. More... | |
| bool | push (TType val, embvm::os_timeout_t timeout=embvm::OS_WAIT_FOREVER) noexcept final |
| Post a message to the queue. More... | |
| std::optional< TType > | pop (embvm::os_timeout_t timeout=embvm::OS_WAIT_FOREVER) noexcept final |
| Retrieve a message from the queue. More... | |
| size_t | size () const noexcept final |
| Get the current size of the message queue. More... | |
| void | reset () noexcept final |
| Reset the message queue to an empty state. More... | |
| bool | empty () const noexcept final |
| Check if the message queue is empty. More... | |
| bool | full () const noexcept final |
| Check if the message queue is full. More... | |
| embvm::msgqueue::handle_t | native_handle () const noexcept final |
| Get the native handle for the message queue object. More... | |
Private Attributes | |
| embvm::msgqueue::handle_t | handle_ |
| size_t | max_length_ |
|
inlineexplicitnoexcept |
Construct a message queue.
| queue_length | The maximum size of the message queue. |
References assert, os::freertos::details::MessageQueueMediator::create(), and os::freertos::MessageQueue< TType >::handle_.
|
inlinenoexcept |
Default destructor, cleans up the message queue.
References os::freertos::details::MessageQueueMediator::destroy(), and os::freertos::MessageQueue< TType >::handle_.
|
inlinefinalvirtualnoexcept |
Check if the message queue is empty.
Implements embvm::VirtualMessageQueue< TType >.
References os::freertos::details::MessageQueueMediator::empty(), and os::freertos::MessageQueue< TType >::handle_.
|
inlinefinalvirtualnoexcept |
Check if the message queue is full.
Implements embvm::VirtualMessageQueue< TType >.
References os::freertos::details::MessageQueueMediator::full(), os::freertos::MessageQueue< TType >::handle_, and os::freertos::MessageQueue< TType >::max_length_.
|
inlinefinalvirtualnoexcept |
Get the native handle for the message queue object.
Implements embvm::VirtualMessageQueue< TType >.
References os::freertos::MessageQueue< TType >::handle_.
|
inlinefinalvirtualnoexcept |
Retrieve a message from the queue.
Retrieve a message from the queue. This function blocks the calling thread until a message is received (if OS_WAIT_FOREVER is specified as a timeout), or until the timeout expires.
| timeout | The time to wait for a new message. A value of OS_WAIT_FOREVER indicates that the thread should block until a new message is posted. |
has_value() member function to determine if the value is valid. A valid value is only returned on success. Implements embvm::VirtualMessageQueue< TType >.
References os::freertos::MessageQueue< TType >::handle_, and os::freertos::details::MessageQueueMediator::pop().
|
inlinefinalvirtualnoexcept |
Post a message to the queue.
Post a message to the queue. This function blocks the calling thread until there is an available slot (if OS_WAIT_FOREVER is specified as a timeout), or until the timeout expires.
Posting a message to the queue will notify all threads waiting on a new message (via pop()).
| val | The data value to post to the queue. |
| timeout | The time to wait for a new message. A value of OS_WAIT_FOREVER indicates that the thread should block until a new message is posted. |
Implements embvm::VirtualMessageQueue< TType >.
References os::freertos::MessageQueue< TType >::handle_, and os::freertos::details::MessageQueueMediator::push().
|
inlinefinalvirtualnoexcept |
Reset the message queue to an empty state.
Implements embvm::VirtualMessageQueue< TType >.
References os::freertos::MessageQueue< TType >::handle_, and os::freertos::details::MessageQueueMediator::reset().
|
inlinefinalvirtualnoexcept |
Get the current size of the message queue.
Size represents the number of elements stored, rather than the maximum size (aka capacity).
Implements embvm::VirtualMessageQueue< TType >.
References os::freertos::MessageQueue< TType >::handle_, and os::freertos::details::MessageQueueMediator::size().
|
private |
Referenced by os::freertos::MessageQueue< TType >::empty(), os::freertos::MessageQueue< TType >::full(), os::freertos::MessageQueue< TType >::MessageQueue(), os::freertos::MessageQueue< TType >::native_handle(), os::freertos::MessageQueue< TType >::pop(), os::freertos::MessageQueue< TType >::push(), os::freertos::MessageQueue< TType >::reset(), os::freertos::MessageQueue< TType >::size(), and os::freertos::MessageQueue< TType >::~MessageQueue().
|
private |
Referenced by os::freertos::MessageQueue< TType >::full().
| class os::freertos::Mutex |
FreeRTOS Mutex Implementation.

Public Member Functions | |
| Mutex (embvm::mutex::type type=embvm::mutex::type::defaultType, embvm::mutex::mode mode=embvm::mutex::mode::defaultMode) noexcept | |
| Construct a FreeRTOS mutex. More... | |
| ~Mutex () noexcept | |
| Default destructor. More... | |
| void | lock () noexcept final |
| Lock the mutex. More... | |
| void | unlock () noexcept final |
| Unlock the mutex. More... | |
| bool | trylock () noexcept final |
| Try to lock the mutex. More... | |
| embvm::mutex::handle_t | native_handle () const noexcept final |
Private Attributes | |
| embvm::mutex::handle_t | handle_ |
| embvm::mutex::type | type_ |
|
explicitnoexcept |
Construct a FreeRTOS mutex.
| type | The mutex type to create (normal, recursive) |
| mode | The mutex poperating mode, which controls priority inheritance behaviors. |
References embvm::mutex::normal, embvm::mutex::recursive, and type.
|
noexcept |
Default destructor.
References handle_, and static_mutex_pool_.
|
finalvirtualnoexcept |
Lock the mutex.
Attempts to lock the mutex. If successful, the function returns with the calling thread owning the lock. If the lock is already owned, the calling thread will block until the lock is available.
Implements embvm::VirtualMutex.
References assert, handle_, portMAX_DELAY, r, embvm::mutex::recursive, and type_.
|
inlinefinalvirtualnoexcept |
Implements embvm::VirtualMutex.
References handle_.
|
finalvirtualnoexcept |
Try to lock the mutex.
Try to lock the mutex, but don't block the thread if the mutex is already owned.
Implements embvm::VirtualMutex.
References handle_, r, embvm::mutex::recursive, and type_.
|
finalvirtualnoexcept |
Unlock the mutex.
Implements embvm::VirtualMutex.
References handle_, embvm::mutex::recursive, and type_.
|
private |
Referenced by lock(), native_handle(), trylock(), unlock(), and ~Mutex().
|
private |
| class os::freertos::Semaphore |
Create a FreeRTOS semaphore (OSX variant)

Public Member Functions | |
| Semaphore (embvm::semaphore::mode mode=embvm::semaphore::mode::counting, embvm::semaphore::count_t ceiling=1, embvm::semaphore::count_t initial_count=-1) noexcept | |
| Create a FreeRTOS sempahore. More... | |
| ~Semaphore () noexcept | |
| Default destructor, cleans up after semaphore on destruction. More... | |
| void | give () noexcept final |
| Increment count Return a resource to the semaphore, incrementing the count. More... | |
| void | giveFromISR () noexcept final |
| Increment count from an ISR Return a resource to the semaphore, incrementing the count. More... | |
| bool | take (const embvm::os_timeout_t &timeout=embvm::OS_WAIT_FOREVER) noexcept final |
| Decrement count Take a resource from the semaphore, decrementing the count. More... | |
| embvm::semaphore::count_t | count () const noexcept final |
| Check the count of the semaphore. More... | |
| embvm::semaphore::handle_t | native_handle () const noexcept final |
Private Attributes | |
| embvm::semaphore::handle_t | handle_ |
|
explicitnoexcept |
Create a FreeRTOS sempahore.
| mode | The semaphore mode (binary, counting). |
| ceiling | The maximum count of the semaphore |
| initial_count | The starting count of the semaphore. Can be used to indicate that resources are in use at hte itme of creation. |
References assert, embvm::semaphore::binary, embvm::semaphore::counting, and embvm::semaphore::defaultMode.
|
noexcept |
Default destructor, cleans up after semaphore on destruction.
References handle_, and static_sem_pool_.
|
finalvirtualnoexcept |
Check the count of the semaphore.
Implements embvm::VirtualSemaphore.
References handle_.
|
finalvirtualnoexcept |
Increment count Return a resource to the semaphore, incrementing the count.
Implements embvm::VirtualSemaphore.
References assert, handle_, and r.
Referenced by os::freertos::ConditionVariable::broadcast(), and os::freertos::ConditionVariable::signal().
|
finalvirtualnoexcept |
Increment count from an ISR Return a resource to the semaphore, incrementing the count.
This function variant is safe to call from an interrupt routine. No locking can be used inside this variant.
Implements embvm::VirtualSemaphore.
References handle_, and portYIELD_FROM_ISR.
|
inlinefinalvirtualnoexcept |
Implements embvm::VirtualSemaphore.
References handle_.
Referenced by os::freertos::ConditionVariable::native_handle().
|
finalvirtualnoexcept |
Decrement count Take a resource from the semaphore, decrementing the count.
| timeout | The time to wait for a semaphore resource. A value of WAIT_FOREVER indicates that the thread should block until the semaphore can be acquired. |
Implements embvm::VirtualSemaphore.
References r.
Referenced by os::freertos::ConditionVariable::broadcast(), and os::freertos::ConditionVariable::signal().
|
private |
Referenced by count(), give(), giveFromISR(), native_handle(), and ~Semaphore().
| class os::freertos::Thread |
Create a FreeRTOS thread.
Your FreeRTOS port must define task priorities for the framework. We recommend that you keep this definition in FreeRTOSConfig.h.
For example, with a max priority of 32:

Public Member Functions | |
| Thread () | |
| Thread (std::string_view name, embvm::thread::func_t func, embvm::thread::input_t arg, embvm::thread::priority p=embvm::thread::priority::normal, size_t stack_size=FREERTOS_STACK_MIN, void *stack_ptr=nullptr) noexcept | |
| Construct a FreeRTOS thread. More... | |
| ~Thread () noexcept | |
| Default destructor, cleans up thread on deletion. More... | |
| void | start () noexcept final |
| Start the thread, if it is not auto-started. More... | |
| void | terminate () noexcept final |
| Terminate a running thread. More... | |
| void | join () noexcept final |
| Join a running thread. More... | |
| std::string_view | name () const noexcept final |
| View the thread's name. More... | |
| embvm::thread::state | state () const noexcept final |
| Get the thread state. More... | |
| embvm::thread::handle_t | native_handle () const noexcept final |
| Get the native handle for the thread. More... | |
Static Public Member Functions | |
| static void | delay_for (uint32_t ticks) noexcept |
Private Member Functions | |
| void | thread_wrapper (embvm::thread::input_t arg) noexcept |
Private Attributes | |
| embvm::thread::handle_t | handle_ = 0 |
| The FreeRTOS thread handle. More... | |
| bool | static_ = false |
|
inline |
|
explicitnoexcept |
Construct a FreeRTOS thread.
| name | The name associated with the mutex. |
| func | The thread function to execute; can be any functor type. |
| arg | The thread's optional input argument. This value is passed to the thread when it is created. |
| p | The thread priority setting. |
| stack_size | The thread stack size. |
| stack_ptr | The thread stack pointer. If stack_ptr is nullptr, then memory will be allocated by the pthread library. |
References assert, freertos_priority(), p, and r.
|
noexcept |
Default destructor, cleans up thread on deletion.
References terminate().
|
staticnoexcept |
Referenced by embvm::this_thread::sleep_for(), and embvm::this_thread::yield().
|
finalvirtualnoexcept |
Join a running thread.
Joins a running thread, blocking the calling thread until the joined thread completes.
Implements embvm::VirtualThread.
References embvm::thread::completed, handle_, state(), and embvm::thread::terminated.
|
finalvirtualnoexcept |
View the thread's name.
Storage for the thread name is implementation defined. For example, the name may be stored in the RTOS memory, or it may require internal object storage.
Implements embvm::VirtualThread.
References handle_.
|
inlinefinalvirtualnoexcept |
Get the native handle for the thread.
If custom extensions or behaviors are needed, the thread handle can be retrieved and manipulated directly.
void*. The user must cast appropriately. Implements embvm::VirtualThread.
References handle_.
|
finalvirtualnoexcept |
Start the thread, if it is not auto-started.
Implements embvm::VirtualThread.
|
finalvirtualnoexcept |
Get the thread state.
Implements embvm::VirtualThread.
References embvm::thread::completed, embvm::thread::executing, handle_, embvm::thread::ready, s, and embvm::thread::suspended.
Referenced by join().
|
finalvirtualnoexcept |
Terminate a running thread.
Grab our TLS handle before we destroy the thread
Implements embvm::VirtualThread.
References exit_func_, handle_, NULL, and static_.
Referenced by ~Thread().
|
privatenoexcept |
|
private |
The FreeRTOS thread handle.
Referenced by join(), name(), native_handle(), state(), and terminate().
Referenced by terminate().
| class os::freertos::Heap |
Static Public Member Functions | |
| static void | addBlock (void *addr, size_t size) noexcept |
| static void | init () noexcept |
| static void * | alloc (size_t size) noexcept |
| static void | free (void *addr) noexcept |
|
staticnoexcept |
References assert, heap_region_cnt, heap_region_max, and heap_regions.
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
References assert, cmp_heap(), heap_region_cnt, heap_regions, and qsort().
| class os::freertos::freertosOSFactory_impl |
Implementation of the FreeRTOS OS Factory For API documentation, see embvm::embvm::VirtualOSFactory.
|
default |
|
default |
|
staticnoexcept |
|
staticnoexcept |
|
inlinestaticnoexcept |
|
staticnoexcept |
References type.
|
staticnoexcept |
|
staticnoexcept |
References p.
|
staticnoexcept |
References assert.
|
staticnoexcept |
References assert.
|
staticnoexcept |
References assert.
|
staticnoexcept |
References assert.
|
staticnoexcept |
References assert.
| using os::freertos::thread_exit_t = typedef void (*)(void*) |
|
noexcept |
References assert, atexit(), and exit_func_.
|
noexcept |
Call this function to start the FreeRTOS scheduler.
We recommend placing this in the platform init() function.
Referenced by nRF52DK_FrameworkDemoPlatform::initOS_().
|
inlinestatic |
1.8.15