Software serial (UART) emulation on any pair of GPIO pins, driven by a timer interrupt.
More...
#include <SoftwareSerial.h>
|
| | SoftwareSerial (pin_size_t receivePin, pin_size_t transmitPin, bool inverse_logic=false) |
| | Create a software serial instance on the given pins.
|
| |
|
virtual | ~SoftwareSerial () |
| | Stop this instance: stop listening and disable its timer interrupt.
|
| |
| void | begin (long speed) |
| | Set the baud rate and initialize the pins.
|
| |
| bool | listen () |
| | Set this instance as the listening one.
|
| |
|
void | end () |
| | Stop this instance: stop listening and disable the timer interrupt.
|
| |
| bool | isListening () |
| | Check if this instance is the active listener.
|
| |
| bool | stopListening () |
| | Stop listening on this instance.
|
| |
| bool | overflow () |
| | Check whether a byte was dropped because the receive buffer was full.
|
| |
| int | peek () |
| | Get the next received byte without removing it from the receive buffer.
|
| |
| virtual size_t | write (uint8_t byte) |
| | Send one byte.
|
| |
| virtual int | read () |
| | Read the next byte from the receive buffer.
|
| |
| virtual int | available () |
| | Get the number of bytes in the receive buffer.
|
| |
|
virtual void | flush () |
| | Clear the receive buffer and wait for any pending transmission to complete.
|
| |
| | operator bool () |
| | Allow the instance to be used in a boolean context.
|
| |
|
| static void | setInterruptPriority (uint32_t preemptPriority, uint32_t subPriority) |
| | Set the priority of the timer interrupt shared by all software serial instances.
|
| |
Software serial (UART) emulation on any pair of GPIO pins, driven by a timer interrupt.
- Note
- When the receive and transmit pins are the same, the instance works in half-duplex mode.
◆ SoftwareSerial()
| SoftwareSerial::SoftwareSerial |
( |
pin_size_t |
receivePin, |
|
|
pin_size_t |
transmitPin, |
|
|
bool |
inverse_logic = false |
|
) |
| |
Create a software serial instance on the given pins.
- Parameters
-
| receivePin | Pin used to receive data (RX). |
| transmitPin | Pin used to transmit data (TX). Use the same pin as receivePin for half-duplex mode. |
| inverse_logic | Optional, true to invert the logic level of the data. Default: false. |
◆ available()
| int SoftwareSerial::available |
( |
| ) |
|
|
virtual |
Get the number of bytes in the receive buffer.
- Returns
- Number of bytes available to read.
◆ begin()
| void SoftwareSerial::begin |
( |
long |
speed | ) |
|
Set the baud rate and initialize the pins.
Starts listening unless the instance is half-duplex.
- Parameters
-
| speed | Baud rate in bits per second. If FORCE_BAUD_RATE is defined, its value is used instead. |
◆ isListening()
| bool SoftwareSerial::isListening |
( |
| ) |
|
|
inline |
Check if this instance is the active listener.
- Returns
- true if this instance is listening, false otherwise.
◆ listen()
| bool SoftwareSerial::listen |
( |
| ) |
|
Set this instance as the listening one.
Only one instance can listen at a time.
If another instance was listening, it is stopped and replaced by this one.
- Returns
- true if this instance became the listening one (replacing another one if any), false if it was already listening.
◆ operator bool()
| SoftwareSerial::operator bool |
( |
| ) |
|
|
inline |
Allow the instance to be used in a boolean context.
- Returns
- Always true.
◆ overflow()
| bool SoftwareSerial::overflow |
( |
| ) |
|
|
inline |
Check whether a byte was dropped because the receive buffer was full.
Clears the flag.
- Returns
- true if an overflow occurred since the last call, false otherwise.
◆ peek()
| int SoftwareSerial::peek |
( |
| ) |
|
Get the next received byte without removing it from the receive buffer.
- Returns
- The next byte, or -1 if the receive buffer is empty.
◆ read()
| int SoftwareSerial::read |
( |
| ) |
|
|
virtual |
Read the next byte from the receive buffer.
- Returns
- The byte read, or -1 if the receive buffer is empty.
◆ setInterruptPriority()
| void SoftwareSerial::setInterruptPriority |
( |
uint32_t |
preemptPriority, |
|
|
uint32_t |
subPriority |
|
) |
| |
|
static |
Set the priority of the timer interrupt shared by all software serial instances.
- Parameters
-
| preemptPriority | Preemption priority of the interrupt. |
| subPriority | Sub-priority of the interrupt. |
◆ stopListening()
| bool SoftwareSerial::stopListening |
( |
| ) |
|
Stop listening on this instance.
Waits for any pending output to complete.
- Returns
- true if this instance was actually listening, false otherwise.
◆ write()
| size_t SoftwareSerial::write |
( |
uint8_t |
byte | ) |
|
|
virtual |
Send one byte.
Waits for any previous transmission to complete.
- Parameters
-
- Returns
- Always 1.
The documentation for this class was generated from the following files:
- libraries/SoftwareSerial/src/SoftwareSerial.h
- libraries/SoftwareSerial/src/SoftwareSerial.cpp