zephyr/machine_adc: Add ADC support.

This commit adds support for ADC peripherals in the Zephyr port.

As is typical for Zephyr, the ADC channel setup is done in the devicetree
(typically using an overlay).  This code requires ADC channels to be listed
in the io-channels property of the zephyr,user root node.

Signed-off-by: Ned Konz <ned@metamagix.tech>
This commit is contained in:
Ned Konz
2025-09-30 12:52:25 -07:00
committed by Damien George
parent c9a16e862c
commit d42a301afd
4 changed files with 247 additions and 2 deletions

View File

@@ -119,6 +119,19 @@ Hardware SPI is accessed via the :ref:`machine.SPI <machine.SPI>` class::
spi.write_readinto(b'abcd', buf) # write to MOSI and read from MISO into the buffer
spi.write_readinto(buf, buf) # write buf to MOSI and read back into the buf
Analog to Digital Converter (ADC)
----------------------------------
Use the :ref:`machine.ADC <machine.ADC>` class.
Example of using ADC to read a pin's analog value (the ``zephyr,user`` node must contain
the ``io-channels`` property containing all the ADC channels)::
from machine import ADC
adc = ADC(("adc", 0))
adc.read_uv()
Disk Access
-----------