+
+/**************************************************************************************/
+void Repair_Data();
+void RCC_Configuration(void)
+{
+ /* --------------------------- System Clocks Configuration -----------------*/
+ /* USART1 clock enable */
+ RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
+
+ /* GPIOB clock enable */
+ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
+}
+
+/**************************************************************************************/
+
+void GPIO_Configuration(void)
+{
+ GPIO_InitTypeDef GPIO_InitStructure;
+
+ /*-------------------------- GPIO Configuration ----------------------------*/
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
+ GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
+ GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_Init(GPIOB, &GPIO_InitStructure);
+
+ /* Connect USART pins to AF */
+ GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_USART1); // USART1_TX
+ GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_USART1); // USART1_RX
+}
+
+/**************************************************************************************/
+
+void USART1_Configuration(void)
+{
+ USART_InitTypeDef USART_InitStructure;
+
+ /* USARTx configuration ------------------------------------------------------*/
+ /* USARTx configured as follow:
+ - BaudRate = 115200 baud
+ - Word Length = 8 Bits
+ - One Stop Bit
+ - No parity
+ - Hardware flow control disabled (RTS and CTS signals)
+ - Receive and transmit enabled
+ */
+ //USART_InitStructure.USART_BaudRate = 9600;
+ //USART_InitStructure.USART_BaudRate = 10000; //Close enough to 9600
+ //USART_InitStructure.USART_BaudRate = 115200;
+ USART_InitStructure.USART_BaudRate = 125200; //Close enough to 115200
+ USART_InitStructure.USART_WordLength = USART_WordLength_8b;
+ USART_InitStructure.USART_StopBits = USART_StopBits_1;
+ USART_InitStructure.USART_Parity = USART_Parity_No;
+ USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
+
+ USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
+
+ USART_Init(USART1, &USART_InitStructure);
+
+ USART_Cmd(USART1, ENABLE);
+}
+
+
+//! Initialize the USART
+void usartinit(){
+ RCC_Configuration();
+
+ GPIO_Configuration();
+
+ USART1_Configuration();
+}
+
+