-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_PIN.c
70 lines (31 loc) · 1.27 KB
/
test_PIN.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
///// ######### 1 #########
#include <ti/drivers/PIN/PINCC26XX.h>
///// ######### 2 #########
static PIN_Config SensortagAppPinTable[] =
{
Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
Board_KEY_RIGHT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
PIN_TERMINATE
};
static PIN_State sbpPins;
static PIN_Handle hSbpPins;
///// ######### 3 #########
static void buttonHwiFxn(PIN_Handle hPin, PIN_Id pinId){
events |= SBP_BTN_EVT;
Semaphore_post(sem);
}
///// ######### 4 #########
#define SBP_BTN_EVT 0x0010
if(events & SBP_BTN_EVT){
events &= ~SBP_BTN_EVT;
if(LED_value){
PIN_setOutputValue(hSbpPins, Board_LED1, LED_value--);
} else{
PIN_setOutputValue(hSbpPins, Board_LED1, LED_value++);
}
}
///// ######### 5 #########
hSbpPins = PIN_open(&sbpPins, SBP_configTable);
PIN_registerIntCb(hSbpPins, buttonHwiFxn);
PIN_setConfig(hSbpPins, PIN_BM_IRQ, Board_KEY_UP | PIN_IRQ_NEGEDGE);
PIN_setConfig(hSbpPins, PINCC26XX_BM_WAKEUP, Board_KEY_UP | PINCC26XX_WAKEUP_NEGEDGE);