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.
This commit is contained in:
parent
11cf742524
commit
c675452566
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue