📄 sht.h
字号:
/****************************************************************
*文件名:sht.h
*描述:提供数字式温湿度传感器的低层驱动程序
*环境:KEIL C51
*版本:v1.0
*作者:wentsing
*日期:2006/03/07
******************************************************************/
#if STH_C
#define DATA P3_4
#define SCK P3_5
#define DEWPOINT false //露点测量
#define STATUS_REG_W 0x06 //000 0011 0
#define STATUS_REG_R 0x07 //000 0011 1
#define MEASURE_TEMP 0x03 //000 0001 1
#define MEASURE_HUMI 0x05 //000 0010 1
#define RESET 0x1e //000 1111 0
#ifndef NOP()
#define NOP() _nop_()
#endif
enum {TEMP,HUMI};
/****************************************************************
下面是可以调用的函数定义
*****************************************************************/
/****************************************************************
*函数性质:公共
*入口:无
*出口:返回成功或者失败
*功能:resets the sensor by a softreset
*调用方式:uchar ShtSoftReset(void)
*****************************************************************/
uchar ShtSoftReset(void);
/****************************************************************
*函数性质:公共
*入口:读入数据缓冲 unsigned char *p_value
*出口:返回成功或者失败
*功能:reads the status register with checksum (8-bit)
*调用方式:uchar ShtReadStatusReg(unsigned char *p_value)
*****************************************************************/
uchar ShtReadStatusReg(unsigned char *p_value);
/****************************************************************
*函数性质:公共
*入口:要写入的状态寄存器数据 unsigned char p_value
*出口:返回成功或者失败
*功能:writes the status register with checksum (8-bit)
*调用方式:uchar ShtWriteStatusReg(unsigned char p_value)
*****************************************************************/
uchar ShtWriteStatusReg(unsigned char p_value);
/****************************************************************
*函数性质:公共
*入口:返回值数据缓冲 unsigned char *p_value 测量类型unsigned char mode
*出口:返回成功或者失败
*功能:makes a measurement (humidity/temperature) with checksum
*调用方式:unsigned char ShtMeasure(unsigned char *p_value, unsigned char mode)
*****************************************************************/
unsigned char ShtMeasure(unsigned char *p_value, unsigned char mode);
/****************************************************************
*函数性质:公共
*入口:返回值湿度缓冲float *p_humidity ,返回值温度缓冲float *p_temperature
*出口:无
*功能:// calculates temperature [癈] and humidity [%RH]
*调用方式:void calc_sth11(float *p_humidity ,float *p_temperature)
*****************************************************************/
void calc_sth11(float *p_humidity ,float *p_temperature);
/****************************************************************
*函数性质:公共
*入口:humidity [%RH], temperature [癈]
*出口:露点值
*功能:// calculates dew point
*调用方式:float calc_dewpoint(float h,float t)
*****************************************************************/
#if DEWPOINT == true
float calc_dewpoint(float h,float t);
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -