[core] Add restartDownloadMode() method

This commit is contained in:
Kuba Szczodrzyński
2022-11-26 19:36:10 +01:00
parent 9e4bbe3e36
commit ec4e946643
3 changed files with 16 additions and 0 deletions

View File

@@ -32,6 +32,10 @@ void LibreTuya::restart() {
bk_reboot();
}
void LibreTuya::restartDownloadMode() {
bk_reboot();
}
ResetReason LibreTuya::getResetReason() {
switch (bk_misc_get_start_type()) {
case RESET_SOURCE_POWERON:

View File

@@ -63,6 +63,10 @@ class LibreTuya {
* @brief Reboot the CPU.
*/
void restart();
/**
* @brief Reboot the CPU and stay in download mode (if possible).
*/
void restartDownloadMode();
/**
* @brief Get the reason of last chip reset.
*/

View File

@@ -15,6 +15,14 @@ void LibreTuya::restart() {
while (1) {}
}
void LibreTuya::restartDownloadMode() {
// mww 0x40000138 0x8
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_NORESET_FF, 0x08);
// reboot it the ugly way
sys_reset();
while (1) {}
}
ResetReason LibreTuya::getResetReason() {
return RESET_REASON_UNKNOWN;
}