rtos: fix astyle

pull/8365/head
Martin Kojtal 2018-10-09 14:59:02 -05:00
parent 140f3e20d6
commit e7acdc4cc8
10 changed files with 88 additions and 56 deletions

View File

@ -67,7 +67,8 @@ public:
* *
* @note You may call this function from ISR context. * @note You may call this function from ISR context.
*/ */
bool empty() const { bool empty() const
{
return _queue.empty(); return _queue.empty();
} }
@ -77,7 +78,8 @@ public:
* *
* @note You may call this function from ISR context. * @note You may call this function from ISR context.
*/ */
bool full() const { bool full() const
{
return _queue.full(); 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. @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(); 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. @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(); return _pool.calloc();
} }
@ -107,7 +111,8 @@ public:
@note You may call this function from ISR context. @note You may call this function from ISR context.
*/ */
osStatus put(T *mptr) { osStatus put(T *mptr)
{
return _queue.put(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. @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); osEvent evt = _queue.get(millisec);
if (evt.status == osEventMessage) { if (evt.status == osEventMessage) {
evt.status = osEventMail; evt.status = osEventMail;
@ -131,7 +137,8 @@ public:
@note You may call this function from ISR context. @note You may call this function from ISR context.
*/ */
osStatus free(T *mptr) { osStatus free(T *mptr)
{
return _pool.free(mptr); return _pool.free(mptr);
} }

View File

@ -54,7 +54,8 @@ public:
* *
* @note You cannot call this function from ISR context. * @note You cannot call this function from ISR context.
*/ */
MemoryPool() { MemoryPool()
{
memset(_pool_mem, 0, sizeof(_pool_mem)); memset(_pool_mem, 0, sizeof(_pool_mem));
memset(&_obj_mem, 0, sizeof(_obj_mem)); memset(&_obj_mem, 0, sizeof(_obj_mem));
osMemoryPoolAttr_t attr = { 0 }; osMemoryPoolAttr_t attr = { 0 };
@ -70,7 +71,8 @@ public:
* *
* @note You cannot call this function from ISR context. * @note You cannot call this function from ISR context.
*/ */
~MemoryPool() { ~MemoryPool()
{
osMemoryPoolDelete(_id); osMemoryPoolDelete(_id);
} }
@ -79,7 +81,8 @@ public:
@note You may call this function from ISR context. @note You may call this function from ISR context.
*/ */
T* alloc(void) { T *alloc(void)
{
return (T *)osMemoryPoolAlloc(_id, 0); return (T *)osMemoryPoolAlloc(_id, 0);
} }
@ -88,7 +91,8 @@ public:
@note You may call this function from ISR context. @note You may call this function from ISR context.
*/ */
T* calloc(void) { T *calloc(void)
{
T *item = (T *)osMemoryPoolAlloc(_id, 0); T *item = (T *)osMemoryPoolAlloc(_id, 0);
if (item != NULL) { if (item != NULL) {
memset(item, 0, sizeof(T)); memset(item, 0, sizeof(T));
@ -104,7 +108,8 @@ public:
@note You may call this function from ISR context. @note You may call this function from ISR context.
*/ */
osStatus free(T *block) { osStatus free(T *block)
{
return osMemoryPoolFree(_id, (void *)block); return osMemoryPoolFree(_id, (void *)block);
} }

View File

@ -56,7 +56,8 @@ public:
* *
* @note You cannot call this function from ISR context. * @note You cannot call this function from ISR context.
*/ */
Queue() { Queue()
{
memset(&_obj_mem, 0, sizeof(_obj_mem)); memset(&_obj_mem, 0, sizeof(_obj_mem));
osMessageQueueAttr_t attr = { 0 }; osMessageQueueAttr_t attr = { 0 };
attr.mq_mem = _queue_mem; attr.mq_mem = _queue_mem;
@ -70,7 +71,8 @@ public:
* *
* @note You cannot call this function from ISR context. * @note You cannot call this function from ISR context.
*/ */
~Queue() { ~Queue()
{
osMessageQueueDelete(_id); osMessageQueueDelete(_id);
} }
@ -80,7 +82,8 @@ public:
* *
* @note You may call this function from ISR context. * @note You may call this function from ISR context.
*/ */
bool empty() const { bool empty() const
{
return osMessageQueueGetCount(_id) == 0; return osMessageQueueGetCount(_id) == 0;
} }
@ -90,7 +93,8 @@ public:
* *
* @note You may call this function from ISR context. * @note You may call this function from ISR context.
*/ */
bool full() const { bool full() const
{
return osMessageQueueGetSpace(_id) == 0; 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. @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); 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. @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; osEvent event;
T *data = NULL; T *data = NULL;
osStatus_t res = osMessageQueueGet(_id, &data, NULL, millisec); osStatus_t res = osMessageQueueGet(_id, &data, NULL, millisec);

View File

@ -28,7 +28,8 @@
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)
{
_function = func; _function = func;
memset(&_obj_mem, 0, sizeof(_obj_mem)); memset(&_obj_mem, 0, sizeof(_obj_mem));
osTimerAttr_t attr = { 0 }; osTimerAttr_t attr = { 0 };
@ -38,15 +39,18 @@ void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type) {
MBED_ASSERT(_id); MBED_ASSERT(_id);
} }
osStatus RtosTimer::start(uint32_t millisec) { osStatus RtosTimer::start(uint32_t millisec)
{
return osTimerStart(_id, millisec); return osTimerStart(_id, millisec);
} }
osStatus RtosTimer::stop(void) { osStatus RtosTimer::stop(void)
{
return osTimerStop(_id); return osTimerStop(_id);
} }
RtosTimer::~RtosTimer() { RtosTimer::~RtosTimer()
{
osTimerDelete(_id); osTimerDelete(_id);
} }

View File

@ -100,7 +100,8 @@ public:
"Replaced with RtosTimer(Callback<void()>, os_timer_type)") "Replaced with RtosTimer(Callback<void()>, os_timer_type)")
MBED_DEPRECATED_SINCE("mbed-os-5.2", MBED_DEPRECATED_SINCE("mbed-os-5.2",
"The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details") "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) { RtosTimer(void (*func)(void const *argument), os_timer_type type = osTimerPeriodic, void *argument = NULL)
{
constructor(mbed::callback((void (*)(void *))func, argument), type); constructor(mbed::callback((void (*)(void *))func, argument), type);
} }
@ -114,7 +115,8 @@ public:
*/ */
MBED_DEPRECATED_SINCE("mbed-os-5.2", MBED_DEPRECATED_SINCE("mbed-os-5.2",
"The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details") "The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details")
RtosTimer(mbed::Callback<void()> func, os_timer_type type=osTimerPeriodic) { RtosTimer(mbed::Callback<void()> func, os_timer_type type = osTimerPeriodic)
{
constructor(func, type); constructor(func, type);
} }
@ -136,7 +138,8 @@ public:
"RtosTimer(callback(obj, method), os_timer_type).") "RtosTimer(callback(obj, method), os_timer_type).")
MBED_DEPRECATED_SINCE("mbed-os-5.2", MBED_DEPRECATED_SINCE("mbed-os-5.2",
"The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details") "The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details")
RtosTimer(T *obj, M method, os_timer_type type=osTimerPeriodic) { RtosTimer(T *obj, M method, os_timer_type type = osTimerPeriodic)
{
constructor(mbed::callback(obj, method), type); constructor(mbed::callback(obj, method), type);
} }

View File

@ -27,15 +27,18 @@
namespace rtos { namespace rtos {
Semaphore::Semaphore(int32_t count) { Semaphore::Semaphore(int32_t count)
{
constructor(count, 0xffff); 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); 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)); memset(&_obj_mem, 0, sizeof(_obj_mem));
osSemaphoreAttr_t attr = { 0 }; osSemaphoreAttr_t attr = { 0 };
attr.cb_mem = &_obj_mem; attr.cb_mem = &_obj_mem;
@ -44,7 +47,8 @@ void Semaphore::constructor(int32_t count, uint16_t max_count) {
MBED_ASSERT(_id != NULL); MBED_ASSERT(_id != NULL);
} }
int32_t Semaphore::wait(uint32_t millisec) { int32_t Semaphore::wait(uint32_t millisec)
{
osStatus_t stat = osSemaphoreAcquire(_id, millisec); osStatus_t stat = osSemaphoreAcquire(_id, millisec);
switch (stat) { switch (stat) {
case osOK: 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(); uint64_t now = Kernel::get_ms_count();
if (now >= millisec) { 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); return osSemaphoreRelease(_id);
} }
Semaphore::~Semaphore() { Semaphore::~Semaphore()
{
osSemaphoreDelete(_id); osSemaphoreDelete(_id);
} }