I was having trouble waking up the DW if it had gone to sleep without setting the wakeup condition bits: DWT_WAKE_WK or DWT_SLP_EN. Under these conditions, the correct way to wake the chip up is to force RSTn low for a short time, and then let it float again. There are strong exhortations in the manual never to drive RSTn high, so my code had been ultra-conservative.
#define RESET_DELAY 1 // 1 msnrf_gpio_cfg( // set the pin up as an output DW_RSTN, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, // input buffer disconnected NRF_GPIO_PIN_NOPULL, // no internal pullups – high impedence I guess NRF_GPIO_PIN_S0D1, // ‘0’ drives it low with 0.5mA max sink; // a ‘1’ disconnects it NRF_GPIO_PIN_NOSENSE // not an input so not relevant );
nrf_gpio_pin_clear(DW_RSTN); // drive the pin lowdeca_sleep(RESET_DELAY); // wait a very long timenrf_gpio_pin_set(DW_RSTN); // disconnect the pindeca_sleep(RESET_DELAY); // wait a very long timenrf_gpio_pin_clear(DW_RSTN); // drive the pin lowdeca_sleep(RESET_DELAY); // wait a very long time
nrf_gpio_cfg( // sets the pin up as an input DW_RSTN, NRF_GPIO_PIN_DIR_INPUT, NRF_GPIO_PIN_INPUT_CONNECT, // connect the input buffer NRF_GPIO_PIN_NOPULL, // no pullups ??? NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE // not using GPIOTE, so no used );
nrf_gpio_input_disconnect(DW_RSTN); // disconnect itdeca_sleep(2);