mirror of https://github.com/ARMmbed/mbed-os.git
RTOS API for bare metal
Provide partial RTOS API for bare metal builds - things that can be done in a single threaded environment. Allows more code to work in both RTOS and bare metal builds without change, and in particular gives easy access to the ability to efficiently wait for something occurring in interrupt. Available in bare-metal: * ThisThread * osThreadFlagsSet to set flags on main thread (can be set from IRQ) * EventFlags (can be set from IRQ) * Semaphores (can be released from IRQ) * Mutex (dummy implementation) Not useful: * ConditionVariable (could only be signalled from 2nd thread) * RtosTimer (calls in a second thread context) * Thread Unimplemented: * Mail, Queue, MemoryPool Possible future work: * ConditionVariableCS to act as IRQ signalled ConditionVariablepull/10104/head
parent
38160035d4
commit
83b329cb71
|
@ -86,6 +86,9 @@ endif(COVERAGE)
|
||||||
# UNIT TESTS
|
# UNIT TESTS
|
||||||
####################
|
####################
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNITTEST")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUNITTEST")
|
||||||
|
|
||||||
# Set include dirs.
|
# Set include dirs.
|
||||||
set(unittest-includes-base
|
set(unittest-includes-base
|
||||||
"${PROJECT_SOURCE_DIR}/target_h"
|
"${PROJECT_SOURCE_DIR}/target_h"
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
#define __MUTEX_H__
|
#define __MUTEX_H__
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "cmsis_os2.h"
|
#include "mbed_rtos_types.h"
|
||||||
|
#include "mbed_rtos1_types.h"
|
||||||
|
|
||||||
namespace rtos {
|
namespace rtos {
|
||||||
|
|
||||||
|
|
2
mbed.h
2
mbed.h
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include "platform/mbed_version.h"
|
#include "platform/mbed_version.h"
|
||||||
|
|
||||||
#if MBED_CONF_RTOS_PRESENT
|
#if MBED_CONF_RTOS_API_PRESENT
|
||||||
#include "rtos/rtos.h"
|
#include "rtos/rtos.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#include "mbed_error.h"
|
#include "mbed_error.h"
|
||||||
#include "mbed_assert.h"
|
#include "mbed_assert.h"
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
|
|
||||||
namespace rtos {
|
namespace rtos {
|
||||||
|
|
||||||
ConditionVariable::Waiter::Waiter(): sem(0), prev(NULL), next(NULL), in_list(false)
|
ConditionVariable::Waiter::Waiter(): sem(0), prev(NULL), next(NULL), in_list(false)
|
||||||
|
@ -150,3 +152,5 @@ ConditionVariable::~ConditionVariable()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -23,12 +23,14 @@
|
||||||
#define CONDITIONVARIABLE_H
|
#define CONDITIONVARIABLE_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "cmsis_os.h"
|
#include "rtos/mbed_rtos_types.h"
|
||||||
#include "rtos/Mutex.h"
|
#include "rtos/Mutex.h"
|
||||||
#include "rtos/Semaphore.h"
|
#include "rtos/Semaphore.h"
|
||||||
|
|
||||||
#include "platform/NonCopyable.h"
|
#include "platform/NonCopyable.h"
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY)
|
||||||
|
|
||||||
namespace rtos {
|
namespace rtos {
|
||||||
/** \addtogroup rtos */
|
/** \addtogroup rtos */
|
||||||
/** @{*/
|
/** @{*/
|
||||||
|
@ -328,4 +330,6 @@ protected:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/** @}*/
|
/** @}*/
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include "rtos/EventFlags.h"
|
#include "rtos/EventFlags.h"
|
||||||
|
#include "rtos/ThisThread.h"
|
||||||
|
#include "mbed_os_timer.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "mbed_error.h"
|
#include "mbed_error.h"
|
||||||
#include "mbed_assert.h"
|
#include "mbed_assert.h"
|
||||||
|
@ -38,27 +40,43 @@ EventFlags::EventFlags(const char *name)
|
||||||
|
|
||||||
void EventFlags::constructor(const char *name)
|
void EventFlags::constructor(const char *name)
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
osEventFlagsAttr_t attr = { 0 };
|
osEventFlagsAttr_t attr = { 0 };
|
||||||
attr.name = name ? name : "application_unnamed_event_flags";
|
attr.name = name ? name : "application_unnamed_event_flags";
|
||||||
attr.cb_mem = &_obj_mem;
|
attr.cb_mem = &_obj_mem;
|
||||||
attr.cb_size = sizeof(_obj_mem);
|
attr.cb_size = sizeof(_obj_mem);
|
||||||
_id = osEventFlagsNew(&attr);
|
_id = osEventFlagsNew(&attr);
|
||||||
MBED_ASSERT(_id);
|
MBED_ASSERT(_id);
|
||||||
|
#else
|
||||||
|
_flags = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t EventFlags::set(uint32_t flags)
|
uint32_t EventFlags::set(uint32_t flags)
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
return osEventFlagsSet(_id, flags);
|
return osEventFlagsSet(_id, flags);
|
||||||
|
#else
|
||||||
|
return core_util_atomic_fetch_or_u32(&_flags, flags) | flags;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t EventFlags::clear(uint32_t flags)
|
uint32_t EventFlags::clear(uint32_t flags)
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
return osEventFlagsClear(_id, flags);
|
return osEventFlagsClear(_id, flags);
|
||||||
|
#else
|
||||||
|
return core_util_atomic_fetch_and_u32(&_flags, ~flags);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t EventFlags::get() const
|
uint32_t EventFlags::get() const
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
return osEventFlagsGet(_id);
|
return osEventFlagsGet(_id);
|
||||||
|
#else
|
||||||
|
return core_util_atomic_load_u32(&_flags);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t EventFlags::wait_all(uint32_t flags, uint32_t millisec, bool clear)
|
uint32_t EventFlags::wait_all(uint32_t flags, uint32_t millisec, bool clear)
|
||||||
|
@ -73,7 +91,9 @@ uint32_t EventFlags::wait_any(uint32_t flags, uint32_t millisec, bool clear)
|
||||||
|
|
||||||
EventFlags::~EventFlags()
|
EventFlags::~EventFlags()
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
osEventFlagsDelete(_id);
|
osEventFlagsDelete(_id);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t EventFlags::wait(uint32_t flags, uint32_t opt, uint32_t millisec, bool clear)
|
uint32_t EventFlags::wait(uint32_t flags, uint32_t opt, uint32_t millisec, bool clear)
|
||||||
|
@ -82,7 +102,24 @@ uint32_t EventFlags::wait(uint32_t flags, uint32_t opt, uint32_t millisec, bool
|
||||||
opt |= osFlagsNoClear;
|
opt |= osFlagsNoClear;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
return osEventFlagsWait(_id, flags, opt, millisec);
|
return osEventFlagsWait(_id, flags, opt, millisec);
|
||||||
|
#else
|
||||||
|
rtos::internal::flags_check_capture check;
|
||||||
|
check.flags = &_flags;
|
||||||
|
check.options = opt;
|
||||||
|
check.flags_wanted = flags;
|
||||||
|
check.result = 0;
|
||||||
|
check.match = false;
|
||||||
|
mbed::internal::do_timed_sleep_relative_or_forever(millisec, rtos::internal::non_rtos_check_flags, &check);
|
||||||
|
if (check.match) {
|
||||||
|
return check.result;
|
||||||
|
} else if (millisec == 0) {
|
||||||
|
return osErrorResource;
|
||||||
|
} else {
|
||||||
|
return osErrorTimeout;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
#define EVENT_FLAG_H
|
#define EVENT_FLAG_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "cmsis_os2.h"
|
#include "rtos/mbed_rtos_types.h"
|
||||||
#include "mbed_rtos1_types.h"
|
#include "rtos/mbed_rtos1_types.h"
|
||||||
#include "mbed_rtos_storage.h"
|
#include "rtos/mbed_rtos_storage.h"
|
||||||
|
|
||||||
#include "platform/NonCopyable.h"
|
#include "platform/NonCopyable.h"
|
||||||
|
|
||||||
|
@ -114,8 +114,12 @@ public:
|
||||||
private:
|
private:
|
||||||
void constructor(const char *name = NULL);
|
void constructor(const char *name = NULL);
|
||||||
uint32_t wait(uint32_t flags, uint32_t opt, uint32_t millisec, bool clear);
|
uint32_t wait(uint32_t flags, uint32_t opt, uint32_t millisec, bool clear);
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
osEventFlagsId_t _id;
|
osEventFlagsId_t _id;
|
||||||
mbed_rtos_storage_event_flags_t _obj_mem;
|
mbed_rtos_storage_event_flags_t _obj_mem;
|
||||||
|
#else
|
||||||
|
uint32_t _flags;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @}*/
|
/** @}*/
|
||||||
|
|
|
@ -20,16 +20,17 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cmsis_os2.h"
|
|
||||||
#include "rtos/Kernel.h"
|
#include "rtos/Kernel.h"
|
||||||
#include "rtos/rtos_idle.h"
|
#include "rtos/rtos_idle.h"
|
||||||
#include "rtos/rtos_handlers.h"
|
#include "rtos/rtos_handlers.h"
|
||||||
#include "platform/mbed_critical.h"
|
#include "platform/mbed_critical.h"
|
||||||
|
#include "platform/mbed_os_timer.h"
|
||||||
|
|
||||||
namespace rtos {
|
namespace rtos {
|
||||||
|
|
||||||
uint64_t Kernel::get_ms_count()
|
uint64_t Kernel::get_ms_count()
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
// CMSIS-RTOS 2.1.0 and 2.1.1 differ in the time type. We assume
|
// CMSIS-RTOS 2.1.0 and 2.1.1 differ in the time type. We assume
|
||||||
// our header at least matches the implementation, so we don't try looking
|
// our header at least matches the implementation, so we don't try looking
|
||||||
// at the run-time version report. (There's no compile-time version report)
|
// at the run-time version report. (There's no compile-time version report)
|
||||||
|
@ -61,8 +62,12 @@ uint64_t Kernel::get_ms_count()
|
||||||
core_util_critical_section_exit();
|
core_util_critical_section_exit();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
return mbed::internal::init_os_timer()->update_and_get_tick();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
void Kernel::attach_idle_hook(void (*fptr)(void))
|
void Kernel::attach_idle_hook(void (*fptr)(void))
|
||||||
{
|
{
|
||||||
rtos_attach_idle_hook(fptr);
|
rtos_attach_idle_hook(fptr);
|
||||||
|
@ -72,5 +77,6 @@ void Kernel::attach_thread_terminate_hook(void (*fptr)(osThreadId_t id))
|
||||||
{
|
{
|
||||||
rtos_attach_thread_terminate_hook(fptr);
|
rtos_attach_thread_terminate_hook(fptr);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#define KERNEL_H
|
#define KERNEL_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "cmsis_os2.h"
|
#include "rtos/mbed_rtos_types.h"
|
||||||
|
|
||||||
namespace rtos {
|
namespace rtos {
|
||||||
/** \addtogroup rtos */
|
/** \addtogroup rtos */
|
||||||
|
|
|
@ -3,7 +3,6 @@ as can be found: LICENSE-apache-2.0.txt.
|
||||||
|
|
||||||
Files licensed under MIT:
|
Files licensed under MIT:
|
||||||
|
|
||||||
- TARGET_CORTEX/mbed_rtos1_types.h
|
|
||||||
- TARGET_CORTEX/mbed_rtos_storage.h
|
- TARGET_CORTEX/mbed_rtos_storage.h
|
||||||
- TARGET_CORTEX/mbed_rtx_conf.h
|
- TARGET_CORTEX/mbed_rtx_conf.h
|
||||||
- TARGET_CORTEX/mbed_rtx_idle.cpp
|
- TARGET_CORTEX/mbed_rtx_idle.cpp
|
||||||
|
|
14
rtos/Mail.h
14
rtos/Mail.h
|
@ -25,11 +25,11 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "Queue.h"
|
#include "rtos/Queue.h"
|
||||||
#include "MemoryPool.h"
|
#include "rtos/MemoryPool.h"
|
||||||
#include "cmsis_os2.h"
|
#include "rtos/mbed_rtos_types.h"
|
||||||
#include "mbed_rtos_storage.h"
|
#include "rtos/mbed_rtos_storage.h"
|
||||||
#include "mbed_rtos1_types.h"
|
#include "rtos/mbed_rtos1_types.h"
|
||||||
|
|
||||||
#include "platform/mbed_toolchain.h"
|
#include "platform/mbed_toolchain.h"
|
||||||
#include "platform/NonCopyable.h"
|
#include "platform/NonCopyable.h"
|
||||||
|
@ -38,6 +38,8 @@
|
||||||
using namespace rtos;
|
using namespace rtos;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY)
|
||||||
|
|
||||||
namespace rtos {
|
namespace rtos {
|
||||||
/** \addtogroup rtos */
|
/** \addtogroup rtos */
|
||||||
/** @{*/
|
/** @{*/
|
||||||
|
@ -238,5 +240,5 @@ private:
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,12 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "cmsis_os2.h"
|
#include "rtos/mbed_rtos_types.h"
|
||||||
#include "mbed_rtos1_types.h"
|
#include "rtos/mbed_rtos1_types.h"
|
||||||
#include "mbed_rtos_storage.h"
|
#include "rtos/mbed_rtos_storage.h"
|
||||||
#include "platform/NonCopyable.h"
|
#include "platform/NonCopyable.h"
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY)
|
||||||
namespace rtos {
|
namespace rtos {
|
||||||
/** \addtogroup rtos */
|
/** \addtogroup rtos */
|
||||||
/** @{*/
|
/** @{*/
|
||||||
|
@ -191,3 +192,4 @@ private:
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
|
@ -26,9 +26,11 @@
|
||||||
#include "mbed_error.h"
|
#include "mbed_error.h"
|
||||||
#include "mbed_assert.h"
|
#include "mbed_assert.h"
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
|
|
||||||
namespace rtos {
|
namespace rtos {
|
||||||
|
|
||||||
Mutex::Mutex(): _count(0)
|
Mutex::Mutex()
|
||||||
{
|
{
|
||||||
constructor();
|
constructor();
|
||||||
}
|
}
|
||||||
|
@ -40,6 +42,7 @@ Mutex::Mutex(const char *name)
|
||||||
|
|
||||||
void Mutex::constructor(const char *name)
|
void Mutex::constructor(const char *name)
|
||||||
{
|
{
|
||||||
|
_count = 0;
|
||||||
osMutexAttr_t attr =
|
osMutexAttr_t attr =
|
||||||
{ 0 };
|
{ 0 };
|
||||||
attr.name = name ? name : "application_unnamed_mutex";
|
attr.name = name ? name : "application_unnamed_mutex";
|
||||||
|
@ -147,3 +150,5 @@ Mutex::~Mutex()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
60
rtos/Mutex.h
60
rtos/Mutex.h
|
@ -23,9 +23,9 @@
|
||||||
#define MUTEX_H
|
#define MUTEX_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "cmsis_os2.h"
|
#include "rtos/mbed_rtos_types.h"
|
||||||
#include "mbed_rtos1_types.h"
|
#include "rtos/mbed_rtos1_types.h"
|
||||||
#include "mbed_rtos_storage.h"
|
#include "rtos/mbed_rtos_storage.h"
|
||||||
|
|
||||||
#include "platform/NonCopyable.h"
|
#include "platform/NonCopyable.h"
|
||||||
#include "platform/ScopedLock.h"
|
#include "platform/ScopedLock.h"
|
||||||
|
@ -56,6 +56,8 @@ typedef mbed::ScopedLock<Mutex> ScopedMutexLock;
|
||||||
/** The Mutex class is used to synchronize the execution of threads.
|
/** The Mutex class is used to synchronize the execution of threads.
|
||||||
This is, for example, used to protect access to a shared resource.
|
This is, for example, used to protect access to a shared resource.
|
||||||
|
|
||||||
|
In bare-metal builds, the Mutex class is a dummy, so lock() and unlock() are no-ops.
|
||||||
|
|
||||||
@note You cannot use member functions of this class in ISR context. If you require Mutex functionality within
|
@note You cannot use member functions of this class in ISR context. If you require Mutex functionality within
|
||||||
ISR handler, consider using @a Semaphore.
|
ISR handler, consider using @a Semaphore.
|
||||||
|
|
||||||
|
@ -88,7 +90,11 @@ public:
|
||||||
@note This function treats RTOS errors as fatal system errors, so it can only return osOK.
|
@note This function treats RTOS errors as fatal system errors, so it can only return osOK.
|
||||||
Use of the return value is deprecated, as the return is expected to become void in the future.
|
Use of the return value is deprecated, as the return is expected to become void in the future.
|
||||||
*/
|
*/
|
||||||
osStatus lock(void);
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
|
osStatus lock();
|
||||||
|
#else
|
||||||
|
void lock(); // Value return backwards compatibility not required for non-RTOS
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Wait until a Mutex becomes available.
|
Wait until a Mutex becomes available.
|
||||||
|
@ -150,14 +156,18 @@ public:
|
||||||
@note This function treats RTOS errors as fatal system errors, so it can only return osOK.
|
@note This function treats RTOS errors as fatal system errors, so it can only return osOK.
|
||||||
Use of the return value is deprecated, as the return is expected to become void in the future.
|
Use of the return value is deprecated, as the return is expected to become void in the future.
|
||||||
*/
|
*/
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
osStatus unlock();
|
osStatus unlock();
|
||||||
|
#else
|
||||||
|
void unlock(); // Value return backwards compatibility not required for non-RTOS
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Get the owner the this mutex
|
/** Get the owner the this mutex
|
||||||
@return the current owner of this mutex.
|
@return the current owner of this mutex.
|
||||||
|
|
||||||
@note You cannot call this function from ISR context.
|
@note You cannot call this function from ISR context.
|
||||||
*/
|
*/
|
||||||
osThreadId get_owner();
|
osThreadId_t get_owner();
|
||||||
|
|
||||||
/** Mutex destructor
|
/** Mutex destructor
|
||||||
*
|
*
|
||||||
|
@ -166,13 +176,53 @@ public:
|
||||||
~Mutex();
|
~Mutex();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
void constructor(const char *name = NULL);
|
void constructor(const char *name = NULL);
|
||||||
friend class ConditionVariable;
|
friend class ConditionVariable;
|
||||||
|
|
||||||
osMutexId_t _id;
|
osMutexId_t _id;
|
||||||
mbed_rtos_storage_mutex_t _obj_mem;
|
mbed_rtos_storage_mutex_t _obj_mem;
|
||||||
uint32_t _count;
|
uint32_t _count;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !MBED_CONF_RTOS_PRESENT
|
||||||
|
inline Mutex::Mutex()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Mutex::Mutex(const char *)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Mutex::~Mutex()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Mutex::lock()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Mutex::trylock()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Mutex::trylock_for(uint32_t)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Mutex::trylock_until(uint64_t)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Mutex::unlock()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/** @}*/
|
/** @}*/
|
||||||
/** @}*/
|
/** @}*/
|
||||||
}
|
}
|
||||||
|
|
10
rtos/Queue.h
10
rtos/Queue.h
|
@ -22,12 +22,14 @@
|
||||||
#ifndef QUEUE_H
|
#ifndef QUEUE_H
|
||||||
#define QUEUE_H
|
#define QUEUE_H
|
||||||
|
|
||||||
#include "cmsis_os2.h"
|
#include "rtos/mbed_rtos_types.h"
|
||||||
#include "mbed_rtos1_types.h"
|
#include "rtos/mbed_rtos1_types.h"
|
||||||
#include "mbed_rtos_storage.h"
|
#include "rtos/mbed_rtos_storage.h"
|
||||||
#include "platform/mbed_error.h"
|
#include "platform/mbed_error.h"
|
||||||
#include "platform/NonCopyable.h"
|
#include "platform/NonCopyable.h"
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY)
|
||||||
|
|
||||||
namespace rtos {
|
namespace rtos {
|
||||||
/** \addtogroup rtos */
|
/** \addtogroup rtos */
|
||||||
/** @{*/
|
/** @{*/
|
||||||
|
@ -219,4 +221,6 @@ private:
|
||||||
|
|
||||||
} // namespace rtos
|
} // namespace rtos
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // QUEUE_H
|
#endif // QUEUE_H
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
|
|
||||||
namespace rtos {
|
namespace rtos {
|
||||||
|
|
||||||
void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type)
|
void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type)
|
||||||
|
@ -54,3 +56,5 @@ RtosTimer::~RtosTimer()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -23,12 +23,14 @@
|
||||||
#define RTOS_TIMER_H
|
#define RTOS_TIMER_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "cmsis_os2.h"
|
#include "rtos/mbed_rtos_types.h"
|
||||||
#include "mbed_rtos_storage.h"
|
#include "rtos/mbed_rtos_storage.h"
|
||||||
#include "platform/Callback.h"
|
#include "platform/Callback.h"
|
||||||
#include "platform/NonCopyable.h"
|
#include "platform/NonCopyable.h"
|
||||||
#include "platform/mbed_toolchain.h"
|
#include "platform/mbed_toolchain.h"
|
||||||
#include "mbed_rtos1_types.h"
|
#include "rtos/mbed_rtos1_types.h"
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY)
|
||||||
|
|
||||||
namespace rtos {
|
namespace rtos {
|
||||||
/** \addtogroup rtos */
|
/** \addtogroup rtos */
|
||||||
|
@ -188,4 +190,4 @@ private:
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -22,7 +22,9 @@
|
||||||
#include "rtos/Semaphore.h"
|
#include "rtos/Semaphore.h"
|
||||||
#include "rtos/Kernel.h"
|
#include "rtos/Kernel.h"
|
||||||
#include "platform/mbed_assert.h"
|
#include "platform/mbed_assert.h"
|
||||||
|
#include "platform/mbed_critical.h"
|
||||||
#include "platform/mbed_error.h"
|
#include "platform/mbed_error.h"
|
||||||
|
#include "platform/mbed_os_timer.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -40,22 +42,51 @@ Semaphore::Semaphore(int32_t count, uint16_t max_count)
|
||||||
|
|
||||||
void Semaphore::constructor(int32_t count, uint16_t max_count)
|
void Semaphore::constructor(int32_t count, uint16_t max_count)
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
osSemaphoreAttr_t attr = { 0 };
|
osSemaphoreAttr_t attr = { 0 };
|
||||||
attr.cb_mem = &_obj_mem;
|
attr.cb_mem = &_obj_mem;
|
||||||
attr.cb_size = sizeof(_obj_mem);
|
attr.cb_size = sizeof(_obj_mem);
|
||||||
_id = osSemaphoreNew(max_count, count, &attr);
|
_id = osSemaphoreNew(max_count, count, &attr);
|
||||||
MBED_ASSERT(_id != NULL);
|
MBED_ASSERT(_id != NULL);
|
||||||
|
#else
|
||||||
|
_count = count;
|
||||||
|
_max_count = max_count;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !MBED_CONF_RTOS_PRESENT
|
||||||
|
struct sem_wait_capture {
|
||||||
|
Semaphore *sem;
|
||||||
|
bool acquired;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool Semaphore::semaphore_available(void *handle)
|
||||||
|
{
|
||||||
|
sem_wait_capture *wait = static_cast<sem_wait_capture *>(handle);
|
||||||
|
return wait->acquired = wait->sem->try_acquire();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool Semaphore::try_acquire()
|
bool Semaphore::try_acquire()
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
osStatus_t status = osSemaphoreAcquire(_id, 0);
|
osStatus_t status = osSemaphoreAcquire(_id, 0);
|
||||||
if (status != osOK && status != osErrorResource) {
|
if (status != osOK && status != osErrorResource) {
|
||||||
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_SEMAPHORE_LOCK_FAILED), "Semaphore acquire failed", status);
|
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_SEMAPHORE_LOCK_FAILED), "Semaphore acquire failed", status);
|
||||||
}
|
}
|
||||||
return status == osOK;
|
return status == osOK;
|
||||||
|
#else
|
||||||
|
int32_t old_count = core_util_atomic_load_s32(&_count);
|
||||||
|
do {
|
||||||
|
if (old_count == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} while (!core_util_atomic_cas_s32(&_count, &old_count, old_count - 1));
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
/* To sidestep deprecation warnings */
|
/* To sidestep deprecation warnings */
|
||||||
int32_t Semaphore::_wait(uint32_t millisec)
|
int32_t Semaphore::_wait(uint32_t millisec)
|
||||||
{
|
{
|
||||||
|
@ -71,14 +102,26 @@ int32_t Semaphore::_wait(uint32_t millisec)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t Semaphore::wait(uint32_t millisec)
|
int32_t Semaphore::wait(uint32_t millisec)
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
return _wait(millisec);
|
return _wait(millisec);
|
||||||
|
#else
|
||||||
|
sem_wait_capture capture = { this, false };
|
||||||
|
mbed::internal::do_timed_sleep_relative_or_forever(millisec, semaphore_available, &capture);
|
||||||
|
if (capture.acquired) {
|
||||||
|
return core_util_atomic_load_s32(&_count) + 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Semaphore::wait_until(uint64_t millisec)
|
int32_t Semaphore::wait_until(uint64_t millisec)
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
uint64_t now = Kernel::get_ms_count();
|
uint64_t now = Kernel::get_ms_count();
|
||||||
|
|
||||||
if (now >= millisec) {
|
if (now >= millisec) {
|
||||||
|
@ -89,18 +132,36 @@ int32_t Semaphore::wait_until(uint64_t millisec)
|
||||||
} else {
|
} else {
|
||||||
return _wait(millisec - now);
|
return _wait(millisec - now);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
sem_wait_capture capture = { this, false };
|
||||||
|
mbed::internal::do_timed_sleep_absolute(millisec, semaphore_available, &capture);
|
||||||
|
if (capture.acquired) {
|
||||||
|
return core_util_atomic_load_s32(&_count) + 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Semaphore::acquire()
|
void Semaphore::acquire()
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
osStatus_t status = osSemaphoreAcquire(_id, osWaitForever);
|
osStatus_t status = osSemaphoreAcquire(_id, osWaitForever);
|
||||||
if (status != osOK) {
|
if (status != osOK) {
|
||||||
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_SEMAPHORE_LOCK_FAILED), "Semaphore acquire failed", status);
|
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_SEMAPHORE_LOCK_FAILED), "Semaphore acquire failed", status);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
sem_wait_capture capture = { this, false };
|
||||||
|
mbed::internal::do_untimed_sleep(semaphore_available, &capture);
|
||||||
|
if (!capture.acquired) {
|
||||||
|
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_SEMAPHORE_LOCK_FAILED), "Semaphore acquire failed");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Semaphore::try_acquire_for(uint32_t millisec)
|
bool Semaphore::try_acquire_for(uint32_t millisec)
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
osStatus_t status = osSemaphoreAcquire(_id, millisec);
|
osStatus_t status = osSemaphoreAcquire(_id, millisec);
|
||||||
if (status == osOK) {
|
if (status == osOK) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -113,10 +174,16 @@ bool Semaphore::try_acquire_for(uint32_t millisec)
|
||||||
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_SEMAPHORE_LOCK_FAILED), "Semaphore acquire failed", status);
|
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_SEMAPHORE_LOCK_FAILED), "Semaphore acquire failed", status);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
#else
|
||||||
|
sem_wait_capture capture = { this, false };
|
||||||
|
mbed::internal::do_timed_sleep_relative_or_forever(millisec, semaphore_available, &capture);
|
||||||
|
return capture.acquired;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Semaphore::try_acquire_until(uint64_t millisec)
|
bool Semaphore::try_acquire_until(uint64_t millisec)
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
uint64_t now = Kernel::get_ms_count();
|
uint64_t now = Kernel::get_ms_count();
|
||||||
|
|
||||||
if (now >= millisec) {
|
if (now >= millisec) {
|
||||||
|
@ -127,16 +194,33 @@ bool Semaphore::try_acquire_until(uint64_t millisec)
|
||||||
} else {
|
} else {
|
||||||
return try_acquire_for(millisec - now);
|
return try_acquire_for(millisec - now);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
sem_wait_capture capture = { this, false };
|
||||||
|
mbed::internal::do_timed_sleep_absolute(millisec, semaphore_available, &capture);
|
||||||
|
return capture.acquired;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
osStatus Semaphore::release(void)
|
osStatus Semaphore::release(void)
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
return osSemaphoreRelease(_id);
|
return osSemaphoreRelease(_id);
|
||||||
|
#else
|
||||||
|
int32_t old_count = core_util_atomic_load_s32(&_count);
|
||||||
|
do {
|
||||||
|
if (old_count == _max_count) {
|
||||||
|
return osErrorResource;
|
||||||
|
}
|
||||||
|
} while (!core_util_atomic_cas_s32(&_count, &old_count, old_count + 1));
|
||||||
|
#endif
|
||||||
|
return osOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Semaphore::~Semaphore()
|
Semaphore::~Semaphore()
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
osSemaphoreDelete(_id);
|
osSemaphoreDelete(_id);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
#define SEMAPHORE_H
|
#define SEMAPHORE_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "cmsis_os2.h"
|
#include "rtos/mbed_rtos_types.h"
|
||||||
#include "mbed_rtos1_types.h"
|
#include "rtos/mbed_rtos1_types.h"
|
||||||
#include "mbed_rtos_storage.h"
|
#include "rtos/mbed_rtos_storage.h"
|
||||||
#include "platform/mbed_toolchain.h"
|
#include "platform/mbed_toolchain.h"
|
||||||
#include "platform/NonCopyable.h"
|
#include "platform/NonCopyable.h"
|
||||||
|
|
||||||
|
@ -141,10 +141,16 @@ public:
|
||||||
private:
|
private:
|
||||||
void constructor(int32_t count, uint16_t max_count);
|
void constructor(int32_t count, uint16_t max_count);
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
int32_t _wait(uint32_t millisec);
|
int32_t _wait(uint32_t millisec);
|
||||||
|
|
||||||
osSemaphoreId_t _id;
|
osSemaphoreId_t _id;
|
||||||
mbed_rtos_storage_semaphore_t _obj_mem;
|
mbed_rtos_storage_semaphore_t _obj_mem;
|
||||||
|
#else
|
||||||
|
static bool semaphore_available(void *);
|
||||||
|
int32_t _count;
|
||||||
|
uint16_t _max_count;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
/** @}*/
|
/** @}*/
|
||||||
/** @}*/
|
/** @}*/
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
{
|
||||||
|
"name": "rtos",
|
||||||
|
"config": {
|
||||||
|
"present": 1,
|
||||||
|
"main-thread-stack-size": {
|
||||||
|
"help": "The size of the main thread's stack",
|
||||||
|
"value": 4096
|
||||||
|
},
|
||||||
|
"timer-thread-stack-size": {
|
||||||
|
"help": "The size of the timer thread's stack",
|
||||||
|
"value": 768
|
||||||
|
},
|
||||||
|
"idle-thread-stack-size": {
|
||||||
|
"help": "The size of the idle thread's stack",
|
||||||
|
"value": 512
|
||||||
|
},
|
||||||
|
"thread-stack-size": {
|
||||||
|
"help": "The default stack size of new threads",
|
||||||
|
"value": 4096
|
||||||
|
},
|
||||||
|
"idle-thread-stack-size-tickless-extra": {
|
||||||
|
"help": "Additional size to add to the idle thread when a specific target or application implementation requires it or in case tickless is enabled and LPTICKER_DELAY_TICKS is used",
|
||||||
|
"value": 256
|
||||||
|
},
|
||||||
|
"idle-thread-stack-size-debug-extra": {
|
||||||
|
"help": "Additional size to add to the idle thread when code compilation optimisation is disabled",
|
||||||
|
"value": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"macros": ["_RTE_"],
|
||||||
|
"target_overrides": {
|
||||||
|
"*": {
|
||||||
|
"target.boot-stack-size": "0x400"
|
||||||
|
},
|
||||||
|
"STM": {
|
||||||
|
"idle-thread-stack-size-debug-extra": 128
|
||||||
|
},
|
||||||
|
"STM32L1": {
|
||||||
|
"idle-thread-stack-size-debug-extra": 512
|
||||||
|
},
|
||||||
|
"MCU_NRF51": {
|
||||||
|
"target.boot-stack-size": "0x800"
|
||||||
|
},
|
||||||
|
"MCU_NRF52840": {
|
||||||
|
"target.boot-stack-size": "0x800"
|
||||||
|
},
|
||||||
|
"MCU_NRF52832": {
|
||||||
|
"target.boot-stack-size": "0x800"
|
||||||
|
},
|
||||||
|
"MCU_NRF51_UNIFIED": {
|
||||||
|
"target.boot-stack-size": "0x800"
|
||||||
|
},
|
||||||
|
"NUVOTON": {
|
||||||
|
"idle-thread-stack-size-debug-extra": 512
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,28 +0,0 @@
|
||||||
/* mbed Microcontroller Library
|
|
||||||
* Copyright (c) 2006-2017 ARM Limited
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
#ifndef MBED_RTOS_RTX1_TYPES_H
|
|
||||||
#define MBED_RTOS_RTX1_TYPES_H
|
|
||||||
|
|
||||||
#include "rtx4/cmsis_os.h"
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -19,8 +19,8 @@
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#ifndef MBED_RTOS_STORAGE_H
|
#ifndef MBED_RTX_STORAGE_H
|
||||||
#define MBED_RTOS_STORAGE_H
|
#define MBED_RTX_STORAGE_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
|
@ -23,39 +23,119 @@
|
||||||
#define __STDC_LIMIT_MACROS
|
#define __STDC_LIMIT_MACROS
|
||||||
#include "rtos/ThisThread.h"
|
#include "rtos/ThisThread.h"
|
||||||
|
|
||||||
|
#include "platform/mbed_toolchain.h"
|
||||||
#include "rtos/Kernel.h"
|
#include "rtos/Kernel.h"
|
||||||
#include "rtos/rtos_idle.h"
|
#include "platform/CriticalSectionLock.h"
|
||||||
#include "platform/mbed_assert.h"
|
#include "platform/mbed_assert.h"
|
||||||
|
#include "platform/mbed_critical.h"
|
||||||
|
#include "platform/mbed_os_timer.h"
|
||||||
|
|
||||||
|
#if !MBED_CONF_RTOS_PRESENT
|
||||||
|
static uint32_t thread_flags;
|
||||||
|
|
||||||
|
/* For the flags to be useful, need a way of setting them, but there's only the main
|
||||||
|
* thread, and that has no Thread object, so Thread class is not provided. Implement
|
||||||
|
* one CMSIS-RTOS function to provide access.
|
||||||
|
*/
|
||||||
|
extern "C"
|
||||||
|
uint32_t osThreadFlagsSet(osThreadId_t /*thread_id*/, uint32_t flags)
|
||||||
|
{
|
||||||
|
return core_util_atomic_fetch_or_u32(&thread_flags, flags) | flags;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace rtos {
|
namespace rtos {
|
||||||
|
|
||||||
uint32_t ThisThread::flags_clear(uint32_t flags)
|
uint32_t ThisThread::flags_clear(uint32_t flags)
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
flags = osThreadFlagsClear(flags);
|
flags = osThreadFlagsClear(flags);
|
||||||
MBED_ASSERT(!(flags & osFlagsError));
|
MBED_ASSERT(!(flags & osFlagsError));
|
||||||
|
#else
|
||||||
|
flags = core_util_atomic_fetch_and_u32(&thread_flags, ~flags);
|
||||||
|
#endif
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ThisThread::flags_get()
|
uint32_t ThisThread::flags_get()
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
return osThreadFlagsGet();
|
return osThreadFlagsGet();
|
||||||
|
#else
|
||||||
|
return core_util_atomic_load_u32(&thread_flags);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !MBED_CONF_RTOS_PRESENT
|
||||||
|
namespace internal {
|
||||||
|
bool non_rtos_check_flags(void *handle)
|
||||||
|
{
|
||||||
|
flags_check_capture *check = static_cast<flags_check_capture *>(handle);
|
||||||
|
uint32_t cur_flags = core_util_atomic_load_u32(check->flags);
|
||||||
|
uint32_t set_flags;
|
||||||
|
do {
|
||||||
|
set_flags = cur_flags & check->flags_wanted;
|
||||||
|
check->result = set_flags;
|
||||||
|
if ((check->options & osFlagsWaitAll) ? set_flags == check->flags_wanted : set_flags != 0) {
|
||||||
|
if (check->options & osFlagsNoClear) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} while (!core_util_atomic_cas_u32(check->flags, &cur_flags, cur_flags & ~set_flags));
|
||||||
|
check->match = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static uint32_t flags_wait_for(uint32_t flags, uint32_t millisec, bool clear, uint32_t options)
|
static uint32_t flags_wait_for(uint32_t flags, uint32_t millisec, bool clear, uint32_t options)
|
||||||
{
|
{
|
||||||
if (!clear) {
|
if (!clear) {
|
||||||
options |= osFlagsNoClear;
|
options |= osFlagsNoClear;
|
||||||
}
|
}
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
flags = osThreadFlagsWait(flags, options, millisec);
|
flags = osThreadFlagsWait(flags, options, millisec);
|
||||||
if (flags & osFlagsError) {
|
if (flags & osFlagsError) {
|
||||||
MBED_ASSERT((flags == osFlagsErrorTimeout && millisec != osWaitForever) ||
|
MBED_ASSERT((flags == osFlagsErrorTimeout && millisec != osWaitForever) ||
|
||||||
(flags == osFlagsErrorResource && millisec == 0));
|
(flags == osFlagsErrorResource && millisec == 0));
|
||||||
flags = ThisThread::flags_get();
|
flags = ThisThread::flags_get();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
rtos::internal::flags_check_capture check;
|
||||||
|
check.flags = &thread_flags;
|
||||||
|
check.options = options;
|
||||||
|
check.flags_wanted = flags;
|
||||||
|
check.result = 0;
|
||||||
|
mbed::internal::do_timed_sleep_relative_or_forever(millisec, rtos::internal::non_rtos_check_flags, &check);
|
||||||
|
flags = check.result;
|
||||||
|
#endif
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t flags_wait(uint32_t flags, bool clear, uint32_t options)
|
||||||
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
|
return flags_wait_for(flags, osWaitForever, clear, options);
|
||||||
|
#else
|
||||||
|
/* Avoids pulling in timer if not used */
|
||||||
|
if (!clear) {
|
||||||
|
options |= osFlagsNoClear;
|
||||||
|
}
|
||||||
|
rtos::internal::flags_check_capture check;
|
||||||
|
check.flags = &thread_flags;
|
||||||
|
check.options = options;
|
||||||
|
check.flags_wanted = flags;
|
||||||
|
check.result = 0;
|
||||||
|
mbed::internal::do_untimed_sleep(rtos::internal::non_rtos_check_flags, &check);
|
||||||
|
flags = check.result;
|
||||||
|
|
||||||
|
return flags;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static uint32_t flags_wait_until(uint32_t flags, uint64_t millisec, bool clear, uint32_t options)
|
static uint32_t flags_wait_until(uint32_t flags, uint64_t millisec, bool clear, uint32_t options)
|
||||||
{
|
{
|
||||||
uint64_t now = Kernel::get_ms_count();
|
uint64_t now = Kernel::get_ms_count();
|
||||||
|
@ -74,7 +154,7 @@ static uint32_t flags_wait_until(uint32_t flags, uint64_t millisec, bool clear,
|
||||||
|
|
||||||
uint32_t ThisThread::flags_wait_all(uint32_t flags, bool clear)
|
uint32_t ThisThread::flags_wait_all(uint32_t flags, bool clear)
|
||||||
{
|
{
|
||||||
return flags_wait_for(flags, osWaitForever, clear, osFlagsWaitAll);
|
return flags_wait(flags, clear, osFlagsWaitAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ThisThread::flags_wait_all_for(uint32_t flags, uint32_t millisec, bool clear)
|
uint32_t ThisThread::flags_wait_all_for(uint32_t flags, uint32_t millisec, bool clear)
|
||||||
|
@ -89,7 +169,7 @@ uint32_t ThisThread::flags_wait_all_until(uint32_t flags, uint64_t millisec, boo
|
||||||
|
|
||||||
uint32_t ThisThread::flags_wait_any(uint32_t flags, bool clear)
|
uint32_t ThisThread::flags_wait_any(uint32_t flags, bool clear)
|
||||||
{
|
{
|
||||||
return flags_wait_for(flags, osWaitForever, clear, osFlagsWaitAny);
|
return flags_wait(flags, clear, osFlagsWaitAny);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ThisThread::flags_wait_any_for(uint32_t flags, uint32_t millisec, bool clear)
|
uint32_t ThisThread::flags_wait_any_for(uint32_t flags, uint32_t millisec, bool clear)
|
||||||
|
@ -104,12 +184,18 @@ uint32_t ThisThread::flags_wait_any_until(uint32_t flags, uint64_t millisec, boo
|
||||||
|
|
||||||
void ThisThread::sleep_for(uint32_t millisec)
|
void ThisThread::sleep_for(uint32_t millisec)
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
osStatus_t status = osDelay(millisec);
|
osStatus_t status = osDelay(millisec);
|
||||||
MBED_ASSERT(status == osOK);
|
MBED_ASSERT(status == osOK);
|
||||||
|
#else
|
||||||
|
// Undocumented, but osDelay(UINT32_MAX) does actually sleep forever
|
||||||
|
mbed::internal::do_timed_sleep_relative_or_forever(millisec);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThisThread::sleep_until(uint64_t millisec)
|
void ThisThread::sleep_until(uint64_t millisec)
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
// CMSIS-RTOS 2.1.0 had 64-bit time and osDelayUntil, but that's been revoked.
|
// CMSIS-RTOS 2.1.0 had 64-bit time and osDelayUntil, but that's been revoked.
|
||||||
// Limit ourselves to manual implementation assuming a >=32-bit osDelay.
|
// Limit ourselves to manual implementation assuming a >=32-bit osDelay.
|
||||||
|
|
||||||
|
@ -126,25 +212,42 @@ void ThisThread::sleep_until(uint64_t millisec)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
mbed::internal::do_timed_sleep_absolute(millisec);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThisThread::yield()
|
void ThisThread::yield()
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
osThreadYield();
|
osThreadYield();
|
||||||
|
#else
|
||||||
|
asm("yield");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
osThreadId_t ThisThread::get_id()
|
osThreadId_t ThisThread::get_id()
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
return osThreadGetId();
|
return osThreadGetId();
|
||||||
|
#else
|
||||||
|
return (osThreadId_t) 1; // dummy non-0 value
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *get_name()
|
const char *get_name()
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
osThreadId_t id = osThreadGetId();
|
osThreadId_t id = osThreadGetId();
|
||||||
if (id == NULL) {
|
if (id == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return osThreadGetName(id);
|
return osThreadGetName(id);
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,14 +23,7 @@
|
||||||
#define THIS_THREAD_H
|
#define THIS_THREAD_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "cmsis_os2.h"
|
#include "rtos/mbed_rtos_types.h"
|
||||||
#include "mbed_rtos1_types.h"
|
|
||||||
#include "mbed_rtos_storage.h"
|
|
||||||
#include "platform/Callback.h"
|
|
||||||
#include "platform/mbed_toolchain.h"
|
|
||||||
#include "platform/NonCopyable.h"
|
|
||||||
#include "rtos/Semaphore.h"
|
|
||||||
#include "rtos/Mutex.h"
|
|
||||||
|
|
||||||
namespace rtos {
|
namespace rtos {
|
||||||
/** \addtogroup rtos */
|
/** \addtogroup rtos */
|
||||||
|
@ -188,6 +181,19 @@ const char *get_name();
|
||||||
};
|
};
|
||||||
/** @}*/
|
/** @}*/
|
||||||
/** @}*/
|
/** @}*/
|
||||||
|
|
||||||
|
namespace internal {
|
||||||
|
struct flags_check_capture {
|
||||||
|
uint32_t *flags;
|
||||||
|
uint32_t options;
|
||||||
|
uint32_t flags_wanted;
|
||||||
|
uint32_t result;
|
||||||
|
bool match;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool non_rtos_check_flags(void *handle);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#include "platform/mbed_assert.h"
|
#include "platform/mbed_assert.h"
|
||||||
#include "platform/mbed_error.h"
|
#include "platform/mbed_error.h"
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
|
|
||||||
#define ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos))
|
#define ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos))
|
||||||
MBED_STATIC_ASSERT(ALIGN_UP(0, 8) == 0, "ALIGN_UP macro error");
|
MBED_STATIC_ASSERT(ALIGN_UP(0, 8) == 0, "ALIGN_UP macro error");
|
||||||
MBED_STATIC_ASSERT(ALIGN_UP(1, 8) == 8, "ALIGN_UP macro error");
|
MBED_STATIC_ASSERT(ALIGN_UP(1, 8) == 8, "ALIGN_UP macro error");
|
||||||
|
@ -432,3 +434,5 @@ void Thread::_thunk(void *thread_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -23,15 +23,17 @@
|
||||||
#define THREAD_H
|
#define THREAD_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "cmsis_os2.h"
|
#include "rtos/mbed_rtos_types.h"
|
||||||
#include "mbed_rtos1_types.h"
|
#include "rtos/mbed_rtos1_types.h"
|
||||||
#include "mbed_rtos_storage.h"
|
#include "rtos/mbed_rtos_storage.h"
|
||||||
#include "platform/Callback.h"
|
#include "platform/Callback.h"
|
||||||
#include "platform/mbed_toolchain.h"
|
#include "platform/mbed_toolchain.h"
|
||||||
#include "platform/NonCopyable.h"
|
#include "platform/NonCopyable.h"
|
||||||
#include "rtos/Semaphore.h"
|
#include "rtos/Semaphore.h"
|
||||||
#include "rtos/Mutex.h"
|
#include "rtos/Mutex.h"
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY) || defined(UNITTEST)
|
||||||
|
|
||||||
namespace rtos {
|
namespace rtos {
|
||||||
/** \addtogroup rtos */
|
/** \addtogroup rtos */
|
||||||
/** @{*/
|
/** @{*/
|
||||||
|
@ -545,4 +547,4 @@ private:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,57 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "rtos",
|
"name": "rtos-api",
|
||||||
"config": {
|
"config": {
|
||||||
"present": 1,
|
"present": 1
|
||||||
"main-thread-stack-size": {
|
}
|
||||||
"help": "The size of the main thread's stack",
|
|
||||||
"value": 4096
|
|
||||||
},
|
|
||||||
"timer-thread-stack-size": {
|
|
||||||
"help": "The size of the timer thread's stack",
|
|
||||||
"value": 768
|
|
||||||
},
|
|
||||||
"idle-thread-stack-size": {
|
|
||||||
"help": "The size of the idle thread's stack",
|
|
||||||
"value": 512
|
|
||||||
},
|
|
||||||
"thread-stack-size": {
|
|
||||||
"help": "The default stack size of new threads",
|
|
||||||
"value": 4096
|
|
||||||
},
|
|
||||||
"idle-thread-stack-size-tickless-extra": {
|
|
||||||
"help": "Additional size to add to the idle thread when a specific target or application implementation requires it or in case tickless is enabled and LPTICKER_DELAY_TICKS is used",
|
|
||||||
"value": 256
|
|
||||||
},
|
|
||||||
"idle-thread-stack-size-debug-extra": {
|
|
||||||
"help": "Additional size to add to the idle thread when code compilation optimisation is disabled",
|
|
||||||
"value": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"macros": ["_RTE_"],
|
|
||||||
"target_overrides": {
|
|
||||||
"*": {
|
|
||||||
"target.boot-stack-size": "0x400"
|
|
||||||
},
|
|
||||||
"STM": {
|
|
||||||
"idle-thread-stack-size-debug-extra": 128
|
|
||||||
},
|
|
||||||
"STM32L1": {
|
|
||||||
"idle-thread-stack-size-debug-extra": 512
|
|
||||||
},
|
|
||||||
"MCU_NRF51": {
|
|
||||||
"target.boot-stack-size": "0x800"
|
|
||||||
},
|
|
||||||
"MCU_NRF52840": {
|
|
||||||
"target.boot-stack-size": "0x800"
|
|
||||||
},
|
|
||||||
"MCU_NRF52832": {
|
|
||||||
"target.boot-stack-size": "0x800"
|
|
||||||
},
|
|
||||||
"MCU_NRF51_UNIFIED": {
|
|
||||||
"target.boot-stack-size": "0x800"
|
|
||||||
},
|
|
||||||
"NUVOTON": {
|
|
||||||
"idle-thread-stack-size-debug-extra": 512
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
/* mbed Microcontroller Library
|
||||||
|
* Copyright (c) 2006-2019 ARM Limited
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef MBED_RTOS_RTX1_TYPES_H
|
||||||
|
#define MBED_RTOS_RTX1_TYPES_H
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT || defined(UNITTEST)
|
||||||
|
|
||||||
|
#include "cmsis_os.h"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
typedef int32_t osStatus;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,28 @@
|
||||||
|
/* mbed Microcontroller Library
|
||||||
|
* Copyright (c) 2006-2019 ARM Limited
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef MBED_RTOS_STORAGE_H
|
||||||
|
#define MBED_RTOS_STORAGE_H
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT || defined(UNITTEST)
|
||||||
|
|
||||||
|
#include "mbed_rtx_storage.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @}*/
|
|
@ -0,0 +1,76 @@
|
||||||
|
/* mbed Microcontroller Library
|
||||||
|
* Copyright (c) 2006-2019, ARM Limited, All Rights Reserved
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef RTOS_TYPES_H_
|
||||||
|
#define RTOS_TYPES_H_
|
||||||
|
|
||||||
|
#if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY) || defined(UNITTEST)
|
||||||
|
#include "cmsis_os2.h"
|
||||||
|
#else
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Minimal definitions for bare metal form of RTOS */
|
||||||
|
|
||||||
|
// Timeout value.
|
||||||
|
#define osWaitForever 0xFFFFFFFFU ///< Wait forever timeout value.
|
||||||
|
|
||||||
|
// Flags options (\ref osThreadFlagsWait and \ref osEventFlagsWait).
|
||||||
|
#define osFlagsWaitAny 0x00000000U ///< Wait for any flag (default).
|
||||||
|
#define osFlagsWaitAll 0x00000001U ///< Wait for all flags.
|
||||||
|
#define osFlagsNoClear 0x00000002U ///< Do not clear flags which have been specified to wait for.
|
||||||
|
|
||||||
|
// Flags errors (returned by osThreadFlagsXxxx and osEventFlagsXxxx).
|
||||||
|
#define osFlagsError 0x80000000U ///< Error indicator.
|
||||||
|
#define osFlagsErrorUnknown 0xFFFFFFFFU ///< osError (-1).
|
||||||
|
#define osFlagsErrorTimeout 0xFFFFFFFEU ///< osErrorTimeout (-2).
|
||||||
|
#define osFlagsErrorResource 0xFFFFFFFDU ///< osErrorResource (-3).
|
||||||
|
#define osFlagsErrorParameter 0xFFFFFFFCU ///< osErrorParameter (-4).
|
||||||
|
#define osFlagsErrorISR 0xFFFFFFFAU ///< osErrorISR (-6).
|
||||||
|
|
||||||
|
// Status code values returned by CMSIS-RTOS functions.
|
||||||
|
typedef enum {
|
||||||
|
osOK = 0, ///< Operation completed successfully.
|
||||||
|
osError = -1, ///< Unspecified RTOS error: run-time error but no other error message fits.
|
||||||
|
osErrorTimeout = -2, ///< Operation not completed within the timeout period.
|
||||||
|
osErrorResource = -3, ///< Resource not available.
|
||||||
|
osErrorParameter = -4, ///< Parameter error.
|
||||||
|
osErrorNoMemory = -5, ///< System is out of memory: it was impossible to allocate or reserve memory for the operation.
|
||||||
|
osErrorISR = -6, ///< Not allowed in ISR context: the function cannot be called from interrupt service routines.
|
||||||
|
osStatusReserved = 0x7FFFFFFF ///< Prevents enum down-size compiler optimization.
|
||||||
|
} osStatus_t;
|
||||||
|
|
||||||
|
|
||||||
|
// \details Thread ID identifies the thread.
|
||||||
|
typedef void *osThreadId_t;
|
||||||
|
|
||||||
|
// Set the specified Thread Flags of a thread.
|
||||||
|
// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
|
||||||
|
// \param[in] flags specifies the flags of the thread that shall be set.
|
||||||
|
// \return thread flags after setting or error code if highest bit set.
|
||||||
|
uint32_t osThreadFlagsSet(osThreadId_t thread_id, uint32_t flags);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* RTOS_TYPES_H_ */
|
|
@ -25,7 +25,7 @@
|
||||||
#ifndef RTOS_H
|
#ifndef RTOS_H
|
||||||
#define RTOS_H
|
#define RTOS_H
|
||||||
|
|
||||||
#include "mbed_rtos_storage.h"
|
#include "rtos/mbed_rtos_storage.h"
|
||||||
#include "rtos/Kernel.h"
|
#include "rtos/Kernel.h"
|
||||||
#include "rtos/Thread.h"
|
#include "rtos/Thread.h"
|
||||||
#include "rtos/ThisThread.h"
|
#include "rtos/ThisThread.h"
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#ifndef RTOS_HANDLERS_H
|
#ifndef RTOS_HANDLERS_H
|
||||||
#define RTOS_HANDLERS_H
|
#define RTOS_HANDLERS_H
|
||||||
|
|
||||||
#include "cmsis_os2.h"
|
#include "rtos/mbed_rtos_types.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
Loading…
Reference in New Issue