added start, stop and isrunning for PCF8523

This commit is contained in:
Horst Eff
2020-07-13 23:31:29 +02:00
parent a7cbdd7135
commit 8b6a3244ca
2 changed files with 43 additions and 0 deletions
+40
View File
@@ -1124,6 +1124,46 @@ DateTime RTC_PCF8523::now() {
return DateTime(y, m, d, hh, mm, ss);
}
/**************************************************************************/
/*!
@brief Resets the STOP bit in register Control_1
*/
/**************************************************************************/
void RTC_PCF8523::start(void)
{
uint8_t ctlreg = read_i2c_register(PCF8523_ADDRESS, PCF8523_CONTROL_1);
if(ctlreg & (1<<5))
{
write_i2c_register(PCF8523_ADDRESS, PCF8523_CONTROL_1, ctlreg & ~(1 << 5));
}
}
/**************************************************************************/
/*!
@brief Sets the STOP bit in register Control_1
*/
/**************************************************************************/
void RTC_PCF8523::stop(void)
{
uint8_t ctlreg = read_i2c_register(PCF8523_ADDRESS, PCF8523_CONTROL_1);
if(!(ctlreg & (1<<5)))
{
write_i2c_register(PCF8523_ADDRESS, PCF8523_CONTROL_1, ctlreg | (1 << 5));
}
}
/**************************************************************************/
/*!
@brief Is the PCF8523 running? Check the STOP bit in register Control_1
@return 1 if the RTC is running, 0 if not
*/
/**************************************************************************/
uint8_t RTC_PCF8523::isrunning()
{
uint8_t ctlreg = read_i2c_register(PCF8523_ADDRESS, PCF8523_CONTROL_1);
return !((ctlreg >> 5) & 1);
}
/**************************************************************************/
/*!
@brief Read the mode of the INT/SQW pin on the PCF8523
+3
View File
@@ -366,6 +366,9 @@ public:
boolean lostPower(void);
boolean initialized(void);
static DateTime now();
void start(void);
void stop(void);
uint8_t isrunning();
Pcf8523SqwPinMode readSqwPinMode();
void writeSqwPinMode(Pcf8523SqwPinMode mode);
void enableSecondTimer(void);