Zo 5 Februari 2012, 12:45
//***************************************************************************** // // File Name : ds1307.c // Title : Support for Maxim DS1307 real time clock // Author : Smoerijf.be // Target MCU : Atmel AVR Series // //***************************************************************************** #include "i2c.h" #include "ds1307.h" /** * @param void * @return void **/ void ds1307Init(void){ u08 buff[2]; // set control register buff[0] = 0x00; buff[1] = 0x00; i2cSend(ds1307addr, 2, buff); } /** * @param *d Pointer voor data opslag [3] * @return void **/ void ds1307Read(u08* d){ *d = 0x00; i2cSend(ds1307addr, 1, d); i2cReceive(ds1307addr, 3, d); } /** * @param p seconds * @return void **/ void ds1307SetSec(u08 p){ u08 buff[2]; buff[0] = 0x00; buff[1] = ((p/10)<<4) | (p%10); i2cSend(ds1307addr, 2, buff); } /** * @param p minutes * @return void **/ void ds1307SetMin(u08 p){ u08 buff[2]; buff[0] = 0x01; buff[1] = ((p/10)<<4) | (p%10); i2cSend(ds1307addr, 2, buff); } /** * @param p hour * @return void **/ void ds1307SetHour(u08 p){ u08 buff[2]; buff[0] = 0x02; buff[1] = ((p/10)<<4) | (p%10); i2cSend(ds1307addr, 2, buff); }
|