8000 Merge pull request #1678 from dhalbert/nrf-nfc-as-gpio · rhwlo/circuitpython@fce63b1 · GitHub
[go: up one dir, main page]

Skip to content

Commit fce63b1

Browse files
authored
Merge pull request adafruit#1678 from dhalbert/nrf-nfc-as-gpio
Allow NFC pins to be used for other purposes. Fixes adafruit#1300
2 parents 26262cd + fe555a4 commit fce63b1

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,3 @@
4040
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
4141

4242
#define BOARD_HAS_CRYSTAL 1 // according to the schematic we do
43-
44-
// See https://github.com/adafruit/circuitpython/issues/1300, circuitpython
45-
// doesn't yet support NFC so just force those pins to be GPIO.
46-
#define CONFIG_NFCT_PINS_AS_GPIOS

ports/nrf/common-hal/microcontroller/Pin.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,5 +168,15 @@ bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) {
168168
}
169169
#endif
170170

171+
#ifdef NRF52840
172+
// If NFC pins are enabled for NFC, don't allow them to be used for GPIO.
173+
if (((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) ==
174+
(UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)) &&
175+
(pin->number == 9 || pin->number == 10)) {
176+
return false;
177+
}
178+
#endif
179+
171180
return pin_number_is_free(pin->number);
181+
172182
}

ports/nrf/mpconfigport.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ CIRCUITPY_RTC = 0
2727

2828
# frequencyio not yet implemented
2929
CIRCUITPY_FREQUENCYIO = 0
30+
31+
# CircuitPython doesn't yet support NFC so force the NFC antenna pins to be GPIO.
32+
# See https://github.com/adafruit/circuitpython/issues/1300
33+
# Defined here because system_nrf52840.c doesn't #include any of our own include files.
34+
CFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS

0 commit comments

Comments
 (0)
0