mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge branch 'master' of ssh://ukleos.des-mesh.net/home/git/ukleos
This commit is contained in:
commit
96206b10a1
@ -57,7 +57,7 @@ void display_symbol(uint8_t symbol, uint8_t mode);
|
||||
* Global Variable section */
|
||||
|
||||
/* Display flags */
|
||||
volatile s_display_flags display;
|
||||
volatile s_display_flags_t display;
|
||||
|
||||
/* Global return string for itoa function */
|
||||
char itoa_str[8];
|
||||
|
@ -67,9 +67,9 @@ typedef union {
|
||||
uint16_t update_acceleration : 1; // 1 = Acceleration data was updated
|
||||
} flag;
|
||||
uint16_t all_flags; // Shortcut to all display flags (for reset)
|
||||
} s_display_flags;
|
||||
} s_display_flags_t;
|
||||
|
||||
extern volatile s_display_flags display;
|
||||
extern volatile s_display_flags_t display;
|
||||
|
||||
// Constants defined in library
|
||||
extern const uint8_t lcd_font[];
|
||||
|
@ -49,13 +49,13 @@ and the mailinglist (subscription via web site)
|
||||
* @note $Id$
|
||||
*/
|
||||
|
||||
typedef struct toprint {
|
||||
typedef struct toprint_t {
|
||||
unsigned int len;
|
||||
char content[];
|
||||
}toprint;
|
||||
}toprint_t;
|
||||
|
||||
#define QUEUESIZE 255
|
||||
static volatile toprint* queue[QUEUESIZE];
|
||||
static volatile toprint_t* queue[QUEUESIZE];
|
||||
static volatile unsigned char queue_head = 0;
|
||||
static volatile unsigned char queue_tail = 0;
|
||||
static volatile unsigned char queue_items = 0;
|
||||
@ -64,7 +64,7 @@ static volatile unsigned int actual_pos = 0;
|
||||
static volatile unsigned int running = 0;
|
||||
static volatile unsigned int fifo = 0;
|
||||
|
||||
static volatile toprint* actual = NULL;
|
||||
static volatile toprint_t* actual = NULL;
|
||||
|
||||
static inline void enqueue(void) {
|
||||
queue_items++;
|
||||
|
@ -35,7 +35,7 @@ typedef struct msg {
|
||||
char *ptr; ///< pointer content field
|
||||
uint32_t value; ///< value content field
|
||||
} content;
|
||||
} msg;
|
||||
} msg_t;
|
||||
|
||||
|
||||
/**
|
||||
@ -54,7 +54,7 @@ typedef struct msg {
|
||||
* @return 0 if receiver is not waiting and block == false
|
||||
* @return -1 on error (invalid PID)
|
||||
*/
|
||||
int msg_send(msg* m, unsigned int target_pid, bool block);
|
||||
int msg_send(msg_t* m, unsigned int target_pid, bool block);
|
||||
|
||||
|
||||
/**
|
||||
@ -68,7 +68,7 @@ int msg_send(msg* m, unsigned int target_pid, bool block);
|
||||
* @return 1 if sending was successfull
|
||||
* @return 0 if receiver is not waiting and block == false
|
||||
*/
|
||||
int msg_send_int(msg* m, unsigned int target_pid);
|
||||
int msg_send_int(msg_t* m, unsigned int target_pid);
|
||||
|
||||
|
||||
/**
|
||||
@ -79,7 +79,7 @@ int msg_send_int(msg* m, unsigned int target_pid);
|
||||
*
|
||||
* @return 1 Function always succeeds or blocks forever.
|
||||
*/
|
||||
int msg_receive(msg* m);
|
||||
int msg_receive(msg_t* m);
|
||||
|
||||
/**
|
||||
* @brief Send a message, block until reply received.
|
||||
@ -90,7 +90,7 @@ int msg_receive(msg* m);
|
||||
* @param target pid the pid of the target process
|
||||
* @return 1 if successful
|
||||
*/
|
||||
int msg_send_receive(msg *m, msg *reply, unsigned int target_pid);
|
||||
int msg_send_receive(msg_t *m, msg_t *reply, unsigned int target_pid);
|
||||
|
||||
/**
|
||||
* @brief Replies to a message.
|
||||
@ -103,7 +103,7 @@ int msg_send_receive(msg *m, msg *reply, unsigned int target_pid);
|
||||
* @return 1 if succcessful
|
||||
* qreturn 0 on error
|
||||
*/
|
||||
int msg_reply(msg *m, msg *reply);
|
||||
int msg_reply(msg_t *m, msg_t *reply);
|
||||
|
||||
/**
|
||||
* @brief Initialize the current thread's message queue.
|
||||
@ -111,7 +111,7 @@ int msg_reply(msg *m, msg *reply);
|
||||
* @param array Pointer to preallocated array of msg objects
|
||||
* @param num Number of msg objects in array. MUST BE POWER OF TWO!
|
||||
*/
|
||||
int msg_init_queue(msg* array, int num);
|
||||
int msg_init_queue(msg_t* array, int num);
|
||||
|
||||
/** @} */
|
||||
#endif /* __MSG_H */
|
||||
|
@ -24,13 +24,13 @@
|
||||
void sched_init();
|
||||
void sched_run();
|
||||
|
||||
void sched_set_status(tcb *process, unsigned int status);
|
||||
void sched_set_status(tcb_t *process, unsigned int status);
|
||||
void sched_switch(uint16_t current_prio, uint16_t other_prio, int in_isr);
|
||||
|
||||
volatile unsigned int sched_context_switch_request;
|
||||
|
||||
volatile tcb *sched_threads[MAXTHREADS];
|
||||
volatile tcb *active_thread;
|
||||
volatile tcb_t *sched_threads[MAXTHREADS];
|
||||
volatile tcb_t *active_thread;
|
||||
|
||||
extern volatile int num_tasks;
|
||||
volatile int thread_pid;
|
||||
|
@ -35,7 +35,7 @@
|
||||
#define STATUS_REPLY_BLOCKED (0x0100)
|
||||
#define STATUS_TIMER_WAITING (0x0200)
|
||||
|
||||
typedef struct tcb {
|
||||
typedef struct tcb_t {
|
||||
char* sp;
|
||||
uint16_t status;
|
||||
|
||||
@ -48,12 +48,12 @@ typedef struct tcb {
|
||||
queue_node_t msg_waiters;
|
||||
|
||||
cib_t msg_queue;
|
||||
msg* msg_array;
|
||||
msg_t* msg_array;
|
||||
|
||||
const char* name;
|
||||
char* stack_start;
|
||||
int stack_size;
|
||||
} tcb;
|
||||
} tcb_t;
|
||||
|
||||
/** @} */
|
||||
#endif /* TCB_H_ */
|
||||
|
@ -33,8 +33,8 @@
|
||||
#define ENABLE_DEBUG
|
||||
#include <debug.h>
|
||||
|
||||
volatile tcb *sched_threads[MAXTHREADS];
|
||||
volatile tcb *active_thread;
|
||||
volatile tcb_t *sched_threads[MAXTHREADS];
|
||||
volatile tcb_t *active_thread;
|
||||
volatile int lpm_prevent_sleep = 0;
|
||||
|
||||
extern void main(void);
|
||||
|
44
core/msg.c
44
core/msg.c
@ -27,7 +27,7 @@
|
||||
//#define ENABLE_DEBUG
|
||||
#include "debug.h"
|
||||
|
||||
static int queue_msg(tcb *target, msg *m) {
|
||||
static int queue_msg(tcb_t *target, msg_t *m) {
|
||||
int n = cib_put(&(target->msg_queue));
|
||||
|
||||
if (n != -1) {
|
||||
@ -38,12 +38,12 @@ static int queue_msg(tcb *target, msg *m) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int msg_send(msg* m, unsigned int target_pid, bool block) {
|
||||
int msg_send(msg_t* m, unsigned int target_pid, bool block) {
|
||||
if (inISR()) {
|
||||
return msg_send_int(m, target_pid);
|
||||
}
|
||||
|
||||
tcb *target = (tcb*)sched_threads[target_pid];
|
||||
tcb_t *target = (tcb_t*)sched_threads[target_pid];
|
||||
|
||||
m->sender_pid = thread_pid;
|
||||
if (m->sender_pid == target_pid) {
|
||||
@ -84,13 +84,13 @@ int msg_send(msg* m, unsigned int target_pid, bool block) {
|
||||
newstatus = STATUS_SEND_BLOCKED;
|
||||
}
|
||||
|
||||
sched_set_status((tcb*)active_thread, newstatus);
|
||||
sched_set_status((tcb_t*)active_thread, newstatus);
|
||||
|
||||
DEBUG("%s: back from send block.\n", active_thread->name);
|
||||
} else {
|
||||
DEBUG("%s: direct msg copy.\n", active_thread->name);
|
||||
/* copy msg to target */
|
||||
msg* target_message = (msg*)target->wait_data;
|
||||
msg_t* target_message = (msg_t*)target->wait_data;
|
||||
*target_message = *m;
|
||||
sched_set_status(target, STATUS_PENDING);
|
||||
}
|
||||
@ -101,8 +101,8 @@ int msg_send(msg* m, unsigned int target_pid, bool block) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int msg_send_int(msg* m, unsigned int target_pid) {
|
||||
tcb *target = (tcb*)sched_threads[target_pid];
|
||||
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) {
|
||||
DEBUG("msg_send_int: direct msg copy.\n");
|
||||
@ -110,7 +110,7 @@ int msg_send_int(msg* m, unsigned int target_pid) {
|
||||
m->sender_pid = target_pid;
|
||||
|
||||
/* copy msg to target */
|
||||
msg* target_message = (msg*)target->wait_data;
|
||||
msg_t* target_message = (msg_t*)target->wait_data;
|
||||
*target_message = *m;
|
||||
sched_set_status(target, STATUS_PENDING);
|
||||
|
||||
@ -122,9 +122,9 @@ int msg_send_int(msg* m, unsigned int target_pid) {
|
||||
}
|
||||
}
|
||||
|
||||
int msg_send_receive(msg *m, msg *reply, unsigned int target_pid) {
|
||||
int msg_send_receive(msg_t *m, msg_t *reply, unsigned int target_pid) {
|
||||
dINT();
|
||||
tcb *me = (tcb*) sched_threads[thread_pid];
|
||||
tcb_t *me = (tcb_t*) sched_threads[thread_pid];
|
||||
sched_set_status(me, STATUS_REPLY_BLOCKED);
|
||||
me->wait_data = (void*) reply;
|
||||
msg_send(m, target_pid, true);
|
||||
@ -134,10 +134,10 @@ int msg_send_receive(msg *m, msg *reply, unsigned int target_pid) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int msg_reply(msg *m, msg *reply) {
|
||||
int msg_reply(msg_t *m, msg_t *reply) {
|
||||
int state = disableIRQ();
|
||||
|
||||
tcb *target = (tcb*)sched_threads[m->sender_pid];
|
||||
tcb_t *target = (tcb_t*)sched_threads[m->sender_pid];
|
||||
if (target->status != STATUS_REPLY_BLOCKED) {
|
||||
DEBUG("%s: msg_reply(): target \"%s\" not waiting for reply.", active_thread->name, target->name);
|
||||
restoreIRQ(state);
|
||||
@ -146,7 +146,7 @@ int msg_reply(msg *m, msg *reply) {
|
||||
|
||||
DEBUG("%s: msg_reply(): direct msg copy.\n", active_thread->name);
|
||||
/* copy msg to target */
|
||||
msg* target_message = (msg*)target->wait_data;
|
||||
msg_t* target_message = (msg_t*)target->wait_data;
|
||||
*target_message = *reply;
|
||||
sched_set_status(target, STATUS_PENDING);
|
||||
restoreIRQ(state);
|
||||
@ -155,24 +155,24 @@ int msg_reply(msg *m, msg *reply) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int msg_reply_int(msg *m, msg *reply) {
|
||||
tcb *target = (tcb*)sched_threads[m->sender_pid];
|
||||
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) {
|
||||
DEBUG("%s: msg_reply_int(): target \"%s\" not waiting for reply.", active_thread->name, target->name);
|
||||
return -1;
|
||||
}
|
||||
msg* target_message = (msg*)target->wait_data;
|
||||
msg_t* target_message = (msg_t*)target->wait_data;
|
||||
*target_message = *reply;
|
||||
sched_set_status(target, STATUS_PENDING);
|
||||
sched_context_switch_request = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int msg_receive(msg* m) {
|
||||
int msg_receive(msg_t* m) {
|
||||
dINT();
|
||||
DEBUG("%s: msg_receive.\n", active_thread->name);
|
||||
|
||||
tcb *me = (tcb*) sched_threads[thread_pid];
|
||||
tcb_t *me = (tcb_t*) sched_threads[thread_pid];
|
||||
|
||||
int n = -1;
|
||||
if (me->msg_array) {
|
||||
@ -202,7 +202,7 @@ int msg_receive(msg* m) {
|
||||
return 1;
|
||||
} else {
|
||||
DEBUG("%s: msg_receive(): Wakeing up waiting thread.\n", active_thread->name);
|
||||
tcb *sender = (tcb*)node->data;
|
||||
tcb_t *sender = (tcb_t*)node->data;
|
||||
|
||||
if (n >= 0) {
|
||||
/* we've already got a messgage from the queue. as there is a
|
||||
@ -212,7 +212,7 @@ int msg_receive(msg* m) {
|
||||
}
|
||||
|
||||
/* copy msg */
|
||||
msg* sender_msg = (msg*)sender->wait_data;
|
||||
msg_t* sender_msg = (msg_t*)sender->wait_data;
|
||||
*m = *sender_msg;
|
||||
|
||||
/* remove sender from queue */
|
||||
@ -224,10 +224,10 @@ int msg_receive(msg* m) {
|
||||
}
|
||||
}
|
||||
|
||||
int msg_init_queue(msg* array, int num) {
|
||||
int msg_init_queue(msg_t* array, int num) {
|
||||
/* make sure brainfuck condition is met */
|
||||
if (num && (num & (num - 1)) == 0) {
|
||||
tcb *me = (tcb*)active_thread;
|
||||
tcb_t *me = (tcb_t*)active_thread;
|
||||
me->msg_array = array;
|
||||
cib_init(&(me->msg_queue), num);
|
||||
return 0;
|
||||
|
@ -61,7 +61,7 @@ void mutex_wait(struct mutex_t *mutex) {
|
||||
return;
|
||||
}
|
||||
|
||||
sched_set_status((tcb*)active_thread, STATUS_MUTEX_BLOCKED);
|
||||
sched_set_status((tcb_t*)active_thread, STATUS_MUTEX_BLOCKED);
|
||||
|
||||
queue_node_t n;
|
||||
n.priority = (unsigned int) active_thread->priority;
|
||||
@ -86,7 +86,7 @@ void mutex_unlock(struct mutex_t* mutex, int yield) {
|
||||
if (mutex->val != 0) {
|
||||
if (mutex->queue.next) {
|
||||
queue_node_t *next = queue_remove_head(&(mutex->queue));
|
||||
tcb* process = (tcb*)next->data;
|
||||
tcb_t* process = (tcb_t*)next->data;
|
||||
DEBUG("%s: waking up waiter %s.\n", process->name);
|
||||
sched_set_status(process, STATUS_PENDING);
|
||||
|
||||
|
14
core/sched.c
14
core/sched.c
@ -56,7 +56,7 @@ void sched_init() {
|
||||
void sched_run() {
|
||||
sched_context_switch_request = 0;
|
||||
|
||||
tcb *my_active_thread = (tcb*)active_thread;
|
||||
tcb_t *my_active_thread = (tcb_t*)active_thread;
|
||||
|
||||
if (my_active_thread) {
|
||||
if( my_active_thread->status == STATUS_RUNNING) {
|
||||
@ -94,9 +94,9 @@ void sched_run() {
|
||||
// if (runqueues[i]) {
|
||||
int nextrq = number_of_lowest_bit(runqueue_bitcache);
|
||||
clist_node_t next = *(runqueues[nextrq]);
|
||||
DEBUG("scheduler: first in queue: %s\n", ((tcb*)next.data)->name);
|
||||
DEBUG("scheduler: first in queue: %s\n", ((tcb_t*)next.data)->name);
|
||||
clist_advance(&(runqueues[nextrq]));
|
||||
my_active_thread = (tcb*)next.data;
|
||||
my_active_thread = (tcb_t*)next.data;
|
||||
thread_pid = (volatile int) my_active_thread->pid;
|
||||
#if SCHEDSTATISTICS
|
||||
pidlist[my_active_thread->pid].laststart = time;
|
||||
@ -115,16 +115,16 @@ void sched_run() {
|
||||
active_thread->status = STATUS_PENDING ;
|
||||
}
|
||||
}
|
||||
sched_set_status((tcb*)my_active_thread, STATUS_RUNNING);
|
||||
sched_set_status((tcb_t*)my_active_thread, STATUS_RUNNING);
|
||||
}
|
||||
|
||||
active_thread = (volatile tcb*) my_active_thread;
|
||||
active_thread = (volatile tcb_t*) my_active_thread;
|
||||
|
||||
DEBUG("scheduler: done.\n");
|
||||
}
|
||||
|
||||
|
||||
void sched_set_status(tcb *process, unsigned int status) {
|
||||
void sched_set_status(tcb_t *process, unsigned int status) {
|
||||
if (status & STATUS_ON_RUNQUEUE) {
|
||||
if (! (process->status & STATUS_ON_RUNQUEUE)) {
|
||||
DEBUG("adding process %s to runqueue %u.\n", process->name, process->priority);
|
||||
@ -163,7 +163,7 @@ void sched_task_exit(void) {
|
||||
sched_threads[active_thread->pid] = NULL;
|
||||
num_tasks--;
|
||||
|
||||
sched_set_status((tcb*)active_thread, STATUS_STOPPED);
|
||||
sched_set_status((tcb_t*)active_thread, STATUS_STOPPED);
|
||||
|
||||
active_thread = NULL;
|
||||
cpu_switch_context_exit();
|
||||
|
@ -39,7 +39,7 @@ unsigned int thread_getstatus(int pid) {
|
||||
void thread_sleep() {
|
||||
if ( inISR()) return;
|
||||
dINT();
|
||||
sched_set_status((tcb*)active_thread, STATUS_SLEEPING);
|
||||
sched_set_status((tcb_t*)active_thread, STATUS_SLEEPING);
|
||||
thread_yield();
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ int thread_wakeup(int pid) {
|
||||
int result = sched_threads[pid]->status;
|
||||
if (result == STATUS_SLEEPING) {
|
||||
DEBUG("thread_wakeup: Thread is sleeping.\n");
|
||||
sched_set_status((tcb*)sched_threads[pid], STATUS_RUNNING);
|
||||
sched_set_status((tcb_t*)sched_threads[pid], STATUS_RUNNING);
|
||||
if (!isr) {
|
||||
eINT();
|
||||
thread_yield();
|
||||
@ -83,7 +83,7 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void (*f
|
||||
{
|
||||
/* allocate our thread control block at the top of our stackspace */
|
||||
int total_stacksize = stacksize;
|
||||
stacksize -= sizeof(tcb);
|
||||
stacksize -= sizeof(tcb_t);
|
||||
|
||||
/* align tcb address on 32bit boundary */
|
||||
unsigned int tcb_address = (unsigned int) stack + stacksize;
|
||||
@ -95,7 +95,7 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void (*f
|
||||
tcb_address-=2;
|
||||
stacksize-=2;
|
||||
}
|
||||
tcb *cb = (tcb*) tcb_address;
|
||||
tcb_t *cb = (tcb_t*) tcb_address;
|
||||
|
||||
if (priority >= SCHED_PRIO_LEVELS) {
|
||||
return -EINVAL;
|
||||
|
@ -189,7 +189,7 @@ interrupt(RTC_VECTOR) __attribute__ ((naked)) rtc_isr(void) {
|
||||
RTCYEARH = (time_to_set.tm_year + 1900) >> 0x08;
|
||||
}
|
||||
if (rtc_second_pid) {
|
||||
msg m;
|
||||
msg_t m;
|
||||
m.type = RTC_SECOND;
|
||||
msg_send_int(&m, rtc_second_pid);
|
||||
}
|
||||
|
@ -48,12 +48,12 @@ and the mailinglist (subscription via web site)
|
||||
#include "cpu.h"
|
||||
#include <irq.h>
|
||||
|
||||
struct irq_callback {
|
||||
struct irq_callback_t {
|
||||
fp_irqcb callback;
|
||||
};
|
||||
|
||||
static struct irq_callback gpioint0[32];
|
||||
static struct irq_callback gpioint2[32];
|
||||
static struct irq_callback_t gpioint0[32];
|
||||
static struct irq_callback_t gpioint2[32];
|
||||
|
||||
|
||||
void gpioint_init(void) {
|
||||
@ -68,7 +68,7 @@ void gpioint_init(void) {
|
||||
bool
|
||||
gpioint_set(int port, uint32_t bitmask, int flags, fp_irqcb callback)
|
||||
{
|
||||
struct irq_callback* cbdata;
|
||||
struct irq_callback_t* cbdata;
|
||||
unsigned long bit;
|
||||
volatile unsigned long* en_f;
|
||||
volatile unsigned long* en_r;
|
||||
@ -123,7 +123,7 @@ gpioint_set(int port, uint32_t bitmask, int flags, fp_irqcb callback)
|
||||
return true; // success
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void __attribute__ ((__no_instrument_function__)) test_irq(int port, unsigned long f_mask, unsigned long r_mask, struct irq_callback* pcb)
|
||||
static void __attribute__ ((__no_instrument_function__)) test_irq(int port, unsigned long f_mask, unsigned long r_mask, struct irq_callback_t* pcb)
|
||||
{
|
||||
/* Test each bit of rising and falling masks, if set trigger interrupt
|
||||
* on corresponding device */
|
||||
|
@ -119,10 +119,10 @@ typedef struct
|
||||
uint64_t m_ticks; ///< 64-bit timestamp
|
||||
uint8_t source; ///< Source address
|
||||
uint8_t identification; ///< Identification (1-bit)
|
||||
} seq_buffer_entry;
|
||||
} seq_buffer_entry_t;
|
||||
|
||||
/// Sequence number buffer for this layer
|
||||
static seq_buffer_entry seq_buffer[MAX_SEQ_BUFFER_SIZE];
|
||||
static seq_buffer_entry_t seq_buffer[MAX_SEQ_BUFFER_SIZE];
|
||||
|
||||
/// Next position to enter a new value into ::seqBuffer
|
||||
static uint8_t seq_buffer_pos = 0;
|
||||
@ -186,7 +186,7 @@ void cc1100_phy_init()
|
||||
pm_init_table((pm_table_t*)&handler_table, MAX_PACKET_HANDLERS, handlers);
|
||||
|
||||
// Clear sequence number buffer
|
||||
memset(seq_buffer, 0, sizeof(seq_buffer_entry) * MAX_SEQ_BUFFER_SIZE);
|
||||
memset(seq_buffer, 0, sizeof(seq_buffer_entry_t) * MAX_SEQ_BUFFER_SIZE);
|
||||
|
||||
// Initialize mutex
|
||||
cc1100_mutex_pid = -1;
|
||||
@ -624,7 +624,7 @@ int cc1100_set_packet_handler(protocol_t protocol, packet_handler_t handler)
|
||||
|
||||
static void cc1100_event_handler_function(void)
|
||||
{
|
||||
msg m;
|
||||
msg_t m;
|
||||
while (1)
|
||||
{
|
||||
if (cc1100_watch_dog_period != 0) {
|
||||
@ -685,7 +685,7 @@ static void cc1100_event_handler_function(void)
|
||||
|
||||
void cc1100_phy_rx_handler(void)
|
||||
{
|
||||
msg m;
|
||||
msg_t m;
|
||||
m.type = MSG_POLL;
|
||||
bool dup = false;
|
||||
bool res = false;
|
||||
|
@ -51,7 +51,7 @@ void cc110x_rx_handler(void) {
|
||||
|
||||
/* notify transceiver thread if any */
|
||||
if (transceiver_pid) {
|
||||
msg m;
|
||||
msg_t m;
|
||||
m.type = (uint16_t) RCV_PKT_CC1100;
|
||||
m.content.value = rx_buffer_next;
|
||||
msg_send_int(&m, transceiver_pid);
|
||||
|
@ -22,9 +22,9 @@ char radio_stack_buffer[RADIO_STACK_SIZE];
|
||||
|
||||
uint8_t snd_buffer[SEND_SIZE];
|
||||
|
||||
msg msg_q[RCV_BUFFER_SIZE];
|
||||
msg_t msg_q[RCV_BUFFER_SIZE];
|
||||
|
||||
static msg mesg;
|
||||
static msg_t mesg;
|
||||
static transceiver_command_t tcmd;
|
||||
static radio_packet_t p;
|
||||
|
||||
@ -48,7 +48,7 @@ void send(radio_address_t dst, uint8_t len, uint8_t *data) {
|
||||
|
||||
|
||||
void radio(void) {
|
||||
msg m;
|
||||
msg_t m;
|
||||
radio_packet_t *p;
|
||||
|
||||
msg_init_queue(msg_q, RCV_BUFFER_SIZE);
|
||||
|
@ -39,9 +39,9 @@ char button_handler_stack_buffer[BUTTON_HANDLER_STACK_SIZE];
|
||||
|
||||
uint8_t snd_buffer[SEND_SIZE];
|
||||
|
||||
msg msg_q[RCV_BUFFER_SIZE];
|
||||
msg_t msg_q[RCV_BUFFER_SIZE];
|
||||
|
||||
static msg mesg;
|
||||
static msg_t mesg;
|
||||
static transceiver_command_t tcmd;
|
||||
static radio_packet_t p;
|
||||
|
||||
@ -66,7 +66,7 @@ void send(radio_address_t dst, uint8_t len, uint8_t *data) {
|
||||
}
|
||||
|
||||
void radio(void) {
|
||||
msg m;
|
||||
msg_t m;
|
||||
radio_packet_t *p;
|
||||
|
||||
msg_init_queue(msg_q, RCV_BUFFER_SIZE);
|
||||
|
@ -25,9 +25,9 @@ char radio_stack_buffer[RADIO_STACK_SIZE];
|
||||
|
||||
uint8_t snd_buffer[SND_BUFFER_SIZE][CC1100_MAX_DATA_LENGTH];
|
||||
|
||||
msg msg_q[RCV_BUFFER_SIZE];
|
||||
msg_t msg_q[RCV_BUFFER_SIZE];
|
||||
|
||||
static msg mesg;
|
||||
static msg_t mesg;
|
||||
static transceiver_command_t tcmd;
|
||||
static radio_packet_t p;
|
||||
|
||||
@ -98,7 +98,7 @@ void print_buffer(char *unused) {
|
||||
}
|
||||
|
||||
void radio(void) {
|
||||
msg m;
|
||||
msg_t m;
|
||||
radio_packet_t *p;
|
||||
uint8_t i;
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
void second_thread(void) {
|
||||
printf("second_thread starting.\n");
|
||||
msg m;
|
||||
msg_t m;
|
||||
|
||||
while(1) {
|
||||
msg_receive(&m);
|
||||
@ -21,7 +21,7 @@ int main(void)
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
|
||||
msg m;
|
||||
msg_t m;
|
||||
|
||||
int pid = thread_create(second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, second_thread, "pong");
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
void second_thread(void) {
|
||||
printf("second_thread starting.\n");
|
||||
msg m;
|
||||
msg_t m;
|
||||
int i = 1;
|
||||
while(1) {
|
||||
msg_receive(&m);
|
||||
@ -21,7 +21,7 @@ int main(void)
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
|
||||
msg m;
|
||||
msg_t m;
|
||||
|
||||
int pid = thread_create(second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, second_thread, "pong");
|
||||
|
||||
|
@ -25,9 +25,9 @@ char radio_stack_buffer[RADIO_STACK_SIZE];
|
||||
|
||||
uint8_t snd_buffer[SND_BUFFER_SIZE][CC1100_MAX_DATA_LENGTH];
|
||||
|
||||
msg msg_q[RCV_BUFFER_SIZE];
|
||||
msg_t msg_q[RCV_BUFFER_SIZE];
|
||||
|
||||
static msg mesg;
|
||||
static msg_t mesg;
|
||||
static transceiver_command_t tcmd;
|
||||
static radio_packet_t p;
|
||||
|
||||
@ -121,7 +121,7 @@ void set_delay(char *delay) {
|
||||
}
|
||||
|
||||
void radio(void) {
|
||||
msg m;
|
||||
msg_t m;
|
||||
radio_packet_t *p;
|
||||
uint8_t i;
|
||||
|
||||
|
@ -14,7 +14,7 @@ void wakeup_thread(void){
|
||||
}
|
||||
|
||||
void msg_thread(void){
|
||||
msg m;
|
||||
msg_t m;
|
||||
msg_receive(&m);
|
||||
printf("%s\n",(char*)m.content.ptr);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
static char alarm_stack[KERNEL_CONF_STACKSIZE_DEFAULT];
|
||||
|
||||
static void alarm_thread(void) {
|
||||
msg m;
|
||||
msg_t m;
|
||||
|
||||
struct tm time;
|
||||
|
||||
|
@ -15,7 +15,7 @@ void time_print(struct tm *time) {
|
||||
static char clock_stack[KERNEL_CONF_STACKSIZE_DEFAULT];
|
||||
|
||||
static void clock_thread(void) {
|
||||
msg m;
|
||||
msg_t m;
|
||||
|
||||
int active = 0;
|
||||
rtc_second_pid = thread_getpid();
|
||||
|
@ -21,7 +21,7 @@ int apps[NUM_APPS];
|
||||
|
||||
int button_thread = 0;
|
||||
void button_star(void) {
|
||||
msg m;
|
||||
msg_t m;
|
||||
|
||||
if (button_thread) {
|
||||
m.type = MSG_BUTTON_STAR;
|
||||
@ -40,7 +40,7 @@ int main(void)
|
||||
|
||||
int active_app = 0;
|
||||
|
||||
msg m;
|
||||
msg_t m;
|
||||
|
||||
//buzzer_beep(15, 5000);
|
||||
|
||||
|
@ -16,13 +16,13 @@ static int min(int a, int b) {
|
||||
else return b;
|
||||
}
|
||||
|
||||
void chardev_loop(ringbuffer *rb) {
|
||||
msg m;
|
||||
void chardev_loop(ringbuffer_t *rb) {
|
||||
msg_t m;
|
||||
|
||||
int pid = thread_getpid();
|
||||
|
||||
int reader_pid = -1;
|
||||
struct posix_iop *r = NULL;
|
||||
struct posix_iop_t *r = NULL;
|
||||
|
||||
puts("UART0 thread started.");
|
||||
|
||||
@ -46,7 +46,7 @@ void chardev_loop(ringbuffer *rb) {
|
||||
m.content.value = -EINVAL;
|
||||
msg_reply(&m, &m);
|
||||
} else {
|
||||
r = (struct posix_iop *)m.content.ptr;
|
||||
r = (struct posix_iop_t *)m.content.ptr;
|
||||
}
|
||||
break;
|
||||
case CLOSE:
|
||||
|
@ -3,6 +3,6 @@
|
||||
|
||||
#include <ringbuffer.h>
|
||||
|
||||
void chardev_loop(ringbuffer *rb);
|
||||
void chardev_loop(ringbuffer_t *rb);
|
||||
|
||||
#endif /* __CHARDEV_THREAD_H */
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define READ 2
|
||||
#define WRITE 3
|
||||
|
||||
struct posix_iop {
|
||||
struct posix_iop_t {
|
||||
int nbytes;
|
||||
char *buffer;
|
||||
};
|
||||
|
@ -8,7 +8,7 @@
|
||||
//#define DEBUG(...) printf (__VA_ARGS__)
|
||||
#define DEBUG(...)
|
||||
|
||||
void ringbuffer_init(ringbuffer *rb, char* buffer, unsigned int bufsize) {
|
||||
void ringbuffer_init(ringbuffer_t *rb, char* buffer, unsigned int bufsize) {
|
||||
rb->buf = buffer;
|
||||
rb->start = 0;
|
||||
rb->end = 0;
|
||||
@ -16,13 +16,13 @@ void ringbuffer_init(ringbuffer *rb, char* buffer, unsigned int bufsize) {
|
||||
rb->avail = 0;
|
||||
}
|
||||
|
||||
void rb_add_elements(ringbuffer* rb, char *buf, int n) {
|
||||
void rb_add_elements(ringbuffer_t* rb, char *buf, int n) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
rb_add_element(rb, buf[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void rb_add_element(ringbuffer* rb, char c) {
|
||||
void rb_add_element(ringbuffer_t* rb, char c) {
|
||||
if (rb->avail == rb->size) rb_get_element(rb);
|
||||
|
||||
rb->buf[rb->end++] = c;
|
||||
@ -31,7 +31,7 @@ void rb_add_element(ringbuffer* rb, char c) {
|
||||
rb->avail++;
|
||||
}
|
||||
|
||||
int rb_get_element(ringbuffer *rb) {
|
||||
int rb_get_element(ringbuffer_t *rb) {
|
||||
if (rb->avail == 0) return -1;
|
||||
|
||||
rb->avail--;
|
||||
@ -42,7 +42,7 @@ int rb_get_element(ringbuffer *rb) {
|
||||
return c;
|
||||
}
|
||||
|
||||
int rb_get_elements(ringbuffer *rb, char* buf, int n) {
|
||||
int rb_get_elements(ringbuffer_t *rb, char* buf, int n) {
|
||||
int count = 0;
|
||||
while (rb->avail && (count < n)) {
|
||||
buf[count++] = rb_get_element(rb);
|
||||
|
@ -7,12 +7,12 @@ typedef struct ringbuffer {
|
||||
unsigned int end;
|
||||
unsigned int size;
|
||||
unsigned int avail;
|
||||
} ringbuffer;
|
||||
} ringbuffer_t;
|
||||
|
||||
void ringbuffer_init(ringbuffer *rb, char* buffer, unsigned int bufsize);
|
||||
void rb_add_element(ringbuffer *rb, char c);
|
||||
void rb_add_elements(ringbuffer *rb, char *buf, int n);
|
||||
int rb_get_element(ringbuffer *rb);
|
||||
int rb_get_elements(ringbuffer *rb, char *buf, int n);
|
||||
void ringbuffer_init(ringbuffer_t *rb, char* buffer, unsigned int bufsize);
|
||||
void rb_add_element(ringbuffer_t *rb, char c);
|
||||
void rb_add_elements(ringbuffer_t *rb, char *buf, int n);
|
||||
int rb_get_element(ringbuffer_t *rb);
|
||||
int rb_get_elements(ringbuffer_t *rb, char *buf, int n);
|
||||
|
||||
#endif /* __RINGBUFFER_H */
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
|
||||
static int _posix_fileop(int pid, int op, int flags) {
|
||||
msg m;
|
||||
msg_t m;
|
||||
m.type = op;
|
||||
m.content.value = flags;
|
||||
msg_send_receive(&m, &m, pid);
|
||||
@ -12,11 +12,11 @@ static int _posix_fileop(int pid, int op, int flags) {
|
||||
}
|
||||
|
||||
static int _posix_fileop_data(int pid, int op, char* buffer, int nbytes) {
|
||||
struct posix_iop r;
|
||||
struct posix_iop_t r;
|
||||
r.nbytes = nbytes;
|
||||
r.buffer = buffer;
|
||||
|
||||
msg m;
|
||||
msg_t m;
|
||||
m.type = op;
|
||||
m.content.ptr = (char*) &r;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#define TEXT_SIZE CC1100_MAX_DATA_LENGTH
|
||||
|
||||
char text_msg[TEXT_SIZE];
|
||||
msg mesg;
|
||||
msg_t mesg;
|
||||
transceiver_command_t tcmd;
|
||||
|
||||
void _cc110x_ng_get_set_address_handler(char *addr) {
|
||||
|
@ -27,7 +27,7 @@ void thread_print_all(void)
|
||||
|
||||
printf("\tpid | %-21s| %-9sQ | pri | stack ( used) location | runtime | switches \n", "name", "state");
|
||||
for( i = 0; i < MAXTHREADS; i++ ) {
|
||||
tcb* p = (tcb*)sched_threads[i];
|
||||
tcb_t* p = (tcb_t*)sched_threads[i];
|
||||
|
||||
if( p != NULL ) {
|
||||
int state = p->status; // copy state
|
||||
|
@ -235,7 +235,7 @@ static void swtimer_action(swtimer_t *swtimer) {
|
||||
}
|
||||
case SWTIMER_MSG:
|
||||
{
|
||||
msg m;
|
||||
msg_t m;
|
||||
m.content.value = swtimer->action.msg.value;
|
||||
int result = msg_send_int(&m, swtimer->action.msg.target_pid);
|
||||
if (result < 0) {
|
||||
|
@ -34,7 +34,7 @@ radio_packet_t transceiver_buffer[TRANSCEIVER_BUFFER_SIZE];
|
||||
uint8_t data_buffer[TRANSCEIVER_BUFFER_SIZE * PAYLOAD_SIZE];
|
||||
|
||||
/* message buffer */
|
||||
msg msg_buffer[TRANSCEIVER_MSG_BUFFER_SIZE];
|
||||
msg_t msg_buffer[TRANSCEIVER_MSG_BUFFER_SIZE];
|
||||
|
||||
uint32_t response; ///< response bytes for messages to upper layer threads
|
||||
|
||||
@ -116,7 +116,7 @@ uint8_t transceiver_register(transceiver_type_t t, int pid) {
|
||||
* loop
|
||||
*/
|
||||
void run(void) {
|
||||
msg m;
|
||||
msg_t m;
|
||||
transceiver_command_t *cmd;
|
||||
|
||||
msg_init_queue(msg_buffer, TRANSCEIVER_MSG_BUFFER_SIZE);
|
||||
@ -180,7 +180,7 @@ static void receive_packet(uint16_t type, uint8_t pos) {
|
||||
uint8_t i = 0;
|
||||
transceiver_type_t t;
|
||||
rx_buffer_pos = pos;
|
||||
msg m;
|
||||
msg_t m;
|
||||
|
||||
DEBUG("Packet received\n");
|
||||
switch (type) {
|
||||
|
@ -10,7 +10,7 @@
|
||||
#define UART0_BUFSIZE (32)
|
||||
#define UART0_STACKSIZE (MINIMUM_STACK_SIZE + 256)
|
||||
|
||||
ringbuffer uart0_ringbuffer;
|
||||
ringbuffer_t uart0_ringbuffer;
|
||||
int uart0_handler_pid;
|
||||
|
||||
static char buffer[UART0_BUFSIZE];
|
||||
@ -33,7 +33,7 @@ void uart0_handle_incoming(int c) {
|
||||
}
|
||||
|
||||
void uart0_notify_thread(void) {
|
||||
msg m;
|
||||
msg_t m;
|
||||
m.type = 0;
|
||||
msg_send_int(&m, uart0_handler_pid);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user