|
HardFOC Vortex V1 HAL
Unified HAL API for the HardFOC Vortex motor-control platform (ESP32-C6, TMC9660)
|
Singleton managing all board communication channels for Vortex V1. More...
#include <CommChannelsManager.h>
Classes | |
| struct | RuntimeI2cSlot |
Public Member Functions | |
| CommChannelsManager (const CommChannelsManager &)=delete | |
| CommChannelsManager & | operator= (const CommChannelsManager &)=delete |
| CommChannelsManager (CommChannelsManager &&)=delete | |
| CommChannelsManager & | operator= (CommChannelsManager &&)=delete |
| bool | EnsureInitialized () noexcept |
| Initialise all communication buses if not already initialised. | |
| bool | IsInitialized () const noexcept |
| Check whether the communication subsystem has been initialised. | |
| CommError | GetLastError () const noexcept |
| Get the most recent error code. | |
| CommError | GetSystemDiagnostics (CommSystemDiagnostics &diagnostics) const noexcept |
| Fill a diagnostics snapshot with current system state. | |
| bool | Deinitialize () noexcept |
| Release all bus resources and reset to uninitialized state. | |
| BaseSpi * | GetSpiDevice (SpiDeviceId device_id) noexcept |
| Get an SPI device handle by enum identifier. | |
| BaseSpi * | GetSpiDevice (uint8_t device_index) noexcept |
| Get an SPI device handle by raw index. | |
| BaseI2c * | GetI2cDevice (I2cDeviceId device_id) noexcept |
| Get a built-in I²C device by enum identifier. | |
| BaseI2c * | GetI2cDevice (uint8_t bus_index, int device_index) noexcept |
| Get I2C device by bus index and device index. | |
| int | CreateI2cDevice (uint8_t device_address, uint32_t speed_hz=400000) noexcept |
| Create an I2C device on the primary bus at runtime. | |
| bool | HasI2cDeviceAtAddress (uint8_t bus_index, uint8_t device_address) const noexcept |
| Check if an I2C device exists at the specified address. | |
| bool | RemoveI2cDevice (int device_index) noexcept |
| Remove a runtime-created I2C device. | |
| bool | I2cProbeAddress (uint8_t address, uint32_t timeout_ms=25) noexcept |
| Probe a single 7-bit address on the primary I²C bus. | |
| size_t | I2cScanBus (uint8_t *out, size_t max_results) noexcept |
Scan the primary I²C bus and copy ACKing addresses into out. | |
| bool | I2cResetBus () noexcept |
| Reset the I²C peripheral / clear-bus sequence (only attempts when bus is up). | |
| BaseUart * | GetUartBus () noexcept |
| Get the UART bus (TMC9660 TMCL). | |
| BaseCan * | GetCanBus () noexcept |
| Get the TWAI/CAN bus. | |
| BaseCan * | GetCanOpenBus () noexcept |
TWAI bus used for CANopen / hf-utils-canopen framing (HfUtilsCanOpenTransport). | |
| uint32_t | GetCanBitRate () const noexcept |
| Nominal bit rate the TWAI bus was configured with (bit/s). | |
| void | DumpStatistics () const noexcept |
| Log communication channel statistics and bus health to the console. | |
Static Public Member Functions | |
| static CommChannelsManager & | GetInstance () noexcept |
| Return the singleton CommChannelsManager instance. | |
Private Member Functions | |
| CommChannelsManager () noexcept | |
| ~CommChannelsManager () | |
| bool | Initialize () noexcept |
| void | ReleaseLocked () noexcept |
| Close every bus through the binding and forget the indices. Caller holds mutex_. | |
| void | UpdateLastError (CommError error) noexcept |
Private Attributes | |
| std::array< int, kSpiDeviceCount > | spi_device_indices_ {} |
| bool | spi_bus_valid_ {false} |
| bool | uart_bus_valid_ {false} |
| bool | can_bus_valid_ {false} |
| std::array< int, kI2cBuiltinCount > | i2c_builtin_indices_ {} |
| bool | i2c_bus_valid_ {false} |
| std::array< RuntimeI2cSlot, kMaxI2cRuntimeDevices > | i2c_runtime_slots_ {} |
| BaseUart * | uart_bus_ {nullptr} |
| BaseCan * | can_bus_ {nullptr} |
| std::atomic< bool > | initialized_ {false} |
| std::atomic< CommError > | last_error_ {CommError::SUCCESS} |
| RtosMutex | mutex_ |
Static Private Attributes | |
| static constexpr uint8_t | kSpiDeviceCount |
| static constexpr uint8_t | kI2cBuiltinCount |
| static constexpr uint8_t | kMaxI2cRuntimeDevices = 4 |
Singleton managing all board communication channels for Vortex V1.
Design decisions :
|
delete |
|
delete |
|
privatenoexcept |
|
privatedefault |
|
noexcept |
Create an I2C device on the primary bus at runtime.
| device_address | 7-bit I2C address |
| speed_hz | I2C clock speed (default 400 kHz) |
|
noexcept |
Release all bus resources and reset to uninitialized state.
|
noexcept |
Log communication channel statistics and bus health to the console.
|
noexcept |
Initialise all communication buses if not already initialised.
|
noexcept |
Nominal bit rate the TWAI bus was configured with (bit/s).
|
noexcept |
Get the TWAI/CAN bus.
|
inlinenoexcept |
TWAI bus used for CANopen / hf-utils-canopen framing (HfUtilsCanOpenTransport).
Vortex V1: same instance as GetCanBus(). Prefer this name in app code that wires CANOpenBLDCThread / CanOpenHostServiceThread so ownership stays with CommChannelsManager.
|
noexcept |
Get a built-in I²C device by enum identifier.
| device_id | I²C device identifier. |
|
noexcept |
Get I2C device by bus index and device index.
| bus_index | Bus index (only 0 supported) |
| device_index | Device index returned by CreateI2cDevice or bus init |
|
staticnoexcept |
|
inlinenoexcept |
Get the most recent error code.
|
noexcept |
Get an SPI device handle by enum identifier.
| device_id | SPI device identifier. |
|
noexcept |
Get an SPI device handle by raw index.
| device_index | Zero-based device index. |
|
noexcept |
Fill a diagnostics snapshot with current system state.
| diagnostics | Output structure to populate |
|
noexcept |
Get the UART bus (TMC9660 TMCL).
|
noexcept |
Check if an I2C device exists at the specified address.
| bus_index | Bus index (only 0 supported) |
| device_address | 7-bit I2C address |
|
noexcept |
Probe a single 7-bit address on the primary I²C bus.
| address | 7-bit slave address (0x08 .. 0x77). |
| timeout_ms | Per-probe timeout in ms (default 25 ms). |
|
noexcept |
Reset the I²C peripheral / clear-bus sequence (only attempts when bus is up).
|
noexcept |
Scan the primary I²C bus and copy ACKing addresses into out.
| out | Buffer to receive the discovered addresses. |
| max_results | Maximum number of entries to write into out. |
out written).
|
privatenoexcept |
|
inlinenoexcept |
Check whether the communication subsystem has been initialised.
|
delete |
|
delete |
|
privatenoexcept |
Close every bus through the binding and forget the indices. Caller holds mutex_.
|
noexcept |
Remove a runtime-created I2C device.
| device_index | Device index returned by CreateI2cDevice |
|
inlineprivatenoexcept |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
private |
|
mutableprivate |
|
private |
|
private |
|
private |
|
private |