Skip to content

Commit e5285ce

Browse files
kwagyemanclaude
andcommitted
docs: machine/network/omv/rp2 library reference audit
- machine: per-port availability sections + grouped methods/constants across ADC, CAN, Counter, Encoder, I2C, I2CTarget, I2S, LED, PWM, Pin, RTC, SDCard, SPI, Timer, UART, WDT. - network: WINC1500/CYW43/NINA driver split, LAN/WLAN/WINC audit, network.rst index cleanup. - omv.image: expanded module intro, restructured functions/constants into themed subsections; converted Blob/Line/Circle/Rect/QRCode/ AprilTag/DataMatrix/BarCode/Displacement/kptmatch/Similarity/ Statistics/Percentile/Threshold from .. method:: x() to .. attribute:: x to match the attrtuple-backed runtime API; expanded Image class intro and ImageIO methods/constants; fixed get_enclosed_ellipse return type (plain tuple, degrees). - omv.csi / omv.sensor: ioctl docs regrouped per sensor family. - rp2: unhidden Flash / PIO / StateMachine docs and scrubbed for hygiene on RP2040. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent e596bf0 commit e5285ce

47 files changed

Lines changed: 3984 additions & 2411 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/conf.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,23 +349,20 @@ def _render_landing_code(src):
349349
"library/esp.rst",
350350
"library/espnow.rst",
351351
"library/esp32.rst",
352-
"library/rp2.rst",
353-
"library/rp2.DMA.rst",
354-
"library/rp2.Flash.rst",
355-
"library/rp2.PIO.rst",
356-
"library/rp2.StateMachine.rst",
357352
"library/wm8960.rst",
358353
"library/zephyr.rst",
359354
"library/zephyr.DiskAccess.rst",
360355
"library/zephyr.FlashArea.rst",
361356
"library/zephyr.zsensor.rst",
362357
"library/lcd160cr.rst",
358+
"library/machine.ADCBlock.rst",
363359
"library/machine.ADCWiPy.rst",
364360
"library/machine.DAC.rst",
365361
"library/machine.SD.rst",
366362
"library/machine.TimerWiPy.rst",
367363
"library/machine.USBDevice.rst",
368364
"library/network.CC3K.rst",
365+
"library/network.PPP.rst",
369366
"library/network.WIZNET5K.rst",
370367
"library/network.WLANWiPy.rst",
371368
"library/pyb.Accel.rst",

docs/library/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ for which boards include each one.
168168
stm.rst
169169
mimxrt.rst
170170
omv.alif.rst
171+
rp2.rst
171172
ubluepy.rst
172173

173174
Hardware drivers
@@ -369,6 +370,7 @@ RP2040-based Nano-form-factor board with the U-blox NINA-W102
369370
Wi-Fi/Bluetooth module. *No longer actively supported; the last OpenMV
370371
firmware release for this board is retained for archival use.*
371372

373+
* :mod:`rp2` --- RP2040-specific PIO / DMA / flash helpers
372374
* :mod:`espflash` --- ESP32 ROM bootloader firmware flasher
373375
* :mod:`lsm6dsox` --- LSM6DSOX 6-axis IMU
374376
* :mod:`dht` --- DHT11 and DHT22 temperature/humidity sensors

docs/library/machine.ADC.rst

Lines changed: 56 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,81 @@
44
class ADC -- analog to digital conversion
55
=========================================
66

7-
The ADC class provides an interface to analog-to-digital converters, and
8-
represents a single endpoint that can sample a continuous voltage and
9-
convert it to a discretised value.
10-
11-
For extra control over ADC sampling see :ref:`machine.ADCBlock <machine.ADCBlock>`.
7+
The :class:`ADC` class wraps a single analog-to-digital converter
8+
channel that samples a voltage on a pin (or one of the on-chip
9+
analog channels) and returns its discretised value.
1210

1311
Example usage::
1412

15-
from machine import ADC
13+
from machine import ADC, Pin
1614

17-
adc = ADC(pin) # create an ADC object acting on a pin
18-
val = adc.read_u16() # read a raw analog value in the range 0-65535
19-
val = adc.read_uv() # read an analog value in microvolts
15+
adc = ADC(Pin("P6")) # ADC channel on header pin P6 (PA5)
16+
val = adc.read_u16() # raw reading scaled to 0..65535
2017

2118
Constructors
2219
------------
2320

24-
.. class:: ADC(id: int | Pin, *, sample_ns: int | None = None, atten: int | None = None)
25-
26-
Access the ADC associated with a source identified by *id*. This
27-
*id* may be an integer (usually specifying a channel number), a
28-
:ref:`Pin <machine.Pin>` object, or other value supported by the
29-
underlying machine.
21+
.. class:: ADC(id: int | str | Pin) -> ADC
3022

31-
If additional keyword-arguments are given then they will configure
32-
various aspects of the ADC. If not given, these settings will take
33-
previous or default values. The settings are:
23+
Construct an :class:`ADC` object for the analog source identified
24+
by ``id``. The accepted forms are:
3425

35-
- *sample_ns* is the sampling time in nanoseconds.
36-
37-
- *atten* specifies the input attenuation.
26+
* an integer channel number (``0`` -- ``18`` on STM32, port-
27+
specific elsewhere);
28+
* a :class:`Pin` object, or a board pin string such as
29+
``"P6"`` -- the pin must be analog-capable;
30+
* one of the internal-channel constants (:data:`CORE_TEMP`,
31+
:data:`CORE_VREF`, :data:`CORE_VBAT`, :data:`VREF` or
32+
:data:`CORE_VDD`) to read the MCU's internal sensors.
33+
STM32 only.
3834

3935
Methods
4036
-------
4137

42-
.. method:: init(*, sample_ns: int | None = None, atten: int | None = None) -> None
38+
.. method:: read_u16() -> int
4339

44-
Apply the given settings to the ADC. Only those arguments that are
45-
specified will be changed. See the ADC constructor above for what the
46-
arguments are.
40+
Sample the analog channel once and return the result as an
41+
unsigned 16-bit integer (``0`` -- ``65535``). Lower-resolution
42+
ADCs are left-aligned into the 16-bit range so the
43+
port-specific raw resolution is hidden.
4744

48-
.. method:: block() -> ADCBlock
45+
.. method:: read_uv() -> int
4946

50-
Return the :ref:`ADCBlock <machine.ADCBlock>` instance associated with
51-
this ADC object.
47+
Sample the analog channel and return the result in microvolts.
48+
The reading is calibrated against the internal reference where
49+
hardware supports it. mimxrt port only.
5250

53-
This method only exists if the port supports the
54-
:ref:`ADCBlock <machine.ADCBlock>` class.
51+
Constants
52+
---------
5553

56-
.. method:: read_u16() -> int
54+
The constants below are only available on the STM32 port; pass
55+
them as the ``id`` argument to construct an :class:`ADC` that
56+
reads one of the on-chip analog sensors. The result of
57+
:meth:`read_u16` is the channel's raw 16-bit reading; for
58+
calibrated values use the helpers on :class:`pyb.ADCAll`.
5759

58-
Take an analog reading and return an integer in the range 0-65535.
59-
The return value represents the raw reading taken by the ADC, scaled
60-
such that the minimum value is 0 and the maximum value is 65535.
60+
.. data:: VREF
61+
:type: int
6162

62-
.. method:: read_uv() -> int
63+
External voltage-reference channel.
64+
65+
.. data:: CORE_VREF
66+
:type: int
67+
68+
Internal 1.21 V (nominal) voltage-reference channel
69+
(``VREFINT``).
70+
71+
.. data:: CORE_TEMP
72+
:type: int
73+
74+
Internal die-temperature sensor channel.
75+
76+
.. data:: CORE_VBAT
77+
:type: int
78+
79+
Backup-battery voltage channel (``VBAT``).
80+
81+
.. data:: CORE_VDD
82+
:type: int
6383

64-
Take an analog reading and return an integer value with units of
65-
microvolts. It is up to the particular port whether or not this value
66-
is calibrated, and how calibration is done.
84+
MCU supply-rail channel (``VDDA``).

docs/library/machine.CAN.rst

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ between one or more nodes connected to a common bus. CAN 2.0 was standardised in
99
ISO-11898, and is now also known as CAN Classic.
1010

1111
There is also a newer, backwards compatible, protocol named CAN FD (CAN with
12-
Flexible Data-Rate). *The machine.CAN driver does not currently support CAN FD
13-
features, use `pyb.CAN` on stm32 if you need CAN FD*.
12+
Flexible Data-Rate). The :class:`machine.CAN` driver does not currently
13+
support CAN FD features; use :class:`pyb.CAN` on STM32 if you need
14+
CAN FD.
1415

1516
CAN support requires a controller (often an internal microcontroller
1617
peripheral), and an external transceiver to level-shift the signals onto the CAN
1718
bus.
1819

20+
Available on STM32 OpenMV cams (M4 / M7 / H7 / H7 Plus / Pure Thermal /
21+
N6, plus the Arduino-branded variants that wire a transceiver). Not
22+
yet supported on the OpenMV Cam RT1062 (mimxrt port) or the OpenMV
23+
Cam AE3 (alif port).
24+
1925
The ``machine.CAN`` interface is a *low level basic* CAN messaging interface
2026
that abstracts a CAN controller as an outgoing priority queue for sending
2127
messages, an incoming queue for receiving messages, and mechanisms for reporting
@@ -573,18 +579,54 @@ Constructor
573579
^^^^^^^^^^
574580

575581
.. data:: IRQ_RX
576-
IRQ_TX
577-
IRQ_STATE
578582
:type: int
579583

580-
IRQ event triggers. Used with :func:`CAN.irq()` and `machine_can_irq_flags`.
584+
Pass to the ``trigger`` argument of :meth:`irq` to fire the
585+
handler each time the CAN controller has received a complete
586+
message into the RX FIFO. Inside the handler, read the
587+
message with :meth:`recv`.
588+
589+
.. data:: IRQ_TX
590+
:type: int
591+
592+
Pass to the ``trigger`` argument of :meth:`irq` to fire the
593+
handler each time the CAN controller finishes a transmit
594+
attempt (success or failure). Inside the handler, use the
595+
additional bits below to recover which mailbox completed and
596+
whether it failed -- see :ref:`machine_can_irq_flags`.
597+
598+
.. data:: IRQ_STATE
599+
:type: int
600+
601+
Pass to the ``trigger`` argument of :meth:`irq` to fire the
602+
handler each time the controller transitions between the
603+
``STATE_*`` values (active / warning / passive / bus-off).
604+
Use :meth:`state` inside the handler to read the new state.
581605

582606
.. data:: IRQ_TX_FAILED
583-
IRQ_TX_IDX_SHIFT
584-
IRQ_TX_IDX_MASK
585607
:type: int
586608

587-
Additional IRQ event flags for `CAN.IRQ_TX`. See `machine_can_irq_flags`.
609+
Status flag that may be set in ``irq().flags()`` when an
610+
:data:`IRQ_TX` event fires. Indicates the transmit attempt
611+
failed (typically because :meth:`cancel_send` was called, or
612+
the controller entered an error state).
613+
614+
.. data:: IRQ_TX_IDX_SHIFT
615+
:type: int
616+
617+
Bit position of the transmit-mailbox-index field within the
618+
``irq().flags()`` value during an :data:`IRQ_TX` event. The
619+
mailbox index is extracted as
620+
``(flags >> IRQ_TX_IDX_SHIFT) & IRQ_TX_IDX_MASK``.
621+
622+
.. data:: IRQ_TX_IDX_MASK
623+
:type: int
624+
625+
Bit mask of the transmit-mailbox-index field within the
626+
``irq().flags()`` value during an :data:`IRQ_TX` event. The
627+
extracted index matches the integer returned by the
628+
corresponding :meth:`send` call (an int in the range ``0`` to
629+
:data:`TX_QUEUE_LEN`).
588630

589631
.. _machine_can_irq_flags:
590632

@@ -606,8 +648,8 @@ information about the TX event:
606648
* ``CAN.IRQ_TX_FAILED`` bit is set if the transmit failed. Usually this will
607649
only happen if :func:`CAN.cancel_send()` was called, although it may also
608650
happen if the controller enters an error state.
609-
* ``CAN.IRQ_TX_MASK << CAN.IRQ_TX_SHIFT`` is a bitmasked region of the flags
610-
value that holds the index of the transmit buffer which generated the event.
651+
* ``CAN.IRQ_TX_IDX_MASK << CAN.IRQ_TX_IDX_SHIFT`` is a bitmasked region of the
652+
flags value that holds the index of the transmit buffer which generated the event.
611653
This will be an integer in the range ``0`` to `CAN.TX_QUEUE_LEN` (exclusive),
612654
and will match the result of a previous call to `CAN.send()`.
613655

0 commit comments

Comments
 (0)