[realtek-ambz] Add gpioRecover() to disable SWD

This commit is contained in:
Kuba Szczodrzyński
2022-06-04 22:32:36 +02:00
parent 6f9be2b139
commit 48f6210607
3 changed files with 16 additions and 0 deletions

View File

@@ -167,3 +167,7 @@ bool LibreTuya::otaCanRollback() {
return true;
return false;
}
__attribute__((weak)) void LibreTuya::gpioRecover() {
// nop by default
}

View File

@@ -93,6 +93,11 @@ class LibreTuya {
* @brief Reboot the CPU.
*/
void restart();
/**
* @brief Reconfigure GPIO pins used for debugging
* (SWD/JTAG), so that they can be used as normal I/O.
*/
void gpioRecover();
public: /* CPU-related */
/**

View File

@@ -12,6 +12,13 @@ void LibreTuya::restart() {
sys_reset();
}
void LibreTuya::gpioRecover() {
// PA14 and PA15 are apparently unusable with SWD enabled
sys_jtag_off();
Pinmux_Config(PA_14, PINMUX_FUNCTION_GPIO);
Pinmux_Config(PA_15, PINMUX_FUNCTION_GPIO);
}
/* CPU-related */
ChipType LibreTuya::getChipType() {