ret = uartx_rxBuffer[uartx_rxIndexOut]; uartx_rxIndexOut++; if(uartx_rxIndexOut >= _MAX_UART_BUFFER_LEN) uartx_rxIndexOut = 0;
return ret; } void UartxInit (u32 baudrate) { USART_Cmd(USARTx, DISABLE); /* 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 Clock disabled - USART CPOL: Clock is active low - USART CPHA: Data is captured on the second edge - USART LastBit: The clock pulse of the last data bit is not output to the SCLK pin */ USART_InitStructure.USART_BaudRate = baudrate; // 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_InitStructure.USART_Clock = USART_Clock_Disable; USART_InitStructure.USART_CPOL = USART_CPOL_Low; USART_InitStructure.USART_CPHA = USART_CPHA_2Edge; USART_InitStructure.USART_LastBit = USART_LastBit_Disable;
/* Configure the USARTx */ USART_Init(USARTx, &USART_InitStructure); /* Enable the USART Transmoit interrupt: this interrupt is generated when the USART1 transmit data register is empty */ //USART_ITConfig(USARTx, USART_IT_TXE, ENABLE); ---walter 20080422
/* Enable the USART Receive interrupt: this interrupt is generated when the USART1 receive data register is not empty */ USART_ITConfig(USARTx, USART_IT_RXNE, ENABLE);
/* Enable the USARTx */ USART_Cmd(USARTx, ENABLE); }