Serial port on one RP2040 UART; sketches use Serial1 and Serial2.
More...
#include <SerialUART.h>
|
| | SerialUARTClass (uart_inst_t *uart, pin_size_t tx_pin, pin_size_t rx_pin) |
| | Binds the port to a UART and its pins; nothing is set up until begin().
|
| void | begin (unsigned long baud) override |
| | Starts the port with 8 data bits, no parity and 1 stop bit.
|
| void | begin (unsigned long baud, uint16_t config) override |
| | Starts the port with the given frame format.
|
| void | end () override |
| | Waits for queued bytes to go out, then stops the port and frees its pins.
|
| int | available () override |
| | Number of received bytes waiting to be read.
|
| int | peek () override |
| | Next received byte, left in the buffer.
|
| int | read () override |
| | Takes the next received byte from the buffer.
|
|
void | flush () override |
| | Waits until every queued byte has been sent.
|
| size_t | write (uint8_t c) override |
| | Sends one byte, waiting while the hardware FIFO is full.
|
| | operator bool () override |
| | Whether the port is running.
|
Serial port on one RP2040 UART; sketches use Serial1 and Serial2.
Received bytes go into a 256-byte buffer from an interrupt; bytes that arrive while it is full are dropped.
◆ SerialUARTClass()
Binds the port to a UART and its pins; nothing is set up until begin().
- Parameters
-
| uart | pico-sdk UART (uart0 or uart1). |
| tx_pin | Arduino pin for TX. |
| rx_pin | Arduino pin for RX. |
◆ available()
| int SerialUARTClass::available |
( |
| ) |
|
|
override |
Number of received bytes waiting to be read.
- Returns
- 0-256.
◆ begin() [1/2]
| void SerialUARTClass::begin |
( |
unsigned long | baud | ) |
|
|
inlineoverride |
Starts the port with 8 data bits, no parity and 1 stop bit.
- Parameters
-
| baud | Baud rate, e.g. 115200. |
◆ begin() [2/2]
| void SerialUARTClass::begin |
( |
unsigned long | baud, |
|
|
uint16_t | config ) |
|
override |
Starts the port with the given frame format.
- Parameters
-
| baud | Baud rate, e.g. 115200. |
| config | Frame format, e.g. SERIAL_8N1 or SERIAL_7E2. Mark and space parity are not supported and give no parity. |
◆ end()
| void SerialUARTClass::end |
( |
| ) |
|
|
override |
Waits for queued bytes to go out, then stops the port and frees its pins.
Unread received bytes are discarded.
◆ operator bool()
| SerialUARTClass::operator bool |
( |
| ) |
|
|
inlineoverride |
Whether the port is running.
- Returns
- true between begin() and end().
◆ peek()
| int SerialUARTClass::peek |
( |
| ) |
|
|
override |
Next received byte, left in the buffer.
- Returns
- 0-255, or -1 if nothing has been received.
◆ read()
| int SerialUARTClass::read |
( |
| ) |
|
|
override |
Takes the next received byte from the buffer.
- Returns
- 0-255, or -1 if nothing has been received.
◆ write()
| size_t SerialUARTClass::write |
( |
uint8_t | c | ) |
|
|
override |
Sends one byte, waiting while the hardware FIFO is full.
- Parameters
-
- Returns
- 1, or 0 if the port has not been started.
The documentation for this class was generated from the following file: