takashi kadono / Mbed OS Nucleo_446

Dependencies:   ssd1331

Embed: (wiki syntax)

« Back to documentation index

Rtos

Data Structures

class  ConditionVariable
 This class provides a safe way to wait for or send notifications of condition changes. More...

Namespaces

namespace  rtos::Kernel
 

Functions in the Kernel namespace control RTOS kernel information.


Modules

 EventFlags class
 Mail class
 MemoryPool class
 Mutex class
 Queue class
 RTOS hook functions
 Idle hook function
 RtosTimer class
 Semaphore class
 ThisThread namespace
 Thread class

Typedefs

typedef mbed::ScopedLock< Mutex > ScopedMutexLock
 Typedef for the mutex lock.

Functions

void wait ()
 Wait for a notification.
bool wait_until (uint64_t millisec)
 Wait for a notification until specified time.
bool wait_for (uint32_t millisec)
 Wait for a notification or timeout.
void notify_one ()
 Notify one waiter on this condition variable that a condition changed.
void notify_all ()
 Notify all waiters on this condition variable that a condition changed.
 ~ConditionVariable ()
 ConditionVariable destructor.
void attach_idle_hook (void(*fptr)(void))
 Attach a function to be called by the RTOS idle task.
void attach_thread_terminate_hook (void(*fptr)(osThreadId_t id))
 Attach a function to be called when a task is killed.

Typedef Documentation

typedef mbed::ScopedLock<Mutex> ScopedMutexLock

Typedef for the mutex lock.

Usage:

 void foo(Mutex &m) {
     ScopedMutexLock lock(m);
     // Mutex lock protects code in this block
 }

Definition at line 38 of file rtos/Mutex.h.


Function Documentation

void attach_idle_hook ( void(*)(void)  fptr )

Attach a function to be called by the RTOS idle task.

Parameters:
fptrpointer to the function to be called
Note:
You may call this function from ISR context.

Definition at line 66 of file Kernel.cpp.

void attach_thread_terminate_hook ( void(*)(osThreadId_t id)  fptr )

Attach a function to be called when a task is killed.

Parameters:
fptrpointer to the function to be called
Note:
You may call this function from ISR context.

Definition at line 71 of file Kernel.cpp.

void notify_all (  ) [inherited]

Notify all waiters on this condition variable that a condition changed.

Note:
- The thread calling this function must be the owner of the ConditionVariable's mutex
You cannot call this function from ISR context.

Definition at line 94 of file ConditionVariable.cpp.

void notify_one (  ) [inherited]

Notify one waiter on this condition variable that a condition changed.

Note:
- The thread calling this function must be the owner of the ConditionVariable's mutex
You cannot call this function from ISR context.

Definition at line 85 of file ConditionVariable.cpp.

void wait (  ) [inherited]

Wait for a notification.

Wait until a notification occurs.

Note:
- The thread calling this function must be the owner of the ConditionVariable's mutex and it must be locked exactly once
- Spurious notifications can occur so the caller of this API should check to make sure the condition they are waiting on has been met

Example:

 mutex.lock();
 while (!condition_met) {
     cond.wait();
 }

 function_to_handle_condition();

 mutex.unlock();
Note:
You cannot call this function from ISR context.

Definition at line 41 of file ConditionVariable.cpp.

bool wait_for ( uint32_t  millisec ) [inherited]

Wait for a notification or timeout.

Parameters:
millisectimeout value or osWaitForever in case of no time-out.
Returns:
true if a timeout occurred, false otherwise.
Note:
- The thread calling this function must be the owner of the ConditionVariable's mutex and it must be locked exactly once
- Spurious notifications can occur so the caller of this API should check to make sure the condition they are waiting on has been met

Example:

 mutex.lock();

 while (!condition_met) {
     cond.wait_for(MAX_SLEEP_TIME);
     if (!condition_met) {
         do_other_work_while_condition_false();
     }
 }

 if (condition_met) {
     function_to_handle_condition();
 }

 mutex.unlock();
Note:
You cannot call this function from ISR context.

Definition at line 46 of file ConditionVariable.cpp.

bool wait_until ( uint64_t  millisec ) [inherited]

Wait for a notification until specified time.

Parameters:
millisecabsolute end time referenced to Kernel::get_ms_count()
Returns:
true if a timeout occurred, false otherwise.
Note:
- The thread calling this function must be the owner of the ConditionVariable's mutex and it must be locked exactly once
- Spurious notifications can occur so the caller of this API should check to make sure the condition they are waiting on has been met

Example:

 mutex.lock();
 uint64_t end_time = Kernel::get_ms_count() + COND_WAIT_TIMEOUT;

 while (!condition_met) {
     if (cond.wait_until(end_time)) {
         break;
     }
 }

 if (condition_met) {
     function_to_handle_condition();
 }

 mutex.unlock();
Note:
You cannot call this function from ISR context.

Definition at line 67 of file ConditionVariable.cpp.

~ConditionVariable (  ) [inherited]

ConditionVariable destructor.

Note:
You cannot call this function from ISR context.

Definition at line 148 of file ConditionVariable.cpp.