|
串口的配置% S' n& s' [5 d/ L; ? //复用口的打开 : v2 q" J) b) p/ \' ~ GPIO_InitTypeDef GPIO_InitStructure;, w) A- p& w! i) B RCC_APB2PeriphClockCmd( RCC_APB2Periph_USART1|RCC_APB2Periph_GPIOA | \& |' M9 r' t# B7 _! K& L RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD|\ RCC_APB2Periph_GPIOE|RCC_APB2Periph_AFIO, ENABLE); 6 ~; b" v3 }7 N: ^: f2 J0 v4 ~+ O //始终配置 " y, w$ ^5 g; t4 v6 K6 w! p RCC_APB1PeriphClockCmd( RCC_APB1Periph_USART2|RCC_APB1Periph_USART3|\ RCC_APB1Periph_UART4,ENABLE); //USART1 GPIO配置' N7 ]! k1 P8 A4 K/ h# c GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; / d0 Z, G2 @. E* V GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; 9 m; ^' R8 C+ f" [- j3 H2 S GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); 4 U! y1 ]- X( X4 } //USART2 GPIO配置2 U$ @3 P# {% P3 U4 u GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; 2 g& s9 x+ s4 O c" F% D" E# I GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; $ N+ s, _- P" \+ s% T' @5 b6 w8 g4 H. ?* d GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); //串口的配置 USART_InitTypeDef USART_InitStructure;/ J/ a! o( V# b( C1 d6 \ USART_InitStructure.USART_BaudRate = 115200; USART_InitStructure.USART_WordLength = USART_WordLength_8b;8 _: Y5 Y* f3 N% t9 ~* @ USART_InitStructure.USART_StopBits = USART_StopBits_1;8 K* ^' x) h6 X: h& x6 ~- F USART_InitStructure.USART_Parity = USART_Parity_No;9 ~' b# [& h6 c8 m' L8 z; [ USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //¶¨Òå½ÓÊպͷ¢ËÍʹÄÜ( c6 [9 L; h( M6 H/ {8 P 2 r) W' p3 c+ q, V9 ~; R USART_Init(USART1, &USART_InitStructure);$ e0 Q. u) \, D5 A, g. |; H; O USART_Init(USART2, &USART_InitStructure); * q1 @" ^% F1 f //中断的配置,注意在中断函数里面清除中断标志 USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); //ʹÄÜÖÐ¶Ï USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); USART_ITConfig(USART2, USART_IT_RXNE, ENABLE); //ʹÄÜÖÐ¶Ï USART_ITConfig(UART4, USART_IT_RXNE, ENABLE);2 t. `7 v( f9 i: v% g/ k : p8 u4 S4 @9 a: T USART_Cmd(USART1, ENABLE); //ʹÄÜÍâÉè USART_Cmd(USART2, ENABLE); //ʹÄÜ% k% i' {7 ?* K5 o% v& W3 U X/ Z( m) D: H |
DMA 原理从 0 到 1:为什么它能解放 CPU?一文讲透 DMA 的工作流程
【福利三:雨露均沾·逢7狂欢】之五:STM32系统时钟PLL故障排除1例
【福利三:雨露均沾·逢7狂欢】之三:AI帮我查BUG
福利三:雨露均沾·逢7狂欢】之二:STM32F407VG串口通信乱码故障的排除
基于STM32F103的I2C主从机通信
最全USB HID开发资料,悉心整理一个月,亲自测试
【源码】STLINK-V3MINI 高速USB仿真器,成功改刷【高速CMSIS-DAP】
OpenBLT移植到STM32F103战舰开发板上适用于所有STM32F103系列的Bootloader
TFT LCD 与 FSMC 的硬件连接大容量 STM32F10xxx FSMC 接口
单片机:初学者该了解的STM32F103基础知识
微信公众号
手机版