CANTram Framework 1.0.1
Dieses Framework ermöglicht die Nutzung der CANTram Hardware, einer Mikrocontroller basierten mdoularen Steuerung.
Loading...
Searching...
No Matches
ESP32_UART Class Reference
Inheritance diagram for ESP32_UART:
Collaboration diagram for ESP32_UART:

Public Types

enum  uartState { NONE , INSTALLED , CONFIGURED , STARTED }
Public Types inherited from UARTCore
enum  DataBits { UART_DATA_5_BITS = 0 , UART_DATA_6_BITS = 1 , UART_DATA_7_BITS = 2 , UART_DATA_8_BITS = 3 }
 Possible data bit widths for UART communication. More...
enum  Parity { UART_PARITY_NONE = 0 , UART_PARITY_EVEN = 1 , UART_PARITY_ODD = 2 }
 Parity configuration options. More...
enum  StopBits { UART_STOP_BITS_1 = 1 , UART_STOP_BITS_1_5 = 2 , UART_STOP_BITS_2 = 3 }
 Stop bit configuration options. More...
Public Types inherited from HardwareResource
enum  Type {
  UART , SPI , I2C , PWM ,
  CAN
}
 Enumeration of hardware resource types. More...

Public Member Functions

virtual bool reset () override
 Reset the ESP32 UART instance.
bool install (int uart_num, uint8_t tx_pin, uint8_t rx_pin, uint16_t bufferSize) override
 Install the UART driver and prepare the instance.
bool applyConfig ()
 Configure UART communication parameters.
bool applyPins (int tx_pin, int rx_pin)
 Set TX and RX pins and start the UART peripheral.
bool applyPins ()
 Apply previously stored TX/RX pin mapping.
void setUARTPort (uart_port_t uartPort)
bool send (const char buffer[], size_t size) override
 Send a buffer of bytes over UART.
size_t read (char buffer[]) override
 Read available bytes from UART into buffer.
size_t available () override
 Get number of bytes available to read.
void flush () override
 Flush UART RX and TX buffers.
Public Member Functions inherited from UARTCore
virtual bool config (uint32_t baudrate, DataBits dataBits, Parity parity, StopBits stopBits)
 Configure UART communication parameters.
virtual bool setBaudrate (uint32_t baudrate)
virtual bool setDataBits (DataBits dataBits)
virtual bool setParity (Parity parity)
virtual bool setStopBits (StopBits stopBits)
HardwareResource::Type getType () override
 Get the HardwareResource type for this core.
virtual bool setPins (uint8_t tx_pin, uint8_t rx_pin)
Public Member Functions inherited from HardwareResource
bool requestUsage ()
 Request a usage slot for this resource.
uint8_t getUsages ()
 Get the current number of usages of this resource.
bool isUsed ()
 Check if the resource is currently used.
virtual uint8_t getRemainingUsages ()
 Get remaining usage capacity for this resource.

Additional Inherited Members

Protected Member Functions inherited from HardwareResource
 HardwareResource ()=default
 Default constructor.
virtual uint8_t getMaxUsages ()
 Get the maximum simultaneous usages allowed for this resource.
Protected Attributes inherited from UARTCore
int8_t _rxPin = DEFAULT_REF
int8_t _txPin = DEFAULT_REF
bool pinsConfigured = false
uint32_t _baudrate = 0
StopBits _stopBits = UART_STOP_BITS_1
Parity _parity = UART_PARITY_NONE
DataBits _dataBits = UART_DATA_8_BITS
Protected Attributes inherited from HardwareResource
uint8_t usages =0
 Current usage counter.

Member Function Documentation

◆ applyConfig()

bool ESP32_UART::applyConfig ( )

Configure UART communication parameters.

Applies baudrate, data bits, parity and stop bits to the UART peripheral. Requires the instance to be in INSTALLED state prior to calling.

Parameters
baudrateDesired baud rate (e.g., 115200).
dataBitsData bits selection from UARTCore::DataBits.
parityParity selection from UARTCore::Parity.
stopBitsStop bits selection from UARTCore::StopBits.
Returns
true if configuration succeeded, false otherwise.

◆ applyPins() [1/2]

bool ESP32_UART::applyPins ( )

Apply previously stored TX/RX pin mapping.

Overload that calls setPins using stored _txPin/_rxPin values.

Returns
true if pins were applied successfully, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyPins() [2/2]

bool ESP32_UART::applyPins ( int tx_pin,
int rx_pin )

Set TX and RX pins and start the UART peripheral.

Configures the UART peripheral to use the provided pins and transitions the state to STARTED. Requires the instance to be in CONFIGURED state.

Parameters
tx_pinGPIO pin number to use for TX.
rx_pinGPIO pin number to use for RX.
Returns
true if pins were set and UART started successfully, false otherwise.

◆ available()

size_t ESP32_UART::available ( )
overridevirtual

Get number of bytes available to read.

Queries the UART driver's buffered data length and returns the number of bytes ready for reading.

Returns
size_t Number of bytes available.

Implements UARTCore.

Here is the caller graph for this function:

◆ flush()

void ESP32_UART::flush ( )
overridevirtual

Flush UART RX and TX buffers.

Ensures any queued transmit data is flushed and input buffers are cleared.

Returns
void

Implements UARTCore.

◆ install()

bool ESP32_UART::install ( int uart_num,
uint8_t tx_pin,
uint8_t rx_pin,
uint16_t bufferSize )
overridevirtual

Install the UART driver and prepare the instance.

Installs the UART driver for the given uart_num if not already installed, stores pin and port configuration and marks the instance state as INSTALLED.

Parameters
uart_numUART peripheral number to install.
tx_pinGPIO pin used for TX.
rx_pinGPIO pin used for RX.
bufferSizeSize in bytes for RX/TX buffers.
Returns
true if installation succeeded, false otherwise.

Implements UARTCore.

◆ read()

size_t ESP32_UART::read ( char buffer[])
overridevirtual

Read available bytes from UART into buffer.

Attempts to read up to the number of bytes currently available. Requires UART to be STARTED.

Parameters
bufferDestination buffer to receive bytes.
Returns
size_t Number of bytes read into the buffer (0 if none).

Reimplemented from UARTCore.

Here is the call graph for this function:

◆ reset()

bool ESP32_UART::reset ( )
overridevirtual

Reset the ESP32 UART instance.

Releases driver resources, flushes buffers and returns the internal state to NONE. Safe to call if driver is not installed; performs no action in that case.

Returns
true on successful reset.

Reimplemented from UARTCore.

Here is the call graph for this function:

◆ send()

bool ESP32_UART::send ( const char buffer[],
size_t size )
overridevirtual

Send a buffer of bytes over UART.

Writes the provided buffer to the UART transmit queue. Requires the UART to be STARTED.

Parameters
bufferCharacter buffer containing bytes to send.
sizeNumber of bytes to send from the buffer.
Returns
true if data was queued/sent successfully, false otherwise.

Reimplemented from UARTCore.

Here is the call graph for this function:

The documentation for this class was generated from the following files:
  • C:/Users/leowa/Documents/PlatformIO/Projects/CANTramFrameworkUsage/lib/CANTramFramework/include/ESP32_UART.h
  • C:/Users/leowa/Documents/PlatformIO/Projects/CANTramFrameworkUsage/lib/CANTramFramework/src/hardware/ESP32_UART.cpp