|
uchar PCF8591_readbyte(void)
{
uchar dat;
I2c_Start();
I2c_writebyte(0x91); //讀
dat = I2c_readbyte();
I2c_Stop();
return dat;
}
// 進(jìn)行一次DA轉(zhuǎn)換(本設(shè)計(jì)中未使用DA轉(zhuǎn)換)
void PCF8591_DAchange(uchar dat)
{
I2c_Start();
I2c_writebyte(0x90);
I2c_writebyte(0x40); //開DA轉(zhuǎn)換
I2c_writebyte(dat); //寫轉(zhuǎn)換數(shù)據(jù)
I2c_Stop();
}
//進(jìn)行一次AD轉(zhuǎn)換 ,num為通道號(hào)
uchar PCF8591_ADchange(uchar num)
{
uchar dat;
PCF8591_writebyte(0x91);
PCF8591_writebyte(num); // 選擇通道 ,開始轉(zhuǎn)換
dat = PCF8591_readbyte();
dat = PCF8591_readbyte();
return dat;
}
|
|