I am using nRF51822 with SDK 10.0.
I want to configure a GPIO pin which can wake up the MCU from SYSTEM OFF Mode and call its IRQ handler.
Please find below configurations I have done in my code:
// Configure a pin to wake up the MCU and call an IRQ handler
void gpio_configuration(void)
{
//Usb sense Interrupt Configuration
nrf_drv_gpiote_in_config_t in_config_1 = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true); // previously we used GPIOTE_CONFIG_IN_SENSE_TOGGLE(false), may have caused to malfunction the code. Didn't checked this yet
in_config_1.pull = NRF_GPIO_PIN_NOPULL;
err_code = nrf_drv_gpiote_in_init(USB_SENSE, &in_config_1, in_pin_handler_1);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable(USB_SENSE, true);
// config pin to wake up the MCU
nrf_gpio_cfg_sense_input(USB_SENSE,NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
}
// I call this function when BLE timeout occurs
uint32_t sd_power_system_off(void)
{
uint8_t * p_buffer;
uint32_t buffer_length = 0;
tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length);
const uint32_t err_code = power_system_off_req_enc(&(p_buffer[1]), &buffer_length);
APP_ERROR_CHECK(err_code);
ser_app_power_system_off_set();
//@note: Increment buffer length as internally managed packet type field must be included.
return ser_sd_transport_cmd_write(p_buffer,
(++buffer_length),
NULL);
}
This code can wake up the MCU but it doesn't call its IRQ handler.
But I want to wake up the MCU and call the IRQ handler as soon as an interrupt is generated on this pin.
Is it possible to do so ?
Please guide me.