Skip to content

Commit

Permalink
docs/psoc6: Adding documentation support for ADC and ADCBlock.
Browse files Browse the repository at this point in the history
Signed-off-by: NikhitaR-IFX <Nikhita.Rajasekhar@infineon.com>
  • Loading branch information
NikhitaR-IFX committed Jul 31, 2023
1 parent d2ae382 commit fa132bd
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docs/psoc6/feature_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ Enabled modules
* SoftSPI
* PWM
* Timer
* ADC
* ADCBlock

* micropython
* ucryptolib
* uctypes
Expand Down Expand Up @@ -99,7 +102,7 @@ Table :ref:`configuration details <table_mpy_configuration>` 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()*. |
Expand All @@ -109,6 +112,10 @@ Table :ref:`configuration details <table_mpy_configuration>` 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*. |
Expand Down
46 changes: 46 additions & 0 deletions docs/psoc6/quickref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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 <machine.ADCBlock>` 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

0 comments on commit fa132bd

Please sign in to comment.