handle changing CPU speed

This commit is contained in:
Joey Castillo
2021-08-29 15:50:46 -04:00
parent 74950b110e
commit 34ec77c7fd
4 changed files with 30 additions and 20 deletions

View File

@@ -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);