Skip to content

Commit 35e3307

Browse files
committed
chore: update check on STM32 core and rtc versions
since lowpower bsp was moved to the library, STM32LowPower API's are no more compatible with the one provided within old core version (<2.0.0). Note: same for STM32RTC Signed-off-by: Frederic Pillon <[email protected]>
1 parent ee9a8e6 commit 35e3307

File tree

5 files changed

+3
-35
lines changed

5 files changed

+3
-35
lines changed

examples/AlarmTimedWakeup/AlarmTimedWakeup.ino

-18
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,9 @@
1717
/* Get the rtc object */
1818
STM32RTC& rtc = STM32RTC::getInstance();
1919

20-
#if defined(STM32_RTC_VERSION) && (STM32_RTC_VERSION >= 0x01010000)
2120
/* Change this value to set alarm match offset in millisecond */
2221
/* Note that STM32F1xx does not manage subsecond only second */
2322
static uint32_t atime = 567;
24-
#else
25-
// Time in second between blink
26-
static uint32_t atime = 1;
27-
#endif
2823

2924
// Declare it volatile since it's incremented inside an interrupt
3025
volatile int alarmMatch_counter = 0;
@@ -73,7 +68,6 @@ void alarmMatch(void* data)
7368
// This function will be called once on device wakeup
7469
// You can do some little operations here (like changing variables which will be used in the loop)
7570
// Remember to avoid calling delay() and long running functions since this functions executes in interrupt context
76-
#if defined(STM32_RTC_VERSION) && (STM32_RTC_VERSION >= 0x01010000)
7771
uint32_t epoc;
7872
uint32_t epoc_ms;
7973
uint32_t sec = 0;
@@ -103,16 +97,4 @@ void alarmMatch(void* data)
10397
#endif
10498
alarmMatch_counter++;
10599
rtc.setAlarmEpoch(epoc + sec, STM32RTC::MATCH_SS, epoc_ms);
106-
#else
107-
uint32_t sec = 1;
108-
if(data != NULL) {
109-
sec = *(uint32_t*)data;
110-
// Minimum is 1 second
111-
if (sec == 0){
112-
sec = 1;
113-
}
114-
}
115-
alarmMatch_counter++;
116-
rtc.setAlarmEpoch( rtc.getEpoch() + sec);
117-
#endif
118100
}

src/STM32LowPower.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ void STM32LowPower::programRtcWakeUp(uint32_t ms, LP_Mode lp_mode)
206206
// Convert millisecond to second
207207
sec = ms / 1000;
208208

209-
#if defined(STM32_RTC_VERSION) && (STM32_RTC_VERSION >= 0x01010000)
210209
uint32_t epoc_ms;
211210
ms = ms % 1000;
212211
epoc = rtc.getEpoch(&epoc_ms);
@@ -219,14 +218,5 @@ void STM32LowPower::programRtcWakeUp(uint32_t ms, LP_Mode lp_mode)
219218
}
220219

221220
rtc.setAlarmEpoch(epoc + sec, STM32RTC::MATCH_DHHMMSS, epoc_ms);
222-
#else
223-
// Minimum is 1 second
224-
if (sec == 0) {
225-
sec = 1;
226-
}
227-
epoc = rtc.getEpoch();
228-
229-
rtc.setAlarmEpoch(epoc + sec);
230-
#endif
231221
}
232222
}

src/STM32LowPower.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@
3939

4040
#include <Arduino.h>
4141

42-
#if defined(STM32_CORE_VERSION) && (STM32_CORE_VERSION > 0x01090000)
43-
#include "low_power.h"
44-
#endif
42+
#include "low_power.h"
4543

4644
// Check if PWR HAL enable in variants/board_name/stm32yzxx_hal_conf.h
4745
#ifndef HAL_PWR_MODULE_ENABLED

src/low_power.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
#include "low_power.h"
2323
#include "stm32yyxx_ll_pwr.h"
2424

25-
#if defined(STM32_CORE_VERSION) && (STM32_CORE_VERSION > 0x01090000) \
26-
&& defined(HAL_PWR_MODULE_ENABLED) && !defined(HAL_PWR_MODULE_ONLY)
25+
#if defined(HAL_PWR_MODULE_ENABLED) && !defined(HAL_PWR_MODULE_ONLY)
2726

2827
#if defined(HAL_UART_MODULE_ENABLED) && !defined(HAL_UART_MODULE_ONLY) \
2928
&& (defined(UART_IT_WUF) || defined(LPUART1_BASE))

src/low_power.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141
#include "stm32_def.h"
4242
#include "uart.h"
4343

44-
#if defined(STM32_CORE_VERSION) && (STM32_CORE_VERSION > 0x01090000) &&\
45-
defined(HAL_PWR_MODULE_ENABLED) && !defined(HAL_PWR_MODULE_ONLY)
44+
#if defined(HAL_PWR_MODULE_ENABLED) && !defined(HAL_PWR_MODULE_ONLY)
4645

4746
#ifdef __cplusplus
4847
extern "C" {

0 commit comments

Comments
 (0)