AVR單片機(jī)的DS18B20 C語(yǔ)言程序
#include
#define uchar unsigned char
#define uint unsigned int
//
#define BIT_SET(a,b) a|=(1<
#define BIT_CLR(a,b) a&=~(1<//清零位a.b
#define BIT_INV(a,b) a^=(1<//翻轉(zhuǎn)位a.b
#define BIT_STATUS(a,b) a&(1< //讀取位a.b
/
#define CLR_DS18B20 BIT_CLR(PORTC,PC7) //數(shù)據(jù)線強(qiáng)制拉低
#define SET_DS18B20 BIT_SET(PORTC,PC7) //數(shù)據(jù)線強(qiáng)制拉高,上拉
#define HLD_DS18B20 BIT_SET(DDRC,PC7) //Mega16控制總線
#define RLS_DS18B20 BIT_CLR(DDRC,PC7) //釋放總線
#define STU_DS18B20 BIT_STATUS(PINC,PC7) //數(shù)據(jù)線的狀態(tài)
uchar const SEG7[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
uchar const ACT[8]={0x08,0x04,0x02,0x01,0x80,0x40,0x20,0x10};
uint T;
//=============================
void delayUs(uchar temp)
{
}
uchar resetDS18B20(void);
unsigned int readTempDS18B20(void);
void port_init(void)
{
}
void delay_ms(uint k)
{
}
//=============================
void display(uchar counter)
{
}
void main()
{
}
評(píng)論