/*------------------------------------------------------------------------------*/
/* ROUTINE NAME: USART1_Init */
/* INPUT/OUTPUT: None. */
/* DESCRIPTION: Initialize the UART2. */
/*------------------------------------------------------------------------------*/
void USART1_Init(void)
{
PC_DDR &= (unsigned char)(~0x0C);
PC_CR1 |= 0x0C;
PC_CR2 &= (unsigned char)(~0x0C); // Set PC2 for RX, PC3 for TX as Pull up Input without interrupt
CLK_PCKENR1 |= 0x20; // Enable UART1 clock
SYSCFG_RMPCR1 = 0x00; // RX and TX remap
USART1_CR1 = 0x00; // Set word length bit[5:4] --- 8 bit : 0x00
USART1_CR3 = 0x00; // Set the STOP bits
// bit 5:4 - 1 bit = 0x00
// 0.5 bit = 0x10
// 2 bit = 0x20
// 1.5 bit = 0x30
USART1_BRR2 = 0x01;
USART1_BRR1 = 0x34;// Set the UART1 BRR1 and BRR2 according to UART1_BaudRate value:
// 8000000 / 9600 = 0 34 1 H
// 8000000 / 19200 = 0 1A 1 H
// 8000000 / 38400 = 0 0D 0 H
// USART1_BRR2 = 0x0B;
// USART1_BRR1 = 0x08;// Set the UART1 BRR1 and BRR2 according to UART1_BaudRate value:
// 8000000 / 57600 = 0 08 B H
// 8000000 / 115200 = 0 04 5 H