-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathevents.c
More file actions
52 lines (43 loc) · 1.37 KB
/
events.c
File metadata and controls
52 lines (43 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* EVENTS MANAGEMENT SOURCE CODE
*
* This file contains the global bitmasks used in the application
* and the definition of utility functions for events management.
*
* Created on: 22/dic/2015
* Author: Paolo Sassi
*/
#include "events.h"
#include "globals.h"
/* Global events bitmasks */
uint8_t t_mask; /* target events bitmask */
uint8_t p_mask; /* patriot events bitmask */
uint8_t evts; /* general events bitmask */
/* Events utility functions */
/*----------------------------------------------------------------------------------+
* clearEvents() |
* |
* Clears all the event bitmasks |
*----------------------------------------------------------------------------------+
*/
void clearEvents() {
t_mask = p_mask = evts = 0;
}
/*----------------------------------------------------------------------------------+
* clearTargetEvents(index) |
* |
* Clears the event bits associated to the target 'index' |
*----------------------------------------------------------------------------------+
*/
void clearTargetEvents(int32_t index) {
uint8_t mask;
int32_t i;
mask = 1; /* 0000 0001 */
for (i = 0; i < index; i++) mask <<= 1;
clearEvent(t_mask, mask);
clearEvent(p_mask, mask);
mask <<= 4;
clearEvent(t_mask, mask);
clearEvent(p_mask, mask);
clearEvent(evts, mask);
}