msg.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
165 #ifndef MSG_H
166 #define MSG_H
167 
168 #include <stdint.h>
169 #include <stdbool.h>
170 
171 #include "sched.h"
172 
173 #ifdef __cplusplus
174 extern "C" {
175 #endif
176 
185 typedef struct {
188  uint16_t type;
189  union {
190  void *ptr;
191  uint32_t value;
192  } content;
193 } msg_t;
194 
213 int msg_send(msg_t *m, kernel_pid_t target_pid);
214 
231 int msg_try_send(msg_t *m, kernel_pid_t target_pid);
232 
247 
251 #define KERNEL_PID_ISR (KERNEL_PID_LAST + 1)
252 
271 int msg_send_int(msg_t *m, kernel_pid_t target_pid);
272 
280 static inline int msg_sent_by_int(const msg_t *m)
281 {
282  return (m->sender_pid == KERNEL_PID_ISR);
283 }
284 
296 
309 
332 int msg_send_receive(msg_t *m, msg_t *reply, kernel_pid_t target_pid);
333 
345 int msg_reply(msg_t *m, msg_t *reply);
346 
359 int msg_reply_int(msg_t *m, msg_t *reply);
360 
367 int msg_avail(void);
368 
379 void msg_init_queue(msg_t *array, int num);
380 
384 void msg_queue_print(void);
385 
386 #ifdef __cplusplus
387 }
388 #endif
389 
390 #endif /* MSG_H */
int msg_send_receive(msg_t *m, msg_t *reply, kernel_pid_t target_pid)
Send a message, block until reply received.
int msg_reply_int(msg_t *m, msg_t *reply)
Replies to a message from interrupt.
int msg_try_receive(msg_t *m)
Try to receive a message.
int msg_send_int(msg_t *m, kernel_pid_t target_pid)
Send message from interrupt.
int msg_reply(msg_t *m, msg_t *reply)
Replies to a message.
void msg_queue_print(void)
Prints the message queue of the current thread.
void msg_init_queue(msg_t *array, int num)
Initialize the current thread's message queue.
static int msg_sent_by_int(const msg_t *m)
Test if the message was sent inside an ISR.
Definition: msg.h:280
int msg_send_to_self(msg_t *m)
Send a message to the current thread.
int msg_try_send(msg_t *m, kernel_pid_t target_pid)
Send a message (non-blocking).
int msg_send(msg_t *m, kernel_pid_t target_pid)
Send a message (blocking).
int msg_avail(void)
Check how many messages are available in the message queue.
#define KERNEL_PID_ISR
Value of msg_t::sender_pid if the sender was an interrupt service routine.
Definition: msg.h:251
int msg_receive(msg_t *m)
Receive a message.
int16_t kernel_pid_t
Unique process identifier.
Definition: sched.h:134
Scheduler API definition.
Describes a message object which can be sent between threads.
Definition: msg.h:185
uint16_t type
Type field.
Definition: msg.h:188
kernel_pid_t sender_pid
PID of sending thread.
Definition: msg.h:186
void * ptr
Pointer content field.
Definition: msg.h:190
uint32_t value
Value content field.
Definition: msg.h:191