1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00
This commit is contained in:
Develo 2020-08-12 18:24:00 -04:00 committed by GitHub
parent 683b8e606c
commit 39524baeb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -151,12 +151,25 @@ milliseconds is not recommended.
Serial Serial
------ ------
``Serial`` object works much the same way as on a regular Arduino. Apart The ``Serial`` object works much the same way as on a regular Arduino. Apart
from hardware FIFO (128 bytes for TX and RX) ``Serial`` has from the hardware FIFO (128 bytes for TX and RX), ``Serial`` has an
additional 256-byte TX and RX buffers. Both transmit and receive is additional customizable 256-byte RX buffer. The size of this software buffer can
interrupt-driven. Write and read functions only block the sketch be changed by the user. It is suggested to use a bigger size at higher receive speeds.
execution when the respective FIFO/buffers are full/empty. Note that
the length of additional 256-bit buffer can be customized. The ``::setRxBufferSize(size_t size`` method changes the RX buffer size as needed. This
should be called before ``::begin()``. The size argument should be at least large enough
to hold all data received before reading.
For transmit-only operation, the buffer can be switched off by passing mode SERIAL_TX_ONLY
to Serial.begin(). Other modes are SERIAL_RX_ONLY and SERIAL_FULL (the default).
Receive is interrupt-driven, but transmit polls and busy-waits. Both are
blocking:
The ``::write()`` call blocks if the TX FIFO is full and waits until there is room
in the FIFO before writing more bytes into it.
The ``::read()`` call does not block if there are no bytes available for reading.
The ``::readBytes()`` call blocks until the number of bytes read complies with the
number of bytes required by the argument passed in.
``Serial`` uses UART0, which is mapped to pins GPIO1 (TX) and GPIO3 ``Serial`` uses UART0, which is mapped to pins GPIO1 (TX) and GPIO3
(RX). Serial may be remapped to GPIO15 (TX) and GPIO13 (RX) by calling (RX). Serial may be remapped to GPIO15 (TX) and GPIO13 (RX) by calling
@ -180,13 +193,12 @@ instead, call ``Serial1.setDebugOutput(true)``.
You also need to use ``Serial.setDebugOutput(true)`` to enable output You also need to use ``Serial.setDebugOutput(true)`` to enable output
from ``printf()`` function. from ``printf()`` function.
The method ``Serial.setRxBufferSize(size_t size)`` allows to define the
receiving buffer depth. The default value is 256.
Both ``Serial`` and ``Serial1`` objects support 5, 6, 7, 8 data bits, Both ``Serial`` and ``Serial1`` objects support 5, 6, 7, 8 data bits,
odd (O), even (E), and no (N) parity, and 1 or 2 stop bits. To set the odd (O), even (E), and no (N) parity, and 1 or 2 stop bits. To set the
desired mode, call ``Serial.begin(baudrate, SERIAL_8N1)``, desired mode, call ``Serial.begin(baudrate, SERIAL_8N1)``,
``Serial.begin(baudrate, SERIAL_6E2)``, etc. ``Serial.begin(baudrate, SERIAL_6E2)``, etc.
Default configuration mode is SERIAL_8N1. Possibilities are SERIAL_[5678][NEO][12].
Example: ``SERIAL_8N1`` means 8bits No parity 1 stop bit.
A new method has been implemented on both ``Serial`` and ``Serial1`` to A new method has been implemented on both ``Serial`` and ``Serial1`` to
get current baud rate setting. To get the current baud rate, call get current baud rate setting. To get the current baud rate, call
@ -206,7 +218,7 @@ current speed. For example
| ``Serial`` and ``Serial1`` objects are both instances of the | ``Serial`` and ``Serial1`` objects are both instances of the
``HardwareSerial`` class. ``HardwareSerial`` class.
| I've done this also for official ESP8266 `Software | This is also done for official ESP8266 `Software
Serial <libraries.rst#softwareserial>`__ Serial <libraries.rst#softwareserial>`__
library, see this `pull library, see this `pull
request <https://github.com/plerup/espsoftwareserial/pull/22>`__. request <https://github.com/plerup/espsoftwareserial/pull/22>`__.