Xiao nrf52 exit qspi flash deep sleep

Hi @msfujino,
No problem.
I am using Visual Studio Code and Platform IO. I am using the board without the sense, if you want to use the sense you have to use the board “xiaoblesense_adafruit” in the platformio.ini file
platformio.ini file:

[env]
platform = https://github.com/maxgerhardt/platform-nordicnrf52
framework = arduino

[env:xiaoble_adafruit_nrf52]
board = xiaoble_adafruit
lib_deps = 
	adafruit/Adafruit SPIFlash@^4.1.1
	adafruit/SdFat - Adafruit Fork@^2.2.1

Then in my code I use this to do to deep sleep and attach a pin interrupt:

#include <Arduino.h>
#include <bluefruit.h>
#include <Adafruit_SPIFlash.h>

#define INTERRUPT 0 // the pin you want to use to interrupt and wake up the device

Adafruit_FlashTransport_QSPI flashTransport;

void shutdown();

void setup()
{
    ...
    // Enable Soft Device
    if (!Bluefruit.begin(1))
    {
        while (1);
    }
    ...
}

void loop()
{
    ...
    if (shutdown_condition)
    {
        shutdown();
    }
    ...
}

void shutdown()
{
    //Put flash into deep sleep
    flashTransport.begin();
    flashTransport.runCommand(0xB9);
    flashTransport.end();
    // attach interrupt to wakeup
    nrf_gpio_cfg_sense_input(g_ADigitalPinMap[INTERRUPT], NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
    // power off
    sd_power_system_off();
}

On wake up the device basically soft resets.

1 Like