Skip to content

Commit

Permalink
docs/library/machine.UART: Fix UART.irq docs to match current code.
Browse files Browse the repository at this point in the history
These docs now match the code in `extmod/machine_uart.c`.

Signed-off-by: Damien George <damien@micropython.org>
  • Loading branch information
dpgeorge authored and robert-hh committed Jun 27, 2024
1 parent 99fce16 commit ce55cc0
Showing 1 changed file with 34 additions and 28 deletions.
62 changes: 34 additions & 28 deletions docs/library/machine.UART.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,31 +152,6 @@ Methods
Send a break condition on the bus. This drives the bus low for a duration
longer than required for a normal transmission of a character.

.. method:: UART.irq(trigger, priority=1, handler=None, wake=machine.IDLE)

Create a callback to be triggered when data is received on the UART.

- *trigger* can only be ``UART.RX_ANY``
- *priority* level of the interrupt. Can take values in the range 1-7.
Higher values represent higher priorities.
- *handler* an optional function to be called when new characters arrive.
- *wake* can only be ``machine.IDLE``.

.. note::

The handler will be called whenever any of the following two conditions are met:

- 8 new characters have been received.
- At least 1 new character is waiting in the Rx buffer and the Rx line has been
silent for the duration of 1 complete frame.

This means that when the handler function is called there will be between 1 to 8
characters waiting.

Returns an irq object.

Availability: WiPy.

.. method:: UART.flush()

Waits until all data has been sent. In case of a timeout, an exception is raised. The timeout
Expand All @@ -203,11 +178,42 @@ Methods

Availability: rp2, esp32, esp8266, mimxrt, cc3200, stm32, nrf ports, renesas-ra

.. method:: UART.irq(handler=None, trigger=0, hard=False)

Configure an interrupt handler to be called when a UART event occurs.

The arguments are:

- *handler* is an optional function to be called when the interrupt event
triggers. The handler must take exactly one argument which is the
``UART`` instance.

- *trigger* configures the event which can generate an interrupt.
Possible values are:

- ``UART.IRQ_RXIDLE`` interrupt after receiving at least one character
and then the RX line goes idle.

- *hard* if true a hardware interrupt is used. This reduces the delay
between the pin change and the handler being called. Hard interrupt
handlers may not allocate memory; see :ref:`isr_rules`.

Returns an irq object.

Availability: renesas-ra, stm32.

Constants
---------

.. data:: UART.RX_ANY
.. data:: UART.RTS
UART.CTS

Flow control options.

Availability: esp32, mimxrt, renesas-ra, rp2, stm32.

.. data:: UART.IRQ_RXIDLE

IRQ trigger sources
IRQ trigger sources.

Availability: WiPy.
Availability: stm32.

0 comments on commit ce55cc0

Please sign in to comment.