Skip to content

Commit

Permalink
cpu/fe310: use CLOCK_CORECLOCK macro to get cpu freq
Browse files Browse the repository at this point in the history
  • Loading branch information
aabadie committed Dec 13, 2019
1 parent 83d34a4 commit 04e60c9
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions cpu/fe310/periph/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,8 @@ int uart_init(uart_t dev, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
/* Power on the device */
uart_poweron(dev);

/* Calculate baudrate divisor given current CPU clk rate
* Ignore the first run (icache needs to be warm) */
uartDiv = PRCI_measure_mcycle_freq(1000, RTC_FREQ);
/* cppcheck-suppress redundantAssignment
* (reason: should ignore first cycle to get correct values) */
uartDiv = PRCI_measure_mcycle_freq(1000, RTC_FREQ);
uartDiv = uartDiv / baudrate;
/* Calculate baudrate divisor given current CPU clk rate */
uartDiv = CLOCK_CORECLOCK / baudrate;

/* Enable UART 8-N-1 at given baudrate */
_REG32(uart_config[dev].addr, UART_REG_DIV) = uartDiv;
Expand Down

0 comments on commit 04e60c9

Please sign in to comment.