Skip to content

Commit cd5c82c

Browse files
authored
Merge pull request #53 from FRASTM/f1_pdiv
adapt the RTC nonReg test in case of stm32F1xx
2 parents d32e562 + 8f4e357 commit cd5c82c

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

examples/NonReg/RTC/RTC_Tests/RTC_Tests.ino

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ static const char* mytime = __TIME__;
3838
clk = RTCCLK / ((predA +1) * (predS +1))
3939
clk = 1000000 / ((99 +1) * (9999+1)) = 1 Hz
4040
*/
41+
#if defined(STM32F1xx)
42+
static uint32_t userPredA = 99;
43+
#else
4144
static int8_t userPredA = 99;
45+
#endif /* STM32F1xx */
4246
static int16_t userPredS = 9999;
4347

4448
/* */
@@ -55,9 +59,9 @@ static STM32RTC::Hour_Format hourFormat = STM32RTC::HOUR_24;
5559
static STM32RTC::AM_PM period = STM32RTC::AM;
5660

5761
#ifndef STM32F1xx
58-
static STM32RTC::Alarm_Match SS_MATCH = STM32RTC::MATCH_SS;
59-
static STM32RTC::Alarm_Match MMSS_MATCH = STM32RTC::MATCH_MMSS;
60-
static STM32RTC::Alarm_Match HHMMSS_MATCH = STM32RTC::MATCH_HHMMSS;
62+
static STM32RTC::Alarm_Match SS_MATCH = STM32RTC::MATCH_SS;
63+
static STM32RTC::Alarm_Match MMSS_MATCH = STM32RTC::MATCH_MMSS;
64+
static STM32RTC::Alarm_Match HHMMSS_MATCH = STM32RTC::MATCH_HHMMSS;
6165
#endif
6266
static STM32RTC::Alarm_Match DHHMMSS_MATCH = STM32RTC::MATCH_DHHMMSS;
6367

@@ -105,9 +109,15 @@ void loop()
105109
}
106110
break;
107111
}
112+
113+
#if defined(STM32F1xx)
114+
Serial.println("Testing only asynchronous prescaler setting");
115+
uint32_t a;
116+
#else
108117
Serial.println("Testing asynchronous and synchronous prescaler setting");
109118
int8_t a;
110-
int16_t s;
119+
#endif /* STM32F1xx */
120+
int16_t s = 0;
111121
rtc.getPrediv(&a, &s);
112122
Serial.print("Async/Sync for default LSI clock: ");
113123
Serial.printf("%i/%i\n", a, s);
@@ -118,19 +128,15 @@ void loop()
118128
rtc.end();
119129

120130
if (clkSource == rtc.HSE_CLOCK) {
121-
Serial.print("User Async/Sync set to ");
122-
Serial.print(userPredA);
123-
Serial.print("/");
124-
Serial.print(userPredS);
125-
Serial.print(": ");
131+
Serial.printf("User Async/Sync set to %i/%i:", userPredA, userPredS);
126132
rtc.setPrediv(userPredA, userPredS);
127133
rtc_config(clkSource, rtc.HOUR_24, mydate, mytime);
128134
rtc.getPrediv(&a, &s);
129135
Serial.printf("%i/%i\n", a, s);
130136
printDateTime(10, 1000, false);
131137
}
132138

133-
Serial.print("User Async/Sync reset use the computed one: ");
139+
Serial.print("User Async/Sync reset to use the computed one: ");
134140
rtc.setPrediv(-1, -1);
135141
rtc_config(clkSource, rtc.HOUR_24, mydate, mytime);
136142
rtc.getPrediv(&a, &s);
@@ -254,4 +260,4 @@ void alarmMatch(void *data)
254260
Serial.println("Unknown STM32RTC::Alarm_Match type");
255261
break;
256262
}
257-
}
263+
}

0 commit comments

Comments
 (0)