?? ds1820rd.c
字號:
#include<io8515.h>
/*********************************************
從DS1820讀1字節數據
*********************************************/
unsigned char ds1820_read(void)
{
unsigned char i,byte,temp;
byte=0x00;
for (i=0;i<8;i++)
{
DDRA|=0x01;//PORTA.0輸出
PORTA&=0xfe;//輸出LOW
delay_us(3);
PORTA|=0x01;//輸出HIGH
DDRA&=0xfe;//PORTA.0輸入
delay_us(10);
temp=(PINA&0x01);
if (temp!=0x00)
byte|=0x80;
if (i<7)
byte=byte>>1;
delay_us(100);
DDRA|=0x01;//PORTA.0輸出
delay_us(5);
}
return byte;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -