Skip to content

Commit a3d885a

Browse files
committed
stm32duino LoraWan enabling the RTC alarm B
Mask is set to ALL in case of MIX mode, so that interrupt is trigged on the sub-second basis (other calendar values do not care) Signed-off-by: Francois Ramu <francois.ramu@st.com>
1 parent 64eee31 commit a3d885a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/STM32LoRaWAN.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
#error "Unexpected txpower constants"
5555
#endif
5656

57+
/* Get the RTC object for init */
58+
STM32RTC& rtc = STM32RTC::getInstance();
59+
5760
STM32LoRaWAN* STM32LoRaWAN::instance;
5861

5962
bool STM32LoRaWAN::begin(_lora_band band)
@@ -62,6 +65,17 @@ bool STM32LoRaWAN::begin(_lora_band band)
6265
return failure("Only one STM32LoRaWAN instance can be used");
6366
instance = this;
6467

68+
/*
69+
* Init RTC as an object :
70+
* use the MIX mode = free running BCD calendar + binary mode for
71+
* the sub-second counter RTC_SSR on 32 bit
72+
*/
73+
rtc.setClockSource(STM32RTC::LSE_CLOCK);
74+
rtc.begin(true, STM32RTC::HOUR_24, STM32RTC::MODE_MIX);
75+
/* Attach the callback function before enabling Interrupt */
76+
rtc.attachInterrupt(UTIL_TIMER_IRQ_MAP_PROCESS, STM32RTC::ALARM_B);
77+
/* The subsecond alarm B is set during the StartTimerEvent */
78+
6579
UTIL_TIMER_Init();
6680

6781
LoRaMacStatus_t res = LoRaMacInitialization(&LoRaMacPrimitives, &LoRaMacCallbacks, (LoRaMacRegion_t)band);

src/STM32LoRaWAN.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141

4242
#include "Arduino.h"
4343
#include "STM32CubeWL/LoRaWAN/Mac/LoRaMac.h"
44-
#include "STM32CubeWL/Utilities/timer/stm32_timer.h"
4544
#include "BSP/mw_log_conf.h"
45+
#include "BSP/timer_if.h"
46+
#include "STM32RTC.h"
4647

4748

4849
/**

0 commit comments

Comments
 (0)