Skip to content

Commit 6b5989f

Browse files
committed
change the set/get prescaler divider Interface in case of stm32F1
The stm32F1 prescaler is asynchronous and mapped on a 32bit param. Signed-off-by: Francois Ramu <francois.ramu@st.com>
1 parent 23c8c3c commit 6b5989f

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/STM32RTC.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,19 @@ void STM32RTC::setClockSource(Source_Clock source)
133133
}
134134
}
135135

136+
#if defined(STM32F1xx)
137+
/**
138+
* @brief get user asynchronous prescaler value for the current clock source.
139+
* @param predivA: pointer to the current Asynchronous prescaler value
140+
* @param dummy : not used (kept for compatibility reason)
141+
* @retval None
142+
*/
143+
void STM32RTC::getPrediv(uint32_t *predivA, int16_t *dummy)
144+
{
145+
UNUSED(dummy);
146+
RTC_getPrediv(predivA);
147+
}
148+
#else
136149
/**
137150
* @brief get user (a)synchronous prescaler values if set else computed
138151
* ones for the current clock source.
@@ -146,7 +159,22 @@ void STM32RTC::getPrediv(int8_t *predivA, int16_t *predivS)
146159
RTC_getPrediv(predivA, predivS);
147160
}
148161
}
162+
#endif /* STM32F1xx */
149163

164+
#if defined(STM32F1xx)
165+
/**
166+
* @brief set user asynchronous prescalers value.
167+
* @note This method must be called before begin().
168+
* @param predivA: Asynchronous prescaler value. Reset value: RTC_AUTO_1_SECOND
169+
* @param dummy : not used (kept for compatibility reason)
170+
* @retval None
171+
*/
172+
void STM32RTC::setPrediv(uint32_t predivA, int16_t dummy)
173+
{
174+
UNUSED(dummy);
175+
RTC_setPrediv(predivA);
176+
}
177+
#else
150178
/**
151179
* @brief set user (a)synchronous prescalers value.
152180
* @note This method must be called before begin().
@@ -158,6 +186,7 @@ void STM32RTC::setPrediv(int8_t predivA, int16_t predivS)
158186
{
159187
RTC_setPrediv(predivA, predivS);
160188
}
189+
#endif /* STM32F1xx */
161190

162191
/**
163192
* @brief enable the RTC alarm.

src/STM32RTC.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,13 @@ class STM32RTC {
189189
void setY2kEpoch(uint32_t ts);
190190
void setAlarmEpoch(uint32_t ts, Alarm_Match match = MATCH_DHHMMSS, uint32_t subSeconds = 0);
191191

192+
#if defined(STM32F1xx)
193+
void getPrediv(uint32_t *predivA, int16_t *dummy = nullptr);
194+
void setPrediv(uint32_t predivA, int16_t dummy = 0);
195+
#else
192196
void getPrediv(int8_t *predivA, int16_t *predivS);
193197
void setPrediv(int8_t predivA, int16_t predivS);
194-
198+
#endif /* STM32F1xx */
195199
bool isConfigured(void)
196200
{
197201
return _configured;

0 commit comments

Comments
 (0)