8000 Allow NFC pins to be used for other purposes. by dhalbert · Pull Request #1678 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

Allow NFC pins to be used for other purposes. #1678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,3 @@
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)

#define BOARD_HAS_CRYSTAL 1 // according to the schematic we do

// See https://github.com/adafruit/circuitpython/issues/1300, circuitpython
// doesn't yet support NFC so just force those pins to be GPIO.
#define CONFIG_NFCT_PINS_AS_GPIOS
10 changes: 10 additions & 0 deletions ports/nrf/common-hal/microcontroller/Pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,15 @@ bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) {
}
#endif

#ifdef NRF52840
// If NFC pins are enabled for NFC, don't allow them to be used for GPIO.
if (((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) ==
(UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)) &&
(pin->number == 9 || pin->number == 10)) {
return false;
}
#endif

return pin_number_is_free(pin->number);

}
5 changes: 5 additions & 0 deletions ports/nrf/mpconfigport.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ CIRCUITPY_RTC = 0

# frequencyio not yet implemented
CIRCUITPY_FREQUENCYIO = 0

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