2023-11-15 05:05 AM
As of version 1.12.0, HAL_RTC_Init uses a macro named __HAL_RTC_IS_CALENDAR_INITIALIZED. It is defined as follows:
#define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__) ((((RTC->ISR) & (RTC_ISR_INITS)) == RTC_ISR_INITS) ? 1U : 0U)
I suppose it should rather be
#define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__) (((((__HANDLE__)->Instance->ISR) & (RTC_ISR_INITS)) == RTC_ISR_INITS) ? 1U : 0U)
2023-11-15 05:43 AM
I hope STM team will check this matter soon.
2023-11-16 07:02 AM - edited 2023-11-16 07:03 AM
Hello @LWChris ,
I reported this issue internally for review .
Internal ticket number: 166508 (This is an internal tracking number and is not accessible or usable by customers).
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-11-20 05:12 AM
Hi @LWChris ,
Both implementations are correct. No functional issue with these two implementations.
Could you please give more details, if you found any issue when you used __HAL_RTC_IS_CALENDAR_INITIALIZED.
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-11-29 09:47 AM
Hi @KDJEM.1
I had no issues with the current implementation, but that is because hrtc->Instance is set to RTC. And I would assume this is probably the case for 99.9% of all projects. But if it wasn't, it would not have worked as intended.
Since literally every other macro in HAL_RTC_Init actually uses the provided handle instead of assuming that __HANDLE__ is referring to RTC, and since the __HAL_RTC_IS_CALENDAR_INITIALIZED macro was only recently introduced in Cube V1.12.0, I found it to be likely a mistake that so far hadn't caused any problems because the default would always be the same.
But in any way it doesn't look right for a macro to have a handle parameter that is subsequently ignored.