云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 基于单片机控制的多功能控制温湿度 - 图文

基于单片机控制的多功能控制温湿度 - 图文

  • 62 次阅读
  • 3 次下载
  • 2025/5/25 21:24:10

_nop_(); DATA=1; _nop_(); SCK=0; }

/*-------------------------------------- ;模块名称:s_connectionreset(); ;功 能:连接复位函数 ;-------------------------------------*/ void s_connectionreset(void)

// 通讯复位: DATA-line=1 and at least 9 SCK cycles followed by transstart

// _____________________________________________________ ________ // |_______|

// _ _ _ _ _ _ _ _ _ ___ ___

// SCK : __| |__| |__| |__| |__| |__| |__| |__| |__| |______| |___| |______ {

unsigned char i; //初始状态 DATA=1;

SCK=0;

for(i=0;i<9;i++) //9 SCK cycles

DATA:

{ SCK=1; SCK=0; }

s_transstart(); //启动传输 }

/*-------------------------------------- ;模块名称:s_write_byte(); ;功 能:SHT10写函数 ;-------------------------------------*/ char s_write_byte(unsigned char value)

//---------------------------------------------------------------------------------- // writes a byte on the Sensibus and checks the acknowledge {

unsigned char i,error=0;

for (i=0x80;i>0;i/=2) //shift bit for masking {

if (i & value) DATA=1; //masking value with i , write to SENSI-BUS

else DATA=0;

SCK=1; //clk for SENSI-BUS _nop_();_nop_();_nop_(); //pulswith approx. 3 us

SCK=0; }

DATA=1; //release DATA-line SCK=1; //clk #9 for ack

error=DATA; //check ack (DATA will be pulled down by SHT10),DATA在第9个上升沿将被SHT10自动下拉为低电平。 _nop_();_nop_();_nop_(); SCK=0;

DATA=1; //release DATA-line

return error; //error=1 in case of no acknowledge //返回:0成功,1失败 }

/*-------------------------------------- ;模块名称:s_read_byte(); ;功 能:SHT10读函数 ;-------------------------------------*/ char s_read_byte(unsigned char ack)

// reads a byte form the Sensibus and gives an acknowledge in case of \ {

unsigned char i,val=0;

DATA=1; //release DATA-line for (i=0x80;i>0;i/=2) //shift bit for masking { SCK=1; //clk for SENSI-BUS

if (DATA) val=(val | i); //read bit _nop_();_nop_();_nop_(); //pulswith approx. 3 us SCK=0; }

if(ack==1)DATA=0; //in case of \pull down DATA-Line

else DATA=1; //如果是校验(ack==0),读取完后结束通讯

_nop_();_nop_();_nop_(); //pulswith approx. 3 us SCK=1; //clk #9 for ack _nop_();_nop_();_nop_(); //pulswith approx. 3 us SCK=0;

_nop_();_nop_();_nop_(); //pulswith approx. 3 us DATA=1; //release DATA-line return val; }

/*-------------------------------------- ;模块名称:s_measure(); ;功 能:测量温湿度函数 ;-------------------------------------*/

char s_measure(unsigned char *p_value, unsigned char *p_checksum, unsigned char mode)

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

_nop_(); DATA=1; _nop_(); SCK=0; } /*-------------------------------------- ;模块名称:s_connectionreset(); ;功 能:连接复位函数 ;-------------------------------------*/ void s_connectionreset(void) // 通讯复位: DATA-line=1 and at least 9 SCK cycles followed by transstart // _____________________________________________________ ________ /

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com