summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobert-hh <robert@hammelrath.com>2021-03-04 20:57:16 +0100
committerDamien George <damien@micropython.org>2021-03-12 00:49:30 +1100
commitc675452566ffcae1a49121b84a0233ed164b2152 (patch)
tree36759620276c141ef2785d9d719ca2638d024767
parent11cf742524202fa5fc062f3e6e3040a82f49b190 (diff)
rp2/modmachine: Re-init UART for REPL on frequency change.
When UART is used for REPL and the MCU frequency is changed, the UART has to be re-initialised. Besides that the UART may have to be recreated after a frequency change, but with USB REPL this is not a problem. Thanks to @HermannSW for spotting and providing the change.
-rw-r--r--ports/rp2/modmachine.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/ports/rp2/modmachine.c b/ports/rp2/modmachine.c
index 139309281..bf5033adb 100644
--- a/ports/rp2/modmachine.c
+++ b/ports/rp2/modmachine.c
@@ -33,6 +33,7 @@
#include "extmod/machine_spi.h"
#include "modmachine.h"
+#include "uart.h"
#include "hardware/clocks.h"
#include "hardware/watchdog.h"
#include "pico/bootrom.h"
@@ -89,6 +90,10 @@ STATIC mp_obj_t machine_freq(size_t n_args, const mp_obj_t *args) {
if (!set_sys_clock_khz(freq / 1000, false)) {
mp_raise_ValueError(MP_ERROR_TEXT("cannot change frequency"));
}
+ #if MICROPY_HW_ENABLE_UART_REPL
+ setup_default_uart();
+ mp_uart_init();
+ #endif
return mp_const_none;
}
}