Skip to content

Commit f88d533

Browse files
authored
Merge pull request #12 from fpistm/enum_naming
Naming conventions for member enums
2 parents b8cbccd + c9bae67 commit f88d533

File tree

9 files changed

+91
-91
lines changed

9 files changed

+91
-91
lines changed

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ The following functions are not supported:
2727
The following functions have been added to support specific STM32 RTC features:
2828

2929
_RTC hours mode (12 or 24)_
30-
* **`void begin(RTC_Hour_Format format)`**
30+
* **`void begin(Hour_Format format)`**
3131

3232
_RTC clock source_
33-
* **`RTC_Source_Clock setClockSource(void)`** : get current clock source.
34-
* **`void setClockSource(RTC_Source_Clock source)`** : this function must be called before `begin()`.
33+
* **`Source_Clock getClockSource(void)`** : get current clock source.
34+
* **`void setClockSource(Source_Clock source)`** : this function must be called before `begin()`.
3535

3636
_RTC Asynchronous and Synchronous prescaler_
3737
* **`void getPrediv(int8_t *predivA, int16_t *predivS)`** : get user (a)synchronous prescaler values if set else computed ones for the current clock source.
@@ -42,20 +42,20 @@ _SubSeconds management_
4242
* **`void setSubSeconds(uint32_t subSeconds)`**
4343

4444
_Hour format (AM or PM)_
45-
* **`uint8_t getHours(RTC_AM_PM *period)`**
46-
* **`void setHours(uint8_t hours, RTC_AM_PM period)`**
47-
* **`void setTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds, RTC_AM_PM period)`**
48-
* **`void setAlarmHours(uint8_t hours, RTC_AM_PM period)`**
49-
* **`uint8_t getAlarmHours(RTC_AM_PM *period)`**
50-
* **`void setAlarmTime(uint8_t hours, uint8_t minutes, uint8_t seconds, RTC_AM_PM period)`**
45+
* **`uint8_t getHours(AM_PM *period)`**
46+
* **`void setHours(uint8_t hours, AM_PM period)`**
47+
* **`void setTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds, AM_PM period)`**
48+
* **`void setAlarmHours(uint8_t hours, AM_PM period)`**
49+
* **`uint8_t getAlarmHours(AM_PM *period)`**
50+
* **`void setAlarmTime(uint8_t hours, uint8_t minutes, uint8_t seconds, AM_PM period)`**
5151

5252
_Week day configuration_
5353
* **`uint8_t getWeekDay(void)`**
5454
* **`void setWeekDay(uint8_t weekDay)`**
5555
* **`void setDate(uint8_t weekDay, uint8_t day, uint8_t month, uint8_t year)`**
5656

5757
_Time and date configuration (added for convenience)_
58-
* **`void getTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *subSeconds, RTC_AM_PM *period = NULL)`**
58+
* **`void getTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *subSeconds, AM_PM *period = NULL)`**
5959
* **`void getDate(uint8_t *weekDay, uint8_t *day, uint8_t *month, uint8_t *year)`**
6060

6161
Refer to the Arduino RTC documentation for the other functions

examples/Epoch/Epoch.ino

+2-2
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

+2-2
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

+2-2
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

+2-2
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

+2-2
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

+7-7
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

+35-35
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ bool STM32RTC::_configured = false;
4949
/**
5050
* @brief initializes the RTC
5151
* @param resetTime: if true reconfigures the RTC
52-
* @param format: hour format: RTC_HOUR_12 or RTC_HOUR_24(default)
52+
* @param format: hour format: HOUR_12 or HOUR_24(default)
5353
* @retval None
5454
*/
55-
void STM32RTC::begin(bool resetTime, RTC_Hour_Format format)
55+
void STM32RTC::begin(bool resetTime, Hour_Format format)
5656
{
5757
if(resetTime == true) {
5858
_configured = false;
@@ -63,15 +63,15 @@ void STM32RTC::begin(bool resetTime, RTC_Hour_Format format)
6363

6464
/**
6565
* @brief initializes the RTC
66-
* @param format: hour format: RTC_HOUR_12 or RTC_HOUR_24(default)
66+
* @param format: hour format: HOUR_12 or HOUR_24(default)
6767
* @retval None
6868
*/
69-
void STM32RTC::begin(RTC_Hour_Format format)
69+
void STM32RTC::begin(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();
@@ -106,25 +106,25 @@ void STM32RTC::end(void)
106106

107107
/**
108108
* @brief get the RTC clock source.
109-
* @retval clock source: RTC_LSI_CLOCK, RTC_LSE_CLOCK or RTC_HSE_CLOCK
109+
* @retval clock source: LSI_CLOCK, LSE_CLOCK or HSE_CLOCK
110110
*/
111-
STM32RTC::RTC_Source_Clock STM32RTC::getClockSource(void)
111+
STM32RTC::Source_Clock STM32RTC::getClockSource(void)
112112
{
113113
return _clockSource;
114114
}
115115

116116
/**
117117
* @brief set the RTC clock source. By default LSI clock is selected. This
118118
* method must be called before begin().
119-
* @param source: clock source: RTC_LSI_CLOCK, RTC_LSE_CLOCK or RTC_HSE_CLOCK
119+
* @param source: clock source: LSI_CLOCK, LSE_CLOCK or HSE_CLOCK
120120
* @retval None
121121
*/
122-
void STM32RTC::setClockSource(RTC_Source_Clock source)
122+
void STM32RTC::setClockSource(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;
@@ -261,7 +261,7 @@ uint8_t STM32RTC::getMinutes(void)
261261
* pointer to the current hour period set in the RTC: AM or PM
262262
* @retval return the current hours from the RTC.
263263
*/
264-
uint8_t STM32RTC::getHours(RTC_AM_PM *period)
264+
uint8_t STM32RTC::getHours(AM_PM *period)
265265
{
266266
syncTime();
267267
if(period != NULL) {
@@ -280,7 +280,7 @@ uint8_t STM32RTC::getHours(RTC_AM_PM *period)
280280
* pointer to the current hour period set in the RTC: AM or PM
281281
* @retval none
282282
*/
283-
void STM32RTC::getTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *subSeconds, RTC_AM_PM *period)
283+
void STM32RTC::getTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *subSeconds, AM_PM *period)
284284
{
285285
syncTime();
286286
if(hours != NULL) {
@@ -401,7 +401,7 @@ uint8_t STM32RTC::getAlarmMinutes(void)
401401
* pointer to the current hour format set in the RTC: AM or PM
402402
* @retval return the current alarm hour.
403403
*/
404-
uint8_t STM32RTC::getAlarmHours(RTC_AM_PM *period)
404+
uint8_t STM32RTC::getAlarmHours(AM_PM *period)
405405
{
406406
syncAlarmTime();
407407
if(period != NULL) {
@@ -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

@@ -516,15 +516,15 @@ void STM32RTC::setHours(uint8_t hours)
516516
* @param hours format: AM or PM
517517
* @retval none
518518
*/
519-
void STM32RTC::setHours(uint8_t hours, RTC_AM_PM period)
519+
void STM32RTC::setHours(uint8_t hours, AM_PM period)
520520
{
521521
if (_configured) {
522522
syncTime();
523523
if(hours < 24) {
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

@@ -560,7 +560,7 @@ void STM32RTC::setTime(uint8_t hours, uint8_t minutes, uint8_t seconds)
560560
* @param hour format: AM or PM
561561
* @retval none
562562
*/
563-
void STM32RTC::setTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds, RTC_AM_PM period)
563+
void STM32RTC::setTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds, AM_PM period)
564564
{
565565
if (_configured) {
566566
syncTime();
@@ -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

@@ -744,7 +744,7 @@ void STM32RTC::setAlarmHours(uint8_t hours)
744744
* @param hour format: AM or PM
745745
* @retval none
746746
*/
747-
void STM32RTC::setAlarmHours(uint8_t hours, RTC_AM_PM period)
747+
void STM32RTC::setAlarmHours(uint8_t hours, AM_PM period)
748748
{
749749
if (_configured) {
750750
if(hours < 24) {
@@ -778,7 +778,7 @@ void STM32RTC::setAlarmTime(uint8_t hours, uint8_t minutes, uint8_t seconds)
778778
* @param hour format: AM or PM
779779
* @retval none
780780
*/
781-
void STM32RTC::setAlarmTime(uint8_t hours, uint8_t minutes, uint8_t seconds, RTC_AM_PM period)
781+
void STM32RTC::setAlarmTime(uint8_t hours, uint8_t minutes, uint8_t seconds, AM_PM period)
782782
{
783783
if (_configured) {
784784
setAlarmHours(hours, period);
@@ -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

@@ -944,7 +944,7 @@ void STM32RTC::setY2kEpoch(uint32_t ts)
944944
* @brief configure RTC source clock for low power
945945
* @param none
946946
*/
947-
void STM32RTC::configForLowPower(RTC_Source_Clock source)
947+
void STM32RTC::configForLowPower(Source_Clock source)
948948
{
949949
#if defined(HAL_PWR_MODULE_ENABLED)
950950
if (!_configured){
@@ -954,7 +954,7 @@ void STM32RTC::configForLowPower(RTC_Source_Clock source)
954954
} else {
955955
if (_clockSource != source) {
956956
// Save current config
957-
RTC_AM_PM period, alarmPeriod = _alarmPeriod;
957+
AM_PM period, alarmPeriod = _alarmPeriod;
958958
uint32_t subSeconds;
959959
uint8_t seconds, minutes, hours, weekDay, day, month, years;
960960
uint8_t alarmSeconds, alarmMinutes, alarmHours, alarmDay;
@@ -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

0 commit comments

Comments
 (0)