lib: cmsis_rtos_v2: Uncrustify source files

Ran uncrustify on all library source files to ensure a compliant base to
work from.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
This commit is contained in:
Carlos Stuart 2019-02-06 08:03:32 +00:00 committed by Anas Nashif
commit ccf51e2f50
10 changed files with 69 additions and 69 deletions

View file

@ -8,7 +8,7 @@
#include "wrapper.h"
K_MEM_SLAB_DEFINE(cv2_event_flags_slab, sizeof(struct cv2_event_flags),
CONFIG_CMSIS_V2_EVT_FLAGS_MAX_COUNT, 4);
CONFIG_CMSIS_V2_EVT_FLAGS_MAX_COUNT, 4);
static const osEventFlagsAttr_t init_event_flags_attrs = {
.name = "ZephyrEvent",
@ -17,8 +17,8 @@ static const osEventFlagsAttr_t init_event_flags_attrs = {
.cb_size = 0,
};
#define DONT_CARE (0)
#define NSEC_PER_MSEC (NSEC_PER_USEC * USEC_PER_MSEC)
#define DONT_CARE (0)
#define NSEC_PER_MSEC (NSEC_PER_USEC * USEC_PER_MSEC)
/**
* @brief Create and Initialize an Event Flags object.
@ -36,7 +36,7 @@ osEventFlagsId_t osEventFlagsNew(const osEventFlagsAttr_t *attr)
}
if (k_mem_slab_alloc(&cv2_event_flags_slab, (void **)&events, 100)
== 0) {
== 0) {
memset(events, 0, sizeof(struct cv2_event_flags));
} else {
return NULL;
@ -44,7 +44,7 @@ osEventFlagsId_t osEventFlagsNew(const osEventFlagsAttr_t *attr)
k_poll_signal_init(&events->poll_signal);
k_poll_event_init(&events->poll_event, K_POLL_TYPE_SIGNAL,
K_POLL_MODE_NOTIFY_ONLY, &events->poll_signal);
K_POLL_MODE_NOTIFY_ONLY, &events->poll_signal);
events->signal_results = 0;
memcpy(events->name, attr->name, 16);
@ -97,7 +97,7 @@ uint32_t osEventFlagsClear(osEventFlagsId_t ef_id, uint32_t flags)
* @brief Wait for one or more Event Flags to become signaled.
*/
uint32_t osEventFlagsWait(osEventFlagsId_t ef_id, uint32_t flags,
uint32_t options, uint32_t timeout)
uint32_t options, uint32_t timeout)
{
struct cv2_event_flags *events = (struct cv2_event_flags *)ef_id;
int retval, key;
@ -140,9 +140,9 @@ uint32_t osEventFlagsWait(osEventFlagsId_t ef_id, uint32_t flags,
}
__ASSERT(events->poll_event.state == K_POLL_STATE_SIGNALED,
"event state not signalled!");
"event state not signalled!");
__ASSERT(events->poll_event.signal->signaled == 1,
"event signaled is not 1");
"event signaled is not 1");
/* Reset the states to facilitate the next trigger */
events->poll_event.signal->signaled = 0;
@ -165,9 +165,9 @@ uint32_t osEventFlagsWait(osEventFlagsId_t ef_id, uint32_t flags,
(u64_t)k_cycle_get_32() - time_stamp_start;
time_delta_ns =
(u32_t)SYS_CLOCK_HW_CYCLES_TO_NS(hwclk_cycles_delta);
(u32_t)SYS_CLOCK_HW_CYCLES_TO_NS(hwclk_cycles_delta);
time_delta_ms = (u32_t)time_delta_ns/NSEC_PER_MSEC;
time_delta_ms = (u32_t)time_delta_ns / NSEC_PER_MSEC;
if (timeout_ms > time_delta_ms) {
timeout_ms -= time_delta_ms;

View file

@ -18,7 +18,7 @@ extern u32_t z_tick_get_32(void);
osStatus_t osKernelGetInfo(osVersion_t *version, char *id_buf, uint32_t id_size)
{
if (version != NULL) {
version->api = sys_kernel_version_get();
version->api = sys_kernel_version_get();
version->kernel = sys_kernel_version_get();
}
@ -76,9 +76,9 @@ int32_t osKernelRestoreLock(int32_t lock)
}
if (lock < 0) {
return 1; /* locked */
return 1; /* locked */
} else {
return 0; /* not locked */
return 0; /* not locked */
}
}

View file

@ -7,10 +7,10 @@
#include <kernel_structs.h>
#include "wrapper.h"
#define TIME_OUT_TICKS 10
#define TIME_OUT_TICKS 10
K_MEM_SLAB_DEFINE(cv2_mem_slab, sizeof(struct cv2_mslab),
CONFIG_CMSIS_V2_MEM_SLAB_MAX_COUNT, 4);
CONFIG_CMSIS_V2_MEM_SLAB_MAX_COUNT, 4);
static const osMemoryPoolAttr_t init_mslab_attrs = {
.name = "ZephyrMemPool",
@ -25,7 +25,7 @@ static const osMemoryPoolAttr_t init_mslab_attrs = {
* @brief Create and Initialize a memory pool.
*/
osMemoryPoolId_t osMemoryPoolNew(uint32_t block_count, uint32_t block_size,
const osMemoryPoolAttr_t *attr)
const osMemoryPoolAttr_t *attr)
{
struct cv2_mslab *mslab;
@ -41,7 +41,7 @@ osMemoryPoolId_t osMemoryPoolNew(uint32_t block_count, uint32_t block_size,
* App layer
*/
if ((attr->mp_mem == NULL) ||
(attr->mp_size < block_count*block_size)) {
(attr->mp_size < block_count * block_size)) {
return NULL;
}
@ -77,16 +77,16 @@ void *osMemoryPoolAlloc(osMemoryPoolId_t mp_id, uint32_t timeout)
if (timeout == 0) {
retval = k_mem_slab_alloc(
(struct k_mem_slab *)(&mslab->z_mslab),
(void **)&ptr, K_NO_WAIT);
(struct k_mem_slab *)(&mslab->z_mslab),
(void **)&ptr, K_NO_WAIT);
} else if (timeout == osWaitForever) {
retval = k_mem_slab_alloc(
(struct k_mem_slab *)(&mslab->z_mslab),
(void **)&ptr, K_FOREVER);
(struct k_mem_slab *)(&mslab->z_mslab),
(void **)&ptr, K_FOREVER);
} else {
retval = k_mem_slab_alloc(
(struct k_mem_slab *)(&mslab->z_mslab),
(void **)&ptr, __ticks_to_ms(timeout));
(struct k_mem_slab *)(&mslab->z_mslab),
(void **)&ptr, __ticks_to_ms(timeout));
}
if (retval == 0) {

View file

@ -8,7 +8,7 @@
#include "wrapper.h"
K_MEM_SLAB_DEFINE(cv2_msgq_slab, sizeof(struct cv2_msgq),
CONFIG_CMSIS_V2_MSGQ_MAX_COUNT, 4);
CONFIG_CMSIS_V2_MSGQ_MAX_COUNT, 4);
static const osMessageQueueAttr_t init_msgq_attrs = {
.name = "ZephyrMsgQ",
@ -23,7 +23,7 @@ static const osMessageQueueAttr_t init_msgq_attrs = {
* @brief Create and Initialize Message queue.
*/
osMessageQueueId_t osMessageQueueNew(uint32_t msg_count, uint32_t msg_size,
const osMessageQueueAttr_t *attr)
const osMessageQueueAttr_t *attr)
{
struct cv2_msgq *msgq;
@ -63,7 +63,7 @@ osMessageQueueId_t osMessageQueueNew(uint32_t msg_count, uint32_t msg_size,
* @brief Put a message to a Queue.
*/
osStatus_t osMessageQueuePut(osMessageQueueId_t msgq_id, const void *msg_ptr,
uint8_t msg_prio, uint32_t timeout)
uint8_t msg_prio, uint32_t timeout)
{
struct cv2_msgq *msgq = (struct cv2_msgq *)msgq_id;
int retval;
@ -85,7 +85,7 @@ osStatus_t osMessageQueuePut(osMessageQueueId_t msgq_id, const void *msg_ptr,
retval = k_msgq_put(&msgq->z_msgq, (void *)msg_ptr, K_FOREVER);
} else {
retval = k_msgq_put(&msgq->z_msgq, (void *)msg_ptr,
__ticks_to_ms(timeout));
__ticks_to_ms(timeout));
}
if (retval == 0) {
@ -101,7 +101,7 @@ osStatus_t osMessageQueuePut(osMessageQueueId_t msgq_id, const void *msg_ptr,
* @brief Get a message or Wait for a Message from a Queue.
*/
osStatus_t osMessageQueueGet(osMessageQueueId_t msgq_id, void *msg_ptr,
uint8_t *msg_prio, uint32_t timeout)
uint8_t *msg_prio, uint32_t timeout)
{
struct cv2_msgq *msgq = (struct cv2_msgq *)msgq_id;
int retval;
@ -123,7 +123,7 @@ osStatus_t osMessageQueueGet(osMessageQueueId_t msgq_id, void *msg_ptr,
retval = k_msgq_get(&msgq->z_msgq, msg_ptr, K_FOREVER);
} else {
retval = k_msgq_get(&msgq->z_msgq, msg_ptr,
__ticks_to_ms(timeout));
__ticks_to_ms(timeout));
}
if (retval == 0) {

View file

@ -8,7 +8,7 @@
#include "wrapper.h"
K_MEM_SLAB_DEFINE(cv2_mutex_slab, sizeof(struct cv2_mutex),
CONFIG_CMSIS_V2_MUTEX_MAX_COUNT, 4);
CONFIG_CMSIS_V2_MUTEX_MAX_COUNT, 4);
static const osMutexAttr_t init_mutex_attrs = {
.name = "ZephyrMutex",
@ -33,10 +33,10 @@ osMutexId_t osMutexNew(const osMutexAttr_t *attr)
}
__ASSERT(attr->attr_bits & osMutexPrioInherit,
"Zephyr supports osMutexPrioInherit by default. Do not unselect it\n");
"Zephyr supports osMutexPrioInherit by default. Do not unselect it\n");
__ASSERT(!(attr->attr_bits & osMutexRobust),
"Zephyr does not support osMutexRobust.\n");
"Zephyr does not support osMutexRobust.\n");
if (k_mem_slab_alloc(&cv2_mutex_slab, (void **)&mutex, 100) == 0) {
memset(mutex, 0, sizeof(struct cv2_mutex));
@ -68,7 +68,7 @@ osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout)
}
if (mutex->z_mutex.lock_count == 0 ||
mutex->z_mutex.owner == _current) {
mutex->z_mutex.owner == _current) {
}
/* Throw an error if the mutex is not configured to be recursive and
@ -76,7 +76,7 @@ osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout)
*/
if ((mutex->state & osMutexRecursive) == 0) {
if ((mutex->z_mutex.owner == _current) &&
(mutex->z_mutex.lock_count != 0)) {
(mutex->z_mutex.lock_count != 0)) {
return osErrorResource;
}
}
@ -87,7 +87,7 @@ osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout)
status = k_mutex_lock(&mutex->z_mutex, K_NO_WAIT);
} else {
status = k_mutex_lock(&mutex->z_mutex,
__ticks_to_ms(timeout));
__ticks_to_ms(timeout));
}
if (status == -EBUSY) {

View file

@ -8,7 +8,7 @@
#include "wrapper.h"
K_MEM_SLAB_DEFINE(cv2_semaphore_slab, sizeof(struct cv2_sem),
CONFIG_CMSIS_V2_SEMAPHORE_MAX_COUNT, 4);
CONFIG_CMSIS_V2_SEMAPHORE_MAX_COUNT, 4);
static const osSemaphoreAttr_t init_sema_attrs = {
.name = "ZephyrSem",
@ -21,7 +21,7 @@ static const osSemaphoreAttr_t init_sema_attrs = {
* @brief Create and Initialize a semaphore object.
*/
osSemaphoreId_t osSemaphoreNew(uint32_t max_count, uint32_t initial_count,
const osSemaphoreAttr_t *attr)
const osSemaphoreAttr_t *attr)
{
struct cv2_sem *semaphore;
@ -34,7 +34,7 @@ osSemaphoreId_t osSemaphoreNew(uint32_t max_count, uint32_t initial_count,
}
if (k_mem_slab_alloc(&cv2_semaphore_slab,
(void **)&semaphore, 100) == 0) {
(void **)&semaphore, 100) == 0) {
(void)memset(semaphore, 0, sizeof(struct cv2_sem));
} else {
return NULL;
@ -69,7 +69,7 @@ osStatus_t osSemaphoreAcquire(osSemaphoreId_t semaphore_id, uint32_t timeout)
status = k_sem_take(&semaphore->z_semaphore, K_NO_WAIT);
} else {
status = k_sem_take(&semaphore->z_semaphore,
__ticks_to_ms(timeout));
__ticks_to_ms(timeout));
}
if (status == -EBUSY) {
@ -105,7 +105,7 @@ osStatus_t osSemaphoreRelease(osSemaphoreId_t semaphore_id)
/* All tokens have already been released */
if (k_sem_count_get(&semaphore->z_semaphore) ==
semaphore->z_semaphore.limit) {
semaphore->z_semaphore.limit) {
return osErrorResource;
}

View file

@ -85,16 +85,16 @@ osThreadId_t osThreadNew(osThreadFunc_t threadfunc, void *arg,
static u32_t one_time;
BUILD_ASSERT_MSG(osPriorityISR <= CONFIG_NUM_PREEMPT_PRIORITIES,
"Configure NUM_PREEMPT_PRIORITIES to at least osPriorityISR");
"Configure NUM_PREEMPT_PRIORITIES to at least osPriorityISR");
__ASSERT(attr->stack_size <= CONFIG_CMSIS_V2_THREAD_MAX_STACK_SIZE,
"invalid stack size\n");
"invalid stack size\n");
__ASSERT(thread_num <= CONFIG_CMSIS_V2_THREAD_MAX_COUNT,
"Exceeded max number of threads\n");
"Exceeded max number of threads\n");
__ASSERT(attr != NULL,
"Zephyr requirement: Pass attributes explicitly for ThreadNew\n");
"Zephyr requirement: Pass attributes explicitly for ThreadNew\n");
/* Zephyr needs valid stack to be specified when this API is called */
__ASSERT(attr->stack_mem, "");
@ -116,7 +116,7 @@ osThreadId_t osThreadNew(osThreadFunc_t threadfunc, void *arg,
k_poll_signal_init(&tid->poll_signal);
k_poll_event_init(&tid->poll_event, K_POLL_TYPE_SIGNAL,
K_POLL_MODE_NOTIFY_ONLY, &tid->poll_signal);
K_POLL_MODE_NOTIFY_ONLY, &tid->poll_signal);
tid->signal_results = 0;
/* TODO: Do this somewhere only once */
@ -128,10 +128,10 @@ osThreadId_t osThreadNew(osThreadFunc_t threadfunc, void *arg,
sys_dlist_append(&thread_list, &tid->node);
(void)k_thread_create(&tid->z_thread,
attr->stack_mem, attr->stack_size,
(k_thread_entry_t)zephyr_thread_wrapper,
(void *)arg, NULL, threadfunc,
prio, 0, K_NO_WAIT);
attr->stack_mem, attr->stack_size,
(k_thread_entry_t)zephyr_thread_wrapper,
(void *)arg, NULL, threadfunc,
prio, 0, K_NO_WAIT);
k_thread_name_set(&tid->z_thread, attr->name);
@ -152,7 +152,7 @@ const char *osThreadGetName(osThreadId_t thread_id)
name = NULL;
} else {
struct cv2_thread *tid =
(struct cv2_thread *)thread_id;
(struct cv2_thread *)thread_id;
name = k_thread_name_get(&tid->z_thread);
}
@ -180,8 +180,8 @@ osPriority_t osThreadGetPriority(osThreadId_t thread_id)
u32_t priority;
if (k_is_in_isr() || (tid == NULL) ||
(is_cmsis_rtos_v2_thread(tid) == NULL) ||
(_is_thread_cmsis_inactive(&tid->z_thread))) {
(is_cmsis_rtos_v2_thread(tid) == NULL) ||
(_is_thread_cmsis_inactive(&tid->z_thread))) {
return osPriorityError;
}
@ -197,7 +197,7 @@ osStatus_t osThreadSetPriority(osThreadId_t thread_id, osPriority_t priority)
struct cv2_thread *tid = (struct cv2_thread *)thread_id;
if ((tid == NULL) || (is_cmsis_rtos_v2_thread(tid) == NULL) ||
(priority <= osPriorityNone) || (priority > osPriorityISR)) {
(priority <= osPriorityNone) || (priority > osPriorityISR)) {
return osErrorParameter;
}
@ -210,7 +210,7 @@ osStatus_t osThreadSetPriority(osThreadId_t thread_id, osPriority_t priority)
}
k_thread_priority_set((k_tid_t)&tid->z_thread,
cmsis_to_zephyr_priority(priority));
cmsis_to_zephyr_priority(priority));
return osOK;
}
@ -224,7 +224,7 @@ osThreadState_t osThreadGetState(osThreadId_t thread_id)
osThreadState_t state;
if (k_is_in_isr() || (tid == NULL) ||
(is_cmsis_rtos_v2_thread(tid) == NULL)) {
(is_cmsis_rtos_v2_thread(tid) == NULL)) {
return osThreadError;
}

View file

@ -7,8 +7,8 @@
#include <kernel_structs.h>
#include "wrapper.h"
#define DONT_CARE (0)
#define NSEC_PER_MSEC (NSEC_PER_USEC * USEC_PER_MSEC)
#define DONT_CARE (0)
#define NSEC_PER_MSEC (NSEC_PER_USEC * USEC_PER_MSEC)
/**
* @brief Set the specified Thread Flags of a thread.
@ -19,7 +19,7 @@ uint32_t osThreadFlagsSet(osThreadId_t thread_id, uint32_t flags)
struct cv2_thread *tid = (struct cv2_thread *)thread_id;
if ((thread_id == NULL) || (is_cmsis_rtos_v2_thread(thread_id) == NULL)
|| (flags & 0x80000000)) {
|| (flags & 0x80000000)) {
return osFlagsErrorParameter;
}
@ -131,9 +131,9 @@ uint32_t osThreadFlagsWait(uint32_t flags, uint32_t options, uint32_t timeout)
}
__ASSERT(tid->poll_event.state == K_POLL_STATE_SIGNALED,
"event state not signalled!");
"event state not signalled!");
__ASSERT(tid->poll_event.signal->signaled == 1,
"event signaled is not 1");
"event signaled is not 1");
/* Reset the states to facilitate the next trigger */
tid->poll_event.signal->signaled = 0;
@ -155,9 +155,9 @@ uint32_t osThreadFlagsWait(uint32_t flags, uint32_t options, uint32_t timeout)
(u64_t)k_cycle_get_32() - time_stamp_start;
time_delta_ns =
(u32_t)SYS_CLOCK_HW_CYCLES_TO_NS(hwclk_cycles_delta);
(u32_t)SYS_CLOCK_HW_CYCLES_TO_NS(hwclk_cycles_delta);
time_delta_ms = (u32_t)time_delta_ns/NSEC_PER_MSEC;
time_delta_ms = (u32_t)time_delta_ns / NSEC_PER_MSEC;
if (timeout_ms > time_delta_ms) {
timeout_ms -= time_delta_ms;

View file

@ -34,7 +34,7 @@ static void zephyr_timer_wrapper(struct k_timer *timer)
* @brief Create a Timer
*/
osTimerId_t osTimerNew(osTimerFunc_t func, osTimerType_t type,
void *argument, const osTimerAttr_t *attr)
void *argument, const osTimerAttr_t *attr)
{
struct cv2_timer *timer;

View file

@ -10,15 +10,15 @@
#include <kernel.h>
#include <cmsis_os2.h>
#define TRUE 1
#define FALSE 0
#define TRUE 1
#define FALSE 0
struct cv2_thread {
sys_dnode_t node;
struct k_thread z_thread;
struct k_poll_signal poll_signal;
struct k_poll_event poll_event;
u32_t signal_results;
struct k_poll_event poll_event;
u32_t signal_results;
char name[16];
u32_t state;
};
@ -57,8 +57,8 @@ struct cv2_msgq {
struct cv2_event_flags {
struct k_poll_signal poll_signal;
struct k_poll_event poll_event;
u32_t signal_results;
struct k_poll_event poll_event;
u32_t signal_results;
char name[16];
};