fixed coding style (space after most keywords)

This commit is contained in:
Oliver Hahm 2013-06-24 22:37:35 +02:00
parent 5bae4f841d
commit c8bee9e554
112 changed files with 1914 additions and 1914 deletions

View File

@ -31,7 +31,7 @@ number_of_highest_bit(unsigned v)
r |= (v >> 1);
#else
r = 0;
while(v >>= 1) { // unroll for more speed...
while (v >>= 1) { // unroll for more speed...
r++;
}
@ -45,7 +45,7 @@ number_of_lowest_bit(register unsigned v)
{
register unsigned r = 0;
while((v & 0x01) == 0) {
while ((v & 0x01) == 0) {
v >>= 1;
r++;
};
@ -58,7 +58,7 @@ number_of_bits_set(unsigned v)
{
unsigned c; // c accumulates the total bits set in v
for(c = 0; v; c++) {
for (c = 0; v; c++) {
v &= v - 1; // clear the least significant bit set
}

View File

@ -16,7 +16,7 @@ int cib_get(cib_t *cib)
{
int avail = cib_avail(cib);
if(avail > 0) {
if (avail > 0) {
return (int)(cib->read_count++ & ~cib->complement);
}
@ -27,7 +27,7 @@ int cib_put(cib_t *cib)
{
int avail = cib_avail(cib);
if((int)(avail + cib->complement) < 0) {
if ((int)(avail + cib->complement) < 0) {
return (int)(cib->write_count++ & ~(cib->complement));
}

View File

@ -21,13 +21,13 @@
/* inserts new_node after node */
void clist_add(clist_node_t **node, clist_node_t *new_node)
{
if(*node != NULL) {
if (*node != NULL) {
new_node->next = (*node);
new_node->prev = (*node)->prev;
(*node)->prev->next = new_node;
(*node)->prev = new_node;
if((*node)->prev == *node) {
if ((*node)->prev == *node) {
(*node)->prev = new_node;
}
}
@ -41,11 +41,11 @@ void clist_add(clist_node_t **node, clist_node_t *new_node)
/* removes node. */
void clist_remove(clist_node_t **list, clist_node_t *node)
{
if(node->next != node) {
if (node->next != node) {
node->prev->next = node->next;
node->next->prev = node->prev;
if(node == *list) {
if (node == *list) {
*list = node->next;
}
}
@ -58,11 +58,11 @@ void clist_print(clist_node_t *clist)
{
clist_node_t *start = clist;
while(clist != NULL) {
while (clist != NULL) {
printf("list entry: %u prev=%u next=%u\n", clist->data, clist->prev->data, clist->next->data);
clist = clist->next;
if(clist == start) {
if (clist == start) {
break;
}
}

View File

@ -55,9 +55,9 @@ void hwtimer_spin(unsigned long ticks)
{
unsigned long co = hwtimer_arch_now() + ticks;
while(hwtimer_arch_now() > co);
while (hwtimer_arch_now() > co);
while(hwtimer_arch_now() < co);
while (hwtimer_arch_now() < co);
}
/*---------------------------------------------------------------------------*/
@ -75,7 +75,7 @@ void hwtimer_init_comp(uint32_t fcpu)
lifo_init(lifo, ARCH_MAXTIMERS);
for(int i = 0; i < ARCH_MAXTIMERS; i++) {
for (int i = 0; i < ARCH_MAXTIMERS; i++) {
lifo_insert(lifo, i);
}
}
@ -84,7 +84,7 @@ void hwtimer_init_comp(uint32_t fcpu)
int hwtimer_active(void)
{
return (! lifo_empty(lifo));
return (!lifo_empty(lifo));
}
/*---------------------------------------------------------------------------*/
@ -98,7 +98,7 @@ unsigned long hwtimer_now(void)
void hwtimer_wait(unsigned long ticks)
{
if(ticks <= 6 || inISR()) {
if (ticks <= 6 || inISR()) {
hwtimer_spin(ticks);
return;
}
@ -106,7 +106,7 @@ void hwtimer_wait(unsigned long ticks)
/* -2 is to adjust the real value */
int res = hwtimer_set(ticks - 2, hwtimer_wakeup, (void*)(unsigned int)(active_thread->pid));
if(res == -1) {
if (res == -1) {
hwtimer_spin(ticks);
return;
}
@ -119,14 +119,14 @@ void hwtimer_wait(unsigned long ticks)
static int _hwtimer_set(unsigned long offset, void (*callback)(void*), void *ptr, bool absolute)
{
if(!inISR()) {
if (!inISR()) {
dINT();
}
int n = lifo_get(lifo);
if(n == -1) {
if(! inISR()) {
if (n == -1) {
if (!inISR()) {
eINT();
}
@ -137,7 +137,7 @@ static int _hwtimer_set(unsigned long offset, void (*callback)(void*), void *ptr
timer[n].callback = callback;
timer[n].data = ptr;
if(absolute) {
if (absolute) {
hwtimer_arch_set_absolute(offset, n);
}
else {
@ -146,7 +146,7 @@ static int _hwtimer_set(unsigned long offset, void (*callback)(void*), void *ptr
lpm_prevent_sleep++;
if(!inISR()) {
if (!inISR()) {
eINT();
}

View File

@ -94,7 +94,7 @@ int msg_receive(msg_t *m);
* @brief Send a message, block until reply received.
*
* This function sends a message to target_pid and then blocks until target has sent a reply.
* @note CAUTION! Use this function only when receiver is already waiting. If not use simple msg_send()
* @note CAUTION!Use this function only when receiver is already waiting. If not use simple msg_send()
* @param m pointer to preallocated msg
* @param reply pointer to preallocated msg. Reply will be written here.
* @param target pid the pid of the target process

View File

@ -42,8 +42,8 @@ extern int main(void);
static void idle_thread(void)
{
while(1) {
if(lpm_prevent_sleep) {
while (1) {
if (lpm_prevent_sleep) {
lpm_set(LPM_IDLE);
}
else {
@ -73,11 +73,11 @@ void kernel_init(void)
sched_init();
if(thread_create(idle_stack, sizeof(idle_stack), PRIORITY_IDLE, CREATE_WOUT_YIELD | CREATE_STACKTEST, idle_thread, idle_name) < 0) {
if (thread_create(idle_stack, sizeof(idle_stack), PRIORITY_IDLE, CREATE_WOUT_YIELD | CREATE_STACKTEST, idle_thread, idle_name) < 0) {
printf("kernel_init(): error creating idle task.\n");
}
if(thread_create(main_stack, sizeof(main_stack), PRIORITY_MAIN, CREATE_WOUT_YIELD | CREATE_STACKTEST, MAIN_FUNC, main_name) < 0) {
if (thread_create(main_stack, sizeof(main_stack), PRIORITY_MAIN, CREATE_WOUT_YIELD | CREATE_STACKTEST, MAIN_FUNC, main_name) < 0) {
printf("kernel_init(): error creating main task.\n");
}

View File

@ -7,7 +7,7 @@ int lifo_empty(int *array)
void lifo_init(int *array, int n)
{
for(int i = 0; i <= n; i++) {
for (int i = 0; i <= n; i++) {
array[i] = -1;
}
}
@ -23,7 +23,7 @@ int lifo_get(int *array)
{
int head = array[0];
if(head != -1) {
if (head != -1) {
array[0] = array[head + 1];
}

View File

@ -32,7 +32,7 @@ static int queue_msg(tcb_t *target, msg_t *m)
{
int n = cib_put(&(target->msg_queue));
if(n != -1) {
if (n != -1) {
target->msg_array[n] = *m;
return 1;
}
@ -42,7 +42,7 @@ static int queue_msg(tcb_t *target, msg_t *m)
int msg_send(msg_t *m, unsigned int target_pid, bool block)
{
if(inISR()) {
if (inISR()) {
return msg_send_int(m, target_pid);
}
@ -50,23 +50,23 @@ int msg_send(msg_t *m, unsigned int target_pid, bool block)
m->sender_pid = thread_pid;
if(m->sender_pid == target_pid) {
if (m->sender_pid == target_pid) {
return -1;
}
if(target == NULL) {
if (target == NULL) {
return -1;
}
dINT();
if(target->status != STATUS_RECEIVE_BLOCKED) {
if(target->msg_array && queue_msg(target, m)) {
if (target->status != STATUS_RECEIVE_BLOCKED) {
if (target->msg_array && queue_msg(target, m)) {
eINT();
return 1;
}
if(!block) {
if (!block) {
DEBUG("%s: receiver not waiting. block=%u\n", active_thread->name, block);
eINT();
return 0;
@ -84,7 +84,7 @@ int msg_send(msg_t *m, unsigned int target_pid, bool block)
int newstatus;
if(active_thread->status == STATUS_REPLY_BLOCKED) {
if (active_thread->status == STATUS_REPLY_BLOCKED) {
newstatus = STATUS_REPLY_BLOCKED;
}
else {
@ -113,7 +113,7 @@ int msg_send_int(msg_t *m, unsigned int target_pid)
{
tcb_t *target = (tcb_t *) sched_threads[target_pid];
if(target->status == STATUS_RECEIVE_BLOCKED) {
if (target->status == STATUS_RECEIVE_BLOCKED) {
DEBUG("msg_send_int: direct msg copy from %i to %i.\n", thread_getpid(), target_pid);
m->sender_pid = target_pid;
@ -151,7 +151,7 @@ int msg_reply(msg_t *m, msg_t *reply)
tcb_t *target = (tcb_t*) sched_threads[m->sender_pid];
if(target->status != STATUS_REPLY_BLOCKED) {
if (target->status != STATUS_REPLY_BLOCKED) {
DEBUG("%s: msg_reply(): target \"%s\" not waiting for reply.", active_thread->name, target->name);
restoreIRQ(state);
return -1;
@ -172,7 +172,7 @@ int msg_reply_int(msg_t *m, msg_t *reply)
{
tcb_t *target = (tcb_t*) sched_threads[m->sender_pid];
if(target->status != STATUS_REPLY_BLOCKED) {
if (target->status != STATUS_REPLY_BLOCKED) {
DEBUG("%s: msg_reply_int(): target \"%s\" not waiting for reply.", active_thread->name, target->name);
return -1;
}
@ -193,11 +193,11 @@ int msg_receive(msg_t *m)
int n = -1;
if(me->msg_array) {
if (me->msg_array) {
n = cib_get(&(me->msg_queue));
}
if(n >= 0) {
if (n >= 0) {
DEBUG("%s: msg_receive(): We've got a queued message.\n", active_thread->name);
*m = me->msg_array[n];
}
@ -207,10 +207,10 @@ int msg_receive(msg_t *m)
queue_node_t *node = queue_remove_head(&(me->msg_waiters));
if(node == NULL) {
if (node == NULL) {
DEBUG("%s: msg_receive(): No thread in waiting list.\n", active_thread->name);
if(n < 0) {
if (n < 0) {
DEBUG("%s: msg_receive(): No msg in queue. Going blocked.\n", active_thread->name);
sched_set_status(me, STATUS_RECEIVE_BLOCKED);
@ -226,7 +226,7 @@ int msg_receive(msg_t *m)
DEBUG("%s: msg_receive(): Wakeing up waiting thread.\n", active_thread->name);
tcb_t *sender = (tcb_t*) node->data;
if(n >= 0) {
if (n >= 0) {
/* we've already got a messgage from the queue. as there is a
* waiter, take it's message into the just freed queue space.
*/
@ -249,7 +249,7 @@ int msg_receive(msg_t *m)
int msg_init_queue(msg_t *array, int num)
{
/* make sure brainfuck condition is met */
if(num && (num & (num - 1)) == 0) {
if (num && (num & (num - 1)) == 0) {
tcb_t *me = (tcb_t*) active_thread;
me->msg_array = array;
cib_init(&(me->msg_queue), num);

View File

@ -52,7 +52,7 @@ int mutex_lock(struct mutex_t *mutex)
{
DEBUG("%s: trying to get mutex. val: %u\n", active_thread->name, mutex->val);
if(atomic_set_return(&mutex->val, 1) != 0) {
if (atomic_set_return(&mutex->val, 1) != 0) {
/* mutex was locked. */
mutex_wait(mutex);
}
@ -65,7 +65,7 @@ void mutex_wait(struct mutex_t *mutex)
int irqstate = disableIRQ();
DEBUG("%s: Mutex in use. %u\n", active_thread->name, mutex->val);
if(mutex->val == 0) {
if (mutex->val == 0) {
/* somebody released the mutex. return. */
mutex->val = thread_pid;
DEBUG("%s: mutex_wait early out. %u\n", active_thread->name, mutex->val);
@ -96,8 +96,8 @@ void mutex_unlock(struct mutex_t *mutex, int yield)
DEBUG("%s: unlocking mutex. val: %u pid: %u\n", active_thread->name, mutex->val, thread_pid);
int irqstate = disableIRQ();
if(mutex->val != 0) {
if(mutex->queue.next) {
if (mutex->val != 0) {
if (mutex->queue.next) {
queue_node_t *next = queue_remove_head(&(mutex->queue));
tcb_t *process = (tcb_t*) next->data;
DEBUG("%s: waking up waiter %s.\n", process->name);

View File

@ -31,7 +31,7 @@ void *_malloc(size_t size)
DEBUG("_malloc(): allocating block of size %u at 0x%X.\n", (unsigned int) size, (unsigned int)ptr);
if(ptr != (void*) - 1) {
if (ptr != (void*) - 1) {
return ptr;
}
else {

View File

@ -23,8 +23,8 @@
void queue_remove(queue_node_t *root, queue_node_t *node)
{
while(root->next != NULL) {
if(root->next == node) {
while (root->next != NULL) {
if (root->next == node) {
root->next = node->next;
node->next = NULL;
return;
@ -38,7 +38,7 @@ queue_node_t *queue_remove_head(queue_node_t *root)
{
queue_node_t *head = root->next;
if(head != NULL) {
if (head != NULL) {
root->next = head->next;
}
@ -47,7 +47,7 @@ queue_node_t *queue_remove_head(queue_node_t *root)
void queue_add_tail(queue_node_t *node, queue_node_t *new_obj)
{
while(node->next != NULL) {
while (node->next != NULL) {
node = node->next;
}
@ -65,8 +65,8 @@ void queue_priority_add(queue_node_t *root, queue_node_t *new_obj)
{
queue_node_t *node = root;
while(node->next != NULL) {
if(node->next->priority > new_obj->priority) {
while (node->next != NULL) {
if (node->next->priority > new_obj->priority) {
new_obj->next = node->next;
node->next = new_obj;
return;
@ -83,8 +83,8 @@ void queue_priority_add_generic(queue_node_t *root, queue_node_t *new_obj, int (
{
queue_node_t *node = root;
while(node->next != NULL) {
if(cmp(node->next, new_obj) < 0) {
while (node->next != NULL) {
if (cmp(node->next, new_obj) < 0) {
new_obj->next = node->next;
node->next = new_obj;
return;
@ -102,7 +102,7 @@ void queue_print(queue_node_t *node)
{
printf("queue:\n");
while(node->next != NULL) {
while (node->next != NULL) {
node = node->next;
printf("Data: %u Priority: %u\n", node->data, node->priority);
}

View File

@ -50,7 +50,7 @@ void sched_init()
printf("Scheduler...");
int i;
for(i = 0; i < MAXTHREADS; i++) {
for (i = 0; i < MAXTHREADS; i++) {
sched_threads[i] = NULL;
#if SCHEDSTATISTICS
pidlist[i].laststart = 0;
@ -62,7 +62,7 @@ void sched_init()
active_thread = NULL;
thread_pid = -1;
for(i = 0; i < SCHED_PRIO_LEVELS; i++) {
for (i = 0; i < SCHED_PRIO_LEVELS; i++) {
runqueues[i] = NULL;
}
@ -75,14 +75,14 @@ void sched_run()
tcb_t *my_active_thread = (tcb_t *)active_thread;
if(my_active_thread) {
if(my_active_thread->status == STATUS_RUNNING) {
if (my_active_thread) {
if (my_active_thread->status == STATUS_RUNNING) {
my_active_thread->status = STATUS_PENDING;
}
#ifdef SCHED_TEST_STACK
if(*((unsigned int *)my_active_thread->stack_start) != (unsigned int) my_active_thread->stack_start) {
if (*((unsigned int *)my_active_thread->stack_start) != (unsigned int) my_active_thread->stack_start) {
printf("scheduler(): stack overflow detected, task=%s pid=%u\n", my_active_thread->name, my_active_thread->pid);
}
@ -95,7 +95,7 @@ void sched_run()
extern unsigned long hwtimer_now(void);
unsigned int time = hwtimer_now();
if(my_active_thread && (pidlist[my_active_thread->pid].laststart)) {
if (my_active_thread && (pidlist[my_active_thread->pid].laststart)) {
pidlist[my_active_thread->pid].runtime += time - pidlist[my_active_thread->pid].laststart;
}
@ -103,10 +103,10 @@ void sched_run()
DEBUG("\nscheduler: previous task: %s\n", (my_active_thread == NULL) ? "none" : my_active_thread->name);
if(num_tasks == 0) {
if (num_tasks == 0) {
DEBUG("scheduler: no tasks left.\n");
while(! num_tasks) {
while (!num_tasks) {
/* loop until a new task arrives */
;
}
@ -116,7 +116,7 @@ void sched_run()
my_active_thread = NULL;
while(! my_active_thread) {
while (!my_active_thread) {
int nextrq = number_of_lowest_bit(runqueue_bitcache);
clist_node_t next = *(runqueues[nextrq]);
DEBUG("scheduler: first in queue: %s\n", ((tcb_t *)next.data)->name);
@ -129,7 +129,7 @@ void sched_run()
#endif
#ifdef MODULE_NSS
if(active_thread && active_thread->pid != last_pid) {
if (active_thread && active_thread->pid != last_pid) {
last_pid = active_thread->pid;
}
@ -138,9 +138,9 @@ void sched_run()
DEBUG("scheduler: next task: %s\n", my_active_thread->name);
if(my_active_thread != active_thread) {
if(active_thread != NULL) { /* TODO: necessary? */
if(active_thread->status == STATUS_RUNNING) {
if (my_active_thread != active_thread) {
if (active_thread != NULL) { /* TODO: necessary? */
if (active_thread->status == STATUS_RUNNING) {
active_thread->status = STATUS_PENDING ;
}
}
@ -162,19 +162,19 @@ void sched_register_cb(void (*callback)(uint32_t, uint32_t))
void sched_set_status(tcb_t *process, unsigned int status)
{
if(status & STATUS_ON_RUNQUEUE) {
if(!(process->status & STATUS_ON_RUNQUEUE)) {
if (status & STATUS_ON_RUNQUEUE) {
if (!(process->status & STATUS_ON_RUNQUEUE)) {
DEBUG("adding process %s to runqueue %u.\n", process->name, process->priority);
clist_add(&runqueues[process->priority], &(process->rq_entry));
runqueue_bitcache |= 1 << process->priority;
}
}
else {
if(process->status & STATUS_ON_RUNQUEUE) {
if (process->status & STATUS_ON_RUNQUEUE) {
DEBUG("removing process %s from runqueue %u.\n", process->name, process->priority);
clist_remove(&runqueues[process->priority], &(process->rq_entry));
if(! runqueues[process->priority]) {
if (!runqueues[process->priority]) {
runqueue_bitcache &= ~(1 << process->priority);
}
}
@ -187,8 +187,8 @@ void sched_switch(uint16_t current_prio, uint16_t other_prio, int in_isr)
{
DEBUG("%s: %i %i %i\n", active_thread->name, (int)current_prio, (int)other_prio, in_isr);
if(current_prio <= other_prio) {
if(in_isr) {
if (current_prio <= other_prio) {
if (in_isr) {
sched_context_switch_request = 1;
}
else {

View File

@ -40,7 +40,7 @@ int thread_getlastpid()
unsigned int thread_getstatus(int pid)
{
if(sched_threads[pid] == NULL) {
if (sched_threads[pid] == NULL) {
return STATUS_NOT_FOUND;
}
@ -49,7 +49,7 @@ unsigned int thread_getstatus(int pid)
void thread_sleep()
{
if(inISR()) {
if (inISR()) {
return;
}
@ -64,18 +64,18 @@ int thread_wakeup(int pid)
DEBUG("thread_wakeup: Trying to wakeup PID %i...\n", pid);
int isr = inISR();
if(! isr) {
if (!isr) {
DEBUG("thread_wakeup: Not in interrupt.\n");
dINT();
}
int result = sched_threads[pid]->status;
if(result == STATUS_SLEEPING) {
if (result == STATUS_SLEEPING) {
DEBUG("thread_wakeup: Thread is sleeping.\n");
sched_set_status((tcb_t *)sched_threads[pid], STATUS_RUNNING);
if(!isr) {
if (!isr) {
eINT();
thread_yield();
}
@ -88,7 +88,7 @@ int thread_wakeup(int pid)
else {
DEBUG("thread_wakeup: Thread is not sleeping!\n");
if(!isr) {
if (!isr) {
eINT();
}
@ -101,7 +101,7 @@ int thread_measure_stack_usage(char *stack)
unsigned int *stackp = (unsigned int *)stack;
/* assumption that the comparison fails before or after end of stack */
while(*stackp == (unsigned int)stackp) {
while (*stackp == (unsigned int)stackp) {
stackp++;
}
@ -118,28 +118,28 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void (*f
/* align tcb address on 32bit boundary */
unsigned int tcb_address = (unsigned int) stack + stacksize;
if(tcb_address & 1) {
if (tcb_address & 1) {
tcb_address--;
stacksize--;
}
if(tcb_address & 2) {
if (tcb_address & 2) {
tcb_address -= 2;
stacksize -= 2;
}
tcb_t *cb = (tcb_t *) tcb_address;
if(priority >= SCHED_PRIO_LEVELS) {
if (priority >= SCHED_PRIO_LEVELS) {
return -EINVAL;
}
if(flags & CREATE_STACKTEST) {
if (flags & CREATE_STACKTEST) {
/* assign each int of the stack the value of it's address */
unsigned int *stackmax = (unsigned int *)((char *)stack + stacksize);
unsigned int *stackp = (unsigned int *)stack;
while(stackp < stackmax) {
while (stackp < stackmax) {
*stackp = (unsigned int)stackp;
stackp++;
}
@ -149,14 +149,14 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void (*f
*stack = (unsigned int)stack;
}
if(! inISR()) {
if (!inISR()) {
dINT();
}
int pid = 0;
while(pid < MAXTHREADS) {
if(sched_threads[pid] == NULL) {
while (pid < MAXTHREADS) {
if (sched_threads[pid] == NULL) {
sched_threads[pid] = cb;
cb->pid = pid;
break;
@ -165,10 +165,10 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void (*f
pid++;
}
if(pid == MAXTHREADS) {
if (pid == MAXTHREADS) {
DEBUG("thread_create(): too many threads!\n");
if(! inISR()) {
if (!inISR()) {
eINT();
}
@ -201,14 +201,14 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void (*f
DEBUG("Created thread %s. PID: %u. Priority: %u.\n", name, cb->pid, priority);
if(flags & CREATE_SLEEPING) {
if (flags & CREATE_SLEEPING) {
sched_set_status(cb, STATUS_SLEEPING);
}
else {
sched_set_status(cb, STATUS_PENDING);
if(!(flags & CREATE_WOUT_YIELD)) {
if(! inISR()) {
if (!(flags & CREATE_WOUT_YIELD)) {
if (!inISR()) {
eINT();
thread_yield();
}
@ -218,7 +218,7 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void (*f
}
}
if(!inISR() && active_thread != NULL) {
if (!inISR() && active_thread != NULL) {
eINT();
}

View File

@ -55,7 +55,7 @@ char *thread_stack_init(void *task_func, void *stack_start, int stack_size)
*stk = (unsigned int)(stack_start + stack_size) - 4;
/* build base stack */
for(int i = REGISTER_CNT; i >= 0 ; i--) {
for (int i = REGISTER_CNT; i >= 0 ; i--) {
stk--;
*stk = i;
}
@ -80,7 +80,7 @@ void thread_print_stack(void)
register int i = 0;
s += 5;
while(*s != STACK_MARKER) {
while (*s != STACK_MARKER) {
printf("STACK (%u) addr=%X = %X \n", i, (unsigned int) s, (unsigned int) *s);
s++;
i++;
@ -97,5 +97,5 @@ __attribute__((naked, noreturn)) void arm_reset(void)
WDFEED = 0xAA;
WDFEED = 0x55;
while(1);
while (1);
}

View File

@ -49,35 +49,35 @@ and the mailinglist (subscription via web site)
#include <thread.h>
void FIQ_Routine(void) __attribute__((interrupt("FIQ")));
//void SWI_Routine (void) __attribute__ ((interrupt("SWI")));
//void SWI_Routine (void) __attribute__((interrupt("SWI")));
void UNDEF_Routine(void) __attribute__((interrupt("UNDEF")));
void IRQ_Routine(void)
{
printf("Kernel Panic,\nEarly IRQ call\n");
while(1) {};
while (1) {};
}
/*-----------------------------------------------------------------------------------*/
void FIQ_Routine(void)
{
printf("Kernel Panic,\nEarly FIQ call\n");
while(1) {};
while (1) {};
}
/*-----------------------------------------------------------------------------------*/
void SWI_Routine(void)
{
printf("Kernel Panic,\nEarly SWI call\n");
while(1) {};
while (1) {};
}
/*-----------------------------------------------------------------------------------*/
void DEBUG_Routine(void)
{
printf("DEBUG hit.");
while(1) {};
while (1) {};
}
/*-----------------------------------------------------------------------------------*/
volatile int arm_abortflag = 0;
@ -95,7 +95,7 @@ void abtorigin(const char *vector, u_long *lnk_ptr1)
__asm__ __volatile__("mov %0, sp" : "=r"(sp)); // copy sp
__asm__ __volatile__("msr cpsr_c, %0" :: "r"(cpsr)); // switch back to abt mode
printf("#! %s abort at %p (0x%08lX) originating from %p (0x%08lX) in mode 0x%X\n",
printf("#!%s abort at %p (0x%08lX) originating from %p (0x%08lX) in mode 0x%X\n",
vector, (void *)lnk_ptr1, *(lnk_ptr1), (void *)lnk_ptr2, *(lnk_ptr2), spsr
);
stdio_flush();
@ -108,7 +108,7 @@ void UNDEF_Routine(void)
register u_long *lnk_ptr;
__asm__ __volatile__("sub %0, lr, #8" : "=r"(lnk_ptr)); // get aborting instruction
if(arm_abortflag == 0) {
if (arm_abortflag == 0) {
arm_abortflag = 1; // remember state (if printing should fail again)
abtorigin("undef", lnk_ptr);
}
@ -121,7 +121,7 @@ void PABT_Routine(void)
register u_long *lnk_ptr;
__asm__ __volatile__("sub %0, lr, #8" : "=r"(lnk_ptr)); // get aborting instruction
if(arm_abortflag == 0) {
if (arm_abortflag == 0) {
arm_abortflag = 1; // remember state (if printing should fail again)
abtorigin("pabt", lnk_ptr);
}
@ -134,7 +134,7 @@ void DABT_Routine(void)
register u_long *lnk_ptr;
__asm__ __volatile__("sub %0, lr, #8" : "=r"(lnk_ptr)); // get aborting instruction
if(arm_abortflag == 0) {
if (arm_abortflag == 0) {
arm_abortflag = 1; // remember state (if printing should fail again)
abtorigin("data", lnk_ptr);
}
@ -161,7 +161,7 @@ bl_init_data(void)
p2 = &_data;
p3 = &_edata;
while(p2 < p3) {
while (p2 < p3) {
*p2++ = *p1++;
}
@ -170,7 +170,7 @@ bl_init_data(void)
p1 = &__bss_start;
p2 = &__bss_end;
while(p1 < p2) {
while (p1 < p2) {
*p1++ = 0;
}
}

View File

@ -35,37 +35,37 @@ static void timer_irq(void)
{
short timer = 0;
if(T0IR) {
if (T0IR) {
timer = 0;
}
else if(T1IR) {
else if (T1IR) {
timer = 4;
}
else if(T2IR) {
else if (T2IR) {
timer = 8;
}
volatile unsigned long base = get_base_address(timer);
if(*VULP(base + TXIR) & BIT0) {
if (*VULP(base + TXIR) & BIT0) {
*VULP(base + TXMCR) &= ~BIT0;
*VULP(base + TXIR) = BIT0;
int_handler(timer);
}
if(*VULP(base + TXIR) & BIT1) {
if (*VULP(base + TXIR) & BIT1) {
*VULP(base + TXMCR) &= ~BIT3;
*VULP(base + TXIR) = BIT1;
int_handler(timer + 1);
}
if(*VULP(base + TXIR) & BIT2) {
if (*VULP(base + TXIR) & BIT2) {
*VULP(base + TXMCR) &= ~BIT6;
*VULP(base + TXIR) = BIT2;
int_handler(timer + 2);
}
if(*VULP(base + TXIR) & BIT3) {
if (*VULP(base + TXIR) & BIT3) {
*VULP(base + TXMCR) &= ~BIT9;
*VULP(base + TXIR) = BIT3;
int_handler(timer + 3);

View File

@ -39,20 +39,20 @@ uint8_t flashrom_write(uint8_t *dst, char *src, size_t size)
sec = iap_get_sector((uint32_t) dst);
if(sec == INVALID_ADDRESS) {
if (sec == INVALID_ADDRESS) {
DEBUG("Invalid address\n");
return 0;
}
/* check sector */
if(blank_check_sector(sec, sec) == SECTOR_NOT_BLANK) {
if (blank_check_sector(sec, sec) == SECTOR_NOT_BLANK) {
DEBUG("Warning: Sector %i not blank\n", sec);
}
/* prepare sector */
err = prepare_sectors(sec, sec);
if(err) {
if (err) {
DEBUG("\n-- ERROR: PREPARE_SECTOR_FOR_WRITE_OPERATION: %u\n", err);
return 0;
}
@ -62,7 +62,7 @@ uint8_t flashrom_write(uint8_t *dst, char *src, size_t size)
err = copy_ram_to_flash((uint32_t) dst, (uint32_t) src, 256);
restoreIRQ(intstate);
if(err) {
if (err) {
DEBUG("ERROR: COPY_RAM_TO_FLASH: %u\n", err);
/* set interrupts back and return */
restoreIRQ(intstate);
@ -72,7 +72,7 @@ uint8_t flashrom_write(uint8_t *dst, char *src, size_t size)
else {
err = compare((uint32_t) dst, (uint32_t) src, 256);
if(err) {
if (err) {
DEBUG("ERROR: COMPARE: %i (at position %u)\n", err, iap_result[1]);
return 0;
}
@ -90,19 +90,19 @@ uint8_t flashrom_erase(uint8_t *addr)
uint8_t sec = iap_get_sector((uint32_t) addr);
unsigned intstate;
if(sec == INVALID_ADDRESS) {
if (sec == INVALID_ADDRESS) {
DEBUG("Invalid address\n");
return 0;
}
/* check sector */
if(!blank_check_sector(sec, sec)) {
if (!blank_check_sector(sec, sec)) {
DEBUG("Sector already blank!\n");
return 1;
}
/* prepare sector */
if(prepare_sectors(sec, sec)) {
if (prepare_sectors(sec, sec)) {
DEBUG("-- ERROR: PREPARE_SECTOR_FOR_WRITE_OPERATION --\n");
return 0;
}
@ -110,7 +110,7 @@ uint8_t flashrom_erase(uint8_t *addr)
intstate = disableIRQ();
/* erase sector */
if(erase_sectors(sec, sec)) {
if (erase_sectors(sec, sec)) {
DEBUG("-- ERROR: ERASE SECTOR --\n");
restoreIRQ(intstate);
return 0;
@ -119,7 +119,7 @@ uint8_t flashrom_erase(uint8_t *addr)
restoreIRQ(intstate);
/* check again */
if(blank_check_sector(sec, sec)) {
if (blank_check_sector(sec, sec)) {
DEBUG("-- ERROR: BLANK_CHECK_SECTOR\n");
return 0;
}

View File

@ -27,14 +27,14 @@ void __attribute__((__no_instrument_function__)) profiling_init(void)
{
uint16_t i;
for(i = 0; i < MAX_TRACED_FUNCTIONS; i++) {
for (i = 0; i < MAX_TRACED_FUNCTIONS; i++) {
functions[i].address = 0;
functions[i].time = 0;
functions[i].consumption = 0;
functions[i].counter = 0;
}
for(i = 0; i < PROFILING_STACK_SIZE; i++) {
for (i = 0; i < PROFILING_STACK_SIZE; i++) {
profiling_stack[i] = 0;
}
@ -47,8 +47,8 @@ static int16_t __attribute__((__no_instrument_function__)) get_function_index(ui
{
uint16_t i;
for(i = 0; i < MAX_TRACED_FUNCTIONS; i++) {
if(functions[i].address == addr) {
for (i = 0; i < MAX_TRACED_FUNCTIONS; i++) {
if (functions[i].address == addr) {
return i;
}
}
@ -58,24 +58,24 @@ static int16_t __attribute__((__no_instrument_function__)) get_function_index(ui
void __attribute__((__no_instrument_function__)) __cyg_profile_func_enter(void *func, void *caller)
{
if(!profiling) {
if (!profiling) {
return;
}
int16_t idx = get_function_index((uint32_t) func);
/* if function is not yet on traced */
if((idx < 0) && (traced_functions < MAX_TRACED_FUNCTIONS)) {
if ((idx < 0) && (traced_functions < MAX_TRACED_FUNCTIONS)) {
idx = traced_functions++;
functions[idx].address = (uint32_t) func;
}
/* maximu of traceable functions reached */
else if(idx < 0) {
else if (idx < 0) {
return;
}
/* check if a profiled function is pending */
if(function_pending && (profiling_stack[profiling_sp] != idx)) {
if (function_pending && (profiling_stack[profiling_sp] != idx)) {
functions[idx].time += T0TC - functions[idx].start_time;
//functions[idx].consumption += ltc4150_get_intcount() - functions[idx].consumption_start;
functions[idx].consumption += ltc4150_get_total_mAh() - functions[idx].consumption_start;
@ -94,13 +94,13 @@ void __attribute__((__no_instrument_function__)) __cyg_profile_func_enter(void
void __attribute__((__no_instrument_function__)) __cyg_profile_func_exit(void *func, void *caller)
{
if(!profiling) {
if (!profiling) {
return;
}
int16_t idx = get_function_index((uint32_t) func);
if(idx >= 0) {
if (idx >= 0) {
functions[idx].time += T0TC - functions[idx].start_time;
//functions[idx].consumption += ltc4150_get_intcount() - functions[idx].consumption_start;
functions[idx].consumption += ltc4150_get_total_mAh() - functions[idx].consumption_start;
@ -110,8 +110,8 @@ void __attribute__((__no_instrument_function__)) __cyg_profile_func_exit(void *f
function_pending = 0;
/* if another function is pending */
if(profiling_sp) {
if(--profiling_sp) {
if (profiling_sp) {
if (--profiling_sp) {
functions[profiling_stack[profiling_sp]].start_time = T0TC;
functions[profiling_stack[profiling_sp]].consumption_start = ltc4150_get_total_mAh();
}
@ -122,7 +122,7 @@ void profiling_stats(void)
{
uint16_t i;
for(i = 0; i < traced_functions; i++) {
for (i = 0; i < traced_functions; i++) {
// printf("Function @%04lX was running %u times for %lu ticks, consuming %li ltc-ticks\n", functions[i].address, functions[i].counter, functions[i].time, functions[i].consumption);
printf("Function @%04lX was running %u times for %lu ticks, consuming %lf mAh\n", functions[i].address, functions[i].counter, functions[i].time, functions[i].consumption);
}

View File

@ -88,7 +88,7 @@ volatile static uint8_t iUsedHeap = 0;
/*-----------------------------------------------------------------------------------*/
void heap_stats(void)
{
for(int i = 0; i < NUM_HEAPS; i++)
for (int i = 0; i < NUM_HEAPS; i++)
printf("# heap %i: %p -- %p -> %p (%li of %li free)\n", i, heap_start[i], heap[i], heap_max[i],
(uint32_t)heap_max[i] - (uint32_t)heap[i], (uint32_t)heap_max[i] - (uint32_t)heap_start[i]);
}
@ -100,7 +100,7 @@ void __assert_func(const char *file, int line, const char *func, const char *fai
trace_number(TRACELOG_EV_ASSERTION, line);
syslog(SL_EMERGENCY, "assert", "%s() in %s:%u\n", func, file, line);
#endif
printf("#! assertion %s failed\n\t%s() in %s:%u\n", failedexpr, func, file, line);
printf("#!assertion %s failed\n\t%s() in %s:%u\n", failedexpr, func, file, line);
_exit(3);
}
/*-----------------------------------------------------------------------------------*/
@ -111,7 +111,7 @@ void __assert(const char *file, int line, const char *failedexpr)
/*-----------------------------------------------------------------------------------*/
caddr_t _sbrk_r(struct _reent *r, size_t incr)
{
if(incr < 0) {
if (incr < 0) {
puts("[syscalls] Negative Values for _sbrk_r are not supported");
r->_errno = ENOMEM;
return NULL;
@ -120,14 +120,14 @@ caddr_t _sbrk_r(struct _reent *r, size_t incr)
uint32_t cpsr = disableIRQ();
/* check all heaps for a chunk of the requested size */
for(; iUsedHeap < NUM_HEAPS; iUsedHeap++) {
for (; iUsedHeap < NUM_HEAPS; iUsedHeap++) {
caddr_t new_heap = heap[iUsedHeap] + incr;
#ifdef MODULE_TRACELOG
trace_pointer(TRACELOG_EV_MEMORY, heap[iUsedHeap]);
#endif
if(new_heap <= heap_max[iUsedHeap]) {
if (new_heap <= heap_max[iUsedHeap]) {
caddr_t prev_heap = heap[iUsedHeap];
#ifdef MODULE_TRACELOG
trace_pointer(TRACELOG_EV_MEMORY, new_heap);
@ -153,7 +153,7 @@ int _isatty_r(struct _reent *r, int fd)
{
r->_errno = 0;
if(fd == STDOUT_FILENO || fd == STDERR_FILENO) {
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
return 1;
}
else {
@ -208,7 +208,7 @@ int _fstat_r(struct _reent *r, int fd, struct stat *st)
r->_errno = 0;
memset(st, 0, sizeof(*st));
if(fd == STDOUT_FILENO || fd == STDERR_FILENO) {
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
st->st_mode = S_IFCHR;
ret = 0;
}
@ -237,10 +237,10 @@ int _write_r(struct _reent *r, int fd, const void *data, unsigned int count)
case STDOUT_FILENO:
case STDERR_FILENO:
#if FEUERWARE_CONF_ENABLE_HAL
if(stdio != NULL) {
if (stdio != NULL) {
result = chardevice_write(stdio, (char *)data, count);
}
else if(hal_state == HAL_NOT_INITIALIZED) {
else if (hal_state == HAL_NOT_INITIALIZED) {
result = fw_puts((char *)data, count);
}
@ -306,12 +306,12 @@ void _exit(int n)
#ifdef MODULE_TRACELOG
trace_number(TRACELOG_EV_EXIT, n);
#endif
printf("#! exit %i: resetting\n", n);
printf("#!exit %i: resetting\n", n);
stdio_flush();
arm_reset();
while(1);
while (1);
}
/*---------------------------------------------------------------------------*/
int _getpid(void)

View File

@ -17,27 +17,27 @@ uint8_t cc110x_strobe(uint8_t c)
uint16_t int_state, gdo_state;
/* Check for valid strobe command */
if((c == 0xBD) || ((c > RF_SRES) && (c < RF_SNOP))) {
if ((c == 0xBD) || ((c > RF_SRES) && (c < RF_SNOP))) {
int_state = disableIRQ();
/* Clear the Status read flag */
RF1AIFCTL1 &= ~(RFSTATIFG);
/* Wait for radio to be ready for next instruction */
while(!(RF1AIFCTL1 & RFINSTRIFG));
while (!(RF1AIFCTL1 & RFINSTRIFG));