summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJF <JF002@users.noreply.github.com>2021-10-09 20:36:49 +0200
committerGitHub <noreply@github.com>2021-10-09 20:36:49 +0200
commit9a831a6fe4137d30b3102f97f3bbc8118fe56c42 (patch)
tree59224b907c298f54266a7a64b32086e47a7c7d5d
parentb969272c90bfbfa8ae7234809a896ba62411f797 (diff)
parent9ef1babb9dfea4be0ef2179254dc3dd8afd1d7e1 (diff)
Merge pull request #715 from hubmartin/gpiote-fix
Fix GPIOTE not calling ISR when button is held during boot
-rw-r--r--src/systemtask/SystemTask.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp
index 582015da..86740532 100644
--- a/src/systemtask/SystemTask.cpp
+++ b/src/systemtask/SystemTask.cpp
@@ -157,19 +157,21 @@ void SystemTask::Work() {
heartRateSensor.Disable();
heartRateApp.Start();
- 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);
+ // Button
nrf_gpio_cfg_output(15);
nrf_gpio_pin_set(15);
nrfx_gpiote_in_config_t pinConfig;
- pinConfig.skip_gpio_setup = true;
+ pinConfig.skip_gpio_setup = false;
pinConfig.hi_accuracy = false;
pinConfig.is_watcher = false;
- pinConfig.sense = (nrf_gpiote_polarity_t) NRF_GPIOTE_POLARITY_HITOLO;
+ pinConfig.sense = (nrf_gpiote_polarity_t) NRF_GPIOTE_POLARITY_TOGGLE;
pinConfig.pull = (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown;
nrfx_gpiote_in_init(PinMap::Button, &pinConfig, nrfx_gpiote_evt_handler);
+ nrfx_gpiote_in_event_enable(PinMap::Button, true);
+ // Touchscreen
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);
pinConfig.skip_gpio_setup = true;
@@ -180,18 +182,17 @@ void SystemTask::Work() {
nrfx_gpiote_in_init(PinMap::Cst816sIrq, &pinConfig, nrfx_gpiote_evt_handler);
+ // Power present
pinConfig.sense = NRF_GPIOTE_POLARITY_TOGGLE;
pinConfig.pull = NRF_GPIO_PIN_NOPULL;
pinConfig.is_watcher = false;
pinConfig.hi_accuracy = false;
- pinConfig.skip_gpio_setup = true;
+ pinConfig.skip_gpio_setup = false;
nrfx_gpiote_in_init(PinMap::PowerPresent, &pinConfig, nrfx_gpiote_evt_handler);
+ nrfx_gpiote_in_event_enable(PinMap::PowerPresent, true);
- if (nrf_gpio_pin_read(PinMap::PowerPresent)) {
- nrf_gpio_cfg_sense_input(PinMap::PowerPresent, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
- } else {
- nrf_gpio_cfg_sense_input(PinMap::PowerPresent, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
- }
+ // Update controller based on current gpio pin state, needs to be called after gpio config
+ batteryController.Update();
batteryController.MeasureVoltage();