-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsrb_gpio_interrupt.c
69 lines (63 loc) · 1.07 KB
/
srb_gpio_interrupt.c
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "srb_gpio_interrupt.h"
// gpioInterruptMode
void gpioInterruptMode(char pin, char mode) {
char port;
mapPin(&pin, &port);
switch (mode) {
case DISABLED:
if (port == 1)
P1IE &= ~pin;
else
P2IE &= ~pin;
break;
case FALLING:
if (port == 1) {
P1IES |= pin;
P1IFG &= ~pin;
P1IE |= pin;
} else {
P2IES |= pin;
P2IFG &= ~pin;
P2IE |= pin;
}
break;
case RISING:
if (port == 1) {
P1IES &= ~pin;
P1IFG &= ~pin;
P1IE |= pin;
} else {
P2IES &= ~pin;
P2IFG &= ~pin;
P2IE |= pin;
}
break;
}
}
// gpioFlagCheck
char gpioFlagCheck(char pin) {
char pin_num, port;
pin_num = pinNum(pin);
mapPin(&pin, &port);
switch (port) {
case 1:
return (P1IFG & pin) >> pin_num;
case 2:
return (P2IFG & pin) >> pin_num;
default:
return 0;
}
}
// gpioFlagClear
void gpioFlagClear(char pin) {
char port;
mapPin(&pin, &port);
switch (port) {
case 1:
P1IFG &= ~pin;
break;
case 2:
P2IFG &= ~pin;
break;
}
}