单片机课程设计报告
I2C_delay(); SCLK=1;
I2C_delay(); if(SDA)
dat|=0x80>>i; }
SCLK=0;
return (dat); }
5.DS1307驱动程序
/******************************** DS1307 PART START ****************/
unsigned char Write1307(unsigned char add,dat) {
unsigned char temp; temp=dat/10; temp<<=4;
temp=dat%10+temp;
I2C_start();
I2C_write_byte(0xD0); I2C_send_ack(0);
I2C_write_byte(add); I2C_send_ack(0);
I2C_write_byte(temp); I2C_send_ack(1); I2C_stop();
return (0); }
/***********************************************************************/
unsigned char Read1307(unsigned char add) {
unsigned char temp,dat; I2C_start();
I2C_write_byte(0xD0); I2C_send_ack(0); I2C_write_byte(add);