欢迎来到天天文库
浏览记录
ID:16921855
大小:14.60 KB
页数:6页
时间:2018-08-25
《基于msp430f149单片机的温湿度传感器sht1x驱动程序》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、基于MSP430F149单片机的温湿度传感器SHT1X驱动程序#include"msp430x14x.h"//头文件#include"SHT1X.h"#define_nop_()_NOP()//floatiAdResult[MM];//----------------------------------------------------------------------------------//modul-var温湿度传感器SHT10驱动程序开始//-------------------------------------------------------------------
2、---------------//----------------------------------------------------------------------------------chars_write_byte(unsignedcharvalue)//----------------------------------------------------------------------------------//writesabyteontheSensibusandcheckstheacknowledge{unsignedchari,error=0;DATA_Ou
3、tDIR();for(i=0x80;i>0;i/=2)//shiftbitformasking{if(i&value)Set_DATA();//DATA=1maskingvaluewithi,writetoSENSI-BUSelseClear_DATA();//DATA=0Set_CLK();//SCK=1clkforSENSI-BUS_nop_();_nop_();_nop_();//pulswithapprox.5usClear_CLK();//SCK=0}Set_DATA();//DATA=1releaseDATA-lineDATA_InDIR();Set_CLK();//SCK=
4、1clk#9forack//DATA_InDIR();error=P1IN&DATA;//error=DATAcheckack(DATAwillbepulleddownbySHT11)DATA_OutDIR();Clear_CLK();//SCK=0if(error)return1;return0;//error=1incaseofnoacknowledge}//----------------------------------------------------------------------------------otherstaffoftheCentre.Duringthew
5、ar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofthelongMarch,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSAR
6、missions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecorderoftheCountypartyCommitteeSecretary,Ministersandchars_read_byte(unsignedcharack)//----------------------------------------------------------------------------------//readsabyteformtheSensibusandgivesanacknowledgeincaseof"ack=1"{unsi
7、gnedchari,val=0;DATA_OutDIR();Set_DATA();//DATA=1releaseDATA-lineDATA_InDIR();for(i=0x80;i>0;i/=2)//shiftbitformasking{Set_CLK();//SCK=1clkforSENSI-BUSif(P1IN&DATA)val=(val
8、i);//(DATA)readbitClear_CLK();//SCK=0}DATA_Ou
此文档下载收益归作者所有