Skip to content

Commit 699658d

Browse files
FRASTMfpistm
authored andcommitted
chore: provide a way to get the RTC handle
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 7714616 commit 699658d

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ It is possible to use it thanks all alarm API with an extra argument:
153153
rtc.enableAlarm(rtc.MATCH_DHHMMSS, STM32RTC::ALARM_B);
154154
```
155155

156+
### Since STM32RTC version higher than 1.3.7
157+
_Get the RTC handle_
158+
159+
* **`RTC_HandleTypeDef *RTC_GetHandle(void)`**
160+
161+
156162
Refer to the Arduino RTC documentation for the other functions
157163
http://arduino.cc/en/Reference/RTC
158164

src/STM32RTC.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ class STM32RTC {
132132

133133
void end(void);
134134

135+
// Could be used to mix Arduino API and STM32Cube HAL API (ex: DMA). Use at your own risk.
136+
RTC_HandleTypeDef *getHandle(void)
137+
{
138+
return RTC_GetHandle();
139+
}
140+
135141
Source_Clock getClockSource(void);
136142
void setClockSource(Source_Clock source, uint32_t predivA = (PREDIVA_MAX + 1), uint32_t predivS = (PREDIVS_MAX + 1));
137143
void getPrediv(uint32_t *predivA, uint32_t *predivS);

src/rtc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ static inline int _log2(int x)
9898

9999
/* Exported functions --------------------------------------------------------*/
100100

101+
/**
102+
* @brief Get pointer to RTC_HandleTypeDef
103+
* @param None
104+
* @retval pointer to RTC_HandleTypeDef
105+
*/
106+
RTC_HandleTypeDef *RTC_GetHandle(void) {
107+
return &RtcHandle;
108+
}
109+
101110
/**
102111
* @brief Set RTC clock source
103112
* @param source: RTC clock source: LSE, LSI or HSE

src/rtc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ typedef void(*voidCallbackPtr)(void *);
173173

174174
/* Exported macro ------------------------------------------------------------*/
175175
/* Exported functions ------------------------------------------------------- */
176+
RTC_HandleTypeDef *RTC_GetHandle(void);
176177
void RTC_SetClockSource(sourceClock_t source);
177178
void RTC_getPrediv(uint32_t *asynch, uint32_t *synch);
178179
void RTC_setPrediv(uint32_t asynch, uint32_t synch);

0 commit comments

Comments
 (0)