// -------------------------------------------------------- // Set the RTC's time from a tmElements_t structure. // Returns the bus status (zero if successful). uint8_t DS1302RTC::write(tmElements_t &tm) { uint8_t buff[8]; writeEN(true); if(!writeEN()) return 255; // Error! Write-protect not disabled buff[0] = dec2bcd(tm.Second); // Disable Clock halt flag buff[1] = dec2bcd(tm.Minute); buff[2] = dec2bcd(tm.Hour); // 24-hour mode buff[3] = dec2bcd(tm.Day); buff[4] = dec2bcd(tm.Month); buff[5] = tm.Wday; buff[6] = dec2bcd(tmYearToY2k(tm.Year)); buff[7] = B10000000; // Write protect enable writeRTC(buff); return writeEN(); }
void sendByte( char b ){ DB = b; writeEN(); asm("nop"); writeDIS(); }