Singleton managing all board communication channels for Flux V1.
More...
#include <CommChannelsManager.h>
Singleton managing all board communication channels for Flux V1.
Design decisions vs. Vortex:
- Fixed compile-time device counts (no heap vectors for device tracking).
- SPI bus + two devices known at link time.
- No I²C bus (GPIO not routed / unused on this product).
- CAN bus available for external controllers (e.g. compressor).
◆ CommChannelsManager() [1/3]
◆ CommChannelsManager() [2/3]
◆ CommChannelsManager() [3/3]
| CommChannelsManager::CommChannelsManager |
( |
| ) |
|
|
privatedefaultnoexcept |
◆ ~CommChannelsManager()
| CommChannelsManager::~CommChannelsManager |
( |
| ) |
|
|
privatedefault |
◆ AcquireUart()
Acquire (lazy-create + cache) a UART on the given hardware port.
First call wins the configuration; subsequent calls with the same port_number return the cached BaseUart& and ignore further config requests (a warning is logged if the new config differs from what was cached). Returns nullptr on configuration error.
RS-485 half-duplex is enabled automatically when rts_pin >= 0.
◆ AcquireUsbSerialJtag()
| BaseUsbSerialJtag * CommChannelsManager::AcquireUsbSerialJtag |
( |
const hf_usb_serial_jtag_config_t & |
cfg = {} | ) |
|
|
noexcept |
Lazy-acquire the built-in USB Serial/JTAG controller.
The ESP32-S3 has exactly one USB Serial/JTAG block, hard-wired to GPIO19/20 — there are no pins or baud rate to configure, only the driver-side TX/RX ring sizes. The first caller wins the ring sizes; subsequent calls reuse the same BaseUsbSerialJtag&.
If the IDF console (CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y) has already installed the underlying driver, this just shares it — both printf / ESP_LOG and our wrapper push to the same TX ring.
- Parameters
-
| cfg | Ring buffer / policy configuration (defaults are sane: 256-byte TX, 256-byte RX). Honoured only on the first call. |
- Returns
- Pointer to the cached
BaseUsbSerialJtag, or nullptr if the host platform has no USB Serial/JTAG block or driver install failed.
◆ Deinitialize()
| bool CommChannelsManager::Deinitialize |
( |
| ) |
|
|
noexcept |
Release all bus resources and reset to uninitialized state.
- Returns
- true on success
◆ DumpStatistics()
| void CommChannelsManager::DumpStatistics |
( |
| ) |
const |
|
noexcept |
Log communication channel statistics and bus health to the console.
◆ EnsureInitialized()
| bool CommChannelsManager::EnsureInitialized |
( |
| ) |
|
|
noexcept |
Initialise all communication buses if not already initialised.
- Returns
- true on success or if already initialised.
◆ GetCanBus()
| BaseCan * CommChannelsManager::GetCanBus |
( |
| ) |
|
|
noexcept |
Get the TWAI/CAN bus.
- Returns
- Pointer to BaseCan, or nullptr if not initialised.
◆ GetI2cBus()
| BaseI2c * CommChannelsManager::GetI2cBus |
( |
| ) |
|
|
inlinenoexcept |
Flux V1 does not bring up an I²C bus in CommChannelsManager.
- Returns
- Always nullptr (API retained for portable example code).
◆ GetInstance()
◆ GetLastError()
| CommError CommChannelsManager::GetLastError |
( |
| ) |
const |
|
inlinenoexcept |
Get the most recent error code.
- Returns
- Last CommError set by any API call
◆ GetManagerError()
◆ GetSpiDevice() [1/2]
| BaseSpi * CommChannelsManager::GetSpiDevice |
( |
SpiDeviceId |
device_id | ) |
|
|
noexcept |
Get an SPI device handle by enum identifier.
- Parameters
-
| device_id | SPI device identifier. |
- Returns
- Pointer to BaseSpi, or nullptr on invalid id or uninitialised.
◆ GetSpiDevice() [2/2]
| BaseSpi * CommChannelsManager::GetSpiDevice |
( |
uint8_t |
device_index | ) |
|
|
noexcept |
Get an SPI device handle by raw index.
- Parameters
-
| device_index | Zero-based device index. |
- Returns
- Pointer to BaseSpi, or nullptr on invalid index or uninitialised.
◆ GetSystemDiagnostics()
◆ GetUart()
| BaseUart * CommChannelsManager::GetUart |
( |
uint8_t |
port_number | ) |
|
|
noexcept |
Look up a previously-acquired UART by port number.
- Returns
- Pointer to the cached BaseUart, or nullptr if no UART has been acquired on that port yet.
◆ GetUsbSerialJtag()
| BaseUsbSerialJtag * CommChannelsManager::GetUsbSerialJtag |
( |
| ) |
|
|
noexcept |
Look up a previously-acquired USB Serial/JTAG instance.
- Returns
- Pointer to the cached
BaseUsbSerialJtag, or nullptr if AcquireUsbSerialJtag() has never been called.
◆ Initialize()
| bool CommChannelsManager::Initialize |
( |
| ) |
|
|
privatenoexcept |
◆ IsCanReady()
| bool CommChannelsManager::IsCanReady |
( |
| ) |
const |
|
inlinenoexcept |
The CAN controller object exists (configured, not started).
◆ IsInitialized()
| bool CommChannelsManager::IsInitialized |
( |
| ) |
const |
|
inlinenoexcept |
Check whether the communication subsystem has been initialised.
- Returns
- true if initialised.
◆ IsPressureBusReady()
| bool CommChannelsManager::IsPressureBusReady |
( |
| ) |
const |
|
inlinenoexcept |
The pressure SPI bus and its ADS7952 chip select are up.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ ReleaseLocked()
| void CommChannelsManager::ReleaseLocked |
( |
| ) |
|
|
privatenoexcept |
◆ UpdateLastError()
| void CommChannelsManager::UpdateLastError |
( |
CommError |
error | ) |
|
|
inlineprivatenoexcept |
◆ can_bus_
| BaseCan* CommChannelsManager::can_bus_ {nullptr} |
|
private |
CAN controller (configured, not started)
◆ can_bus_valid_
| bool CommChannelsManager::can_bus_valid_ {false} |
|
private |
◆ initialized_
| std::atomic<bool> CommChannelsManager::initialized_ {false} |
|
private |
◆ kMaxUartPorts
| constexpr uint8_t CommChannelsManager::kMaxUartPorts = 3 |
|
staticconstexpr |
Maximum number of UART ports the manager will track (one slot per ESP32-S3 hardware UART; UART0 is normally the IDF console, UART2 the operator console — pick a free port for app use).
◆ kSpiDeviceCount
◆ last_error_
◆ manager_error_
◆ mutex_
| RtosMutex CommChannelsManager::mutex_ |
|
mutableprivate |
◆ spi3_bus_valid_
| bool CommChannelsManager::spi3_bus_valid_ {false} |
|
private |
Pressure bus (ADS7952) up.
◆ spi_bus_valid_
| bool CommChannelsManager::spi_bus_valid_ {false} |
|
private |
Valve bus (MAX22200 + TLE92466ED) up.
◆ spi_devices_
One device per SpiDeviceId; nullptr when its bus or chip select failed.
◆ uarts_
| std::array<BaseUart*, kMaxUartPorts> CommChannelsManager::uarts_ {} |
|
private |
◆ usb_serial_jtag_
| BaseUsbSerialJtag* CommChannelsManager::usb_serial_jtag_ {nullptr} |
|
private |
The documentation for this class was generated from the following files: