9 // enable clock to UART1
10 *RCC_APB2ENR = 0x4005;
11 *GPIOA_CRH = 0x444444D4;
14 *USART1_CR1 = (0 << 13); // disable control register
18 * 115200 = 8MHz / (16 * USARTDIV)
20 * FRACTION: 16 x 0.34 = 0d5.44 0d5 -> 0x5
21 * MANTISSA: 0d4.34 0d4 -> 0x4
24 *USART1_BRR = 0x00000045;
26 /* parity = 8 bit, UART1 enabled, TX and RX enabled, interrupts enabled */
27 *USART1_CR1 = (volatile uint32_t) 0x000030AC;
31 1. Disable the UART by clearing the UARTEN bit in the UARTCTL register.
32 2. Write the integer portion of the BRD to the UARTIBRD register.
33 3. Write the fractional portion of the BRD to the UARTFBRD register.
34 4. Write the desired serial parameters to the UARTLCRH register
35 5. Enable the UART by setting the UARTEN bit in the UARTCTL register.
38 /* TODO: bitrate: How fast is CPU running?*/
55 extern void uart_putc(unsigned char ch) {
58 // while ((*UART1_DR & 0x8)); // busy bit
59 // *USART1_DR = 0x0D; // return line
62 // while ((*UART0_FLAG & 0x8)); // busy bit
66 extern void uart_puts(unsigned char *str)
71 for (i = 0; i < strlen(str); i++)