Bootload from SD card to sector 0, and jump to sector 24 where new firmware resides
Fork of Panel-Controller-Bootloader by
usart.c
- Committer:
- bonchenko
- Date:
- 2015-04-22
- Revision:
- 2:0fa89ba8f6fe
- Parent:
- 0:c3a652eff606
File content as of revision 2:0fa89ba8f6fe:
#include "usart.h" void USART_Initialise(void) { USART_InitTypeDef usartConfig; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); USART_Cmd(USART1, ENABLE); usartConfig.USART_BaudRate = 115200; usartConfig.USART_WordLength = USART_WordLength_8b; usartConfig.USART_StopBits = USART_StopBits_1; usartConfig.USART_Parity = USART_Parity_No; usartConfig.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; usartConfig.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_Init(USART1, &usartConfig); GPIO_InitTypeDef gpioConfig; //PA9 = USART1.TX => Alternative Function Output gpioConfig.GPIO_Mode = GPIO_Mode_AF_PP; gpioConfig.GPIO_Pin = GPIO_Pin_9; gpioConfig.GPIO_Speed = GPIO_Speed_2MHz; GPIO_Init(GPIOA, &gpioConfig); //PA10 = USART1.RX => Input gpioConfig.GPIO_Mode = GPIO_Mode_IN_FLOATING; gpioConfig.GPIO_Pin = GPIO_Pin_10; GPIO_Init(GPIOA, &gpioConfig); } void USART_SendString(char* message) { while(*message) { while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET); USART_SendData(USART1, *message++); } } unsigned char USART_ReadByteSync(USART_TypeDef *USARTx) { while ((USARTx->SR & USART_SR_RXNE) == 0) { } return (unsigned char)USART_ReceiveData(USARTx); }