cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in STM32WBXX_HAL_RTC

LWChris
Associate III

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)

 

4 REPLIES 4
liaifat85
Senior III

I hope STM team will check this matter soon.

KDJEM.1
ST Employee

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.

KDJEM.1
ST Employee

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.

LWChris
Associate III

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.