mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-15 17:43:51 +01:00
changed msg to msg_t
This commit is contained in:
parent
d96783a66e
commit
6a96de0d2f
@ -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 */
|
||||
|
||||
@ -48,7 +48,7 @@ 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;
|
||||
|
||||
26
core/msg.c
26
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 *target, msg_t *m) {
|
||||
int n = cib_put(&(target->msg_queue));
|
||||
|
||||
if (n != -1) {
|
||||
@ -38,7 +38,7 @@ 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);
|
||||
}
|
||||
@ -90,7 +90,7 @@ int msg_send(msg* m, unsigned int target_pid, bool block) {
|
||||
} 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,7 +101,7 @@ int msg_send(msg* m, unsigned int target_pid, bool block) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int msg_send_int(msg* m, unsigned int target_pid) {
|
||||
int msg_send_int(msg_t* m, unsigned int target_pid) {
|
||||
tcb *target = (tcb*)sched_threads[target_pid];
|
||||
|
||||
if (target->status == STATUS_RECEIVE_BLOCKED) {
|
||||
@ -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,7 +122,7 @@ 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];
|
||||
sched_set_status(me, STATUS_REPLY_BLOCKED);
|
||||
@ -134,7 +134,7 @@ 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];
|
||||
@ -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,20 +155,20 @@ int msg_reply(msg *m, msg *reply) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int msg_reply_int(msg *m, msg *reply) {
|
||||
int msg_reply_int(msg_t *m, msg_t *reply) {
|
||||
tcb *target = (tcb*)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);
|
||||
|
||||
@ -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,7 +224,7 @@ 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;
|
||||
|
||||
@ -187,7 +187,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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -27,9 +27,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;
|
||||
|
||||
@ -52,7 +52,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);
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ static int min(int a, int b) {
|
||||
}
|
||||
|
||||
void chardev_loop(ringbuffer *rb) {
|
||||
msg m;
|
||||
msg_t m;
|
||||
|
||||
int pid = thread_getpid();
|
||||
|
||||
|
||||
@ -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);
|
||||
@ -16,7 +16,7 @@ static int _posix_fileop_data(int pid, int op, char* buffer, int nbytes) {
|
||||
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) {
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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…
x
Reference in New Issue
Block a user