mirror of https://github.com/ARMmbed/mbed-os.git
rtos: fix astyle
parent
140f3e20d6
commit
e7acdc4cc8
|
@ -36,10 +36,10 @@ namespace rtos {
|
|||
* \defgroup rtos_EventFlags EventFlags class
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** The EventFlags class is used to control event flags or wait for event flags other threads control.
|
||||
|
||||
@note
|
||||
@note
|
||||
EventFlags support 31 flags. The MSB flag is ignored. It is used to return an error code (@a osFlagsError).
|
||||
|
||||
@note
|
||||
|
|
23
rtos/Mail.h
23
rtos/Mail.h
|
@ -42,7 +42,7 @@ namespace rtos {
|
|||
* \defgroup rtos_Mail Mail class
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** The Mail class allow to control, send, receive, or wait for mail.
|
||||
A mail is a memory block that is send to a thread or interrupt service routine.
|
||||
@tparam T data type of a single message element.
|
||||
|
@ -67,7 +67,8 @@ public:
|
|||
*
|
||||
* @note You may call this function from ISR context.
|
||||
*/
|
||||
bool empty() const {
|
||||
bool empty() const
|
||||
{
|
||||
return _queue.empty();
|
||||
}
|
||||
|
||||
|
@ -77,7 +78,8 @@ public:
|
|||
*
|
||||
* @note You may call this function from ISR context.
|
||||
*/
|
||||
bool full() const {
|
||||
bool full() const
|
||||
{
|
||||
return _queue.full();
|
||||
}
|
||||
|
||||
|
@ -87,7 +89,8 @@ public:
|
|||
|
||||
@note You may call this function from ISR context if the millisec parameter is set to 0.
|
||||
*/
|
||||
T* alloc(uint32_t millisec=0) {
|
||||
T *alloc(uint32_t millisec = 0)
|
||||
{
|
||||
return _pool.alloc();
|
||||
}
|
||||
|
||||
|
@ -97,7 +100,8 @@ public:
|
|||
|
||||
@note You may call this function from ISR context if the millisec parameter is set to 0.
|
||||
*/
|
||||
T* calloc(uint32_t millisec=0) {
|
||||
T *calloc(uint32_t millisec = 0)
|
||||
{
|
||||
return _pool.calloc();
|
||||
}
|
||||
|
||||
|
@ -107,7 +111,8 @@ public:
|
|||
|
||||
@note You may call this function from ISR context.
|
||||
*/
|
||||
osStatus put(T *mptr) {
|
||||
osStatus put(T *mptr)
|
||||
{
|
||||
return _queue.put(mptr);
|
||||
}
|
||||
|
||||
|
@ -117,7 +122,8 @@ public:
|
|||
|
||||
@note You may call this function from ISR context if the millisec parameter is set to 0.
|
||||
*/
|
||||
osEvent get(uint32_t millisec=osWaitForever) {
|
||||
osEvent get(uint32_t millisec = osWaitForever)
|
||||
{
|
||||
osEvent evt = _queue.get(millisec);
|
||||
if (evt.status == osEventMessage) {
|
||||
evt.status = osEventMail;
|
||||
|
@ -131,7 +137,8 @@ public:
|
|||
|
||||
@note You may call this function from ISR context.
|
||||
*/
|
||||
osStatus free(T *mptr) {
|
||||
osStatus free(T *mptr)
|
||||
{
|
||||
return _pool.free(mptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace rtos {
|
|||
* \defgroup rtos_MemoryPool MemoryPool class
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** Define and manage fixed-size memory pools of objects of a given type.
|
||||
@tparam T data type of a single object (element).
|
||||
@tparam queue_sz maximum number of objects (elements) in the memory pool.
|
||||
|
@ -48,13 +48,14 @@ namespace rtos {
|
|||
*/
|
||||
template<typename T, uint32_t pool_sz>
|
||||
class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
|
||||
MBED_STATIC_ASSERT(pool_sz > 0, "Invalid memory pool size. Must be greater than 0.");
|
||||
MBED_STATIC_ASSERT(pool_sz > 0, "Invalid memory pool size. Must be greater than 0.");
|
||||
public:
|
||||
/** Create and Initialize a memory pool.
|
||||
*
|
||||
* @note You cannot call this function from ISR context.
|
||||
*/
|
||||
MemoryPool() {
|
||||
MemoryPool()
|
||||
{
|
||||
memset(_pool_mem, 0, sizeof(_pool_mem));
|
||||
memset(&_obj_mem, 0, sizeof(_obj_mem));
|
||||
osMemoryPoolAttr_t attr = { 0 };
|
||||
|
@ -70,7 +71,8 @@ public:
|
|||
*
|
||||
* @note You cannot call this function from ISR context.
|
||||
*/
|
||||
~MemoryPool() {
|
||||
~MemoryPool()
|
||||
{
|
||||
osMemoryPoolDelete(_id);
|
||||
}
|
||||
|
||||
|
@ -79,8 +81,9 @@ public:
|
|||
|
||||
@note You may call this function from ISR context.
|
||||
*/
|
||||
T* alloc(void) {
|
||||
return (T*)osMemoryPoolAlloc(_id, 0);
|
||||
T *alloc(void)
|
||||
{
|
||||
return (T *)osMemoryPoolAlloc(_id, 0);
|
||||
}
|
||||
|
||||
/** Allocate a memory block of type T from a memory pool and set memory block to zero.
|
||||
|
@ -88,8 +91,9 @@ public:
|
|||
|
||||
@note You may call this function from ISR context.
|
||||
*/
|
||||
T* calloc(void) {
|
||||
T *item = (T*)osMemoryPoolAlloc(_id, 0);
|
||||
T *calloc(void)
|
||||
{
|
||||
T *item = (T *)osMemoryPoolAlloc(_id, 0);
|
||||
if (item != NULL) {
|
||||
memset(item, 0, sizeof(T));
|
||||
}
|
||||
|
@ -104,8 +108,9 @@ public:
|
|||
|
||||
@note You may call this function from ISR context.
|
||||
*/
|
||||
osStatus free(T *block) {
|
||||
return osMemoryPoolFree(_id, (void*)block);
|
||||
osStatus free(T *block)
|
||||
{
|
||||
return osMemoryPoolFree(_id, (void *)block);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -52,7 +52,7 @@ typedef mbed::ScopedLock<Mutex> ScopedMutexLock;
|
|||
* \defgroup rtos_Mutex Mutex class
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** The Mutex class is used to synchronize the execution of threads.
|
||||
This is, for example, used to protect access to a shared resource.
|
||||
|
||||
|
|
24
rtos/Queue.h
24
rtos/Queue.h
|
@ -38,7 +38,7 @@ namespace rtos {
|
|||
* \defgroup rtos_Queue Queue class
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** The Queue class allow to control, send, receive, or wait for messages.
|
||||
A message can be a integer or pointer value to a certain type T that is send
|
||||
to a thread or interrupt service routine.
|
||||
|
@ -56,21 +56,23 @@ public:
|
|||
*
|
||||
* @note You cannot call this function from ISR context.
|
||||
*/
|
||||
Queue() {
|
||||
Queue()
|
||||
{
|
||||
memset(&_obj_mem, 0, sizeof(_obj_mem));
|
||||
osMessageQueueAttr_t attr = { 0 };
|
||||
attr.mq_mem = _queue_mem;
|
||||
attr.mq_size = sizeof(_queue_mem);
|
||||
attr.cb_mem = &_obj_mem;
|
||||
attr.cb_size = sizeof(_obj_mem);
|
||||
_id = osMessageQueueNew(queue_sz, sizeof(T*), &attr);
|
||||
_id = osMessageQueueNew(queue_sz, sizeof(T *), &attr);
|
||||
MBED_ASSERT(_id);
|
||||
}
|
||||
/** Queue destructor
|
||||
*
|
||||
* @note You cannot call this function from ISR context.
|
||||
*/
|
||||
~Queue() {
|
||||
~Queue()
|
||||
{
|
||||
osMessageQueueDelete(_id);
|
||||
}
|
||||
|
||||
|
@ -80,7 +82,8 @@ public:
|
|||
*
|
||||
* @note You may call this function from ISR context.
|
||||
*/
|
||||
bool empty() const {
|
||||
bool empty() const
|
||||
{
|
||||
return osMessageQueueGetCount(_id) == 0;
|
||||
}
|
||||
|
||||
|
@ -90,7 +93,8 @@ public:
|
|||
*
|
||||
* @note You may call this function from ISR context.
|
||||
*/
|
||||
bool full() const {
|
||||
bool full() const
|
||||
{
|
||||
return osMessageQueueGetSpace(_id) == 0;
|
||||
}
|
||||
|
||||
|
@ -106,7 +110,8 @@ public:
|
|||
|
||||
@note You may call this function from ISR context if the millisec parameter is set to 0.
|
||||
*/
|
||||
osStatus put(T* data, uint32_t millisec=0, uint8_t prio=0) {
|
||||
osStatus put(T *data, uint32_t millisec = 0, uint8_t prio = 0)
|
||||
{
|
||||
return osMessageQueuePut(_id, &data, prio, millisec);
|
||||
}
|
||||
|
||||
|
@ -121,7 +126,8 @@ public:
|
|||
|
||||
@note You may call this function from ISR context if the millisec parameter is set to 0.
|
||||
*/
|
||||
osEvent get(uint32_t millisec=osWaitForever) {
|
||||
osEvent get(uint32_t millisec = osWaitForever)
|
||||
{
|
||||
osEvent event;
|
||||
T *data = NULL;
|
||||
osStatus_t res = osMessageQueueGet(_id, &data, NULL, millisec);
|
||||
|
@ -149,7 +155,7 @@ public:
|
|||
|
||||
private:
|
||||
osMessageQueueId_t _id;
|
||||
char _queue_mem[queue_sz * (sizeof(T*) + sizeof(mbed_rtos_storage_message_t))];
|
||||
char _queue_mem[queue_sz * (sizeof(T *) + sizeof(mbed_rtos_storage_message_t))];
|
||||
mbed_rtos_storage_msg_queue_t _obj_mem;
|
||||
};
|
||||
/** @}*/
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
|
||||
namespace rtos {
|
||||
|
||||
void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type) {
|
||||
void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type)
|
||||
{
|
||||
_function = func;
|
||||
memset(&_obj_mem, 0, sizeof(_obj_mem));
|
||||
osTimerAttr_t attr = { 0 };
|
||||
|
@ -38,15 +39,18 @@ void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type) {
|
|||
MBED_ASSERT(_id);
|
||||
}
|
||||
|
||||
osStatus RtosTimer::start(uint32_t millisec) {
|
||||
osStatus RtosTimer::start(uint32_t millisec)
|
||||
{
|
||||
return osTimerStart(_id, millisec);
|
||||
}
|
||||
|
||||
osStatus RtosTimer::stop(void) {
|
||||
osStatus RtosTimer::stop(void)
|
||||
{
|
||||
return osTimerStop(_id);
|
||||
}
|
||||
|
||||
RtosTimer::~RtosTimer() {
|
||||
RtosTimer::~RtosTimer()
|
||||
{
|
||||
osTimerDelete(_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace rtos {
|
|||
* \defgroup rtos_RtosTimer RtosTimer class
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** The RtosTimer class allow creating and and controlling of timer functions in the system.
|
||||
A timer function is called when a time period expires whereby both on-shot and
|
||||
periodic timers are possible. A timer can be started, restarted, or stopped.
|
||||
|
@ -97,13 +97,14 @@ public:
|
|||
@note You cannot call this function from ISR context.
|
||||
*/
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
||||
"Replaced with RtosTimer(Callback<void()>, os_timer_type)")
|
||||
"Replaced with RtosTimer(Callback<void()>, os_timer_type)")
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.2",
|
||||
"The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details")
|
||||
RtosTimer(void (*func)(void const *argument), os_timer_type type=osTimerPeriodic, void *argument=NULL) {
|
||||
"The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details")
|
||||
RtosTimer(void (*func)(void const *argument), os_timer_type type = osTimerPeriodic, void *argument = NULL)
|
||||
{
|
||||
constructor(mbed::callback((void (*)(void *))func, argument), type);
|
||||
}
|
||||
|
||||
|
||||
/** Create timer.
|
||||
@param func function to be executed by this timer.
|
||||
@param type osTimerOnce for one-shot or osTimerPeriodic for periodic behaviour. (default: osTimerPeriodic)
|
||||
|
@ -113,11 +114,12 @@ public:
|
|||
@note You cannot call this function from ISR context.
|
||||
*/
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.2",
|
||||
"The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details")
|
||||
RtosTimer(mbed::Callback<void()> func, os_timer_type type=osTimerPeriodic) {
|
||||
"The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details")
|
||||
RtosTimer(mbed::Callback<void()> func, os_timer_type type = osTimerPeriodic)
|
||||
{
|
||||
constructor(func, type);
|
||||
}
|
||||
|
||||
|
||||
/** Create timer.
|
||||
@param obj pointer to the object to call the member function on.
|
||||
@param method member function to be executed by this timer.
|
||||
|
@ -132,11 +134,12 @@ public:
|
|||
*/
|
||||
template <typename T, typename M>
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
||||
"The RtosTimer constructor does not support cv-qualifiers. Replaced by "
|
||||
"RtosTimer(callback(obj, method), os_timer_type).")
|
||||
"The RtosTimer constructor does not support cv-qualifiers. Replaced by "
|
||||
"RtosTimer(callback(obj, method), os_timer_type).")
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.2",
|
||||
"The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details")
|
||||
RtosTimer(T *obj, M method, os_timer_type type=osTimerPeriodic) {
|
||||
"The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details")
|
||||
RtosTimer(T *obj, M method, os_timer_type type = osTimerPeriodic)
|
||||
{
|
||||
constructor(mbed::callback(obj, method), type);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,15 +27,18 @@
|
|||
|
||||
namespace rtos {
|
||||
|
||||
Semaphore::Semaphore(int32_t count) {
|
||||
Semaphore::Semaphore(int32_t count)
|
||||
{
|
||||
constructor(count, 0xffff);
|
||||
}
|
||||
|
||||
Semaphore::Semaphore(int32_t count, uint16_t max_count) {
|
||||
Semaphore::Semaphore(int32_t count, uint16_t max_count)
|
||||
{
|
||||
constructor(count, max_count);
|
||||
}
|
||||
|
||||
void Semaphore::constructor(int32_t count, uint16_t max_count) {
|
||||
void Semaphore::constructor(int32_t count, uint16_t max_count)
|
||||
{
|
||||
memset(&_obj_mem, 0, sizeof(_obj_mem));
|
||||
osSemaphoreAttr_t attr = { 0 };
|
||||
attr.cb_mem = &_obj_mem;
|
||||
|
@ -44,7 +47,8 @@ void Semaphore::constructor(int32_t count, uint16_t max_count) {
|
|||
MBED_ASSERT(_id != NULL);
|
||||
}
|
||||
|
||||
int32_t Semaphore::wait(uint32_t millisec) {
|
||||
int32_t Semaphore::wait(uint32_t millisec)
|
||||
{
|
||||
osStatus_t stat = osSemaphoreAcquire(_id, millisec);
|
||||
switch (stat) {
|
||||
case osOK:
|
||||
|
@ -58,7 +62,8 @@ int32_t Semaphore::wait(uint32_t millisec) {
|
|||
}
|
||||
}
|
||||
|
||||
int32_t Semaphore::wait_until(uint64_t millisec) {
|
||||
int32_t Semaphore::wait_until(uint64_t millisec)
|
||||
{
|
||||
uint64_t now = Kernel::get_ms_count();
|
||||
|
||||
if (now >= millisec) {
|
||||
|
@ -71,11 +76,13 @@ int32_t Semaphore::wait_until(uint64_t millisec) {
|
|||
}
|
||||
}
|
||||
|
||||
osStatus Semaphore::release(void) {
|
||||
osStatus Semaphore::release(void)
|
||||
{
|
||||
return osSemaphoreRelease(_id);
|
||||
}
|
||||
|
||||
Semaphore::~Semaphore() {
|
||||
Semaphore::~Semaphore()
|
||||
{
|
||||
osSemaphoreDelete(_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
@note You cannot call this function from ISR context.
|
||||
*/
|
||||
Semaphore(int32_t count=0);
|
||||
Semaphore(int32_t count = 0);
|
||||
|
||||
/** Create and Initialize a Semaphore object used for managing resources.
|
||||
@param count number of available resources
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
|
||||
@note You may call this function from ISR context if the millisec parameter is set to 0.
|
||||
*/
|
||||
int32_t wait(uint32_t millisec=osWaitForever);
|
||||
int32_t wait(uint32_t millisec = osWaitForever);
|
||||
|
||||
/** Wait until a Semaphore resource becomes available.
|
||||
@param millisec absolute timeout time, referenced to Kernel::get_ms_count()
|
||||
|
|
|
@ -35,7 +35,7 @@ extern "C" {
|
|||
* \defgroup rtos_Idle Idle hook function
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
/**
|
||||
@note
|
||||
Sets the hook function called by idle task
|
||||
@param fptr Hook function pointer.
|
||||
|
|
Loading…
Reference in New Issue