Skip to content

Commit b29cdae

Browse files
committed
Add accessors for Control and Status registers; Whitespace changes to appease clang.
1 parent 1486dfc commit b29cdae

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

src/RTC_DS3231.cpp

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ float RTC_DS3231::getTemperature() {
125125
*/
126126
/**************************************************************************/
127127
int8_t RTC_DS3231::getAging() {
128-
return read_register(DS3231_AGING);
128+
return read_register(DS3231_AGING);
129129
}
130130

131131
/**************************************************************************/
@@ -135,9 +135,51 @@ int8_t RTC_DS3231::getAging() {
135135
*/
136136
/**************************************************************************/
137137
void RTC_DS3231::setAging(int8_t val) {
138-
write_register(DS3231_AGING, val);
138+
write_register(DS3231_AGING, val);
139139
}
140140

141+
/**************************************************************************/
142+
/*!
143+
@brief Get the current value of the control register
144+
@return Control register bits (unsigned int8)
145+
*/
146+
/**************************************************************************/
147+
uint8_t RTC_DS3231::getControlReg() {
148+
return read_register(DS3231_CONTROL);
149+
}
150+
151+
/**************************************************************************/
152+
/*!
153+
@brief Write new values to all bits of the control register
154+
@param val New value for the 8 bit control register.
155+
*/
156+
/**************************************************************************/
157+
void RTC_DS3231::setControlReg(uint8_t val) {
158+
write_register(DS3231_CONTROL, val);
159+
}
160+
161+
/**************************************************************************/
162+
/*!
163+
@brief Get the current value of the status register
164+
@return Status register bits (unsigned int8)
165+
*/
166+
/**************************************************************************/
167+
uint8_t RTC_DS3231::getStatusReg() {
168+
return read_register(DS3231_STATUSREG);
169+
}
170+
171+
/**************************************************************************/
172+
/*!
173+
@brief Write new values to all bits of the status register e.g., to
174+
clear flags.
175+
@param val New value for the 8 bit status register.
176+
*/
177+
/**************************************************************************/
178+
void RTC_DS3231::setStatusReg(uint8_t val) {
179+
write_register(DS3231_STATUSREG, val);
180+
}
181+
182+
141183
/**************************************************************************/
142184
/*!
143185
@brief Set alarm 1 for DS3231

src/RTClib.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,10 @@ class RTC_DS3231 : RTC_I2C {
390390
float getTemperature(); // in Celsius degree
391391
int8_t getAging();
392392
void setAging(int8_t val);
393+
uint8_t getControlReg();
394+
void setControlReg(uint8_t val);
395+
uint8_t getStatusReg();
396+
void setStatusReg(uint8_t val);
393397
/*!
394398
@brief Convert the day of the week to a representation suitable for
395399
storing in the DS3231: from 1 (Monday) to 7 (Sunday).

0 commit comments

Comments
 (0)