-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
ADC STM32: Various fixes and enhancements #82955
ADC STM32: Various fixes and enhancements #82955
Conversation
79f099b
to
59f8450
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nice improvement. Few open comments, but otherwise LGTM
drivers/adc/adc_stm32.c
Outdated
if (LL_ADC_IsActiveFlag_OVR(adc)) { | ||
LL_ADC_ClearFlag_OVR(adc); | ||
LOG_ERR("ADC overrun error occurred. Reduce clock source frequency, " | ||
"increase prescaler value, or increase sampling times."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick:
"increase prescaler value, or increase sampling times."); | |
"increase prescaler value or increase sampling times."); | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Displays an error log message when an ADC overrun occurs. Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
STM32F3 and H7 have multiple ADC versions difficult to differentiate. Use clearer macros to make code more readable. Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
59f8450
to
a21a2af
Compare
On STM32 ADC, there are currently two types of oversamplers (if present), one with 8 available oversampling values, the other with 1024. To simplify the driver, add the oversampler as a dts property. Also add defines to avoid magic values in the dtsi. Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Add ADC oversampler type to all ADC of all series. Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Use the new oversampler property to simplify the management of the ADC oversampling. Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Remove specific cases for H7 and U5: group them together and only call a single function. ADC3 of H72x/H73x and ADC4 of U5 are different from other ADC of their series, and have dedicated functions in the LL for enabling DMA, but they're doing the exact same operation as LL_ADC_REG_SetDataTransferMode. Incidentally, this change allows H7A/H7B to use the DMA (it seems to have been missed before). Last, this change enables the DMA support for F1x ADC. Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
c29a8b7
to
b50eed6
Compare
Also applied string enum to st,adc-clock-source property that I missed earlier |
Adds an ADC DMA test for Nucleo F103RB board now that support for it is added in the ADC driver. Reading multiple channels in F1 is only possible with the DMA, hence the necessity to have a dedicated twister test for it. Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
STM32 sequencer property and clock source were defined using arbitrary numbers. Use string instead. Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
In all STM32 dtsi and board dts, update the st,adc-sequencer and the st,adc-clock-source properties so they are strings. Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com> fu dts: arm: st: use string instead of enum
…erty Now that st,adc-sequencer and st,adc_clock-source use a string, update the ADC driver. Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com> fu drv adc update driver with string
Now that clock source and sequencer are defined with strings in device tree, move the old defines directly in the driver Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Listify the content of the tables used for sequencer and oversampling. Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
config->base is already defined as ADC_TypeDef so no there is no need to cast it as such. Remove all occurrences throughout the file. Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
b50eed6
to
21eaef6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
Could it be that there is an entry in the release notes/migration guide missing? Because changing the type of the properties to string is somewhat a breaking change. I just stumbled upon this. No big deal, but might be noteworthy in the documentation. |
+1. @gautierg-st please follow up on adding this to the migration guide. |
Done here #85643 |
This PR contains various fixes and enhancements for the STM32 ADC driver:
Fixes #79909