Hi
I'm trying to develop a solution where I have a different button debounce value (i.e. one call, then another call to app_button_init(..)) depending which part of the program the user is currently at. It works fine with just one call to app_button_init(..).
Snipping away the bulk of the working code, my code looks something like this
#include "app_button.h"
#include "app_error.h"
#include "app_timer.h"
#define APP_BUTTON_DETECTION_DELAY APP_TIMER_TICKS(200) // Application Mode:
#define CAL_BUTTON_DETECTION_DELAY APP_TIMER_TICKS(5000) // Calibration Mode:
static void buttons_init(uint32_t button_delay)
{
ret_code_t err_code;
// The array must be static because a pointer to it will be saved in the button handler module.
static app_button_cfg_t buttons[] = {{PWR_BUTTON, false, BUTTON_PULL, button_event_handler},
{UNITS_BUTTON, false, BUTTON_PULL, button_event_handler},
{BT_BUTTON, false, BUTTON_PULL, button_event_handler}};
err_code = app_button_init(buttons, ARRAY_SIZE(buttons), button_delay);
APP_ERROR_CHECK(err_code);
}
int main (void) {
// do something
// Set button timeouts for calibration mode use
buttons_init(CAL_BUTTON_DETECTION_DELAY);
APP_ERROR_CHECK(app_button_enable());
// do something
// Reset button timeouts for application use
APP_ERROR_CHECK(app_button_disable());
buttons_init(APP_BUTTON_DETECTION_DELAY); // <== throws error here
APP_ERROR_CHECK(app_button_enable());
// do something
while (true)
{
// do something
}
}the code above throws an error at APP_ERROR_CHECK(err_code) with error code NRFX_ERROR_INVALID_STATE from nrfx_gpiote.c
/* Only one GPIOTE channel can be assigned to one physical pin. */
if (pin_in_use_by_gpiote(pin))
{
err_code = NRFX_ERROR_INVALID_STATE;
}Is there away to clear / reset the GPIOTE channel before making another call to app_button_init ?
thanks