-
Notifications
You must be signed in to change notification settings - Fork 3k
[NUCLEO_F334R8] Fix issue with multiple ADC initialization #809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The variables should be definitely private and the check does not work as expected , anyway, my question is if we can make this runtime check. A pseudo code:
|
You are right the first code was not correct (it was just before end of year holidays...). I have changed it and it works ok. |
I meant, was an approach in some files already, recently also used here https://github.com/mbedmicro/mbed/pull/815/files - runtime check if it was already initialized |
Yes, this is what I've done. During initialization I check if the ADC has been already initialized. If yes then I exit. But instead of reading an HW register I use a local variable... |
Can you change that to use hw? |
Yes I can do it but as you know, STM strategy is to avoid as much as possible to use hw registers and use STM32Cube HAL function instead. I've found that the "HAL_ADC_GetState" function can be used to check if the ADC is initialized or not. Is it ok to use this function ? |
Looks good for that use, the definition of ADC State type:
|
I've just tried it but it doesn't work as I expected unfortunately. The returned state is for the AdcHandle variable and so I need to save this result for the two different ADCs and I need for this two local variables... This is even worse as before because with this method, I need to call a function instead of just reading a local variable... I've also tried to use two different handles (i.e. Adc1Handle and Adc2Handle) but here also there is two many code to add for managing this. For my understanding, what is the problem to use local variables (i.e. adcx_inited) ? This is not the first time I use this method and I have duplicated it a long time ago from Freescale or NXP targets. And it is still in use for example in us_ticker hal for those targets. |
I'll merge this as it is. Thanks for looking again at this. HAL should be stateless, this type of information can be retrieved from hw, thus no need to keep it in RAM. |
NUCLEO_F334R8 - Fix issue with multiple ADC initialization
No description provided.