GPIOTE fix of button and power detection experiment

This commit is contained in:
hubmartin 2021-10-03 16:47:01 +02:00
parent 6cf5797049
commit 2aebbe3f47

View file

@ -158,19 +158,21 @@ void SystemTask::Work() {
heartRateSensor.Disable(); heartRateSensor.Disable();
heartRateApp.Start(); 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_cfg_output(15);
nrf_gpio_pin_set(15); nrf_gpio_pin_set(15);
nrfx_gpiote_in_config_t pinConfig; nrfx_gpiote_in_config_t pinConfig;
pinConfig.skip_gpio_setup = true; pinConfig.skip_gpio_setup = false;
pinConfig.hi_accuracy = false; pinConfig.hi_accuracy = false;
pinConfig.is_watcher = 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; 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_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); 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; pinConfig.skip_gpio_setup = true;
@ -181,18 +183,20 @@ void SystemTask::Work() {
nrfx_gpiote_in_init(PinMap::Cst816sIrq, &pinConfig, nrfx_gpiote_evt_handler); nrfx_gpiote_in_init(PinMap::Cst816sIrq, &pinConfig, nrfx_gpiote_evt_handler);
// Power present
pinConfig.sense = NRF_GPIOTE_POLARITY_TOGGLE; pinConfig.sense = NRF_GPIOTE_POLARITY_TOGGLE;
pinConfig.pull = NRF_GPIO_PIN_NOPULL; pinConfig.pull = NRF_GPIO_PIN_NOPULL;
pinConfig.is_watcher = false; pinConfig.is_watcher = false;
pinConfig.hi_accuracy = 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_init(PinMap::PowerPresent, &pinConfig, nrfx_gpiote_evt_handler);
nrfx_gpiote_in_event_enable(PinMap::PowerPresent, true);
if (nrf_gpio_pin_read(PinMap::PowerPresent)) { // if (nrf_gpio_pin_read(PinMap::PowerPresent)) {
nrf_gpio_cfg_sense_input(PinMap::PowerPresent, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW); // nrf_gpio_cfg_sense_input(PinMap::PowerPresent, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
} else { // } else {
nrf_gpio_cfg_sense_input(PinMap::PowerPresent, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH); // nrf_gpio_cfg_sense_input(PinMap::PowerPresent, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
} // }
idleTimer = xTimerCreate("idleTimer", pdMS_TO_TICKS(2000), pdFALSE, this, IdleTimerCallback); idleTimer = xTimerCreate("idleTimer", pdMS_TO_TICKS(2000), pdFALSE, this, IdleTimerCallback);
dimTimer = xTimerCreate("dimTimer", pdMS_TO_TICKS(settingsController.GetScreenTimeOut() - 2000), pdFALSE, this, DimTimerCallback); dimTimer = xTimerCreate("dimTimer", pdMS_TO_TICKS(settingsController.GetScreenTimeOut() - 2000), pdFALSE, this, DimTimerCallback);