|
串口的配置 //复用口的打开 GPIO_InitTypeDef GPIO_InitStructure;+ P# ~, M J# E7 _( V' E& v RCC_APB2PeriphClockCmd( RCC_APB2Periph_USART1|RCC_APB2Periph_GPIOA | \ RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD|\. l0 S) \, G9 i5 `4 i, Z- J/ x5 f RCC_APB2Periph_GPIOE|RCC_APB2Periph_AFIO, ENABLE); 9 t d4 |3 I" M: x9 d $ v4 r, ^" P' r //始终配置 RCC_APB1PeriphClockCmd( RCC_APB1Periph_USART2|RCC_APB1Periph_USART3|\% y' W% v8 n' T& T) A1 p- W RCC_APB1Periph_UART4,ENABLE); 6 D1 N) U% Y2 w //USART1 GPIO配置 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; ' v. E: |! t& q$ @; _: _: _3 ^5 I GPIO_Init(GPIOA, &GPIO_InitStructure); 1 L" s2 t _: f* Y1 Y GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; # _+ j9 [0 |- I7 k0 o% V GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); //USART2 GPIO配置 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; $ Y1 r- n' X& B# M GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); & W: C: l3 f. u: _& a% n5 @% B / @2 R# L. [ c GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; 3 t; u% R3 _1 F! c* g2 N GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; d9 e. L* h8 K9 R GPIO_Init(GPIOA, &GPIO_InitStructure); / b1 x9 W/ \9 ~ //串口的配置 j6 J6 u$ D! a5 P USART_InitTypeDef USART_InitStructure;9 n& C! [4 Y1 f) [9 {7 V4 w6 T o USART_InitStructure.USART_BaudRate = 115200;% v/ K5 {) U. E4 e USART_InitStructure.USART_WordLength = USART_WordLength_8b;+ Y, I7 @# M |9 A- f USART_InitStructure.USART_StopBits = USART_StopBits_1;8 ^: D% u. Q0 c, i g! P USART_InitStructure.USART_Parity = USART_Parity_No;+ e/ @' u1 N8 f6 e3 N USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;* o, ~' {" G: g( D USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //¶¨Òå½ÓÊպͷ¢ËÍʹÄÜ7 {7 [3 m$ y. g8 g1 N0 { $ C! F: D1 q5 F+ x$ B USART_Init(USART1, &USART_InitStructure); USART_Init(USART2, &USART_InitStructure); //中断的配置,注意在中断函数里面清除中断标志 USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); //ʹÄÜÖÐ¶Ï USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);" C, {' r* i2 U: R' ~ USART_ITConfig(USART2, USART_IT_RXNE, ENABLE); //ʹÄÜÖÐ¶Ï USART_ITConfig(UART4, USART_IT_RXNE, ENABLE); USART_Cmd(USART1, ENABLE); //ʹÄÜÍâÉè USART_Cmd(USART2, ENABLE); //ʹÄÜ 5 \* C4 _7 R3 W/ Q 1 { p4 Y* v3 F+ K6 z |
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基础知识
微信公众号
手机版