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 #include "kernel_types.h"
171 
172 #ifdef __cplusplus
173 extern "C" {
174 #endif
175 
184 typedef struct {
187  uint16_t type;
188  union {
189  void *ptr;
190  uint32_t value;
191  } content;
192 } msg_t;
193 
194 
213 int msg_send(msg_t *m, kernel_pid_t target_pid);
214 
215 
232 int msg_try_send(msg_t *m, kernel_pid_t target_pid);
233 
234 
248 int msg_send_to_self(msg_t *m);
249 
253 #define KERNEL_PID_ISR (KERNEL_PID_LAST + 1)
254 
273 int msg_send_int(msg_t *m, kernel_pid_t target_pid);
274 
282 static inline int msg_sent_by_int(const msg_t *m)
283 {
284  return (m->sender_pid == KERNEL_PID_ISR);
285 }
286 
297 int msg_receive(msg_t *m);
298 
310 int msg_try_receive(msg_t *m);
311 
328 int msg_send_receive(msg_t *m, msg_t *reply, kernel_pid_t target_pid);
329 
341 int msg_reply(msg_t *m, msg_t *reply);
342 
355 int msg_reply_int(msg_t *m, msg_t *reply);
356 
363 int msg_avail(void);
364 
375 void msg_init_queue(msg_t *array, int num);
376 
380 void msg_queue_print(void);
381 
382 #ifdef __cplusplus
383 }
384 #endif
385 
386 #endif /* MSG_H */
387 
Types used by the kernel.
uint32_t value
Value content field.
Definition: msg.h:190
void msg_init_queue(msg_t *array, int num)
Initialize the current thread&#39;s message queue.
int msg_send_to_self(msg_t *m)
Send a message to the current thread.
int16_t kernel_pid_t
Unique process identifier.
Definition: kernel_types.h:83
int msg_send(msg_t *m, kernel_pid_t target_pid)
Send a message (blocking).
int msg_try_send(msg_t *m, kernel_pid_t target_pid)
Send a message (non-blocking).
void msg_queue_print(void)
Prints the message queue of the current thread.
int msg_reply_int(msg_t *m, msg_t *reply)
Replies to a message from interrupt.
kernel_pid_t sender_pid
PID of sending thread.
Definition: msg.h:185
int msg_send_int(msg_t *m, kernel_pid_t target_pid)
Send message from interrupt.
Describes a message object which can be sent between threads.
Definition: msg.h:184
#define KERNEL_PID_ISR
Value of msg_t::sender_pid if the sender was an interrupt service routine.
Definition: msg.h:253
int msg_send_receive(msg_t *m, msg_t *reply, kernel_pid_t target_pid)
Send a message, block until reply received.
int msg_avail(void)
Check how many messages are available in the message queue.
static int msg_sent_by_int(const msg_t *m)
Test if the message was sent inside an ISR.
Definition: msg.h:282
int msg_reply(msg_t *m, msg_t *reply)
Replies to a message.
int msg_receive(msg_t *m)
Receive a message.
void * ptr
Pointer content field.
Definition: msg.h:189
uint16_t type
Type field.
Definition: msg.h:187
int msg_try_receive(msg_t *m)
Try to receive a message.