Files
TencentOS-tiny/board/GoKit3_STM32F103C8T6/BSP/HardWare/DHT11/DHT11_BUS.h
Supowang1989 e40ef2019e add Gokit3 board support
add Gokit3 board support
2020-03-02 09:21:46 +08:00

51 lines
2.0 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef __DHT11_BUS_H__
#define __DHT11_BUS_H__
/* 包含头文件 ----------------------------------------------------------------*/
#include "stm32f1xx_hal.h"
#include "mcu_init.h"
/* 类型定义 ------------------------------------------------------------------*/
/************************ DHT11 数据类型定义******************************/
typedef struct
{
uint8_t humi_high8bit; //原始数据湿度高8位
uint8_t humi_low8bit; //原始数据湿度低8位
uint8_t temp_high8bit; //原始数据温度高8位
uint8_t temp_low8bit; //原始数据温度高8位
uint8_t check_sum; //校验和
float humidity; //实际湿度
float temperature; //实际温度
} DHT11_Data_TypeDef;
/* 宏定义 -------------------------------------------------------------------*/
/*********************** DHT11 连接引脚定义 **************************/
#define DHT11_Dout_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define DHT11_Dout_PORT GPIOB
#define DHT11_Dout_PIN GPIO_PIN_3
/*********************** DHT11 函数宏定义 ****************************/
#define DHT11_Dout_LOW() HAL_GPIO_WritePin(DHT11_Dout_PORT,DHT11_Dout_PIN,GPIO_PIN_RESET)
#define DHT11_Dout_HIGH() HAL_GPIO_WritePin(DHT11_Dout_PORT,DHT11_Dout_PIN,GPIO_PIN_SET)
#define DHT11_Data_IN() HAL_GPIO_ReadPin(DHT11_Dout_PORT,DHT11_Dout_PIN)
/***************************************************************
* 函数名称: DHT11_Msg_TypeDef
* 说 明: DHT11字符串数据的结构体
* 参 数: 无
* 返 回 值: 无
***************************************************************/
typedef struct
{
char temp[4];
char hum[4];
}DHT11_Msg_TypeDef;
/* 扩展变量 ------------------------------------------------------------------*/
/* 函数声明 ------------------------------------------------------------------*/
void DHT11_Init( void );
uint8_t DHT11_Read_TempAndHumidity(DHT11_Data_TypeDef * DHT11_Data);
#endif /* __DHT11_BUS_H__ */