31
31
// ================ Local function declarations =================
32
32
static void _button_init ();
33
33
static void _button_cycle (uint64_t u64Ticks );
34
+ static void _button_isr (void * pvParam );
34
35
35
36
// =================== Global constants ================
36
37
const bool gbStartAppCpu = START_APP_CPU ;
37
38
const uint16_t gu16Tim00Divisor = TIM0_0_DIVISOR ;
38
39
const uint64_t gu64tckSchedulePeriod = (CLK_FREQ_HZ / SCHEDULE_FREQ_HZ );
39
40
40
41
// ==================== Local Data ================
41
- static volatile bool gbLedOn = false;
42
42
static const char acMessage [] = "Button pressed.\n" ;
43
43
44
- // Implementation
45
-
44
+ // ================ Local function definitions =================
46
45
IRAM_ATTR static void _button_isr (void * pvParam ) {
47
46
bool bButtonEvent = gsGPIO .STATUS & (1 << BUTTON_GPIO );
48
47
if (bButtonEvent ) {
@@ -57,6 +56,8 @@ IRAM_ATTR static void _button_isr(void *pvParam) {
57
56
}
58
57
59
58
static void _button_init () {
59
+ // setup iomux & gpio regs
60
+ // note: GPIO0 is "preconfigured"
60
61
IomuxGpioConfReg rIOMux ;
61
62
rIOMux .raw = iomux_get_gpioconf (BUTTON_GPIO );
62
63
rIOMux .u1FunIE = 1 ;
@@ -66,6 +67,7 @@ static void _button_init() {
66
67
.u5PinIntEn = 5
67
68
};
68
69
gsGPIO .PIN [BUTTON_GPIO ] = sPinReg ;
70
+ gsGPIO .STATUS_W1TC = (1 << BUTTON_GPIO );
69
71
70
72
// register ISR and enable it
71
73
ECpu eCpu = CPU_PRO ;
@@ -74,7 +76,6 @@ static void _button_init() {
74
76
* prDportIntMap = INT_CH ;
75
77
_xtos_set_interrupt_handler_arg (INT_CH , _button_isr , 0 );
76
78
ets_isr_unmask (1 << INT_CH );
77
-
78
79
}
79
80
80
81
static void _button_cycle (uint64_t u64Ticks ) {
0 commit comments