Skip to content

Commit

Permalink
Add ability to set halt state on DS1307
Browse files Browse the repository at this point in the history
  • Loading branch information
AmirHmZz committed Oct 13, 2023
1 parent 33fb040 commit 78fc148
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
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

0 comments on commit 78fc148

Please sign in to comment.