Skip to content

Commit 8a568c7

Browse files
authored
Merge pull request #8 from fpistm/enum_rtc
Update RTC sketch after enum changed
2 parents 910d849 + d25945d commit 8a568c7

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

examples/NonReg/RTC/RTC_Tests/RTC_Config.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
void rtc_config(STM32RTC::RTC_Source_Clock source, STM32RTC::RTC_Hour_Format format, const char* date, const char* time) {
2+
void rtc_config(STM32RTC::Source_Clock source, STM32RTC::Hour_Format format, const char* date, const char* time) {
33
if (!IS_CLOCK_SOURCE(source)) {
44
Serial.println("Wrong clock source");
55
return;

examples/NonReg/RTC/RTC_Tests/RTC_Tests.ino

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ static byte day = 0;
5151
static byte month = 0;
5252
static byte year = 0;
5353

54-
static STM32RTC::RTC_Hour_Format hourFormat = STM32RTC::RTC_HOUR_24;
55-
static STM32RTC::RTC_AM_PM period = STM32RTC::RTC_AM;
54+
static STM32RTC::Hour_Format hourFormat = STM32RTC::HOUR_24;
55+
static STM32RTC::AM_PM period = STM32RTC::AM;
5656

5757
#ifndef STM32F1xx
5858
static STM32RTC::Alarm_Match SS_MATCH = STM32RTC::MATCH_SS;
@@ -70,13 +70,13 @@ void setup()
7070
void loop()
7171
{
7272
int c; // Serial input
73-
STM32RTC::RTC_Source_Clock clkSource = rtc.RTC_LSI_CLOCK;
73+
STM32RTC::Source_Clock clkSource = rtc.LSI_CLOCK;
7474

75-
// Select RTC clock source: RTC_LSI_CLOCK, RTC_LSE_CLOCK or RTC_HSE_CLOCK.
75+
// Select RTC clock source: LSI_CLOCK, LSE_CLOCK or HSE_CLOCK.
7676
Serial.println("Select clock Source:");
77-
Serial.println("1- RTC_LSI_CLOCK");
78-
Serial.println("2- RTC_LSE_CLOCK");
79-
Serial.println("3- RTC_HSE_CLOCK");
77+
Serial.println("1- LSI_CLOCK");
78+
Serial.println("2- LSE_CLOCK");
79+
Serial.println("3- HSE_CLOCK");
8080
Serial.println();
8181
// get input
8282
while (1) {
@@ -91,16 +91,16 @@ void loop()
9191
switch(c) {
9292
case '1':
9393
default:
94-
Serial.println("Test will use RTC_LSI_CLOCK");
95-
clkSource = rtc.RTC_LSI_CLOCK;
94+
Serial.println("Test will use LSI_CLOCK");
95+
clkSource = rtc.LSI_CLOCK;
9696
break;
9797
case '2':
98-
Serial.println("Test will use RTC_LSE_CLOCK");
99-
clkSource = rtc.RTC_LSE_CLOCK;
98+
Serial.println("Test will use LSE_CLOCK");
99+
clkSource = rtc.LSE_CLOCK;
100100
break;
101101
case '3':
102-
Serial.println("Test will use RTC_HSE_CLOCK");
103-
clkSource = rtc.RTC_HSE_CLOCK;
102+
Serial.println("Test will use HSE_CLOCK");
103+
clkSource = rtc.HSE_CLOCK;
104104
break;
105105
}
106106
break;
@@ -112,46 +112,46 @@ void loop()
112112
rtc.getPrediv(&a, &s);
113113
Serial.print("Async/Sync for default LSI clock: ");
114114
Serial.print(a); Serial.print('/'); Serial.println(s);
115-
rtc_config(clkSource, rtc.RTC_HOUR_24, mydate, mytime);
115+
rtc_config(clkSource, rtc.HOUR_24, mydate, mytime);
116116
Serial.print("Async/Sync for selected clock: ");
117117
rtc.getPrediv(&a, &s);
118118
Serial.print(a); Serial.print('/'); Serial.println(s);
119119
rtc.end();
120120

121-
if(clkSource == rtc.RTC_HSE_CLOCK) {
121+
if(clkSource == rtc.HSE_CLOCK) {
122122
Serial.print("User Async/Sync set to ");
123123
Serial.print(userPredA);
124124
Serial.print("/");
125125
Serial.print(userPredS);
126126
Serial.print(": ");
127127
rtc.setPrediv(userPredA, userPredS);
128-
rtc_config(clkSource, rtc.RTC_HOUR_24, mydate, mytime);
128+
rtc_config(clkSource, rtc.HOUR_24, mydate, mytime);
129129
rtc.getPrediv(&a, &s);
130130
Serial.print(a); Serial.print('/'); Serial.println(s);
131131
printDateTime(10, 1000, false);
132132
}
133133

134134
Serial.print("User Async/Sync reset use the computed one: ");
135135
rtc.setPrediv(-1, -1);
136-
rtc_config(clkSource, rtc.RTC_HOUR_24, mydate, mytime);
136+
rtc_config(clkSource, rtc.HOUR_24, mydate, mytime);
137137
rtc.getPrediv(&a, &s);
138138
Serial.print(a); Serial.print('/'); Serial.println(s);
139139

140140
// Check date change
141141
Serial.println("Testing date and time");
142142
Serial.println("24H format, new year");
143-
rtc_config(clkSource, rtc.RTC_HOUR_24, "Dec 31 2017", "23:59:56");
143+
rtc_config(clkSource, rtc.HOUR_24, "Dec 31 2017", "23:59:56");
144144
printDateTime(8, 1000, false);
145145
Serial.println();
146146

147147
#ifndef STM32F1xx
148148
Serial.println("12H format, new year");
149-
rtc_config(clkSource, rtc.RTC_HOUR_12, "Dec 31 2017", "23:59:56");
149+
rtc_config(clkSource, rtc.HOUR_12, "Dec 31 2017", "23:59:56");
150150
printDateTime(8, 1000, false);
151151
Serial.println();
152152

153153
Serial.println("12H format, from AM to PM");
154-
rtc_config(clkSource, rtc.RTC_HOUR_12, "Dec 31 2017", "11:59:56");
154+
rtc_config(clkSource, rtc.HOUR_12, "Dec 31 2017", "11:59:56");
155155
printDateTime(8, 1000, false);
156156
Serial.println();
157157
#endif //STM32F1xx
@@ -167,7 +167,7 @@ void loop()
167167
}
168168

169169
Serial.println("\nTesting alarm");
170-
rtc_config(clkSource, rtc.RTC_HOUR_24, mydate, mytime);
170+
rtc_config(clkSource, rtc.HOUR_24, mydate, mytime);
171171
byte alarmSeconds = ((seconds+5)<60) ? seconds+5 : 5;
172172
byte alarmMinutes = ((seconds+5)<60) ? minutes : ((minutes+1)<60) ? minutes+1 : 0;
173173
byte alarmHours = ((seconds+5)<60) ? hours : ((minutes+1)<60) ? hours : ((hours+1)<24) ? hours+1 : 0;
@@ -210,7 +210,7 @@ void loop()
210210
rtc.disableAlarm();
211211
rtc.detachInterrupt();
212212

213-
rtc_config(clkSource, rtc.RTC_HOUR_24, mydate, mytime);
213+
rtc_config(clkSource, rtc.HOUR_24, mydate, mytime);
214214
Serial.println("\nAlarm disabled. Printing each 10s.");
215215
printDateTime(-1, 10000, false);
216216
}

examples/NonReg/RTC/RTC_Tests/RTC_utils.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ void initDateTime (const char* date, const char* time) {
2929
}
3030
day = conv2d(date + 4);
3131
hours = conv2d(time);
32-
if (hourFormat == rtc.RTC_HOUR_12) {
33-
period = hours >= 12 ? rtc.RTC_PM : rtc.RTC_AM;
32+
if (hourFormat == rtc.HOUR_12) {
33+
period = hours >= 12 ? rtc.PM : rtc.AM;
3434
hours = hours >= 13 ? hours - 12 : (hours < 1 ? hours + 12 : hours);
3535
}
3636
minutes = conv2d(time + 3);
@@ -56,8 +56,8 @@ void printDateTime(uint32_t t, uint32_t d, bool a) {
5656
print2digits(rtc.getMinutes());
5757
Serial.print(":");
5858
print2digits(rtc.getSeconds());
59-
if (hourFormat == rtc.RTC_HOUR_12) {
60-
Serial.print(period == rtc.RTC_AM ? " AM":" PM");
59+
if (hourFormat == rtc.HOUR_12) {
60+
Serial.print(period == rtc.AM ? " AM":" PM");
6161
}
6262
if(a) {
6363
// Print day...
@@ -71,8 +71,8 @@ void printDateTime(uint32_t t, uint32_t d, bool a) {
7171
print2digits(rtc.getAlarmMinutes());
7272
Serial.print(":");
7373
print2digits(rtc.getAlarmSeconds());
74-
if (hourFormat == rtc.RTC_HOUR_12) {
75-
Serial.print(period == rtc.RTC_AM ? " AM":" PM");
74+
if (hourFormat == rtc.HOUR_12) {
75+
Serial.print(period == rtc.AM ? " AM":" PM");
7676
}
7777
}
7878
Serial.println();

0 commit comments

Comments
 (0)