MCPcopy Create free account
hub / github.com/SmingHub/Sming / write

Method write

Sming/Libraries/DS3232RTC/DS3232RTC.cpp:221–236  ·  view source on GitHub ↗

----------------------------------------------------------------------* * 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). * *----------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

219 * Returns the I2C status (zero if successful). *
220 *----------------------------------------------------------------------*/
221byte 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. *

Callers 2

StartReadNextMethod · 0.45
DoMeasureMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected