软件:KeilMDK 芯片:STM32F103/STM32F107 串口数量:4 备注:4 个串口均配置为 DMA 读取 //串口1 初始化函数 void uart1_init(u32 bound) { //GPIO 端口设置 GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1|RCC_APB2Periph_GPIOA, ENABLE); //使能 USART1,GPIOA 时钟 USART_DeInit(USART1); //复位串口1 //USART1_TX PA
9 GPIO_InitStructure
GPIO_Pin = GPIO_Pin_9; //PA
9 GPIO_InitStructure
GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure
GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出 GPIO_Init(GPIOA, &GPIO_InitStructure); //初始化 PA9 //USART1_RX PA
10 GPIO_InitStructure
GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure
GPIO_Mode = GPIO_Mode_IN_FLOATING;//浮空输入 GPIO_Init(GPIOA, &GPIO_InitStructure); //初始化 PA10 //Usart1 NVIC 配置 NVIC_InitStructure
NVIC_IRQChannel =