Skip to content

adapt the RTC nonReg test in case of stm32F1xx #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions examples/NonReg/RTC/RTC_Tests/RTC_Tests.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ static const char* mytime = __TIME__;
clk = RTCCLK / ((predA +1) * (predS +1))
clk = 1000000 / ((99 +1) * (9999+1)) = 1 Hz
*/
#if defined(STM32F1xx)
static uint32_t userPredA = 99;
#else
static int8_t userPredA = 99;
#endif /* STM32F1xx */
static int16_t userPredS = 9999;

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

#ifndef STM32F1xx
static STM32RTC::Alarm_Match SS_MATCH = STM32RTC::MATCH_SS;
static STM32RTC::Alarm_Match MMSS_MATCH = STM32RTC::MATCH_MMSS;
static STM32RTC::Alarm_Match HHMMSS_MATCH = STM32RTC::MATCH_HHMMSS;
static STM32RTC::Alarm_Match SS_MATCH = STM32RTC::MATCH_SS;
static STM32RTC::Alarm_Match MMSS_MATCH = STM32RTC::MATCH_MMSS;
static STM32RTC::Alarm_Match HHMMSS_MATCH = STM32RTC::MATCH_HHMMSS;
#endif
static STM32RTC::Alarm_Match DHHMMSS_MATCH = STM32RTC::MATCH_DHHMMSS;

Expand Down Expand Up @@ -105,9 +109,15 @@ void loop()
}
break;
}

#if defined(STM32F1xx)
Serial.println("Testing only asynchronous prescaler setting");
uint32_t a;
#else
Serial.println("Testing asynchronous and synchronous prescaler setting");
int8_t a;
int16_t s;
#endif /* STM32F1xx */
int16_t s = 0;
rtc.getPrediv(&a, &s);
Serial.print("Async/Sync for default LSI clock: ");
Serial.printf("%i/%i\n", a, s);
Expand All @@ -118,19 +128,15 @@ void loop()
rtc.end();

if (clkSource == rtc.HSE_CLOCK) {
Serial.print("User Async/Sync set to ");
Serial.print(userPredA);
Serial.print("/");
Serial.print(userPredS);
Serial.print(": ");
Serial.printf("User Async/Sync set to %i/%i:", userPredA, userPredS);
rtc.setPrediv(userPredA, userPredS);
rtc_config(clkSource, rtc.HOUR_24, mydate, mytime);
rtc.getPrediv(&a, &s);
Serial.printf("%i/%i\n", a, s);
printDateTime(10, 1000, false);
}

Serial.print("User Async/Sync reset use the computed one: ");
Serial.print("User Async/Sync reset to use the computed one: ");
rtc.setPrediv(-1, -1);
rtc_config(clkSource, rtc.HOUR_24, mydate, mytime);
rtc.getPrediv(&a, &s);
Expand Down Expand Up @@ -254,4 +260,4 @@ void alarmMatch(void *data)
Serial.println("Unknown STM32RTC::Alarm_Match type");
break;
}
}
}