Skip to content

Commit

Permalink
Add accessors for Control and Status registers; Whitespace changes to…
Browse files Browse the repository at this point in the history
… appease clang.
  • Loading branch information
dpwe committed Jan 11, 2023
1 parent 1486dfc commit b29cdae
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
46 changes: 44 additions & 2 deletions src/RTC_DS3231.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ float RTC_DS3231::getTemperature() {
*/
/**************************************************************************/
int8_t RTC_DS3231::getAging() {
return read_register(DS3231_AGING);
return read_register(DS3231_AGING);
}

/**************************************************************************/
Expand All @@ -135,9 +135,51 @@ int8_t RTC_DS3231::getAging() {
*/
/**************************************************************************/
void RTC_DS3231::setAging(int8_t val) {
write_register(DS3231_AGING, val);
write_register(DS3231_AGING, val);
}

/**************************************************************************/
/*!
@brief Get the current value of the control register
@return Control register bits (unsigned int8)
*/
/**************************************************************************/
uint8_t RTC_DS3231::getControlReg() {
return read_register(DS3231_CONTROL);
}

/**************************************************************************/
/*!
@brief Write new values to all bits of the control register
@param val New value for the 8 bit control register.
*/
/**************************************************************************/
void RTC_DS3231::setControlReg(uint8_t val) {
write_register(DS3231_CONTROL, val);
}

/**************************************************************************/
/*!
@brief Get the current value of the status register
@return Status register bits (unsigned int8)
*/
/**************************************************************************/
uint8_t RTC_DS3231::getStatusReg() {
return read_register(DS3231_STATUSREG);
}

/**************************************************************************/
/*!
@brief Write new values to all bits of the status register e.g., to
clear flags.
@param val New value for the 8 bit status register.
*/
/**************************************************************************/
void RTC_DS3231::setStatusReg(uint8_t val) {
write_register(DS3231_STATUSREG, val);
}


/**************************************************************************/
/*!
@brief Set alarm 1 for DS3231
Expand Down
4 changes: 4 additions & 0 deletions src/RTClib.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ class RTC_DS3231 : RTC_I2C {
float getTemperature(); // in Celsius degree
int8_t getAging();
void setAging(int8_t val);
uint8_t getControlReg();
void setControlReg(uint8_t val);
uint8_t getStatusReg();
void setStatusReg(uint8_t val);
/*!
@brief Convert the day of the week to a representation suitable for
storing in the DS3231: from 1 (Monday) to 7 (Sunday).
Expand Down

0 comments on commit b29cdae

Please sign in to comment.