Skip to content

Commit b0faddc

Browse files
committed
Add alarm status
Signed-off-by: Frederic.Pillon <[email protected]>
1 parent a901c86 commit b0faddc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/STM32RTC.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ void STM32RTC::begin(bool resetTime, RTC_Hour_Format format)
5656
{
5757
if(resetTime == true) {
5858
_configured = false;
59+
_alarmEnabled = false;
5960
}
6061
begin(format);
6162
}
@@ -99,6 +100,7 @@ void STM32RTC::end(void)
99100
if(_configured == true) {
100101
RTC_DeInit();
101102
_configured = false;
103+
_alarmEnabled = false;
102104
}
103105
}
104106

@@ -174,6 +176,7 @@ void STM32RTC::enableAlarm(Alarm_Match match)
174176
RTC_StartAlarm(_alarmDay, _alarmHours, _alarmMinutes, _alarmSeconds,
175177
_alarmSubSeconds, (_alarmPeriod == RTC_AM)? AM: PM,
176178
static_cast<uint8_t>(_alarmMatch));
179+
_alarmEnabled = true;
177180
break;
178181
default:
179182
break;
@@ -189,6 +192,7 @@ void STM32RTC::disableAlarm(void)
189192
{
190193
if(_configured) {
191194
RTC_StopAlarm();
195+
_alarmEnabled = false;
192196
}
193197
}
194198

src/STM32RTC.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ class STM32RTC {
182182
bool isConfigured(void) {
183183
return _configured;
184184
}
185-
185+
bool isAlarmEnabled(void) {
186+
return _alarmEnabled;
187+
}
186188
friend class STM32LowPower;
187189

188190
private:
@@ -207,6 +209,7 @@ class STM32RTC {
207209
uint32_t _alarmSubSeconds;
208210
RTC_AM_PM _alarmPeriod;
209211
Alarm_Match _alarmMatch;
212+
bool _alarmEnabled;
210213

211214
RTC_Source_Clock _clockSource;
212215

0 commit comments

Comments
 (0)