evtimer_msg.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-17 Kaspar Schleiser <kaspar@schleiser.de>
3  * 2017 Freie Universit├Ąt Berlin
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
20 #ifndef EVTIMER_MSG_H
21 #define EVTIMER_MSG_H
22 
23 #include "msg.h"
24 #include "evtimer.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
35 
40 typedef struct {
44 
53 static inline void evtimer_add_msg(evtimer_msg_t *evtimer,
55  kernel_pid_t target_pid)
56 {
57  /* use sender_pid field to get target_pid into callback function */
58  event->msg.sender_pid = target_pid;
59  evtimer_add(evtimer, &event->event);
60 }
61 
68 {
69  evtimer_msg_event_t *mevent = (evtimer_msg_event_t *)event;
70  msg_send_int(&mevent->msg, mevent->msg.sender_pid);
71 }
72 
78 static inline void evtimer_init_msg(evtimer_t *evtimer)
79 {
81 }
82 
83 #ifdef __cplusplus
84 }
85 #endif
86 
87 #endif /* EVTIMER_MSG_H */
88 
void evtimer_init(evtimer_t *evtimer, evtimer_callback_t handler)
Initializes an event timer.
evtimer_t evtimer_msg_t
IPC-message event timer.
Definition: evtimer_msg.h:34
int16_t kernel_pid_t
Unique process identifier.
Definition: kernel_types.h:83
void evtimer_add(evtimer_t *evtimer, evtimer_event_t *event)
Adds event to an event timer.
static void evtimer_init_msg(evtimer_t *evtimer)
Initializes event timer to handle events via IPC.
Definition: evtimer_msg.h:78
event structure
Definition: event.h:127
evtimer API definitions
static void _evtimer_msg_handler(evtimer_event_t *event)
Event handler for IPC messages.
Definition: evtimer_msg.h:67
Event timer.
Definition: evtimer.h:70
evtimer_event_t event
base class
Definition: evtimer_msg.h:41
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.
Messaging API for inter process communication.
Describes a message object which can be sent between threads.
Definition: msg.h:184
IPC-message event.
Definition: evtimer_msg.h:40
static void evtimer_add_msg(evtimer_msg_t *evtimer, evtimer_msg_event_t *event, kernel_pid_t target_pid)
Adds event to an event timer that handles events via IPC.
Definition: evtimer_msg.h:53
msg_t msg
the IPC message to generate on event
Definition: evtimer_msg.h:42
Generic event.
Definition: evtimer.h:57