From fa132bd78f2252de8e0d3c8757fb564ff5d809c2 Mon Sep 17 00:00:00 2001 From: NikhitaR-IFX Date: Mon, 31 Jul 2023 22:26:27 +0530 Subject: [PATCH] docs/psoc6: Adding documentation support for ADC and ADCBlock. Signed-off-by: NikhitaR-IFX --- docs/psoc6/feature_list.rst | 9 +++++++- docs/psoc6/quickref.rst | 46 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/docs/psoc6/feature_list.rst b/docs/psoc6/feature_list.rst index d43d048c9d41..133f4a3e0da4 100644 --- a/docs/psoc6/feature_list.rst +++ b/docs/psoc6/feature_list.rst @@ -42,6 +42,9 @@ Enabled modules * SoftSPI * PWM * Timer + * ADC + * ADCBlock + * micropython * ucryptolib * uctypes @@ -99,7 +102,7 @@ Table :ref:`configuration details ` below lists specifi | | | | | Constants not yet implemented : *WLAN_WAKE*, *PIN_WAKE*, *RTC_WAKE*, *IDLE*, *SLEEP*, *DEEPSLEEP*. | | | | -| | Submodules/classes not yet implemented: *ADC*, *bitstream*, *mem*, *Signal*, *SD*, *SDCard*, *SoftSPI*, *SPI*, | +| | Submodules/classes not yet implemented: *bitstream*, *mem*, *Signal*, *SD*, *SDCard*, *SoftSPI*, *SPI*, | | | *Timer*, *UART*, *WDT*. | +-----------------+----------------------------------------------------------------------------------------------------------------------+ | machine.Pin | Functions not yet implemented: *drive()*, *irq()*, *mode()*, *pull()*. | @@ -109,6 +112,10 @@ Table :ref:`configuration details ` below lists specifi +-----------------+----------------------------------------------------------------------------------------------------------------------+ | machine.I2C | Option ``MICROPY_PY_MACHINE_I2C`` enabled. | +-----------------+----------------------------------------------------------------------------------------------------------------------+ +| machine.ADC | Functions not implemented: *init()*. | ++-----------------+----------------------------------------------------------------------------------------------------------------------+ +| machine.ADCBlock| All functions enabled. | ++-----------------+----------------------------------------------------------------------------------------------------------------------+ | machine.RTC | Functions not yet implemented: *alarm()*, *alarm_left()*, *cancel()*, *irq()*. | | | | | | Constants not yet implemented: *ALARM0*. | diff --git a/docs/psoc6/quickref.rst b/docs/psoc6/quickref.rst index 3efdde24b95d..9cdef756d2f8 100644 --- a/docs/psoc6/quickref.rst +++ b/docs/psoc6/quickref.rst @@ -463,3 +463,49 @@ Use the :mod:`machine.Timer` class:: Here id=0 should be passed mandatorily. .. note:: Here mode=Timer.PERIODIC is not currently supported + +ADC (analog to digital conversion) +---------------------------------- + +On the PSoC6, a single ADC block with id - '0' is available. The ADC functionality is available on the +following pins : "P10_0" - "P10_5". + +Use the :ref:`machine.ADC ` class:: + + from machine import ADC, Pin + + adc = ADC(Pin("P10_0")) # create an ADC object on ADC pin + val = adc.read_u16() # read a raw analog value in the range 0-65535 + val = adc.read_uv() # read an analog value in micro volts + +The PSoC6 port also supports :ref:`machine.ADC ` API to have control over the ADC configuration. Currently +PSoC6 supports only 1 12-bit SAR ADC with the following channel to pin mapping and the defaults are set accordingly: + ++---------+-------+ +| Channel | Pin | ++=========+=======+ +| 0 | P10_0 | ++---------+-------+ +| 1 | P10_1 | ++---------+-------+ +| 2 | P10_2 | ++---------+-------+ +| 3 | P10_3 | ++---------+-------+ +| 4 | P10_4 | ++---------+-------+ +| 5 | P10_5 | ++---------+-------+ + +.. note:: + Arbitrary connection of ADC channels to GPIO is not supported. Specifying a pin that is not connected to this block, + or specifying a mismatched channel and pin, will raise an exception. + +To use the APIs: + + from machine import ADCBlock, Pin + + adcBlock = ADCBlock(0, bits=12) # create an ADCBlock 0 object + adc = adcBlock.connect(0, Pin("P10_0")) # connect channel 0 to pin P10_0 + val = adc.read_uv() # read an analog value in micro volts +