@@ -77,6 +77,7 @@ static uint32_t prediv = RTC_AUTO_1_SECOND;
77
77
#endif /* !STM32F1xx */
78
78
79
79
static hourFormat_t initFormat = HOUR_FORMAT_12 ;
80
+ static rtcMode_t initMode = MODE_BINARY_NONE ;
80
81
81
82
/* Private function prototypes -----------------------------------------------*/
82
83
static void RTC_initClock (sourceClock_t source );
@@ -334,11 +335,12 @@ static void RTC_computePrediv(int8_t *asynch, int16_t *synch)
334
335
* RTC is set to the 1st January 2001
335
336
* Note: year 2000 is invalid as it is the hardware reset value and doesn't raise INITS flag
336
337
* @param format: enable the RTC in 12 or 24 hours mode
338
+ * @param mode: enable the RTC in BCD or Mix or Binary mode
337
339
* @param source: RTC clock source: LSE, LSI or HSE
338
340
* @param reset: force RTC reset, even if previously configured
339
341
* @retval True if RTC is reinitialized, else false
340
342
*/
341
- bool RTC_init (hourFormat_t format , sourceClock_t source , bool reset )
343
+ bool RTC_init (hourFormat_t format , rtcMode_t mode , sourceClock_t source , bool reset )
342
344
{
343
345
bool reinit = false;
344
346
hourAM_PM_t period = HOUR_AM , alarmPeriod = HOUR_AM ;
@@ -360,6 +362,7 @@ bool RTC_init(hourFormat_t format, sourceClock_t source, bool reset)
360
362
#endif
361
363
362
364
initFormat = format ;
365
+ initMode = mode ;
363
366
RtcHandle .Instance = RTC ;
364
367
365
368
/* Ensure backup domain is enabled before we init the RTC so we can use the backup registers for date retention on stm32f1xx boards */
@@ -390,7 +393,7 @@ bool RTC_init(hourFormat_t format, sourceClock_t source, bool reset)
390
393
#else
391
394
if (!LL_RTC_IsActiveFlag_INITS (RtcHandle .Instance ) || reset ) {
392
395
// RTC needs initialization
393
- RtcHandle .Init .HourFormat = format == HOUR_FORMAT_12 ? RTC_HOURFORMAT_12 : RTC_HOURFORMAT_24 ;
396
+ RtcHandle .Init .HourFormat = ( format == HOUR_FORMAT_12 ) ? RTC_HOURFORMAT_12 : RTC_HOURFORMAT_24 ;
394
397
RtcHandle .Init .OutPut = RTC_OUTPUT_DISABLE ;
395
398
RtcHandle .Init .OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH ;
396
399
RtcHandle .Init .OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN ;
@@ -401,8 +404,8 @@ bool RTC_init(hourFormat_t format, sourceClock_t source, bool reset)
401
404
RtcHandle .Init .OutPutRemap = RTC_OUTPUT_REMAP_NONE ;
402
405
#endif /* RTC_OUTPUT_REMAP_NONE */
403
406
#if defined(RTC_BINARY_NONE )
404
- RtcHandle .Init .BinMode = RTC_BINARY_NONE ;
405
- #endif
407
+ RtcHandle .Init .BinMode = ( mode == MODE_BINARY_MIX ) ? RTC_BINARY_MIX : (( mode == MODE_BINARY_ONLY ) ? RTC_BINARY_ONLY : RTC_BINARY_NONE ) ;
408
+ #endif /* RTC_BINARY_NONE */
406
409
RTC_getPrediv ((int8_t * ) & (RtcHandle .Init .AsynchPrediv ), (int16_t * ) & (RtcHandle .Init .SynchPrediv ));
407
410
#endif // STM32F1xx
408
411
// Init RTC clock
0 commit comments