文章原始地址: http://feotech.com/?p=56
示例1.通过UART1进行数据发送
UART 1 的初始化
/**
* @brief UART1 Initialise.
* @param None.
* @retval None.
*/
void UART1_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); //UART1 选择对应UART的RCC时钟
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //选择串口对应引脚的RCC时钟
//UART1_TX GPIOA_Pin_9
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; //GPIOC_Pin_9
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //
GPIO_Init(GPIOA, &GPIO_InitStructure); //
//UART1_RX GPIOA_Pin_10
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //GPIOA_Pin_10
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mo