diff options
Diffstat (limited to 'arduino/libraries/Bluefruit52Lib/examples/Hardware/nfc_to_gpio')
-rwxr-xr-x | arduino/libraries/Bluefruit52Lib/examples/Hardware/nfc_to_gpio/nfc_to_gpio.ino | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/arduino/libraries/Bluefruit52Lib/examples/Hardware/nfc_to_gpio/nfc_to_gpio.ino b/arduino/libraries/Bluefruit52Lib/examples/Hardware/nfc_to_gpio/nfc_to_gpio.ino new file mode 100755 index 0000000..89fa7cb --- /dev/null +++ b/arduino/libraries/Bluefruit52Lib/examples/Hardware/nfc_to_gpio/nfc_to_gpio.ino @@ -0,0 +1,40 @@ +// 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. + +// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +// !!!!! IMPORTANT NOTE ... READ BEFORE RUNNING THIS SKETCH !!!!! +// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +// UICR customer registers are meant to be stored with values +// that are supposed to stay there during the life time of the softdevice. +// You cannot erase them without erasing everything on chip, so setting the +// NFC pins to GPIO mode is a ONE WAY OPERATION and you will need a debugger +// like a Segger J-Link to set them back to NFC mode! + +void setup() { + Serial.begin(115200); + while ( !Serial ) delay(10); // for nrf52840 with native usb + + Serial.println("Bluefruit52 NFC to GPIO Pin Config"); + Serial.println("----------------------------------\n"); + 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: +} |