Skip to content

Commit 6d8dd0c

Browse files
committed
rtos: astyle update
1 parent 5c945b3 commit 6d8dd0c

20 files changed

+474
-391
lines changed

rtos/EventFlags.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ namespace rtos {
3636
* \defgroup rtos_EventFlags EventFlags class
3737
* @{
3838
*/
39-
39+
4040
/** The EventFlags class is used to signal or wait for an arbitrary event or events.
41-
@note
41+
@note
4242
EventFlags support 31 flags so the MSB flag is ignored, it is used to return an error code (@a osFlagsError)
4343
@note
4444
Memory considerations: The EventFlags control structures will be created on current thread's stack, both for the mbed OS

rtos/Kernel.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626

2727
namespace rtos {
2828

29-
uint64_t Kernel::get_ms_count() {
29+
uint64_t Kernel::get_ms_count()
30+
{
3031
// CMSIS-RTOS 2.1.0 and 2.1.1 differ in the time type. We assume
3132
// our header at least matches the implementation, so we don't try looking
3233
// at the run-time version report. (There's no compile-time version report)
@@ -36,7 +37,7 @@ uint64_t Kernel::get_ms_count() {
3637
// 2.1.x who knows? We assume could go back to uint64_t
3738
if (sizeof osKernelGetTickCount() == sizeof(uint64_t)) {
3839
return osKernelGetTickCount();
39-
} else /* assume 32-bit */ {
40+
} else { /* assume 32-bit */
4041
// Based on suggestion in CMSIS-RTOS 2.1.1 docs, but with reentrancy
4142
// protection for the tick memory. We use critical section rather than a
4243
// mutex, as hopefully this method can be callable from interrupt later -

rtos/Mail.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace rtos {
4242
* \defgroup rtos_Mail Mail class
4343
* @{
4444
*/
45-
45+
4646
/** The Mail class allow to control, send, receive, or wait for mail.
4747
A mail is a memory block that is send to a thread or interrupt service routine.
4848
@tparam T data type of a single message element.
@@ -67,7 +67,8 @@ class Mail : private mbed::NonCopyable<Mail<T, queue_sz> > {
6767
*
6868
* @note You may call this function from ISR context.
6969
*/
70-
bool empty() const {
70+
bool empty() const
71+
{
7172
return _queue.empty();
7273
}
7374

@@ -77,7 +78,8 @@ class Mail : private mbed::NonCopyable<Mail<T, queue_sz> > {
7778
*
7879
* @note You may call this function from ISR context.
7980
*/
80-
bool full() const {
81+
bool full() const
82+
{
8183
return _queue.full();
8284
}
8385

@@ -87,7 +89,8 @@ class Mail : private mbed::NonCopyable<Mail<T, queue_sz> > {
8789
8890
@note You may call this function from ISR context if the millisec parameter is set to 0.
8991
*/
90-
T* alloc(uint32_t millisec=0) {
92+
T *alloc(uint32_t millisec = 0)
93+
{
9194
return _pool.alloc();
9295
}
9396

@@ -97,7 +100,8 @@ class Mail : private mbed::NonCopyable<Mail<T, queue_sz> > {
97100
98101
@note You may call this function from ISR context if the millisec parameter is set to 0.
99102
*/
100-
T* calloc(uint32_t millisec=0) {
103+
T *calloc(uint32_t millisec = 0)
104+
{
101105
return _pool.calloc();
102106
}
103107

@@ -107,7 +111,8 @@ class Mail : private mbed::NonCopyable<Mail<T, queue_sz> > {
107111
108112
@note You may call this function from ISR context.
109113
*/
110-
osStatus put(T *mptr) {
114+
osStatus put(T *mptr)
115+
{
111116
return _queue.put(mptr);
112117
}
113118

@@ -117,7 +122,8 @@ class Mail : private mbed::NonCopyable<Mail<T, queue_sz> > {
117122
118123
@note You may call this function from ISR context if the millisec parameter is set to 0.
119124
*/
120-
osEvent get(uint32_t millisec=osWaitForever) {
125+
osEvent get(uint32_t millisec = osWaitForever)
126+
{
121127
osEvent evt = _queue.get(millisec);
122128
if (evt.status == osEventMessage) {
123129
evt.status = osEventMail;
@@ -131,7 +137,8 @@ class Mail : private mbed::NonCopyable<Mail<T, queue_sz> > {
131137
132138
@note You may call this function from ISR context.
133139
*/
134-
osStatus free(T *mptr) {
140+
osStatus free(T *mptr)
141+
{
135142
return _pool.free(mptr);
136143
}
137144

rtos/MemoryPool.h

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace rtos {
3737
* \defgroup rtos_MemoryPool MemoryPool class
3838
* @{
3939
*/
40-
40+
4141
/** Define and manage fixed-size memory pools of objects of a given type.
4242
@tparam T data type of a single object (element).
4343
@tparam queue_sz maximum number of objects (elements) in the memory pool.
@@ -48,13 +48,14 @@ namespace rtos {
4848
*/
4949
template<typename T, uint32_t pool_sz>
5050
class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
51-
MBED_STATIC_ASSERT(pool_sz > 0, "Invalid memory pool size. Must be greater than 0.");
51+
MBED_STATIC_ASSERT(pool_sz > 0, "Invalid memory pool size. Must be greater than 0.");
5252
public:
5353
/** Create and Initialize a memory pool.
5454
*
5555
* @note You cannot call this function from ISR context.
5656
*/
57-
MemoryPool() {
57+
MemoryPool()
58+
{
5859
memset(_pool_mem, 0, sizeof(_pool_mem));
5960
memset(&_obj_mem, 0, sizeof(_obj_mem));
6061
osMemoryPoolAttr_t attr = { 0 };
@@ -70,7 +71,8 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
7071
*
7172
* @note You cannot call this function from ISR context.
7273
*/
73-
~MemoryPool() {
74+
~MemoryPool()
75+
{
7476
osMemoryPoolDelete(_id);
7577
}
7678

@@ -79,17 +81,19 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
7981
8082
@note You may call this function from ISR context.
8183
*/
82-
T* alloc(void) {
83-
return (T*)osMemoryPoolAlloc(_id, 0);
84+
T *alloc(void)
85+
{
86+
return (T *)osMemoryPoolAlloc(_id, 0);
8487
}
8588

8689
/** Allocate a memory block of type T from a memory pool and set memory block to zero.
8790
@return address of the allocated memory block or NULL in case of no memory available.
8891
8992
@note You may call this function from ISR context.
9093
*/
91-
T* calloc(void) {
92-
T *item = (T*)osMemoryPoolAlloc(_id, 0);
94+
T *calloc(void)
95+
{
96+
T *item = (T *)osMemoryPoolAlloc(_id, 0);
9397
if (item != NULL) {
9498
memset(item, 0, sizeof(T));
9599
}
@@ -104,8 +108,9 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
104108
105109
@note You may call this function from ISR context.
106110
*/
107-
osStatus free(T *block) {
108-
return osMemoryPoolFree(_id, (void*)block);
111+
osStatus free(T *block)
112+
{
113+
return osMemoryPoolFree(_id, (void *)block);
109114
}
110115

111116
private:

rtos/Mutex.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,22 @@ void Mutex::constructor(const char *name)
5050
MBED_ASSERT(_id);
5151
}
5252

53-
osStatus Mutex::lock(uint32_t millisec) {
53+
osStatus Mutex::lock(uint32_t millisec)
54+
{
5455
osStatus status = osMutexAcquire(_id, millisec);
5556
if (osOK == status) {
5657
_count++;
5758
}
5859
return status;
5960
}
6061

61-
bool Mutex::trylock() {
62+
bool Mutex::trylock()
63+
{
6264
return trylock_for(0);
6365
}
6466

65-
bool Mutex::trylock_for(uint32_t millisec) {
67+
bool Mutex::trylock_for(uint32_t millisec)
68+
{
6669
osStatus status = lock(millisec);
6770
if (status == osOK) {
6871
return true;
@@ -73,7 +76,8 @@ bool Mutex::trylock_for(uint32_t millisec) {
7376
return false;
7477
}
7578

76-
bool Mutex::trylock_until(uint64_t millisec) {
79+
bool Mutex::trylock_until(uint64_t millisec)
80+
{
7781
uint64_t now = Kernel::get_ms_count();
7882

7983
if (now >= millisec) {
@@ -86,16 +90,19 @@ bool Mutex::trylock_until(uint64_t millisec) {
8690
}
8791
}
8892

89-
osStatus Mutex::unlock() {
93+
osStatus Mutex::unlock()
94+
{
9095
_count--;
9196
return osMutexRelease(_id);
9297
}
9398

94-
osThreadId Mutex::get_owner() {
99+
osThreadId Mutex::get_owner()
100+
{
95101
return osMutexGetOwner(_id);
96102
}
97103

98-
Mutex::~Mutex() {
104+
Mutex::~Mutex()
105+
{
99106
osMutexDelete(_id);
100107
}
101108

rtos/Mutex.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ typedef mbed::ScopedLock<Mutex> ScopedMutexLock;
5151
* \defgroup rtos_Mutex Mutex class
5252
* @{
5353
*/
54-
54+
5555
/** The Mutex class is used to synchronize the execution of threads.
5656
This is for example used to protect access to a shared resource.
5757
@@ -89,7 +89,7 @@ class Mutex : private mbed::NonCopyable<Mutex> {
8989
9090
@note You cannot call this function from ISR context.
9191
*/
92-
osStatus lock(uint32_t millisec=osWaitForever);
92+
osStatus lock(uint32_t millisec = osWaitForever);
9393

9494
/** Try to lock the mutex, and return immediately
9595
@return true if the mutex was acquired, false otherwise.

rtos/Queue.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace rtos {
3838
* \defgroup rtos_EventFlags EventFlags class
3939
* @{
4040
*/
41-
41+
4242
/** The Queue class allow to control, send, receive, or wait for messages.
4343
A message can be a integer or pointer value to a certain type T that is send
4444
to a thread or interrupt service routine.
@@ -56,21 +56,23 @@ class Queue : private mbed::NonCopyable<Queue<T, queue_sz> > {
5656
*
5757
* @note You cannot call this function from ISR context.
5858
*/
59-
Queue() {
59+
Queue()
60+
{
6061
memset(&_obj_mem, 0, sizeof(_obj_mem));
6162
osMessageQueueAttr_t attr = { 0 };
6263
attr.mq_mem = _queue_mem;
6364
attr.mq_size = sizeof(_queue_mem);
6465
attr.cb_mem = &_obj_mem;
6566
attr.cb_size = sizeof(_obj_mem);
66-
_id = osMessageQueueNew(queue_sz, sizeof(T*), &attr);
67+
_id = osMessageQueueNew(queue_sz, sizeof(T *), &attr);
6768
MBED_ASSERT(_id);
6869
}
6970
/** Queue destructor
7071
*
7172
* @note You cannot call this function from ISR context.
7273
*/
73-
~Queue() {
74+
~Queue()
75+
{
7476
osMessageQueueDelete(_id);
7577
}
7678

@@ -80,7 +82,8 @@ class Queue : private mbed::NonCopyable<Queue<T, queue_sz> > {
8082
*
8183
* @note You may call this function from ISR context.
8284
*/
83-
bool empty() const {
85+
bool empty() const
86+
{
8487
return osMessageQueueGetCount(_id) == 0;
8588
}
8689

@@ -90,7 +93,8 @@ class Queue : private mbed::NonCopyable<Queue<T, queue_sz> > {
9093
*
9194
* @note You may call this function from ISR context.
9295
*/
93-
bool full() const {
96+
bool full() const
97+
{
9498
return osMessageQueueGetSpace(_id) == 0;
9599
}
96100

@@ -106,7 +110,8 @@ class Queue : private mbed::NonCopyable<Queue<T, queue_sz> > {
106110
107111
@note You may call this function from ISR context if the millisec parameter is set to 0.
108112
*/
109-
osStatus put(T* data, uint32_t millisec=0, uint8_t prio=0) {
113+
osStatus put(T *data, uint32_t millisec = 0, uint8_t prio = 0)
114+
{
110115
return osMessageQueuePut(_id, &data, prio, millisec);
111116
}
112117

@@ -121,7 +126,8 @@ class Queue : private mbed::NonCopyable<Queue<T, queue_sz> > {
121126
122127
@note You may call this function from ISR context if the millisec parameter is set to 0.
123128
*/
124-
osEvent get(uint32_t millisec=osWaitForever) {
129+
osEvent get(uint32_t millisec = osWaitForever)
130+
{
125131
osEvent event;
126132
T *data = NULL;
127133
osStatus_t res = osMessageQueueGet(_id, &data, NULL, millisec);
@@ -149,7 +155,7 @@ class Queue : private mbed::NonCopyable<Queue<T, queue_sz> > {
149155

150156
private:
151157
osMessageQueueId_t _id;
152-
char _queue_mem[queue_sz * (sizeof(T*) + sizeof(mbed_rtos_storage_message_t))];
158+
char _queue_mem[queue_sz * (sizeof(T *) + sizeof(mbed_rtos_storage_message_t))];
153159
mbed_rtos_storage_msg_queue_t _obj_mem;
154160
};
155161
/** @}*/

rtos/RtosTimer.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828

2929
namespace rtos {
3030

31-
void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type) {
31+
void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type)
32+
{
3233
_function = func;
3334
memset(&_obj_mem, 0, sizeof(_obj_mem));
3435
osTimerAttr_t attr = { 0 };
@@ -38,15 +39,18 @@ void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type) {
3839
MBED_ASSERT(_id);
3940
}
4041

41-
osStatus RtosTimer::start(uint32_t millisec) {
42+
osStatus RtosTimer::start(uint32_t millisec)
43+
{
4244
return osTimerStart(_id, millisec);
4345
}
4446

45-
osStatus RtosTimer::stop(void) {
47+
osStatus RtosTimer::stop(void)
48+
{
4649
return osTimerStop(_id);
4750
}
4851

49-
RtosTimer::~RtosTimer() {
52+
RtosTimer::~RtosTimer()
53+
{
5054
osTimerDelete(_id);
5155
}
5256

0 commit comments

Comments
 (0)