#include /*****************************************************Write a byte to 24C01A Input: E2ROM address, byte data ******************************************************/void write24c01a(uchar uadd_1,uchar udata_1){sendbyte=0xa0;start();send(sendbyte);if (!ack())continue;send(uadd_1);if (!ack())continue;send(udata_1)if (!ack())continue;stop();}/**************************************Send starts********************************************/void start(void){a_scl=1;a_sda=1;a_sda=0;a_scl=0;a_scl=1;}/************************************************Send stops***********************************************/void stop(void){a_scl=0;a_sda=0;a_scl=1;a_sda=1;} /*************************************************Send feedback************************************************/bit ack(void){int a_acka_scl=0;a_scl=0;a_scl=0;a_scl=1;a_ack=a_sda;a_scl=0;return(a_ack)}/******************************************Send without feedback****************************************/bit noack(void){int a_ack;a_scl=1;a_scl=1;a_scl=0;}/***********************************************Send************************************************/void send(uchar undata){uchar i;sendbyte=undatafor(i=8;i>0;i--){a_sda=sendbyte7;a_scl=0;a_scl=1;sendbyte=sendbyte<<1}}/************************************************Accept************************************************/ void receive(void){int i;uchar data;for(i=8;i>0;i--){ a_scl=1;receivebyte7=a_sda;a_scl=0;receivebyte=receivebyte>>1}receivedata=receivebyte;}/************************************************Read a byte from 24c01a; Input: EEROM address; Output: EEROM data;********************************************/void read24c01a(uchar counter){receivebyte=0xa1;start();send(receivebyte);if (!ack())continue;send(counter);if (!ack())continue;receive()noack();stop();}