Skip to content
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

Dmesg #400

Closed
wants to merge 15 commits into from
80 changes: 57 additions & 23 deletions model/MicroBit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,60 @@ static const uint32_t reflash_status = 0xffffffff;

static volatile MicroBitNoInitMemoryRegion __attribute__ ((section (".noinit"))) microbit_no_init_memory_region;

#define IS_3_3_V() ((NRF_UICR->REGOUT0 & 7) == 5)

NFConPins::NFConPins() {
DMESG("disableNFConPins\n");
// 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;

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

// 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();
}
}

/*
// Ensure NFC pins are configured as GPIO. If not, update the non-volatile UICR.



if (NRF_UICR->NFCPINS)
{
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.
NRF_UICR->NFCPINS = 0;

// 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();
}
*/

/**
* Constructor.
*
Expand All @@ -59,7 +113,7 @@ MicroBit::MicroBit() :
bleManager(),
ble( &bleManager),
#endif

nfc(),
systemTimer(NRF_TIMER1, TIMER1_IRQn),
adcTimer(NRF_TIMER2, TIMER2_IRQn),

Expand All @@ -71,7 +125,8 @@ MicroBit::MicroBit() :
io(adc, touchSensor),
serial(io.usbTx, io.usbRx, NRF_UARTE0),
_i2c(io.sda, io.scl),
i2c(io.P20, io.P19),
i2c(io.sda, io.scl),
// i2c(io.P20, io.P19),
power(_i2c, io, systemTimer),
flash(_i2c, io, power),
internalFlash(MICROBIT_STORAGE_PAGE, 1, MICROBIT_CODEPAGESIZE),
Expand All @@ -95,27 +150,6 @@ MicroBit::MicroBit() :
// Clear our status
status = 0;

/*
// Ensure NFC pins are configured as GPIO. If not, update the non-volatile UICR.
if (NRF_UICR->NFCPINS)
{
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.
NRF_UICR->NFCPINS = 0;

// 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();
}
*/

// Configure serial port for debugging

//SERIAL_TODO:
Expand Down
6 changes: 5 additions & 1 deletion model/MicroBit.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ DEALINGS IN THE SOFTWARE.
*/
namespace codal
{
class NFConPins {
public: NFConPins();
};

class MicroBit : public MicroBitDevice, public CodalComponent
{
private:
Expand Down Expand Up @@ -132,7 +136,7 @@ namespace codal
MicroBitBLEManager bleManager;
BLEDevice *ble;
#endif

NFConPins nfc;
NRFLowLevelTimer systemTimer;
NRFLowLevelTimer adcTimer;
NRFLowLevelTimer capTouchTimer;
Expand Down
4 changes: 2 additions & 2 deletions target-locked.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"CODAL_TIMESTAMP": "uint64_t",
"CONFIG_GPIO_AS_PINRESET": 1,
"CONFIG_NFCT_PINS_AS_GPIOS": 1,
"DEVICE_BLE": 1,
"DEVICE_BLE": 0,
"DEVICE_COMPONENT_COUNT": 60,
"DEVICE_DEFAULT_PULLMODE": "PullMode::Down",
"DEVICE_DEFAULT_SERIAL_MODE": "SYNC_SLEEP",
Expand All @@ -26,7 +26,7 @@
"DEVICE_STACK_SIZE": 2048,
"DEVICE_TAG": 0,
"DEVICE_USB": 0,
"DMESG_SERIAL_DEBUG": 0,
"DMESG_SERIAL_DEBUG": 1,
"EVENT_LISTENER_DEFAULT_FLAGS": "MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY",
"HARDWARE_NEOPIXEL": 1,
"LED_MATRIX_MAXIMUM_BRIGHTNESS": 245,
Expand Down
4 changes: 2 additions & 2 deletions target.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"DEVICE_COMPONENT_COUNT":60,
"DEVICE_DEFAULT_PULLMODE":"PullMode::Down",
"DEVICE_PANIC_HEAP_FULL":1,
"DMESG_SERIAL_DEBUG":0,
"DMESG_SERIAL_DEBUG":1,
"CODAL_DEBUG":"CODAL_DEBUG_DISABLED",
"DEVICE_USB":0,
"CODAL_TIMESTAMP":"uint64_t",
Expand All @@ -42,7 +42,7 @@
"CAPTOUCH_DEFAULT_CALIBRATION" : 3500,
"HARDWARE_NEOPIXEL": 1,
"CODAL_TIMER_32BIT": 1,
"DEVICE_BLE": 1
"DEVICE_BLE": 0
},
"definitions":"-DAPP_TIMER_V2 -DAPP_TIMER_V2_RTC1_ENABLED -DNRF_DFU_TRANSPORT_BLE=1 -DNRF52833_XXAA -DNRF52833 -DTARGET_MCU_NRF52833 -DNRF5 -DNRF52833 -D__CORTEX_M4 -DS113 -DTOOLCHAIN_GCC -D__START=target_start",

Expand Down
Loading