DS3231 External RTC I2C
Fork of DS3231 by
Diff: DS3231.cpp
- Revision:
- 3:f599542b06ad
- Parent:
- 2:fc6317727d1d
- Child:
- 5:6fab75b89838
--- a/DS3231.cpp Tue Nov 03 08:15:12 2015 +0000 +++ b/DS3231.cpp Thu Nov 05 16:44:45 2015 +0000 @@ -266,6 +266,17 @@ _i2c.read( ADDR, temp, 2); return float(temp[0]) + 0.25*(temp[1]>>6); } +bool DS3231::status(void) { + // Checks DS3231 and returns the status. + // returns true if DS3231 is present and on + char temp[2]; + char cmd; + cmd = 0x11; + int w= _i2c.write(ADDR, &cmd, 1); + int r= _i2c.read( ADDR, temp, 2); + bool error=((w!=0)||(r!=0)); + return !error; +} void DS3231::getA1Time(uint8_t& A1Day, uint8_t& A1Hour, uint8_t& A1Minute, uint8_t& A1Second, uint8_t& AlarmBits, bool& A1Dy, bool& A1h12, bool& A1PM) { uint8_t temp_buffer;