Hi there,
I have the configuration that I have a motion detector connected to a GPIO-PIN of the BM833. Now, when the motion detector detects motion, it will set the GPIO PIN's line to high, else it will be low. I want an interrupt to be issued when this happens.
As I already use the "button app" (because the device also has a button), I thought to add a second button. This works after starting to get a motion event once, but fails after that to detect motion ever after again (until reset).
I also tried handling with GPIO event (MOTACTIVE), but then, this event handler is never called.
Here relevant code pieces:
#ifdef MOTACTIVE //be a GPIO PIN
#define NUM_OF_BUTTONS 1
//Configure 1 button with pullup and detection on low state
static const app_button_cfg_t app_buttons[NUM_OF_BUTTONS] =
{
{__bt1, false, BUTTON_PULL, button_event_handler},
};
//static void mot_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
NRF_LOG_INFO("GPIO input event callback");
//sd_nvic_SystemReset();
//NVIC_SystemReset();
//nrf_gpio_cfg_output(pin_no);
//nrf_gpio_pin_clear(pin_no);
//nrf_delay_ms(50);
//nrf_gpio_cfg_input(pin_no, NRF_GPIO_PIN_PULLDOWN );
//APP_ERROR_CHECK(err_code);
}
#else //be a button
#define NUM_OF_BUTTONS 2
static const app_button_cfg_t app_buttons[NUM_OF_BUTTONS] =
{
{__bt1, false, BUTTON_PULL, button_event_handler},
{__mot, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLDOWN , mot_handler}
};
static void mot_handler(uint8_t pin_no, uint8_t button_action)
{
NRF_LOG_INFO("GPIO input event callback");
//sd_nvic_SystemReset();
//NVIC_SystemReset();
//app_button_disable();
//nrf_gpio_cfg_output(pin_no);
//nrf_gpio_pin_clear(pin_no);
//nrf_delay_ms(50);
//nrf_gpio_cfg_input(pin_no, NRF_GPIO_PIN_PULLDOWN );
//APP_ERROR_CHECK(err_code);
//app_button_enable();
}
#endif
int main(void)
{
(...)
//init app_button module, 50ms detection delay (button debouncing)
err_code = app_button_init((app_button_cfg_t *)app_buttons, NUM_OF_BUTTONS, APP_TIMER_TICKS(50));
APP_ERROR_CHECK(err_code);
err_code = app_button_enable();
APP_ERROR_CHECK(err_code);
#ifdef MOTACTIVE
//err_code=nrfx_gpiote_init();
//APP_ERROR_CHECK(err_code);
nrfx_gpiote_in_config_t p_config;
p_config.hi_accuracy=0;
p_config.is_watcher=0;
p_config.pull=NRF_GPIO_PIN_PULLDOWN;
p_config.skip_gpio_setup=1;
p_config.sense=NRF_GPIOTE_POLARITY_TOGGLE;
err_code=nrfx_gpiote_in_init(__mot, &p_config, mot_handler);
APP_ERROR_CHECK(err_code);
nrfx_gpiote_in_event_enable(__mot, true);
#endif
(...)
}
How could I achieve to get the event to be "ready" again without doing a reset?
Best regards,
Richard