Skip to content

Commit 0d5437f

Browse files
committed
Merge pull request #1357 from petermm/uart-doc-fix
Update UART programmers guide Previously failed to mention RX/TX options, and suggested they would default according to the schema, which they dont. Fixes #1356 These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents 4c45ca7 + 9d0d748 commit 0d5437f

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

doc/src/programmers-guide.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,34 +1716,37 @@ Information about the ESP32 UART interface can be found in the IDF SDK [UART Doc
17161716

17171717
The AtomVM UART implementation uses the AtomVM Port mechanism and must be initialized using the [`uart:open/2`](./apidocs/erlang/eavmlib/uart.md#open2) function.
17181718

1719-
The first parameter indicates the ESP32 UART hardware interface. Legal values are:
1719+
The first parameter indicates the ESP32 UART hardware interface. Valid values are:
17201720

17211721
```erlang
17221722
"UART0" | "UART1" | "UART2"
17231723
```
17241724

1725-
The selection of the hardware interface dictates the default RX and TX pins on the ESP32:
1726-
1727-
| Port | RX pin | TX pin |
1728-
|-------------|--------|-------|
1729-
| `UART0` | GPIO_3 | GPIO_1 |
1730-
| `UART1` | GPIO_9 | GPIO_10 |
1731-
| `UART2` | GPIO_16 | GPIO_17 |
1732-
17331725
The second parameter is a properties list, containing the following elements:
17341726

17351727
| Key | Value Type | Required | Default Value | Description |
17361728
|-----|------------|----------|---------------|-------------|
1729+
| `rx` | `integer()` | no | -1 (`UART_PIN_NO_CHANGE`) | RX GPIO Pin |
1730+
| `tx` | `integer()` | no | -1 (`UART_PIN_NO_CHANGE`) | TX GPIO Pin |
17371731
| `speed` | `integer()` | no | 115200 | UART baud rate (bits/sec) |
17381732
| `data_bits` | `5 \| 6 \| 7 \| 8` | no | 8 | UART data bits |
17391733
| `stop_bits` | `1 \| 2` | no | 1 | UART stop bits |
17401734
| `flow_control` | `hardware \| software \| none` | no | `none` | Flow control |
17411735
| `parity` | `even \| odd \| none` | no | `none` | UART parity check |
17421736

1737+
1738+
These are the usual RX and TX pins for the various UARTs on the ESP32 (as always check your board specs):
1739+
1740+
| Port | RX pin | TX pin |
1741+
|-------------|--------|-------|
1742+
| `UART0` | GPIO_3 | GPIO_1 |
1743+
| `UART1` | GPIO_9 | GPIO_10 |
1744+
| `UART2` | GPIO_16 | GPIO_17 |
1745+
17431746
For example,
17441747

17451748
```erlang
1746-
UART = uart:open("UART0", [{speed, 9600}])
1749+
UART = uart:open("UART0", [{rx, 3}, {tx, 1}, {speed, 9600}])
17471750
```
17481751

17491752
Once the port is opened, you can use the returned `UART` instance to read and write bytes to the attached device.

0 commit comments

Comments
 (0)