----------------------------------------------------------------------* * Sets the RTC's time from a tmElements_t structure and clears the * * oscillator stop flag (OSF) in the Control/Status register. * * Returns the I2C status (zero if successful). * *----------------------------------------------------------------------*/
| 219 | * Returns the I2C status (zero if successful). * |
| 220 | *----------------------------------------------------------------------*/ |
| 221 | byte DS3232RTC::write(tmElements_t &tm) |
| 222 | { |
| 223 | i2cBeginTransmission(RTC_ADDR); |
| 224 | i2cWrite((uint8_t)RTC_SECONDS); |
| 225 | i2cWrite(dec2bcd(tm.Second)); |
| 226 | i2cWrite(dec2bcd(tm.Minute)); |
| 227 | i2cWrite(dec2bcd(tm.Hour)); //sets 24 hour format (Bit 6 == 0) |
| 228 | i2cWrite(tm.Wday); |
| 229 | i2cWrite(dec2bcd(tm.Day)); |
| 230 | i2cWrite(dec2bcd(tm.Month)); |
| 231 | i2cWrite(dec2bcd(tmYearToY2k(tm.Year))); |
| 232 | byte ret = i2cEndTransmission(); |
| 233 | uint8_t s = readRTC(RTC_STATUS); //read the status register |
| 234 | writeRTC( RTC_STATUS, s & ~_BV(OSF) ); //clear the Oscillator Stop Flag |
| 235 | return ret; |
| 236 | } |
| 237 | |
| 238 | /*----------------------------------------------------------------------* |
| 239 | * Write multiple bytes to RTC RAM. * |
no outgoing calls
no test coverage detected