void SendData ( u8 addr )//發(fā)送函數(shù)。 { u8 i; /*發(fā)送時關(guān)掉中斷,防止中斷影響時序 */ SDA = 1; /*開始拉高*/ delay_us ( 1000 ); SDA = 0; /*開始引導(dǎo)碼*/ delay_us ( 3200 );/*此處延時最少要大于2ms*/ for ( i = 0; i < 8; i++ ) /*總共8位數(shù)據(jù) */ { SDA = 1; if ( addr & 0x01 ) /*3:1表示數(shù)據(jù)位1,每個位用兩個脈沖表示 */ { delay_us ( 600 ); SDA = 0; delay_us ( 200 ); } else /*1:3表示數(shù)據(jù)位0 ,每個位用兩個脈沖表示 */ { delay_us ( 200 ); SDA = 0; delay_us ( 600 ); } addr >>= 1; } SDA = 1; //恢復(fù)中斷 } |