22#ifndef FLUX_COMM_CHANNELS_MANAGER_H_
23#define FLUX_COMM_CHANNELS_MANAGER_H_
32#include "core/hf-core-drivers/internal/hf-internal-interface-wrap/inc/base/BaseSpi.h"
33#include "core/hf-core-drivers/internal/hf-internal-interface-wrap/inc/base/BaseCan.h"
34#include "core/hf-core-drivers/internal/hf-internal-interface-wrap/inc/base/BaseUart.h"
35#include "core/hf-core-drivers/internal/hf-internal-interface-wrap/inc/base/BaseUsbSerialJtag.h"
83 default:
return "Unknown error";
278 BaseUart*
GetUart(uint8_t port_number)
noexcept;
303 const hf_usb_serial_jtag_config_t& cfg = {})
noexcept;
344 std::array<BaseUart*, kMaxUartPorts>
uarts_{};
356 last_error_.store(error, std::memory_order_release);
CommChannelsManager & GetCommChannelsManager() noexcept
Convenience accessor — equivalent to CommChannelsManager::GetInstance().
Definition CommChannelsManager.h:368
constexpr const char * CommErrorToString(CommError error) noexcept
Convert CommError to a human-readable string.
Definition CommChannelsManager.h:69
CommError
Communication channels manager error codes for consistent error reporting.
Definition CommChannelsManager.h:49
@ NOT_INITIALIZED
Manager not yet initialised.
@ INVALID_BUS_INDEX
Bus index out of range.
@ MUTEX_LOCK_FAILED
RTOS mutex acquire timed out.
@ INVALID_DEVICE_INDEX
Device index out of range.
@ COMMUNICATION_FAILED
A bus-level transfer failed.
@ DEVICE_ALREADY_EXISTS
A device at that address already exists.
@ DEVICE_NOT_FOUND
Device index or id not in registry.
@ SUCCESS
Operation completed successfully.
@ DEVICE_CREATION_FAILED
Heap allocation or driver init for device failed.
@ BUS_NOT_AVAILABLE
Requested bus is not present or not ready.
@ INITIALIZATION_FAILED
Bus or device initialisation failed.
@ INVALID_PARAMETER
Null pointer or out-of-range argument.
SpiDeviceId
SPI device identifiers for the Flux V1 board.
Definition CommChannelsManager.h:113
@ DEVICE_COUNT
Sentinel — total number of SPI devices.
@ MAX22200_SOLENOID_DRIVER
MAX22200 octal solenoid driver (SPI2, Mode 0)
@ TLE92466_LOWSIDE_DRIVER
TLE92466ED six-channel driver (SPI2, Mode 1)
@ ADS7952_ADC_0
ADS7952 12-ch ADC device 0 (SPI3, Mode 0)
Singleton managing all board communication channels for Flux V1.
Definition CommChannelsManager.h:134
std::array< BaseSpi *, kSpiDeviceCount > spi_devices_
One device per SpiDeviceId; nullptr when its bus or chip select failed.
Definition CommChannelsManager.h:337
BaseUsbSerialJtag * usb_serial_jtag_
Definition CommChannelsManager.h:348
BaseUart * GetUart(uint8_t port_number) noexcept
Look up a previously-acquired UART by port number.
Definition CommChannelsManager.cpp:290
std::atomic< flux::hal::ManagerError > manager_error_
Definition CommChannelsManager.h:352
void DumpStatistics() const noexcept
Log communication channel statistics and bus health to the console.
Definition CommChannelsManager.cpp:325
std::array< BaseUart *, kMaxUartPorts > uarts_
Definition CommChannelsManager.h:344
BaseUsbSerialJtag * GetUsbSerialJtag() noexcept
Look up a previously-acquired USB Serial/JTAG instance.
Definition CommChannelsManager.cpp:317
CommChannelsManager & operator=(const CommChannelsManager &)=delete
CommChannelsManager(const CommChannelsManager &)=delete
bool IsCanReady() const noexcept
The CAN controller object exists (configured, not started).
Definition CommChannelsManager.h:181
BaseUart * AcquireUart(const UartAcquireConfig &cfg) noexcept
Acquire (lazy-create + cache) a UART on the given hardware port.
Definition CommChannelsManager.cpp:233
BaseUsbSerialJtag * AcquireUsbSerialJtag(const hf_usb_serial_jtag_config_t &cfg={}) noexcept
Lazy-acquire the built-in USB Serial/JTAG controller.
Definition CommChannelsManager.cpp:299
static constexpr uint8_t kMaxUartPorts
Definition CommChannelsManager.h:259
BaseCan * GetCanBus() noexcept
Get the TWAI/CAN bus.
Definition CommChannelsManager.cpp:215
static constexpr uint8_t kSpiDeviceCount
Definition CommChannelsManager.h:331
CommError GetSystemDiagnostics(CommSystemDiagnostics &diagnostics) const noexcept
Fill a diagnostics snapshot with current system state.
Definition CommChannelsManager.cpp:341
BaseI2c * GetI2cBus() noexcept
Flux V1 does not bring up an I²C bus in CommChannelsManager.
Definition CommChannelsManager.h:222
bool spi3_bus_valid_
Pressure bus (ADS7952) up.
Definition CommChannelsManager.h:334
bool Initialize() noexcept
Definition CommChannelsManager.cpp:106
bool spi_bus_valid_
Valve bus (MAX22200 + TLE92466ED) up.
Definition CommChannelsManager.h:333
bool Deinitialize() noexcept
Release all bus resources and reset to uninitialized state.
Definition CommChannelsManager.cpp:368
CommChannelsManager(CommChannelsManager &&)=delete
void UpdateLastError(CommError error) noexcept
Definition CommChannelsManager.h:355
bool IsPressureBusReady() const noexcept
The pressure SPI bus and its ADS7952 chip select are up.
Definition CommChannelsManager.h:178
BaseSpi * GetSpiDevice(SpiDeviceId device_id) noexcept
Get an SPI device handle by enum identifier.
Definition CommChannelsManager.cpp:201
bool can_bus_valid_
Definition CommChannelsManager.h:340
void ReleaseLocked() noexcept
Definition CommChannelsManager.cpp:186
RtosMutex mutex_
Definition CommChannelsManager.h:353
std::atomic< bool > initialized_
Definition CommChannelsManager.h:350
static CommChannelsManager & GetInstance() noexcept
Return the singleton CommChannelsManager instance.
Definition CommChannelsManager.cpp:78
CommChannelsManager & operator=(CommChannelsManager &&)=delete
bool IsInitialized() const noexcept
Check whether the communication subsystem has been initialised.
Definition CommChannelsManager.h:159
BaseCan * can_bus_
CAN controller (configured, not started)
Definition CommChannelsManager.h:339
flux::hal::ManagerError GetManagerError() const noexcept
Lifecycle / bind error of the last EnsureInitialized() (shared catalog).
Definition CommChannelsManager.h:173
CommError GetLastError() const noexcept
Get the most recent error code.
Definition CommChannelsManager.h:165
bool EnsureInitialized() noexcept
Initialise all communication buses if not already initialised.
Definition CommChannelsManager.cpp:87
std::atomic< CommError > last_error_
Definition CommChannelsManager.h:351
Shared HAL types for Flux V1: the manager error catalog and the facade result.
ManagerError
Lifecycle / bind failure catalog shared by every manager (GetManagerError()).
Definition flux_hal_types.hpp:37
@ NotInitialized
Manager not initialised (or shut down)
Lazy-acquire configuration for a hardware UART port.
Definition CommChannelsManager.h:245
int16_t tx_pin
GPIO; -1 to skip pin assignment.
Definition CommChannelsManager.h:247
uint8_t port_number
Hardware UART port (0/1/2)
Definition CommChannelsManager.h:246
int16_t cts_pin
-1 = no CTS (typical).
Definition CommChannelsManager.h:250
uint16_t tx_buffer_size
Definition CommChannelsManager.h:252
uint16_t rx_buffer_size
Definition CommChannelsManager.h:253
int16_t rts_pin
-1 = plain UART, else RS-485 DE/RE.
Definition CommChannelsManager.h:249
int16_t rx_pin
GPIO; -1 to skip pin assignment.
Definition CommChannelsManager.h:248
uint32_t baud_bps
Definition CommChannelsManager.h:251
System-level diagnostics snapshot for communication channels.
Definition CommChannelsManager.h:94
bool i2c_bus_valid
Always false — Flux V1 has no I²C manager bus.
Definition CommChannelsManager.h:98
bool system_healthy
True when all configured buses are operational.
Definition CommChannelsManager.h:95
bool can_bus_valid
CAN/TWAI bus initialised and usable.
Definition CommChannelsManager.h:99
uint8_t spi_device_count
Number of SPI devices with valid indices.
Definition CommChannelsManager.h:100
bool spi_bus_valid
SPI bus initialised and usable.
Definition CommChannelsManager.h:97
bool system_initialized
True if EnsureInitialized() completed.
Definition CommChannelsManager.h:96
CommError last_error
Most recent error code from any operation.
Definition CommChannelsManager.h:101