Hi all,
I am currently developing on the RIGADO BMD-300 (nRF52832) eval board. I have the following code setup to interrupt on a button press (aim is to have 9 buttons). I am storing the current state of the button in a single byte (m_custom_value). The idea is that all buttons are pulled-up so that start high. As the IN Sense is set to Toggle, i was assuming that when the button is pressed, i would get an interrupt and when the button is released i would get another interrupt. Ultimately, i would expect the button state to stay low (0) if i hold down the button and then change to high when i release the button.
This seams to work, but not very well. I am not interrupting on every press and release. Can someone please tell me if there is a more robust way of doing this instead of polling the specific inputs and using lots of processing time?
Regards,
Zoran
void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
if (pin == GL1)
{
value[2] = value[2] ^ 0x01;
}
else if (pin == GL2)
{
value[2] = value[2] ^ 0x02;
}
}
static void gpio_init(void)
{
ret_code_t err_code;
value[2] = 0xFF;
if (!nrf_drv_gpiote_is_init())
{
err_code = nrf_drv_gpiote_init();
APP_ERROR_CHECK(err_code);
}
nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
err_code = nrf_drv_gpiote_out_init(12, &out_config);
APP_ERROR_CHECK(err_code);
//Setup GL1 Input
nrf_drv_gpiote_in_config_t in_config_GL1 = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
in_config_GL1.pull = NRF_GPIO_PIN_PULLUP;
err_code = nrf_drv_gpiote_in_init(GL1, &in_config_GL1, in_pin_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable(GL1, true);
//Setup GL2 Input
nrf_drv_gpiote_in_config_t in_config_GL2 = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
in_config_GL2.pull = NRF_GPIO_PIN_PULLUP;
err_code = nrf_drv_gpiote_in_init(GL2, &in_config_GL2, in_pin_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable(GL2, true);
}