@@ -66,6 +66,8 @@ static uint8_t HSEDiv = 0;
66
66
static uint8_t predivSync_bits = 0xFF ;
67
67
static int8_t predivAsync = -1 ;
68
68
static int16_t predivSync = -1 ;
69
+ #else
70
+ static uint32_t prediv = RTC_AUTO_1_SECOND ;
69
71
#endif /* !STM32F1xx */
70
72
71
73
static hourFormat_t initFormat = HOUR_FORMAT_12 ;
@@ -203,6 +205,20 @@ static void RTC_initClock(sourceClock_t source)
203
205
__HAL_RCC_RTC_ENABLE ();
204
206
}
205
207
208
+ #if defined(STM32F1xx )
209
+ /**
210
+ * @brief set user asynchronous prescaler value.
211
+ * @note use RTC_AUTO_1_SECOND to reset value
212
+ * @param asynch: asynchronous prescaler value in range 0 - PREDIVA_MAX
213
+ * @retval None
214
+ */
215
+ void RTC_setPrediv (uint32_t asynch )
216
+ {
217
+ /* set the prescaler for a stm32F1 (value is hold by one param) */
218
+ prediv = asynch ;
219
+ LL_RTC_SetAsynchPrescaler (RTC , asynch );
220
+ }
221
+ #else
206
222
/**
207
223
* @brief set user (a)synchronous prescaler values.
208
224
* @note use -1 to reset value and use computed ones
@@ -212,7 +228,6 @@ static void RTC_initClock(sourceClock_t source)
212
228
*/
213
229
void RTC_setPrediv (int8_t asynch , int16_t synch )
214
230
{
215
- #if !defined(STM32F1xx )
216
231
if ((asynch >= -1 ) && ((uint32_t )asynch <= PREDIVA_MAX ) && \
217
232
(synch >= -1 ) && ((uint32_t )synch <= PREDIVS_MAX )) {
218
233
predivAsync = asynch ;
@@ -221,12 +236,22 @@ void RTC_setPrediv(int8_t asynch, int16_t synch)
221
236
RTC_computePrediv (& predivAsync , & predivSync );
222
237
}
223
238
predivSync_bits = (uint8_t )_log2 (predivSync ) + 1 ;
224
- #else
225
- UNUSED (asynch );
226
- UNUSED (synch );
227
- #endif /* !STM32F1xx */
228
239
}
240
+ #endif /* STM32F1xx */
229
241
242
+ #if defined(STM32F1xx )
243
+ /**
244
+ * @brief get user asynchronous prescaler value for the current clock source.
245
+ * @param asynch: pointer where return asynchronous prescaler value.
246
+ * @retval None
247
+ */
248
+ void RTC_getPrediv (uint32_t * asynch )
249
+ {
250
+ /* get the prescaler for a stm32F1 (value is hold by one param) */
251
+ prediv = LL_RTC_GetDivider (RTC );
252
+ * asynch = prediv ;
253
+ }
254
+ #else
230
255
/**
231
256
* @brief get user (a)synchronous prescaler values if set else computed ones
232
257
* for the current clock source.
@@ -236,7 +261,6 @@ void RTC_setPrediv(int8_t asynch, int16_t synch)
236
261
*/
237
262
void RTC_getPrediv (int8_t * asynch , int16_t * synch )
238
263
{
239
- #if !defined(STM32F1xx )
240
264
if ((predivAsync == -1 ) || (predivSync == -1 )) {
241
265
RTC_computePrediv (& predivAsync , & predivSync );
242
266
}
@@ -245,11 +269,8 @@ void RTC_getPrediv(int8_t *asynch, int16_t *synch)
245
269
* synch = predivSync ;
246
270
}
247
271
predivSync_bits = (uint8_t )_log2 (predivSync ) + 1 ;
248
- #else
249
- UNUSED (asynch );
250
- UNUSED (synch );
251
- #endif /* !STM32F1xx */
252
272
}
273
+ #endif /* STM32F1xx */
253
274
254
275
#if !defined(STM32F1xx )
255
276
/**
0 commit comments