mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 20:50:14 +01:00
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:
@@ -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
|
||||
-----------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user