Skip to content

Commit

Permalink
disable NFC pins
Browse files Browse the repository at this point in the history
  • Loading branch information
tballmsft committed Jan 27, 2024
1 parent d96f8c1 commit 53371d6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 32 deletions.
32 changes: 0 additions & 32 deletions errors.txt

This file was deleted.

38 changes: 38 additions & 0 deletions libs/core/codal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,49 @@ MicroBit uBit;
MicroBitEvent lastEvent;
bool serialLoggingDisabled;

#if defined(NRF52840) || defined(NRF52833)
#define IS_3_3_V() ((NRF_UICR->REGOUT0 & 7) == 5)
#else
#define IS_3_3_V() 1
#endif

static void disableNFConPins() {
// Ensure NFC pins are configured as GPIO. If not, update the non-volatile UICR.
if (NRF_UICR->NFCPINS || !IS_3_3_V()) {
DMESG("RESET UICR\n");
// Enable Flash Writes
NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos);
while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
;

// Configure PINS for GPIO use.
if (NRF_UICR->NFCPINS)
NRF_UICR->NFCPINS = 0;

#if defined(NRF52840) || defined(NRF52833)
// Set VDD to 3.3V
if ((NRF_UICR->REGOUT0 & 7) != 5)
NRF_UICR->REGOUT0 = (NRF_UICR->REGOUT0 & ~7) | 5;
#endif

// Disable Flash Writes
NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos);
while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
;

// Reset, so the changes can take effect.
NVIC_SystemReset();
}
}

void platform_init() {
microbit_seed_random();
int seed = microbit_random(0x7fffffff);
DMESG("random seed: %d", seed);
seedRandom(seed);

// not working here, try in CODAL
// disableNFConPins();
}

void initMicrobitGC() {
Expand Down

0 comments on commit 53371d6

Please sign in to comment.