diff options
author | Joey Castillo <jose.castillo@gmail.com> | 2021-08-29 15:50:46 -0400 |
---|---|---|
committer | Joey Castillo <jose.castillo@gmail.com> | 2021-08-29 17:11:31 -0400 |
commit | 34ec77c7fdb29afaca981624153fa0f16350c632 (patch) | |
tree | cc9661f5c92322ec529d088ac80e270a7f60775e /watch-library/watch/watch_uart.c | |
parent | 74950b110ebed7baf5cd2fa9e86cbf6d40e0fcb1 (diff) | |
download | Sensor-Watch-34ec77c7fdb29afaca981624153fa0f16350c632.tar.gz Sensor-Watch-34ec77c7fdb29afaca981624153fa0f16350c632.tar.bz2 Sensor-Watch-34ec77c7fdb29afaca981624153fa0f16350c632.zip |
handle changing CPU speed
Diffstat (limited to 'watch-library/watch/watch_uart.c')
-rw-r--r-- | watch-library/watch/watch_uart.c | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/watch-library/watch/watch_uart.c b/watch-library/watch/watch_uart.c index afebff1b..1ab888bd 100644 --- a/watch-library/watch/watch_uart.c +++ b/watch-library/watch/watch_uart.c @@ -53,24 +53,7 @@ #include "peripheral_clk_config.h" void watch_enable_debug_uart(uint32_t baud) { - uint8_t fsel = hri_oscctrl_get_OSC16MCTRL_FSEL_bf(OSCCTRL, OSCCTRL_OSC16MCTRL_MASK); - uint32_t freq = 0; - switch (fsel) { - case OSCCTRL_OSC16MCTRL_FSEL_4_Val: - freq = 4000000; - break; - case OSCCTRL_OSC16MCTRL_FSEL_8_Val: - freq = 8000000; - break; - case OSCCTRL_OSC16MCTRL_FSEL_12_Val: - freq = 12000000; - break; - case OSCCTRL_OSC16MCTRL_FSEL_16_Val: - freq = 16000000; - break; - default: - return; - } + uint32_t freq = watch_get_cpu_speed(); uint64_t br = (uint64_t)65536 * ((freq * 4) - 16 * baud) / (freq * 4); gpio_set_pin_direction(D1, GPIO_DIRECTION_IN); |