资源简介
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
相关资源
- 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
- 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
- STM32F103 CC2500完整驱动(模拟SPI)
评论
共有 条评论