summaryrefslogtreecommitdiff
path: root/firmware/events.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/events.c')
-rw-r--r--firmware/events.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/firmware/events.c b/firmware/events.c
index eaf2e5c352..00c0099bb9 100644
--- a/firmware/events.c
+++ b/firmware/events.c
@@ -23,12 +23,13 @@
23 23
24struct sysevent { 24struct sysevent {
25 unsigned short id; 25 unsigned short id;
26 bool oneshot;
26 void (*callback)(void *data); 27 void (*callback)(void *data);
27}; 28};
28 29
29struct sysevent events[MAX_SYS_EVENTS]; 30struct sysevent events[MAX_SYS_EVENTS];
30 31
31bool add_event(unsigned short id, void (*handler)) 32bool add_event(unsigned short id, bool oneshot, void (*handler))
32{ 33{
33 int i; 34 int i;
34 35
@@ -45,6 +46,7 @@ bool add_event(unsigned short id, void (*handler))
45 if (events[i].callback == NULL) 46 if (events[i].callback == NULL)
46 { 47 {
47 events[i].id = id; 48 events[i].id = id;
49 events[i].oneshot = oneshot;
48 events[i].callback = handler; 50 events[i].callback = handler;
49 return true; 51 return true;
50 } 52 }
@@ -70,7 +72,7 @@ void remove_event(unsigned short id, void (*handler))
70 panicf("event not found"); 72 panicf("event not found");
71} 73}
72 74
73void send_event(unsigned short id, bool oneshot, void *data) 75void send_event(unsigned short id, void *data)
74{ 76{
75 int i; 77 int i;
76 78
@@ -80,7 +82,7 @@ void send_event(unsigned short id, bool oneshot, void *data)
80 { 82 {
81 events[i].callback(data); 83 events[i].callback(data);
82 84
83 if (oneshot) 85 if (events[i].oneshot)
84 events[i].callback = NULL; 86 events[i].callback = NULL;
85 } 87 }
86 } 88 }