Skip to content
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

STM32N6: add ADC support #85587

Merged
merged 8 commits into from
Feb 14, 2025
Merged

Conversation

gautierg-st
Copy link
Contributor

Add ADC support for STM32N6. Enable ADC on STM32N6570-DK and Nucleo N657X0, and add ADC test overlays for these two boards.

@gautierg-st
Copy link
Contributor Author

Test result of tests/drivers/adc/adc_api (with DMA):

*** Booting Zephyr OS build v4.0.0-4952-gb5ca8de099b0 ***
Running TESTSUITE adc_basic
===================================================================
START - test_adc_asynchronous_call
Samples read: 0x0000071d 0x00000611 0x00000589 0x00000540 0x0000051c 0x80000000
 PASS - test_adc_asynchronous_call in 0.008 seconds
===================================================================
START - test_adc_invalid_request
E: Invalid resolution
E: Invalid resolution
Samples read: 0x00000715 0x80000000 0x80000000 0x80000000 0x80000000 0x80000000
 PASS - test_adc_invalid_request in 0.012 seconds
===================================================================
START - test_adc_repeated_samplings
repeated_samplings_callback: done 1
Samples read: 0x00000717 0x000005d0 0x80000000 0x80000000 0x80000000 0x80000000
repeated_samplings_callback: done 2
Samples read: 0x00000717 0x000005d0 0x00000711 0x000005d0 0x80000000 0x80000000
repeated_samplings_callback: done 3
Samples read: 0x00000717 0x000005d0 0x00000711 0x000005d0 0x80000000 0x80000000
repeated_samplings_callback: done 4
Samples read: 0x00000717 0x000005d0 0x0000070e 0x000005cf 0x80000000 0x80000000
repeated_samplings_callback: done 5
Samples read: 0x00000717 0x000005d0 0x00000711 0x000005ce 0x80000000 0x80000000
repeated_samplings_callback: done 6
Samples read: 0x00000717 0x000005d0 0x0000070e 0x000005ce 0x80000000 0x80000000
repeated_samplings_callback: done 7
Samples read: 0x00000717 0x000005d0 0x0000070f 0x000005ce 0x80000000 0x80000000
repeated_samplings_callback: done 8
Samples read: 0x00000717 0x000005d0 0x0000070f 0x000005cc 0x80000000 0x80000000
repeated_samplings_callback: done 9
Samples read: 0x00000717 0x000005d0 0x00000715 0x000005d0 0x80000000 0x80000000
repeated_samplings_callback: done 10
Samples read: 0x00000717 0x000005d0 0x00000717 0x000005d1 0x80000000 0x80000000
 PASS - test_adc_repeated_samplings in 0.104 seconds
===================================================================
START - test_adc_sample_one_channel
Samples read: 0x0000071d 0x80000000 0x80000000 0x80000000 0x80000000 0x80000000
 PASS - test_adc_sample_one_channel in 0.008 seconds
===================================================================
START - test_adc_sample_two_channels
Samples read: 0x0000071c 0x000005d1 0x80000000 0x80000000 0x80000000 0x80000000
 PASS - test_adc_sample_two_channels in 0.008 seconds
===================================================================
START - test_adc_sample_with_interval
sample_with_interval_callback: sampling 0
sample_with_interval_callback: sampling 1
sample_with_interval_callback: sampling 2
sample_with_interval_callback: sampling 3
sample_with_interval_callback: sampling 4
Samples read: 0x0000071a 0x00000717 0x0000071d 0x0000071e 0x00000717 0x80000000
 PASS - test_adc_sample_with_interval in 0.411 seconds
===================================================================
TESTSUITE adc_basic succeeded

------ TESTSUITE SUMMARY START ------

SUITE PASS - 100.00% [adc_basic]: pass = 6, fail = 0, skip = 0, total = 6 duration = 0.551 seconds
 - PASS - [adc_basic.test_adc_asynchronous_call] duration = 0.008 seconds
 - PASS - [adc_basic.test_adc_invalid_request] duration = 0.012 seconds
 - PASS - [adc_basic.test_adc_repeated_samplings] duration = 0.104 seconds
 - PASS - [adc_basic.test_adc_sample_one_channel] duration = 0.008 seconds
 - PASS - [adc_basic.test_adc_sample_two_channels] duration = 0.008 seconds
 - PASS - [adc_basic.test_adc_sample_with_interval] duration = 0.411 seconds

------ TESTSUITE SUMMARY END ------

===================================================================
PROJECT EXECUTION SUCCESSFUL

djiatsaf-st
djiatsaf-st previously approved these changes Feb 12, 2025
Copy link
Collaborator

@djiatsaf-st djiatsaf-st left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gautierg-st
Copy link
Contributor Author

Rebased to fix conflicts

djiatsaf-st
djiatsaf-st previously approved these changes Feb 13, 2025
marwaiehm-st
marwaiehm-st previously approved these changes Feb 13, 2025
STM32N6 ADC doesn't have an integrated prescaler, so these properties have
to be removed.
Though the F1 compatible also removes these two same properties, grouping
the N6 with the F1 would not be convenient since there are lots of
differences between the two.

Signed-off-by: Guillaume Gautier <[email protected]>
Add support for STM32N6 ADC in the STM32 ADC driver.

Signed-off-by: Guillaume Gautier <[email protected]>
Move code to enable the analog supply in a dedicated function.

Signed-off-by: Guillaume Gautier <[email protected]>
On STM32N6, the register holding the data is 32 bits and DMA must operate
in word transfer to work properly. So we change the type of the buffer in
which we store the ADC data from uint16_t to uint32_t for N6.

Signed-off-by: Guillaume Gautier <[email protected]>
Add ADC1 and ADC2 to STM32N6 device tree.

Signed-off-by: Guillaume Gautier <[email protected]>
Enable ADC for STM32N6570-DK and Nucleo N657X0 boards.

Signed-off-by: Guillaume Gautier <[email protected]>
STM32N6 needs to have a buffer of 32-bit data instead of 16-bit.
Adds a Kconfig to select whether the test shall use a 32-bit buffer.

Signed-off-by: Guillaume Gautier <[email protected]>
Add dts and conf overlay for nucleo_n657x0 and stm32n6570_dk boards.

Signed-off-by: Guillaume Gautier <[email protected]>
@gautierg-st
Copy link
Contributor Author

Rebase round 2

@kartben kartben merged commit 5155cb6 into zephyrproject-rtos:main Feb 14, 2025
22 checks passed
@gautierg-st gautierg-st deleted the n6_add_adc branch February 14, 2025 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ADC Analog-to-Digital Converter (ADC) platform: STM32 ST Micro STM32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants