@@ -1716,34 +1716,37 @@ Information about the ESP32 UART interface can be found in the IDF SDK [UART Doc
1716
1716
1717
1717
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.
1718
1718
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:
1720
1720
1721
1721
```erlang
1722
1722
"UART0" | "UART1" | "UART2"
1723
1723
```
1724
1724
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
-
1733
1725
The second parameter is a properties list, containing the following elements:
1734
1726
1735
1727
| Key | Value Type | Required | Default Value | Description |
1736
1728
|-----|------------|----------|---------------|-------------|
1729
+ | `rx` | `integer()` | no | -1 (`UART_PIN_NO_CHANGE`) | RX GPIO Pin |
1730
+ | `tx` | `integer()` | no | -1 (`UART_PIN_NO_CHANGE`) | TX GPIO Pin |
1737
1731
| `speed` | `integer()` | no | 115200 | UART baud rate (bits/sec) |
1738
1732
| `data_bits` | `5 \| 6 \| 7 \| 8` | no | 8 | UART data bits |
1739
1733
| `stop_bits` | `1 \| 2` | no | 1 | UART stop bits |
1740
1734
| `flow_control` | `hardware \| software \| none` | no | `none` | Flow control |
1741
1735
| `parity` | `even \| odd \| none` | no | `none` | UART parity check |
1742
1736
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
+
1743
1746
For example,
1744
1747
1745
1748
```erlang
1746
- UART = uart:open("UART0", [{speed , 9600 }])
1749
+ UART = uart:open("UART0", [{rx , 3 }, { tx , 1 }, { speed , 9600 }])
1747
1750
```
1748
1751
1749
1752
Once the port is opened , you can use the returned `UART ` instance to read and write bytes to the attached device .
0 commit comments