好文档 - 专业文书写作范文服务资料分享网站

温湿度传感器SHT10驱动

天下 分享 时间: 加入收藏 我要投稿 点赞

/****************************************Copyright (c)************************************************** ******************************************LiPeng******************************************************** **--------------File Info------------------------------------------------------------------------------- ** File Name: Sht10_Driver.c ** Created by: LiPeng ** Created date: 2008-09-15 ** Version: 1.0

** Descriptions: The original version **

**------------------------------------------------------------------------------------------------------ ** Modified by: ** Modified date: ** Version:

** Descriptions: **

**------------------------------------------------------------------------------------------------------ ** System Function: Sht10 Driver------温湿度传感器SHT10驱动 ** 使用MSP430-F413连接方式:

** VCC: P6.3 ** SCK: P6.4 ** SDA: P6.5 **

********************************************************************************************************/ #include

/*宏定义,延时函数,参数为1时相应延时分别为1us和1ms*/ #define CPU_F (double)1000000

#define delay_us(x) __delay_cycles((long)(CPU_F * (double)x/1000000.0)) #define delay_ms(x) __delay_cycles((long)(CPU_F * (double)x/1000.0)) /*常量定义*/

#define uint unsigned int #define uchar unsigned char #define ulong unsigned long

//adr command r/w #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 #define bitselect 0x01 //选择温度与湿度的低位读 #define noACK 0 #define ACK 1 #define HUMIDITY 2 #define TEMPERATURE 1 #define SCK BIT4 #define SDA BIT5 #define SVCC BIT3

#define SCK_H P6OUT|=SCK #define SCK_L P6OUT&=~SCK #define SDA_H P6OUT|=SDA #define SDA_L P6OUT&=~SDA #define SVCC_H P6OUT|=SVCC #define SVCC_L P6OUT&=~SVCC typedef union {

unsigned int i; float f; }value;

uint table_temp[3]; uint table_humi[3]; uint temten; uint humi_true;

/********************************************************************************************************** **Function Name: S_Init **Description: 初始化 **Input Parameters: 无 **Output Parameters: 无

**********************************************************************************************************/ void S_Init() {

温湿度传感器SHT10驱动

/****************************************Copyright(c)********************************************************************************************LiPeng********************************************
推荐度:
点击下载文档文档为doc格式
5ns2k9uzv12wkqr4m2h9
领取福利

微信扫码领取福利

微信扫码分享