Skip to content

psoc-edge: Add ADC support - #197

Merged
AkshayChandra-IFX merged 34 commits into
psoc-edge-mainfrom
machine_adc
Aug 5, 2026
Merged

psoc-edge: Add ADC support#197
AkshayChandra-IFX merged 34 commits into
psoc-edge-mainfrom
machine_adc

Conversation

@AkshayChandra-IFX

Copy link
Copy Markdown

Summary

Adds machine.ADC and machine.ADCBlock support for the PSoC Edge port. The implementation uses the PSoC Edge SAR ADC peripheral via the cy_autanalog / cy_autanalog_sar HAL drivers. BSP peripheral config, pin alternate-function CSV, and modmachine are updated accordingly. Documentation and tests are included.

Testing

Tested on KIT_PSE84_AI. A voltage divider is used as the hardware input to drive the ADC pin, enabling the test script to exercise full ADC functionality: pin read, ADCBlock channel init/deinit, read_u16(), read_uv(), and voltage conversion. All [adc.py] cases pass.

Trade-offs and Alternatives

None significant

Generative AI

I used generative AI tools when creating this PR, but a human has checked the
code and is responsible for the code and the description above.

@IFX-Anusha IFX-Anusha left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice ! some minor things to check before merge

Comment thread ports/psoc-edge/machine_adc.c
Comment thread ports/psoc-edge/machine_adc.c
Comment thread ports/psoc-edge/machine_adc.c Outdated
Comment thread docs/psoc-edge/quickref.rst Outdated
Comment thread ports/psoc-edge/modmachine.c
Comment thread ports/psoc-edge/modmachine.h
Comment thread ports/psoc-edge/boards/KIT_PSE84_AI/bsp-cfg/cycfg_peripherals.c Outdated
AkshayChandra-IFX and others added 17 commits August 4, 2026 16:27
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: jaenrig-ifx <enriquezgarcia.external@infineon.com>
Signed-off-by: jaenrig-ifx <enriquezgarcia.external@infineon.com>
Signed-off-by: jaenrig-ifx <enriquezgarcia.external@infineon.com>
Apply reviewed ADC fixes and cleanup.

- Use mapped sar_block in ADC setup and read flow.
- Reload SAR config only on channel config changes.
- Compute read_uv from raw 12-bit data using BSP VDDA.
- Fix read_uv overflow with 64-bit intermediate arithmetic.
- Remove unused ADC block capability macro generation.
- Include genhdr/pins_af.h explicitly and drop broad genhdr include path.
- Fix ruff formatting in make-pins.py.

Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
AkshayChandra-IFX and others added 15 commits August 4, 2026 16:27
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: jaenrig-ifx <enriquezgarcia.external@infineon.com>
Signed-off-by: jaenrig-ifx <enriquezgarcia.external@infineon.com>
Signed-off-by: jaenrig-ifx <enriquezgarcia.external@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com>
@AkshayChandra-IFX
AkshayChandra-IFX requested review from jaenrig-ifx and removed request for jaenrig-ifx August 4, 2026 11:36

@jaenrig-ifx jaenrig-ifx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let´s go! 🤖

@AkshayChandra-IFX
AkshayChandra-IFX merged commit 9921c1a into psoc-edge-main Aug 5, 2026
28 checks passed
@AkshayChandra-IFX
AkshayChandra-IFX deleted the machine_adc branch August 5, 2026 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants