资源简介
STM32工程中可直接调用USART1-UART5,封装好串口中断,接收指针,数据传输稳定可靠无误。
代码片段和文件信息
#include “A_UART.h“
#include “includes.h“
#if USART1_Enable
COM_TypeDef COM1;
#endif
#if USART2_Enable
COM_TypeDef COM2;
#endif
#if USART3_Enable
COM_TypeDef COM3;
#endif
#if UART4_Enable
COM_TypeDef COM4;
#endif
#if UART5_Enable
COM_TypeDef COM5;
#endif
void Memery_Copy1(uint8_t *Destinationuint8_t *Sourceuint16_t Len)
{
uint8_t i;
uint8_t *ptr;
ptr = Source;
for(i=0;i {
*Destination = *ptr;
Destination++;
ptr++;
}
}
//管脚配置
void GPIO_USARTx_Pin_Config(USART_TypeDef*uart)
{
NVIC_InitTypeDef NVIC_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
#if USART1_Enable
if(uart==USART1) //USART1(PB6PB7)
{
RCC_APB2PeriphClockCmd(USART1_RCC ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 ENABLE);
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 5;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
GPIO_InitStructure.GPIO_Pin = USART1_T_Pin;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_AF_PP;
GPIO_Init(USART1_Port &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = USART1_R_Pin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(USART1_Port &GPIO_InitStructure);
GPIO_PinRemapConfig(GPIO_Remap_USART1ENABLE);
}
#endif
#if USART2_Enable
if(uart==USART2) //USART2(PA2PA3)
{
RCC_APB2PeriphClockCmd(USART2_RCC ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2 ENABLE);
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 5;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
GPIO_InitStructure.GPIO_Pin = USART2_T_Pin;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_AF_PP;
GPIO_Init(GPIOA &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = USART2_R_Pin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA &GPIO_InitStructure);
}
#endif
#if USART3_Enable
if(uart==USART3) //USART3(PB10PB11)
{
RCC_APB2PeriphClockCmd(USART3_RCC ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3 ENABLE);
NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 5;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
GPIO_InitStructure.GPIO_Pin = USART3_T_Pin;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_AF_PP;
GPIO_Init(USART3_Port &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin =
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2481 2018-11-28 15:45 A_UART.h
文件 12587 2018-11-28 15:45 A_UART.c
----------- --------- ---------- ----- ----
15068 2
相关资源
- STM32L4_硬件SPI配置_LL库版.rar
- STM 32 Nucleo H743zi芯片引脚图STM32 H732Z
- STM32的USART串口查询方式(库函数)
- STM32的PS2鼠标程序,亲测可用
- STM32F103RCT6使用DS1302时钟模块
- stm32F407光电编码器代码
- 音频信号FFT变换后节拍检测的软件.
- stm32f103zet6最小系统原理图
- STM32F103单片机输出SPWM波
- STM32F103 ADC 中断模式 连续转换
- stm32f103引脚详图
- stm32控制ch376s例程
- STM32使用HAL库移植freemodbus-v1.6
- DOTween 专业稳定版本
- stm32 LabVIEW控制开发板LED灯显示
- STM32F103C8T6+1.44寸ST7735TFT LCD彩屏驱动程
-
Jli
nk unlock for F1,解锁F1系列的ARM芯 - f407_mpu6050.rar
- 基于STM32的AD9834驱动
- 基于STM32HAL库的AD9834驱动代码修正.z
- STM32Cube之ID加密
- JPEG解码,可以移植到STM32中
- stm32cubemx软件iic读取mpu6050dmp通过串口
- 基于STM32实现的简易电子琴
- STM32F207中文数据手册
- STM32F407W5500
- Flymcu(STM32)
- nRF24LE1与nRF24L01通讯程序
- stm32内部结构图
- STM32 多通道 不同频率 可变频 pwm输出
评论
共有 条评论