|
|
|
@ -5,6 +5,29 @@ |
|
|
|
#include "TxtDataHelpers.h" |
|
|
|
#include <RTClib.h> |
|
|
|
|
|
|
|
#if defined(NRF52_PLATFORM) |
|
|
|
#include <nrf.h> |
|
|
|
#include <nrf_soc.h> |
|
|
|
|
|
|
|
#ifndef DFU_MAGIC_UF2_RESET |
|
|
|
#define DFU_MAGIC_UF2_RESET 0x57 |
|
|
|
#endif |
|
|
|
|
|
|
|
static void resetToUf2Bootloader() { |
|
|
|
uint8_t sd_enabled = 0; |
|
|
|
sd_softdevice_is_enabled(&sd_enabled); |
|
|
|
|
|
|
|
if (sd_enabled) { |
|
|
|
sd_power_gpregret_clr(0, 0xFF); |
|
|
|
sd_power_gpregret_set(0, DFU_MAGIC_UF2_RESET); |
|
|
|
} else { |
|
|
|
NRF_POWER->GPREGRET = DFU_MAGIC_UF2_RESET; |
|
|
|
} |
|
|
|
|
|
|
|
NVIC_SystemReset(); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
#ifndef BRIDGE_MAX_BAUD |
|
|
|
#define BRIDGE_MAX_BAUD 115200 |
|
|
|
#endif |
|
|
|
@ -217,6 +240,12 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re |
|
|
|
_board->powerOff(); // doesn't return
|
|
|
|
} else if (memcmp(command, "reboot", 6) == 0) { |
|
|
|
_board->reboot(); // doesn't return
|
|
|
|
} else if (sender_timestamp == 0 && memcmp(command, "uf2reset", 8) == 0 && (command[8] == 0 || command[8] == ' ')) { // from serial command line only
|
|
|
|
#if defined(NRF52_PLATFORM) |
|
|
|
resetToUf2Bootloader(); // doesn't return
|
|
|
|
#else |
|
|
|
strcpy(reply, "ERR: unsupported"); |
|
|
|
#endif |
|
|
|
} else if (memcmp(command, "clkreboot", 9) == 0) { |
|
|
|
// Reset clock
|
|
|
|
getRTCClock()->setCurrentTime(1715770351); // 15 May 2024, 8:50pm
|
|
|
|
|