|
CANTram Framework 1.0.1
Dieses Framework ermöglicht die Nutzung der CANTram Hardware, einer Mikrocontroller basierten mdoularen Steuerung.
|
Base class for platform-specific UART implementations. More...
#include <UARTCore.h>


Public Types | |
| 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 | install (int uart_num, uint8_t tx_pin, uint8_t rx_pin, uint16_t bufferSize)=0 |
| Install and initialize the UART driver and resources. | |
| virtual bool | reset () override |
| Reset the UART core and release/clear resources. | |
| 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) |
| virtual bool | send (const char buffer[], size_t size) |
| Send a buffer of bytes over UART. | |
| virtual size_t | read (char buffer[]) |
| Read available bytes from the UART into the provided buffer. | |
| virtual size_t | available ()=0 |
| Get the number of bytes currently available for reading. | |
| virtual void | flush ()=0 |
| Flush the UART transmit buffer. | |
| 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. | |
Protected Attributes | |
| 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. | |
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. | |
Base class for platform-specific UART implementations.
Derive from UARTCore when implementing UART support for a specific microcontroller or platform. The class integrates with the HardwareResource lifecycle provided by CANTramCore.
| enum UARTCore::DataBits |
Possible data bit widths for UART communication.
Enum values map to typical UART data length settings.
| enum UARTCore::Parity |
Parity configuration options.
Select no parity, even parity or odd parity for UART frames.
| enum UARTCore::StopBits |
Stop bit configuration options.
Specifies 1, 1.5 or 2 stop bits for UART frames.
|
pure virtual |
Get the number of bytes currently available for reading.
Query the UART driver's RX buffer to determine how many bytes can be read without blocking.
Implemented in ESP32_UART.
|
inlinevirtual |
Configure UART communication parameters.
Set baudrate, data bits, parity and stop bits for the UART peripheral.
| baudrate | Desired baud rate (e.g., 115200). |
| dataBits | Data bit selection from DataBits enum. |
| parity | Parity selection from Parity enum. |
| stopBits | Stop bit selection from StopBits enum. |
|
pure virtual |
Flush the UART transmit buffer.
Ensure that any queued transmit data is sent. Implementation should block until transmit is complete if required.
Implemented in ESP32_UART.
|
inlineoverridevirtual |
Get the HardwareResource type for this core.
Overrides HardwareResource::getType() to return HardwareResource::Type::UART.
Implements HardwareResource.
|
pure virtual |
Install and initialize the UART driver and resources.
Prepare the underlying hardware driver and allocate required memory/buffers for UART operation. This method should be called once before attempting to use the UART for I/O.
| uart_num | Identifier of the UART peripheral to install (platform-specific). |
| tx_pin | GPIO pin used for UART TX. |
| rx_pin | GPIO pin used for UART RX. |
| bufferSize | Size in bytes of the RX buffer to allocate. |
Implemented in ESP32_UART.
|
inlinevirtual |
Read available bytes from the UART into the provided buffer.
Attempt to read up to the size of the provided buffer. The concrete implementation should return the actual number of bytes read.
| buffer | Destination buffer to receive bytes. |
Reimplemented in ESP32_UART.

|
inlineoverridevirtual |
Reset the UART core and release/clear resources.
Default implementation logs the reset and delegates to HardwareResource::reset() to clear usage counters. Override if additional platform-specific teardown is required.
Reimplemented from HardwareResource.
Reimplemented in ESP32_UART.


|
inlinevirtual |
Send a buffer of bytes over UART.
Write the provided buffer to the UART transmit queue or driver. Default implementation logs and returns false.
| buffer | Character buffer containing bytes to send. |
| size | Number of bytes to send from the buffer. |
Reimplemented in ESP32_UART.
