Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/RTC_DS1307.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**************************************************************************/
/*!
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/RTClib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down