Skip to content

Commit 9a831a6

Browse files
authored
Merge pull request #715 from hubmartin/gpiote-fix
Fix GPIOTE not calling ISR when button is held during boot
2 parents b969272 + 9ef1bab commit 9a831a6

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

src/systemtask/SystemTask.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,21 @@ void SystemTask::Work() {
157157
heartRateSensor.Disable();
158158
heartRateApp.Start();
159159

160-
nrf_gpio_cfg_sense_input(PinMap::Button, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_High);
160+
// Button
161161
nrf_gpio_cfg_output(15);
162162
nrf_gpio_pin_set(15);
163163

164164
nrfx_gpiote_in_config_t pinConfig;
165-
pinConfig.skip_gpio_setup = true;
165+
pinConfig.skip_gpio_setup = false;
166166
pinConfig.hi_accuracy = false;
167167
pinConfig.is_watcher = false;
168-
pinConfig.sense = (nrf_gpiote_polarity_t) NRF_GPIOTE_POLARITY_HITOLO;
168+
pinConfig.sense = (nrf_gpiote_polarity_t) NRF_GPIOTE_POLARITY_TOGGLE;
169169
pinConfig.pull = (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown;
170170

171171
nrfx_gpiote_in_init(PinMap::Button, &pinConfig, nrfx_gpiote_evt_handler);
172+
nrfx_gpiote_in_event_enable(PinMap::Button, true);
172173

174+
// Touchscreen
173175
nrf_gpio_cfg_sense_input(PinMap::Cst816sIrq, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pullup, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_Low);
174176

175177
pinConfig.skip_gpio_setup = true;
@@ -180,18 +182,17 @@ void SystemTask::Work() {
180182

181183
nrfx_gpiote_in_init(PinMap::Cst816sIrq, &pinConfig, nrfx_gpiote_evt_handler);
182184

185+
// Power present
183186
pinConfig.sense = NRF_GPIOTE_POLARITY_TOGGLE;
184187
pinConfig.pull = NRF_GPIO_PIN_NOPULL;
185188
pinConfig.is_watcher = false;
186189
pinConfig.hi_accuracy = false;
187-
pinConfig.skip_gpio_setup = true;
190+
pinConfig.skip_gpio_setup = false;
188191
nrfx_gpiote_in_init(PinMap::PowerPresent, &pinConfig, nrfx_gpiote_evt_handler);
192+
nrfx_gpiote_in_event_enable(PinMap::PowerPresent, true);
189193

190-
if (nrf_gpio_pin_read(PinMap::PowerPresent)) {
191-
nrf_gpio_cfg_sense_input(PinMap::PowerPresent, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
192-
} else {
193-
nrf_gpio_cfg_sense_input(PinMap::PowerPresent, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
194-
}
194+
// Update controller based on current gpio pin state, needs to be called after gpio config
195+
batteryController.Update();
195196

196197
batteryController.MeasureVoltage();
197198

0 commit comments

Comments
 (0)