From 69c40efd32ec72519f123417e5a162bada84e211 Mon Sep 17 00:00:00 2001 From: microbuilder Date: Tue, 21 Feb 2017 18:03:25 +0100 Subject: [PATCH] NFC to GPIO pin config sketch --- .../Hardware/nfc_to_gpio/nfc_to_gpio.ino | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 libraries/AdafruitFeather52Examples/Hardware/nfc_to_gpio/nfc_to_gpio.ino diff --git a/libraries/AdafruitFeather52Examples/Hardware/nfc_to_gpio/nfc_to_gpio.ino b/libraries/AdafruitFeather52Examples/Hardware/nfc_to_gpio/nfc_to_gpio.ino new file mode 100644 index 00000000..1928d394 --- /dev/null +++ b/libraries/AdafruitFeather52Examples/Hardware/nfc_to_gpio/nfc_to_gpio.ino @@ -0,0 +1,25 @@ +// This sketch will check if the NFC pins are configured for NFC mode, +// and if so it will switch them to operate in GPIO mode. A system +// reset is required before this change takes effect since the CONFIG +// memory is only read on power up. + +void setup() { + Serial.begin(115200); + Serial.println("Bluefruit52 NFC to GPIO Pin Config"); + if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)){ + Serial.println("Fix NFC pins"); + NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; + while (NRF_NVMC->READY == NVMC_READY_READY_Busy); + NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk; + while (NRF_NVMC->READY == NVMC_READY_READY_Busy); + NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; + while (NRF_NVMC->READY == NVMC_READY_READY_Busy); + Serial.println("Done"); + delay(500); + NVIC_SystemReset(); + } + +} +void loop() { + // put your main code here, to run repeatedly: +}