Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .github/workflows/Continuous-Integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
with:
custom-config: "./extras/rtc_cores_config.json"
additional-url: 'https://github.com/stm32duino/BoardManagerFiles/raw/dev/package_stmicroelectronics_index.json'
use-core-repo: 'true'

env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
# Use the output from the `Compile` step
- name: Compilation Errors
if: failure()
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ To know if a time has already been set use:
### Since STM32RTC version higher than 1.3.4
_Second alarm (Alarm B)_

Some STM32 RTC have a second alarm named `RTC_ALARM_B`.
Some STM32 RTC have a second alarm named `ALARM_B`.
It is possible to use it thanks all alarm API with an extra argument:
- `STM32RTC::ALARM_A`
- `STM32RTC::ALARM_B`
Expand All @@ -158,7 +158,8 @@ It is possible to use it thanks all alarm API with an extra argument:

### Since STM32RTC version higher than 1.3.7
_Get the RTC handle_

> [!NOTE]
> Only available for the STM32 HAL driver version 1
* **`RTC_HandleTypeDef *RTC_GetHandle(void)`**

_binary and mix modes_
Expand Down
14 changes: 7 additions & 7 deletions examples/RTCReset/RTCReset.ino
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ typedef struct {
} cb_data_t;

static cb_data_t atime = { 2222, true };
#ifdef RTC_ALARM_B
#if defined(ALARM_B_AVAILABLE)
static cb_data_t btime = { 3333, false };
#endif
static byte seconds = 0;
Expand Down Expand Up @@ -107,7 +107,7 @@ void setup() {

// In any case attach a callback to the RTC alarm interrupt.
rtc.attachInterrupt(alarmMatch, &atime);
#ifdef RTC_ALARM_B
#ifdef ALARM_B_AVAILABLE
rtc.attachInterrupt(alarmMatch, &btime, STM32RTC::ALARM_B);
#endif
rtc.begin(); // Initialize RTC 24H format
Expand All @@ -120,7 +120,7 @@ void setup() {
rtc.setAlarmDay(day);
rtc.setAlarmTime(hours, minutes, seconds + 5, 567);
rtc.enableAlarm(rtc.MATCH_DHHMMSS);
#ifdef RTC_ALARM_B
#ifdef ALARM_B_AVAILABLE
// ALARM_B
rtc.setAlarmDay(day, STM32RTC::ALARM_B);
rtc.setAlarmTime(hours, minutes, seconds + 5, 567, STM32RTC::ALARM_B);
Expand All @@ -144,7 +144,7 @@ void setup() {
Serial.printf("Alarm A was enabled and restored\n");
}
}
#ifdef RTC_ALARM_B
#ifdef ALARM_B_AVAILABLE
// ALARM_B
if (rtc.isAlarmEnabled(STM32RTC::ALARM_B)) {
rtc.enableAlarm(rtc.MATCH_DHHMMSS, STM32RTC::ALARM_B);
Expand All @@ -168,7 +168,7 @@ void setup() {
rtc.setAlarmTime(hours, minutes, seconds + 5, 567);
rtc.enableAlarm(rtc.MATCH_DHHMMSS);
}
#ifdef RTC_ALARM_B
#ifdef ALARM_B_AVAILABLE
bool alarmB = rtc.isAlarmEnabled(STM32RTC::ALARM_B);
Serial.printf("Alarm B enable status: %s\n", (alarmB) ? "True" : "False");
if (!alarmB) {
Expand All @@ -187,7 +187,7 @@ void loop() {
Serial.printf("\n%02d/%02d/%02d %02d:%02d:%02d.%03d\n", rtc.getDay(), rtc.getMonth(), rtc.getYear(), hours, minutes, seconds, subSeconds);
// Print current alarm configuration
Serial.printf("Alarm A: %02d %02d:%02d:%02d.%03d\n", rtc.getAlarmDay(), rtc.getAlarmHours(), rtc.getAlarmMinutes(), rtc.getAlarmSeconds(), rtc.getAlarmSubSeconds());
#ifdef RTC_ALARM_B
#ifdef ALARM_B_AVAILABLE
Serial.printf("Alarm B: %02d %02d:%02d:%02d.%03d\n", rtc.getAlarmDay(STM32RTC::ALARM_B), rtc.getAlarmHours(STM32RTC::ALARM_B), rtc.getAlarmMinutes(STM32RTC::ALARM_B), rtc.getAlarmSeconds(STM32RTC::ALARM_B), rtc.getAlarmSubSeconds(STM32RTC::ALARM_B));
#endif
delay(1000);
Expand Down Expand Up @@ -227,7 +227,7 @@ void alarmMatch(void* data) {
Serial.printf("\t\t\tAlarm A Match %i\n", ++alarmMatch_counter);
rtc.setAlarmEpoch(epoc + sec, STM32RTC::MATCH_SS, epoc_ms);
}
#ifdef RTC_ALARM_B
#ifdef ALARM_B_AVAILABLE
else {
Serial.printf("\t\t\tAlarm B Match %i\n", ++alarmMatchB_counter);
rtc.setAlarmEpoch(epoc + sec, STM32RTC::MATCH_SS, epoc_ms, STM32RTC::ALARM_B);
Expand Down
6 changes: 3 additions & 3 deletions examples/advancedRTCAlarm/advancedRTCAlarm.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ STM32RTC& rtc = STM32RTC::getInstance();

/* Declare it volatile since it's incremented inside an interrupt */
volatile int alarmMatch_counter = 0;
#ifdef RTC_ALARM_B
#if defined(ALARM_B_AVAILABLE)
volatile int alarmBMatch_counter = 0;
#endif

Expand Down Expand Up @@ -64,7 +64,7 @@ void setup()
rtc.setAlarmTime(16, 0, 10, 567);
rtc.enableAlarm(rtc.MATCH_DHHMMSS);

#ifdef RTC_ALARM_B
#if defined(ALARM_B_AVAILABLE)
rtc.attachInterrupt(alarmBMatch, STM32RTC::ALARM_B);
rtc.setAlarmDay(day, STM32RTC::ALARM_B);
rtc.setAlarmTime(16, 0, 11, 567, STM32RTC::ALARM_B);
Expand Down Expand Up @@ -110,7 +110,7 @@ void alarmMatch(void *data)
rtc.setAlarmEpoch(epoc + sec, STM32RTC::MATCH_SS, epoc_ms);
}

#ifdef RTC_ALARM_B
#if defined(ALARM_B_AVAILABLE)
void alarmBMatch(void *data)
{
(void)data;
Expand Down
8 changes: 4 additions & 4 deletions examples/bin_onlyRTCAlarm/bin_onlyRTCAlarm.ino
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void setup()
rtc.enableAlarm(rtc.MATCH_SUBSEC);
Serial.printf("Set Alarm A in 12s (at %d ms)\r\n", rtc.getAlarmSubSeconds());

#ifdef RTC_ALARM_B
#if defined(ALARM_B_AVAILABLE)
/* Program ALARM B in 600ms ms from now (keep timeout < 1000ms) */
timeout = rtc.getSubSeconds() + 600;

Expand All @@ -58,7 +58,7 @@ void setup()
rtc.enableAlarm(rtc.MATCH_SUBSEC, STM32RTC::ALARM_B);
Serial.printf("Set Alarm B (in %d ms) at %d ms\r\n", 600,
rtc.getAlarmSubSeconds(STM32RTC::ALARM_B));
#endif /* RTC_ALARM_B */
#endif /* ALARM_B_AVAILABLE */

}

Expand All @@ -74,12 +74,12 @@ void alarmAMatch(void *data)
Serial.printf("Alarm A Match at %d ms \r\n", rtc.getSubSeconds());
}

#ifdef RTC_ALARM_B
#if defined(ALARM_B_AVAILABLE)
void alarmBMatch(void *data)
{
UNUSED(data);
rtc.disableAlarm(STM32RTC::ALARM_B); /* Else it will trig again */
Serial.printf("Alarm B Match at %d ms\r\n", rtc.getSubSeconds());
}
#endif /* RTC_ALARM_B */
#endif /* ALARM_B_AVAILABLE */

8 changes: 4 additions & 4 deletions examples/mixRTCAlarm/mixRTCAlarm.ino
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void setup()
Serial.printf("Set Alarm A in 12s (at %02d:%02d:%02d)\r\n",
rtc.getAlarmHours(), rtc.getAlarmMinutes(), rtc.getAlarmSeconds());

#ifdef RTC_ALARM_B
#if defined(ALARM_B_AVAILABLE)
/* Program ALARM B in 600ms ms from now (keep timeout < 1000ms) */
timeout = rtc.getSubSeconds() + 600;

Expand All @@ -73,7 +73,7 @@ void setup()
rtc.enableAlarm(rtc.MATCH_SUBSEC, STM32RTC::ALARM_B);
Serial.printf("Set Alarm B (in %d ms) at %d ms\r\n", 600,
rtc.getAlarmSubSeconds(STM32RTC::ALARM_B));
#endif /* RTC_ALARM_B */
#endif /* ALARM_B_AVAILABLE */
}

void loop()
Expand All @@ -89,11 +89,11 @@ void alarmAMatch(void *data)
rtc.getHours(), rtc.getMinutes(), rtc.getSeconds());
}

#ifdef RTC_ALARM_B
#if defined(ALARM_B_AVAILABLE)
void alarmBMatch(void *data)
{
UNUSED(data);
rtc.disableAlarm(STM32RTC::ALARM_B);
Serial.printf("Alarm B Match at %d ms\r\n", rtc.getSubSeconds());
}
#endif /* RTC_ALARM_B */
#endif /* ALARM_B_AVAILABLE */
Loading