Expose UART 1 (#1934)

* Expose UART 1 and update uart module documentation
This commit is contained in:
dnc40085 2017-04-24 13:06:54 -07:00 committed by Arnim Läuger
parent f5fac7a19e
commit 9dbae1c963
2 changed files with 11 additions and 4 deletions

View File

@ -11,7 +11,7 @@
// Number of resources (0 if not available/not implemented) // Number of resources (0 if not available/not implemented)
#define NUM_GPIO GPIO_PIN_NUM #define NUM_GPIO GPIO_PIN_NUM
#define NUM_SPI 2 #define NUM_SPI 2
#define NUM_UART 1 #define NUM_UART 2
#define NUM_PWM GPIO_PIN_NUM #define NUM_PWM GPIO_PIN_NUM
#define NUM_ADC 1 #define NUM_ADC 1
#define NUM_CAN 0 #define NUM_CAN 0

View File

@ -7,6 +7,10 @@ The [UART](https://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmi
The default setup for the uart is controlled by build-time settings. The default rate is 115,200 bps. In addition, auto-baudrate detection is enabled for the first two minutes The default setup for the uart is controlled by build-time settings. The default rate is 115,200 bps. In addition, auto-baudrate detection is enabled for the first two minutes
after platform boot. This will cause a switch to the correct baud rate once a few characters are received. Auto-baudrate detection is disabled when `uart.setup` is called. after platform boot. This will cause a switch to the correct baud rate once a few characters are received. Auto-baudrate detection is disabled when `uart.setup` is called.
!!! important
Although there are two UARTs(0 and 1) available to NodeMCU, **UART 1 is not capable of receiving data and is therefore transmit only**.
## uart.alt() ## uart.alt()
Change UART pin assignment. Change UART pin assignment.
@ -28,6 +32,9 @@ Sets the callback function to handle UART events.
Currently only the "data" event is supported. Currently only the "data" event is supported.
!!! note
Due to limitations of the ESP8266, only UART 0 is capable of receiving data.
#### Syntax #### Syntax
`uart.on(method, [number/end_char], [function], [run_input])` `uart.on(method, [number/end_char], [function], [run_input])`
@ -77,7 +84,7 @@ end, 0)
`uart.setup(id, baud, databits, parity, stopbits[, echo])` `uart.setup(id, baud, databits, parity, stopbits[, echo])`
#### Parameters #### Parameters
- `id` always zero, only one uart supported - `id` UART id (0 or 1).
- `baud` one of 300, 600, 1200, 2400, 4800, 9600, 19200, 31250, 38400, 57600, 74880, 115200, 230400, 256000, 460800, 921600, 1843200, 3686400 - `baud` one of 300, 600, 1200, 2400, 4800, 9600, 19200, 31250, 38400, 57600, 74880, 115200, 230400, 256000, 460800, 921600, 1843200, 3686400
- `databits` one of 5, 6, 7, 8 - `databits` one of 5, 6, 7, 8
- `parity` `uart.PARITY_NONE`, `uart.PARITY_ODD`, or `uart.PARITY_EVEN` - `parity` `uart.PARITY_NONE`, `uart.PARITY_ODD`, or `uart.PARITY_EVEN`
@ -101,7 +108,7 @@ Returns the current configuration parameters of the UART.
`uart.getconfig(id)` `uart.getconfig(id)`
#### Parameters #### Parameters
- `id` always zero, only one uart supported - `id` UART id (0 or 1).
#### Returns #### Returns
Four values as follows: Four values as follows:
@ -127,7 +134,7 @@ Write string or byte to the UART.
`uart.write(id, data1 [, data2, ...])` `uart.write(id, data1 [, data2, ...])`
#### Parameters #### Parameters
- `id` always 0, only one UART supported - `id` UART id (0 or 1).
- `data1`... string or byte to send via UART - `data1`... string or byte to send via UART
#### Returns #### Returns