UART Component
Installation
The component requires ESP-IDF 5.0 and higher and is installed using IDF Component Manager.
Add this to the idf_component.yml
in the project main
directory or in the component directory:
dependencies:
plasmapper/pl_uart: "^1.1.0"
Add this to the source code:
#include "pl_uart.h"
Add extern "C"
to the app_main
function:
extern "C" void app_main(void) {...}
Add this to the sdkconfig.defaults
in the project directory or configure the values using Project Configuration:
CONFIG_COMPILER_CXX_RTTI=y
Features
PL::Uart
- aPL::HardwareInterface
andPL::Stream
implementation for ESP internal UART ports.PL::Uart::Initialize()
installs the UART driver.PL::Uart::Enable()
enables the port (discarding the incoming data). A number of Get And Set methods get and set UART port parameters. A number ofPL::Uart::Read()
andPL::Uart::Write()
functions read and write from/to the port. Reading and writing to/fromPL::Buffer
object checks the data size and locks the object so these methods can be used in multithreaded applications.PL::StreamServer
can be used withPL::Uart
to implement a stream server for ESP internal UART ports. The descendant class should overridePL::StreamServer::HandleRequest()
to handle the client request.PL::StreamServer::HandleRequest()
is only called when there is incoming data in the internal buffer.
Thread safety
Class method thread safety is implemented by having the PL::Lockable
as a base class and creating the class object lock guard at the beginning of the methods.
Examples
API reference
- Types
- PL::Uart class
Uart
Uart::Uart()
Uart::Lock()
Uart::Unlock()
Uart::Initialize()
Uart::Enable()
Uart::Disable()
Uart::EnableLoopback()
Uart::DisableLoopback()
Uart::Read()
Uart::Write()
Uart::IsEnabled()
Uart::GetReadableSize()
Uart::GetReadTimeout()
Uart::SetReadTimeout()
Uart::GetBaudRate()
Uart::SetBaudRate()
Uart::GetDataBits()
Uart::SetDataBits()
Uart::GetParity()
Uart::SetParity()
Uart::GetStopBits()
Uart::SetStopBits()
Uart::GetFlowControl()
Uart::SetFlowControl()
Uart::SetMode()
Uart::GetName()
Uart::SetName()
Uart::Read()
Uart::ReadUntil()
Uart::ReadUntil()
Uart::ReadUntil()
Uart::Write()
Uart::Write()
Uart::FlushReadBuffer()
Uart::enabledEvent
Uart::disabledEvent
Uart::defaultName
Uart::minBufferSize
Uart::defaultReadTimeout
Uart::defaultBaudRate
Uart::defaultDataBits
Uart::defaultParity
Uart::defaultStopBits
Uart::defaultFlowControl
Uart::defaultMode