Skip to content

Commit e675684

Browse files
committed
Naming conventions for member enums
Remove redundant RTC_ prefix. Fix #7 Require Core version higher than 1.3.0 Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
1 parent b8cbccd commit e675684

File tree

8 files changed

+48
-48
lines changed

8 files changed

+48
-48
lines changed

examples/Epoch/Epoch.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ STM32RTC& rtc = STM32RTC::getInstance();
4444
void setup() {
4545
Serial.begin(9600);
4646

47-
// Select RTC clock source: RTC_LSI_CLOCK, RTC_LSE_CLOCK or RTC_HSE_CLOCK.
47+
// Select RTC clock source: LSI_CLOCK, LSE_CLOCK or HSE_CLOCK.
4848
// By default the LSI is selected as source.
49-
//rtc.setClockSource(STM32RTC::RTC_LSE_CLOCK);
49+
//rtc.setClockSource(STM32RTC::LSE_CLOCK);
5050

5151
rtc.begin(); // initialize RTC 24H format
5252

examples/RTCClockSelection/RTCClockSelection.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ void setup()
5858
{
5959
Serial.begin(9600);
6060

61-
// Select RTC clock source: RTC_LSI_CLOCK, RTC_LSE_CLOCK or RTC_HSE_CLOCK.
61+
// Select RTC clock source: LSI_CLOCK, LSE_CLOCK or HSE_CLOCK.
6262
// By default the LSI is selected as source.
63-
rtc.setClockSource(STM32RTC::RTC_LSE_CLOCK);
63+
rtc.setClockSource(STM32RTC::LSE_CLOCK);
6464

6565
rtc.begin(); // initialize RTC 24H format
6666

examples/SimpleRTC/SimpleRTC.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ void setup()
5757
{
5858
Serial.begin(9600);
5959

60-
// Select RTC clock source: RTC_LSI_CLOCK, RTC_LSE_CLOCK or RTC_HSE_CLOCK.
60+
// Select RTC clock source: LSI_CLOCK, LSE_CLOCK or HSE_CLOCK.
6161
// By default the LSI is selected as source.
62-
//rtc.setClockSource(STM32RTC::RTC_LSE_CLOCK);
62+
//rtc.setClockSource(STM32RTC::LSE_CLOCK);
6363

6464
rtc.begin(); // initialize RTC 24H format
6565

examples/advancedRTCAlarm/advancedRTCAlarm.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ void setup()
4040
{
4141
Serial.begin(9600);
4242

43-
// Select RTC clock source: RTC_LSI_CLOCK, RTC_LSE_CLOCK or RTC_HSE_CLOCK.
43+
// Select RTC clock source: LSI_CLOCK, LSE_CLOCK or HSE_CLOCK.
4444
// By default the LSI is selected as source.
45-
//rtc.setClockSource(STM32RTC::RTC_LSE_CLOCK);
45+
//rtc.setClockSource(STM32RTC::LSE_CLOCK);
4646

4747
rtc.begin(); // initialize RTC 24H format
4848

examples/simpleRTCAlarm/simpleRTCAlarm.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ void setup()
5555
{
5656
Serial.begin(9600);
5757

58-
// Select RTC clock source: RTC_LSI_CLOCK, RTC_LSE_CLOCK or RTC_HSE_CLOCK.
58+
// Select RTC clock source: LSI_CLOCK, LSE_CLOCK or HSE_CLOCK.
5959
// By default the LSI is selected as source.
60-
//rtc.setClockSource(STM32RTC::RTC_LSE_CLOCK);
60+
//rtc.setClockSource(STM32RTC::LSE_CLOCK);
6161

6262
rtc.begin(); // initialize RTC 24H format
6363

keywords.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ MATCH_HHMMSS LITERAL1
8585
MATCH_DHHMMSS LITERAL1
8686
MATCH_MMDDHHMMSS LITERAL1
8787
MATCH_YYMMDDHHMMSS LITERAL1
88-
RTC_HOUR_12 LITERAL1
89-
RTC_HOUR_24 LITERAL1
90-
RTC_AM LITERAL1
91-
RTC_PM LITERAL1
92-
RTC_LSE_CLOCK LITERAL1
93-
RTC_LSI_CLOCK LITERAL1
94-
RTC_HSE_CLOCK LITERAL1
88+
HOUR_12 LITERAL1
89+
HOUR_24 LITERAL1
90+
AM LITERAL1
91+
PM LITERAL1
92+
LSE_CLOCK LITERAL1
93+
LSI_CLOCK LITERAL1
94+
HSE_CLOCK LITERAL1

src/STM32RTC.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ void STM32RTC::begin(bool resetTime, RTC_Hour_Format format)
6969
void STM32RTC::begin(RTC_Hour_Format format)
7070
{
7171
if(_configured == false) {
72-
RTC_init((format == RTC_HOUR_12)? HOUR_FORMAT_12: HOUR_FORMAT_24,
73-
(_clockSource == RTC_LSE_CLOCK)? LSE_CLOCK:
74-
(_clockSource == RTC_HSE_CLOCK)? HSE_CLOCK : LSI_CLOCK);
72+
RTC_init((format == HOUR_12)? HOUR_FORMAT_12: HOUR_FORMAT_24,
73+
(_clockSource == LSE_CLOCK)? ::LSE_CLOCK:
74+
(_clockSource == HSE_CLOCK)? ::HSE_CLOCK : ::LSI_CLOCK);
7575
// Must be set before call of sync methods
7676
_configured = true;
7777
syncTime();
@@ -123,8 +123,8 @@ void STM32RTC::setClockSource(RTC_Source_Clock source)
123123
{
124124
if(IS_CLOCK_SOURCE(source)) {
125125
_clockSource = source;
126-
RTC_SetClockSource((_clockSource == RTC_LSE_CLOCK)? LSE_CLOCK:
127-
(_clockSource == RTC_HSE_CLOCK)? HSE_CLOCK : LSI_CLOCK);
126+
RTC_SetClockSource((_clockSource == LSE_CLOCK)? ::LSE_CLOCK:
127+
(_clockSource == HSE_CLOCK)? ::HSE_CLOCK : ::LSI_CLOCK);
128128
}
129129
}
130130

@@ -174,7 +174,7 @@ void STM32RTC::enableAlarm(Alarm_Match match)
174174
case MATCH_MMSS:
175175
case MATCH_SS:
176176
RTC_StartAlarm(_alarmDay, _alarmHours, _alarmMinutes, _alarmSeconds,
177-
_alarmSubSeconds, (_alarmPeriod == RTC_AM)? AM: PM,
177+
_alarmSubSeconds, (_alarmPeriod == AM)? HOUR_AM: HOUR_PM,
178178
static_cast<uint8_t>(_alarmMatch));
179179
_alarmEnabled = true;
180180
break;
@@ -458,7 +458,7 @@ void STM32RTC::setSubSeconds(uint32_t subSeconds)
458458
if(subSeconds < 1000) {
459459
_subSeconds = subSeconds;
460460
}
461-
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == RTC_AM)? AM : PM);
461+
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == AM)? HOUR_AM : HOUR_PM);
462462
}
463463
}
464464

@@ -474,7 +474,7 @@ void STM32RTC::setSeconds(uint8_t seconds)
474474
if(seconds < 60) {
475475
_seconds = seconds;
476476
}
477-
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == RTC_AM)? AM : PM);
477+
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == AM)? HOUR_AM : HOUR_PM);
478478
}
479479
}
480480

@@ -490,7 +490,7 @@ void STM32RTC::setMinutes(uint8_t minutes)
490490
if(minutes < 60) {
491491
_minutes = minutes;
492492
}
493-
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == RTC_AM)? AM : PM);
493+
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == AM)? HOUR_AM : HOUR_PM);
494494
}
495495
}
496496

@@ -506,7 +506,7 @@ void STM32RTC::setHours(uint8_t hours)
506506
if(hours < 24) {
507507
_hours = hours;
508508
}
509-
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == RTC_AM)? AM : PM);
509+
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == AM)? HOUR_AM : HOUR_PM);
510510
}
511511
}
512512

@@ -524,7 +524,7 @@ void STM32RTC::setHours(uint8_t hours, RTC_AM_PM period)
524524
_hours = hours;
525525
}
526526
_hoursPeriod = period;
527-
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == RTC_AM)? AM : PM);
527+
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == AM)? HOUR_AM : HOUR_PM);
528528
}
529529
}
530530

@@ -548,7 +548,7 @@ void STM32RTC::setTime(uint8_t hours, uint8_t minutes, uint8_t seconds)
548548
if(hours < 24) {
549549
_hours = hours;
550550
}
551-
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == RTC_AM)? AM : PM);
551+
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == AM)? HOUR_AM : HOUR_PM);
552552
}
553553
}
554554

@@ -577,7 +577,7 @@ void STM32RTC::setTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t
577577
_hours = hours;
578578
}
579579
_hoursPeriod = period;
580-
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == RTC_AM)? AM : PM);
580+
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == AM)? HOUR_AM : HOUR_PM);
581581
}
582582
}
583583

@@ -925,7 +925,7 @@ void STM32RTC::setEpoch(uint32_t ts)
925925
_seconds = tmp->tm_sec;
926926

927927
RTC_SetDate(_year, _month, _day, _wday);
928-
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == RTC_AM)? AM : PM);
928+
RTC_SetTime(_hours, _minutes, _seconds, _subSeconds, (_hoursPeriod == AM)? HOUR_AM : HOUR_PM);
929929
}
930930
}
931931

@@ -993,9 +993,9 @@ void STM32RTC::configForLowPower(RTC_Source_Clock source)
993993
void STM32RTC::syncTime(void)
994994
{
995995
if(_configured) {
996-
hourAM_PM_t p = AM;
996+
hourAM_PM_t p = HOUR_AM;
997997
RTC_GetTime(&_hours, &_minutes, &_seconds, &_subSeconds, &p);
998-
_hoursPeriod = (p == AM)? RTC_AM : RTC_PM;
998+
_hoursPeriod = (p == HOUR_AM)? AM : PM;
999999
}
10001000
}
10011001

@@ -1017,11 +1017,11 @@ void STM32RTC::syncDate(void)
10171017
void STM32RTC::syncAlarmTime(void)
10181018
{
10191019
if(_configured) {
1020-
hourAM_PM_t p = AM;
1020+
hourAM_PM_t p = HOUR_AM;
10211021
uint8_t match;
10221022
RTC_GetAlarm(&_alarmDay, &_alarmHours, &_alarmMinutes, &_alarmSeconds,
10231023
&_alarmSubSeconds, &p, &match);
1024-
_alarmPeriod = (p == AM)? RTC_AM : RTC_PM;
1024+
_alarmPeriod = (p == HOUR_AM)? AM : PM;
10251025
switch (static_cast<Alarm_Match>(match)) {
10261026
case MATCH_OFF:
10271027
case MATCH_YYMMDDHHMMSS://kept for compatibility

src/STM32RTC.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,23 @@
4848

4949
typedef void(*voidFuncPtr)(void *);
5050

51-
#define IS_CLOCK_SOURCE(SRC) (((SRC) == STM32RTC::RTC_LSI_CLOCK) || ((SRC) == STM32RTC::RTC_LSE_CLOCK) ||\
52-
((SRC) == STM32RTC::RTC_HSE_CLOCK))
53-
#define IS_HOUR_FORMAT(FMT) (((FMT) == STM32RTC::RTC_HOUR_12) || ((FMT) == STM32RTC::RTC_HOUR_24))
51+
#define IS_CLOCK_SOURCE(SRC) (((SRC) == STM32RTC::LSI_CLOCK) || ((SRC) == STM32RTC::LSE_CLOCK) ||\
52+
((SRC) == STM32RTC::HSE_CLOCK))
53+
#define IS_HOUR_FORMAT(FMT) (((FMT) == STM32RTC::HOUR_12) || ((FMT) == STM32RTC::HOUR_24))
5454

5555
class STM32RTC {
5656
public:
5757

5858
enum RTC_Hour_Format : uint8_t
5959
{
60-
RTC_HOUR_12 = HOUR_FORMAT_12,
61-
RTC_HOUR_24 = HOUR_FORMAT_24
60+
HOUR_12 = HOUR_FORMAT_12,
61+
HOUR_24 = HOUR_FORMAT_24
6262
};
6363

6464
enum RTC_AM_PM : uint8_t
6565
{
66-
RTC_AM = AM,
67-
RTC_PM = PM
66+
AM = HOUR_AM,
67+
PM = HOUR_PM
6868
};
6969

7070
enum Alarm_Match: uint8_t
@@ -81,9 +81,9 @@ class STM32RTC {
8181

8282
enum RTC_Source_Clock: uint8_t
8383
{
84-
RTC_LSI_CLOCK = LSI_CLOCK,
85-
RTC_LSE_CLOCK = LSE_CLOCK,
86-
RTC_HSE_CLOCK = HSE_CLOCK
84+
LSI_CLOCK = ::LSI_CLOCK,
85+
LSE_CLOCK = ::LSE_CLOCK,
86+
HSE_CLOCK = ::HSE_CLOCK
8787
};
8888

8989
static STM32RTC& getInstance() {
@@ -95,8 +95,8 @@ class STM32RTC {
9595
STM32RTC(STM32RTC const&) = delete;
9696
void operator=(STM32RTC const&) = delete;
9797

98-
void begin(bool resetTime, RTC_Hour_Format format = RTC_HOUR_24);
99-
void begin(RTC_Hour_Format format = RTC_HOUR_24);
98+
void begin(bool resetTime, RTC_Hour_Format format = HOUR_24);
99+
void begin(RTC_Hour_Format format = HOUR_24);
100100

101101
void end(void);
102102

@@ -188,7 +188,7 @@ class STM32RTC {
188188
friend class STM32LowPower;
189189

190190
private:
191-
STM32RTC(void): _clockSource(RTC_LSI_CLOCK) {}
191+
STM32RTC(void): _clockSource(LSI_CLOCK) {}
192192

193193
static bool _configured;
194194

0 commit comments

Comments
 (0)