diff --git a/src/RTC_DS1307.cpp b/src/RTC_DS1307.cpp index f353e291..1ac4767c 100644 --- a/src/RTC_DS1307.cpp +++ b/src/RTC_DS1307.cpp @@ -3,6 +3,7 @@ #define DS1307_ADDRESS 0x68 ///< I2C address for DS1307 #define DS1307_CONTROL 0x07 ///< Control register #define DS1307_NVRAM 0x08 ///< Start of RAM registers - 56 bytes, 0x08 to 0x3f +#define DS1307_HALT 0x80 /**************************************************************************/ /*! @@ -28,6 +29,22 @@ bool RTC_DS1307::begin(TwoWire *wireInstance) { /**************************************************************************/ uint8_t RTC_DS1307::isrunning(void) { return !(read_register(0) >> 7); } +/**************************************************************************/ +/*! + @brief Set DS1307 halt state + @param halt set halt to specified value +*/ +/**************************************************************************/ +void RTC_DS1307::halt(bool halt) { + uint8_t reg = read_register(0); + if (halt) { + reg |= DS1307_HALT; + } else { + reg &= ~DS1307_HALT; + } + write_register(0, reg); +} + /**************************************************************************/ /*! @brief Set the date and time in the DS1307 diff --git a/src/RTClib.h b/src/RTClib.h index 879bb3fa..685705eb 100644 --- a/src/RTClib.h +++ b/src/RTClib.h @@ -353,6 +353,7 @@ class RTC_DS1307 : RTC_I2C { bool begin(TwoWire *wireInstance = &Wire); void adjust(const DateTime &dt); uint8_t isrunning(void); + void halt(bool halt); DateTime now(); Ds1307SqwPinMode readSqwPinMode(); void writeSqwPinMode(Ds1307SqwPinMode mode);