STS_E2/Air_Quality_LORAWAN_WINEXT_.../User/bsp_usart.h

238 lines
9.6 KiB
C

#ifndef __BSP_USART_H
#define __BSP_USART_H
#include "stm32f0xx.h"
#include <stdio.h>
//DEBUG_USART1引脚定义
/*******************************************************/
#define DEBUG_USART USART2
#define DEBUG_USART_CLK RCC_APB1Periph_USART2
#define DEBUG_USART_BAUDRATE 115200 //串口波特率
#define DEBUG_USART_RX_GPIO_PORT GPIOA
#define DEBUG_USART_RX_GPIO_CLK RCC_AHBPeriph_GPIOA
#define DEBUG_USART_RX_PIN GPIO_Pin_3
#define DEBUG_USART_RX_AF GPIO_AF_1
#define DEBUG_USART_RX_SOURCE GPIO_PinSource3
#define DEBUG_USART_TX_GPIO_PORT GPIOA
#define DEBUG_USART_TX_GPIO_CLK RCC_AHBPeriph_GPIOA
#define DEBUG_USART_TX_PIN GPIO_Pin_2
#define DEBUG_USART_TX_AF GPIO_AF_1
#define DEBUG_USART_TX_SOURCE GPIO_PinSource2
#define DEBUG_USART_IRQHandler USART2_IRQHandler
#define DEBUG_USART_IRQ USART2_IRQn
/************************************************************/
//NH3_USART2引脚定义
/*******************************************************/
#define NH3_USART USART1
#define NH3_USART_CLK RCC_APB2Periph_USART1
#define NH3_USART_BAUDRATE 9600 //串口波特率
#define NH3_USART_RX_GPIO_PORT GPIOB
#define NH3_USART_RX_GPIO_CLK RCC_AHBPeriph_GPIOB
#define NH3_USART_RX_PIN GPIO_Pin_7
#define NH3_USART_RX_AF GPIO_AF_0
#define NH3_USART_RX_SOURCE GPIO_PinSource7
#define NH3_USART_TX_GPIO_PORT GPIOB
#define NH3_USART_TX_GPIO_CLK RCC_AHBPeriph_GPIOB
#define NH3_USART_TX_PIN GPIO_Pin_6
#define NH3_USART_TX_AF GPIO_AF_0
#define NH3_USART_TX_SOURCE GPIO_PinSource6
#define NH3_USART_IRQHandler USART1_IRQHandler
#define NH3_USART_IRQ USART1_IRQn
/************************************************************/
//CH2O_USART3引脚定义
/*******************************************************/
#define CH2O_USART USART3
#define CH2O_USART_CLK RCC_APB1Periph_USART3
#define CH2O_USART_BAUDRATE 9600 //串口波特率
#define CH2O_USART_RX_GPIO_PORT GPIOC
#define CH2O_USART_RX_GPIO_CLK RCC_AHBPeriph_GPIOC
#define CH2O_USART_RX_PIN GPIO_Pin_5
#define CH2O_USART_RX_AF GPIO_AF_1
#define CH2O_USART_RX_SOURCE GPIO_PinSource5
#define CH2O_USART_TX_GPIO_PORT GPIOC
#define CH2O_USART_TX_GPIO_CLK RCC_AHBPeriph_GPIOC
#define CH2O_USART_TX_PIN GPIO_Pin_4
#define CH2O_USART_TX_AF GPIO_AF_1
#define CH2O_USART_TX_SOURCE GPIO_PinSource4
#define CH2O_USART_IRQHandler USART3_8_IRQHandler
#define CH2O_USART_IRQ USART3_8_IRQn
/************************************************************/
//PM25_USART4引脚定义
/*******************************************************/
#define PM25_USART USART4
#define PM25_USART_CLK RCC_APB1Periph_USART4
#define PM25_USART_BAUDRATE 9600 //串口波特率
#define PM25_USART_RX_GPIO_PORT GPIOA
#define PM25_USART_RX_GPIO_CLK RCC_AHBPeriph_GPIOA
#define PM25_USART_RX_PIN GPIO_Pin_1
#define PM25_USART_RX_AF GPIO_AF_4
#define PM25_USART_RX_SOURCE GPIO_PinSource1
#define PM25_USART_TX_GPIO_PORT GPIOA
#define PM25_USART_TX_GPIO_CLK RCC_AHBPeriph_GPIOA
#define PM25_USART_TX_PIN GPIO_Pin_0
#define PM25_USART_TX_AF GPIO_AF_4
#define PM25_USART_TX_SOURCE GPIO_PinSource0
#define PM25_USART_IRQHandler USART3_8_IRQHandler
#define PM25_USART_IRQ USART3_8_IRQn
/************************************************************/
//H2S_USART5引脚定义
/*******************************************************/
#define H2S_USART USART5
#define H2S_USART_CLK RCC_APB1Periph_USART5
#define H2S_USART_BAUDRATE 9600 //串口波特率
#define H2S_USART_RX_GPIO_PORT GPIOD
#define H2S_USART_RX_GPIO_CLK RCC_AHBPeriph_GPIOD
#define H2S_USART_RX_PIN GPIO_Pin_2
#define H2S_USART_RX_AF GPIO_AF_2
#define H2S_USART_RX_SOURCE GPIO_PinSource2
#define H2S_USART_TX_GPIO_PORT GPIOC
#define H2S_USART_TX_GPIO_CLK RCC_AHBPeriph_GPIOC
#define H2S_USART_TX_PIN GPIO_Pin_12
#define H2S_USART_TX_AF GPIO_AF_2
#define H2S_USART_TX_SOURCE GPIO_PinSource12
#define H2S_USART_IRQHandler USART3_8_IRQHandler
#define H2S_USART_IRQ USART3_8_IRQn
/************************************************************/
//CO2_USART6引脚定义
/*******************************************************/
#define CO2_USART USART6
#define CO2_USART_CLK RCC_APB2Periph_USART6
#define CO2_USART_BAUDRATE 9600 //串口波特率
#define CO2_USART_RX_GPIO_PORT GPIOA
#define CO2_USART_RX_GPIO_CLK RCC_AHBPeriph_GPIOA
#define CO2_USART_RX_PIN GPIO_Pin_5
#define CO2_USART_RX_AF GPIO_AF_5
#define CO2_USART_RX_SOURCE GPIO_PinSource5
#define CO2_USART_TX_GPIO_PORT GPIOA
#define CO2_USART_TX_GPIO_CLK RCC_AHBPeriph_GPIOA
#define CO2_USART_TX_PIN GPIO_Pin_4
#define CO2_USART_TX_AF GPIO_AF_5
#define CO2_USART_TX_SOURCE GPIO_PinSource4
#define CO2_USART_IRQHandler USART3_8_IRQHandler
#define CO2_USART_IRQ USART3_8_IRQn
/************************************************************/
//WIFI_USART7引脚定义
/*******************************************************/
#define WIFI_USART USART7
#define WIFI_USART_CLK RCC_APB2Periph_USART7
#define WIFI_USART_BAUDRATE 115200 //串口波特率
#define WIFI_USART_RX_GPIO_PORT GPIOC
#define WIFI_USART_RX_GPIO_CLK RCC_AHBPeriph_GPIOC
#define WIFI_USART_RX_PIN GPIO_Pin_7
#define WIFI_USART_RX_AF GPIO_AF_1
#define WIFI_USART_RX_SOURCE GPIO_PinSource7
#define WIFI_USART_TX_GPIO_PORT GPIOC
#define WIFI_USART_TX_GPIO_CLK RCC_AHBPeriph_GPIOC
#define WIFI_USART_TX_PIN GPIO_Pin_6
#define WIFI_USART_TX_AF GPIO_AF_1
#define WIFI_USART_TX_SOURCE GPIO_PinSource6
#define WIFI_USART_IRQHandler USART3_8_IRQHandler
#define WIFI_USART_IRQ USART3_8_IRQn
/************************************************************/
//LORA_USART8引脚定义
/*******************************************************/
#define LORA_USART USART8
#define LORA_USART_CLK RCC_APB2Periph_USART8
#define LORA_USART_BAUDRATE 9600 //串口波特率
#define LORA_USART_RX_GPIO_PORT GPIOC
#define LORA_USART_RX_GPIO_CLK RCC_AHBPeriph_GPIOC
#define LORA_USART_RX_PIN GPIO_Pin_9
#define LORA_USART_RX_AF GPIO_AF_1
#define LORA_USART_RX_SOURCE GPIO_PinSource9
#define LORA_USART_TX_GPIO_PORT GPIOC
#define LORA_USART_TX_GPIO_CLK RCC_AHBPeriph_GPIOC
#define LORA_USART_TX_PIN GPIO_Pin_8
#define LORA_USART_TX_AF GPIO_AF_1
#define LORA_USART_TX_SOURCE GPIO_PinSource8
#define LORA_USART_IRQHandler USART3_8_IRQHandler
#define LORA_USART_IRQ USART3_8_IRQn
/************************************************************/
//按键引脚定义
/*******************************************************/
#define BUTTON0_PORT GPIOB
#define BUTTON0_CLK RCC_AHBPeriph_GPIOB
#define BUTTON0_PIN GPIO_Pin_0
#define BUTTON0_EXTI_PORTSOURCE EXTI_PortSourceGPIOB
#define BUTTON0_EXTI_PINSOURCE EXTI_PinSource0
#define BUTTON0_EXTI_LINE EXTI_Line0
#define BUTTON0_EXTI_IRQ EXTI0_1_IRQn
#define BUTTON0_IRQHandler EXTI0_1_IRQHandler
/*******************************************************/
//LORA_RST引脚定义
#define LORA_RST_PORT GPIOA
#define LORA_RST_CLK RCC_AHBPeriph_GPIOA
#define LORA_RST_PIN GPIO_Pin_8
#define NH3_BUF_LEN 64
#define CH2O_BUF_LEN 64
#define PM25_BUF_LEN 128
#define H2S_BUF_LEN 64
#define CO2_BUF_LEN 64
#define NH3_BUF_LEN 64
#define LoraNode_BUF_LEN 128
#define WIFI_BUF_LEN 128
void USART_RCC_Configuration(void);
void GPIO_Configuration(void);
void USART_Configuration(void);
void NVIC_Configuration(void);
void EXTI_Button_Config(void);
void UsartxSendDataByte(USART_TypeDef* USARTx,uint16_t Data);
void UsartxSendDataStr(USART_TypeDef* USARTx,const uint8_t Data[],uint32_t len);
#endif /* __BSP_USART_H */