Skip to content

Commit fb963fb

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 <[email protected]>
1 parent 3c286d2 commit fb963fb

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/STM32RTC.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,20 @@ void STM32RTC::setClockSource(Source_Clock source)
133133
}
134134
}
135135

136+
#if defined(STM32F1xx)
137+
/**
138+
* @brief get user (a)synchronous prescaler values if set else computed
139+
* ones for the current clock source.
140+
* @param predivA: pointer to the current Asynchronous prescaler value
141+
* @param dummy : not used (kept for compatibility reason)
142+
* @retval None
143+
*/
144+
void STM32RTC::getPrediv(uint32_t *predivA, int16_t *dummy)
145+
{
146+
UNUSED(dummy);
147+
RTC_getPrediv(predivA);
148+
}
149+
#else
136150
/**
137151
* @brief get user (a)synchronous prescaler values if set else computed
138152
* ones for the current clock source.
@@ -146,7 +160,22 @@ void STM32RTC::getPrediv(int8_t *predivA, int16_t *predivS)
146160
RTC_getPrediv(predivA, predivS);
147161
}
148162
}
163+
#endif /* STM32F1xx */
149164

165+
#if defined(STM32F1xx)
166+
/**
167+
* @brief set user (a)synchronous prescalers value.
168+
* @note This method must be called before begin().
169+
* @param predivA: Asynchronous prescaler value. Reset value: RTC_AUTO_1_SECOND
170+
* @param dummy : not used (kept for compatibility reason)
171+
* @retval None
172+
*/
173+
void STM32RTC::setPrediv(uint32_t predivA, int16_t dummy)
174+
{
175+
UNUSED(dummy);
176+
RTC_setPrediv(predivA);
177+
}
178+
#else
150179
/**
151180
* @brief set user (a)synchronous prescalers value.
152181
* @note This method must be called before begin().
@@ -158,6 +187,7 @@ void STM32RTC::setPrediv(int8_t predivA, int16_t predivS)
158187
{
159188
RTC_setPrediv(predivA, predivS);
160189
}
190+
#endif /* STM32F1xx */
161191

162192
/**
163193
* @brief enable the RTC alarm.

src/STM32RTC.h

+5-1
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)