资源简介
STM32串口接收不定长数据程序,并进行处理,非常方便而且注释明确

代码片段和文件信息
#include “uart.h“
void USART1_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;// 定义一个GPIO_InitTypeDef类型的变量
USART_InitTypeDef USART_InitStructure;// 定义一个USART_InitTypeDef类型的变量
NVIC_InitTypeDef NVIC_InitStructure;
/* 允许GPIOA和USART1的时钟 */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA ENABLE);
/* 配置USART1 */
/* 配置PA9(TXD) */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; // 选择PIN9
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; // 复用推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // 50MHz速度
GPIO_Init(GPIOA &GPIO_InitStructure);// 把参数带进函数配置
/* 配置PA10(RXD) */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;// 选择PIN10
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;// 选择浮空输入
GPIO_Init(GPIOA &GPIO_InitStructure); // 把参数带进函数配置
/* 配置串口USART1的模式 */
USART_InitStructure.USART_BaudRate = 115200; // 波特率9600
USART_InitStructure.USART_WordLength = USART_WordLength_8b;// 8个数据位
USART_InitStructure.USART_StopBits = USART_StopBits_1; // 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_Init(USART1 &USART_InitStructure); //把上面配置的参数带进函数里面初始化串口
/* 打开空闲中断 */
USART_ITConfig(USART1 USART_IT_IDLE ENABLE);
/* 打开接收中断 */
USART_ITConfig(USART1 USART_IT_RXNE ENABLE);
/* 配置NVIC优先级组 */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
/* 允许UART1中断 */
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
USART_ClearFlag(USART1USART_FLAG_TC);
USART_Cmd(USART1 ENABLE);// 打开串口1
}
// 发送一个字节
void USART1_Send_byte(uint8_t val)
{
USART_SendData(USART1 val);
while (USART_GetFlagStatus(USART1 USART_FLAG_TC) == RESET); //等待发送完成
}
// 接收一个字节
uint8_t USART1_Recv_byte(void)
{
while (USART_GetFlagStatus(USART1 USART_FLAG_RXNE) == RESET);
return USART_ReceiveData(USART1);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-10-24 21:39 STM32串口接收不定长数据程序\
目录 0 2015-10-24 21:39 STM32串口接收不定长数据程序\CFG\
文件 2348 2015-10-24 20:03 STM32串口接收不定长数据程序\CFG\uart.c
文件 179 2015-03-05 15:34 STM32串口接收不定长数据程序\CFG\uart.h
目录 0 2015-10-24 21:39 STM32串口接收不定长数据程序\Libraries\
目录 0 2015-10-24 21:39 STM32串口接收不定长数据程序\Libraries\CMSIS\
目录 0 2015-10-24 21:39 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\
目录 0 2015-10-24 21:39 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\CoreSupport\
文件 17273 2010-06-07 10:25 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\CoreSupport\core_cm3.c
文件 85714 2011-02-09 14:59 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\CoreSupport\core_cm3.h
目录 0 2015-10-23 19:45 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\
目录 0 2015-10-23 19:45 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\
目录 0 2015-10-24 21:39 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\
文件 26297 2011-03-14 12:31 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\Release_Notes.html
目录 0 2015-10-24 21:39 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\
目录 0 2015-10-24 21:39 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\
文件 15766 2011-03-10 10:52 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\startup_stm32f10x_cl.s
文件 15503 2011-03-10 10:52 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\startup_stm32f10x_hd.s
文件 15692 2011-03-10 10:52 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\startup_stm32f10x_hd_vl.s
文件 12376 2011-03-10 10:52 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\startup_stm32f10x_ld.s
文件 13656 2011-03-10 10:52 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\startup_stm32f10x_ld_vl.s
文件 12765 2011-03-10 10:52 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\startup_stm32f10x_md.s
文件 14073 2011-03-10 10:51 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\startup_stm32f10x_md_vl.s
文件 15955 2011-03-10 10:51 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\startup_stm32f10x_xl.s
目录 0 2015-10-24 21:39 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\gcc_ride7\
文件 13072 2011-03-10 10:52 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\gcc_ride7\startup_stm32f10x_cl.s
文件 13160 2011-03-10 10:52 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\gcc_ride7\startup_stm32f10x_hd.s
文件 12482 2011-03-10 10:52 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\gcc_ride7\startup_stm32f10x_hd_vl.s
文件 9814 2011-03-10 10:52 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\gcc_ride7\startup_stm32f10x_ld.s
文件 10562 2011-03-10 10:52 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\gcc_ride7\startup_stm32f10x_ld_vl.s
文件 10269 2011-03-10 10:52 STM32串口接收不定长数据程序\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\gcc_ride7\startup_stm32f10x_md.s
............此处省略128个文件信息
相关资源
- stm32做的红外遥控解码程序
- 《emwin实战指南(基于STM32-ISO开发板)
- Beginning STM32: Developing with FreeRTOS libo
- stm32f103c8t6_sch.Lib
- ALIENTEK战舰STM32F1 V3开发板原理图.rar
- STM32F103RC+ADC+DMA多通道采样LCD显示
- I2C读写AT24C02 基于STM32F103 cube116540
- 基于stm32f103ve的程序——跑马灯实验
- 基于STM32RCT6的步进电机驱动程序
- stm32f407上的两个can发送和接收例程
- STM32 led 时钟
- STM32 2.4G通信例程
- 直流无刷电机方波驱动 stm32 例程代码
- STM32中文资料
- STM32蓝牙和串口程序
- STM32f103超声波模块例程
- stm32f103c8t6 4 oled.rar
- LCD显示温度+串口接收温度.rar
- stm32f030 IAP Demo(原创)
- STM32基于rt_thread操作系统的SDHC卡文件
- NRF24L01实现51与STM32双向通讯
- STM32F103 串口程序(完整版)
- stm32 ds18b20 温度传感器 测试通过
- stm32官方例程
- STM32F103定时器中断程序
- [免费]基于stm32f103ze 的OLED驱动代码
- STM32F103RBT6驱动UC1698控制芯片的160160黑
- STM32F103 DS18B20 V3.5.0固件库驱动程序工
- STM32定时器使用入门。看了这个程序会
- SIM908 SDIO FSMC STM32 FIFO
评论
共有 条评论