mirror of https://github.com/ARMmbed/mbed-os.git
commit
124480213c
|
@ -51,7 +51,7 @@ extern "C" {
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#elif defined(EQUEUE_PLATFORM_MBED)
|
#elif defined(EQUEUE_PLATFORM_MBED)
|
||||||
#include "cmsis_os2.h"
|
#include "cmsis_os2.h"
|
||||||
#include "rtx_lib.h"
|
#include "mbed_rtos_storage.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ typedef struct equeue_sema {
|
||||||
#elif defined(EQUEUE_PLATFORM_MBED) && defined(MBED_CONF_RTOS_PRESENT)
|
#elif defined(EQUEUE_PLATFORM_MBED) && defined(MBED_CONF_RTOS_PRESENT)
|
||||||
typedef struct equeue_sema {
|
typedef struct equeue_sema {
|
||||||
osEventFlagsId_t id;
|
osEventFlagsId_t id;
|
||||||
os_event_flags_t mem;
|
mbed_rtos_storage_event_flags_t mem;
|
||||||
} equeue_sema_t;
|
} equeue_sema_t;
|
||||||
#elif defined(EQUEUE_PLATFORM_MBED)
|
#elif defined(EQUEUE_PLATFORM_MBED)
|
||||||
typedef volatile int equeue_sema_t;
|
typedef volatile int equeue_sema_t;
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include "Queue.h"
|
#include "Queue.h"
|
||||||
#include "MemoryPool.h"
|
#include "MemoryPool.h"
|
||||||
#include "cmsis_os2.h"
|
#include "cmsis_os2.h"
|
||||||
#include "rtx_lib.h"
|
#include "mbed_rtos_storage.h"
|
||||||
#include "mbed_rtos1_types.h"
|
#include "mbed_rtos1_types.h"
|
||||||
|
|
||||||
#include "platform/NonCopyable.h"
|
#include "platform/NonCopyable.h"
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "cmsis_os2.h"
|
#include "cmsis_os2.h"
|
||||||
#include "rtx_lib.h"
|
#include "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"
|
||||||
|
@ -150,7 +150,7 @@ private:
|
||||||
|
|
||||||
osTimerId_t _id;
|
osTimerId_t _id;
|
||||||
osTimerAttr_t _attr;
|
osTimerAttr_t _attr;
|
||||||
os_timer_t _obj_mem;
|
mbed_rtos_storage_timer_t _obj_mem;
|
||||||
mbed::Callback<void()> _function;
|
mbed::Callback<void()> _function;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "rtx_lib.h"
|
#include "rtx_lib.h"
|
||||||
|
#include "mbed_rtx_conf.h"
|
||||||
|
|
||||||
typedef os_mutex_t mbed_rtos_storage_mutex_t;
|
typedef os_mutex_t mbed_rtos_storage_mutex_t;
|
||||||
typedef os_semaphore_t mbed_rtos_storage_semaphore_t;
|
typedef os_semaphore_t mbed_rtos_storage_semaphore_t;
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
|
|
||||||
#include "mbed_rtx.h"
|
#include "mbed_rtx.h"
|
||||||
|
|
||||||
|
/** Any access to RTX5 specific data structures used in common code should be wrapped in ifdef MBED_OS_BACKEND_RTX5 */
|
||||||
|
#define MBED_OS_BACKEND_RTX5
|
||||||
|
|
||||||
/** The thread's stack size can be configured by the application, if not explicitly specified it'll default to 4K */
|
/** The thread's stack size can be configured by the application, if not explicitly specified it'll default to 4K */
|
||||||
#ifndef MBED_CONF_APP_THREAD_STACK_SIZE
|
#ifndef MBED_CONF_APP_THREAD_STACK_SIZE
|
||||||
#define MBED_CONF_APP_THREAD_STACK_SIZE 4096
|
#define MBED_CONF_APP_THREAD_STACK_SIZE 4096
|
||||||
|
|
|
@ -168,7 +168,11 @@ Thread::State Thread::get_state() {
|
||||||
_mutex.lock();
|
_mutex.lock();
|
||||||
|
|
||||||
if (_tid != NULL) {
|
if (_tid != NULL) {
|
||||||
|
#if defined(MBED_OS_BACKEND_RTX5)
|
||||||
state = _obj_mem.state;
|
state = _obj_mem.state;
|
||||||
|
#else
|
||||||
|
state = osThreadGetState(_tid);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
_mutex.unlock();
|
_mutex.unlock();
|
||||||
|
@ -185,6 +189,7 @@ Thread::State Thread::get_state() {
|
||||||
case osThreadRunning:
|
case osThreadRunning:
|
||||||
user_state = Running;
|
user_state = Running;
|
||||||
break;
|
break;
|
||||||
|
#if defined(MBED_OS_BACKEND_RTX5)
|
||||||
case osRtxThreadWaitingDelay:
|
case osRtxThreadWaitingDelay:
|
||||||
user_state = WaitingDelay;
|
user_state = WaitingDelay;
|
||||||
break;
|
break;
|
||||||
|
@ -212,6 +217,7 @@ Thread::State Thread::get_state() {
|
||||||
case osRtxThreadWaitingMessagePut:
|
case osRtxThreadWaitingMessagePut:
|
||||||
user_state = WaitingMessagePut;
|
user_state = WaitingMessagePut;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case osThreadTerminated:
|
case osThreadTerminated:
|
||||||
default:
|
default:
|
||||||
user_state = Deleted;
|
user_state = Deleted;
|
||||||
|
@ -226,8 +232,7 @@ uint32_t Thread::stack_size() {
|
||||||
_mutex.lock();
|
_mutex.lock();
|
||||||
|
|
||||||
if (_tid != NULL) {
|
if (_tid != NULL) {
|
||||||
os_thread_t *thread = (os_thread_t *)_tid;
|
size = osThreadGetStackSize(_tid);
|
||||||
size = thread->stack_size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_mutex.unlock();
|
_mutex.unlock();
|
||||||
|
@ -238,10 +243,12 @@ uint32_t Thread::free_stack() {
|
||||||
uint32_t size = 0;
|
uint32_t size = 0;
|
||||||
_mutex.lock();
|
_mutex.lock();
|
||||||
|
|
||||||
|
#if defined(MBED_OS_BACKEND_RTX5)
|
||||||
if (_tid != NULL) {
|
if (_tid != NULL) {
|
||||||
os_thread_t *thread = (os_thread_t *)_tid;
|
os_thread_t *thread = (os_thread_t *)_tid;
|
||||||
size = (uint32_t)thread->sp - (uint32_t)thread->stack_mem;
|
size = (uint32_t)thread->sp - (uint32_t)thread->stack_mem;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
_mutex.unlock();
|
_mutex.unlock();
|
||||||
return size;
|
return size;
|
||||||
|
@ -251,10 +258,12 @@ uint32_t Thread::used_stack() {
|
||||||
uint32_t size = 0;
|
uint32_t size = 0;
|
||||||
_mutex.lock();
|
_mutex.lock();
|
||||||
|
|
||||||
|
#if defined(MBED_OS_BACKEND_RTX5)
|
||||||
if (_tid != NULL) {
|
if (_tid != NULL) {
|
||||||
os_thread_t *thread = (os_thread_t *)_tid;
|
os_thread_t *thread = (os_thread_t *)_tid;
|
||||||
size = ((uint32_t)thread->stack_mem + thread->stack_size) - thread->sp;
|
size = ((uint32_t)thread->stack_mem + thread->stack_size) - thread->sp;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
_mutex.unlock();
|
_mutex.unlock();
|
||||||
return size;
|
return size;
|
||||||
|
@ -265,11 +274,15 @@ uint32_t Thread::max_stack() {
|
||||||
_mutex.lock();
|
_mutex.lock();
|
||||||
|
|
||||||
if (_tid != NULL) {
|
if (_tid != NULL) {
|
||||||
|
#if defined(MBED_OS_BACKEND_RTX5)
|
||||||
os_thread_t *thread = (os_thread_t *)_tid;
|
os_thread_t *thread = (os_thread_t *)_tid;
|
||||||
uint32_t high_mark = 0;
|
uint32_t high_mark = 0;
|
||||||
while (((uint32_t *)(thread->stack_mem))[high_mark] == 0xE25A2EA5)
|
while (((uint32_t *)(thread->stack_mem))[high_mark] == 0xE25A2EA5)
|
||||||
high_mark++;
|
high_mark++;
|
||||||
size = thread->stack_size - (high_mark * sizeof(uint32_t));
|
size = thread->stack_size - (high_mark * sizeof(uint32_t));
|
||||||
|
#else
|
||||||
|
size = osThreadGetStackSize(_tid) - osThreadGetStackSpace(_tid);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
_mutex.unlock();
|
_mutex.unlock();
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "cmsis_os2.h"
|
#include "cmsis_os2.h"
|
||||||
#include "mbed_rtos1_types.h"
|
#include "mbed_rtos1_types.h"
|
||||||
#include "mbed_rtos_storage.h"
|
#include "mbed_rtos_storage.h"
|
||||||
#include "mbed_rtx_conf.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"
|
||||||
|
|
|
@ -25,8 +25,6 @@
|
||||||
#ifndef RTOS_H
|
#ifndef RTOS_H
|
||||||
#define RTOS_H
|
#define RTOS_H
|
||||||
|
|
||||||
#include "mbed_rtx.h"
|
|
||||||
#include "mbed_rtx_conf.h"
|
|
||||||
#include "mbed_rtos_storage.h"
|
#include "mbed_rtos_storage.h"
|
||||||
#include "rtos/Thread.h"
|
#include "rtos/Thread.h"
|
||||||
#include "rtos/Mutex.h"
|
#include "rtos/Mutex.h"
|
||||||
|
|
Loading…
Reference in New Issue