HardFOC Vortex V1 HAL
Unified HAL API for the HardFOC Vortex motor-control platform (ESP32-C6, TMC9660)
Loading...
Searching...
No Matches
Classes | Enumerations | Functions
CommChannelsManager.h File Reference

Communication channels manager for the HardFOC Vortex V1 platform. More...

#include <array>
#include <atomic>
#include <cstdint>
#include <memory>
#include "base/BaseSpi.h"
#include "base/BaseI2c.h"
#include "base/BaseUart.h"
#include "base/BaseCan.h"
#include "RtosMutex.h"
Include dependency graph for CommChannelsManager.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CommSystemDiagnostics
 System-level diagnostics snapshot for communication channels. More...
 
class  CommChannelsManager
 Singleton managing all board communication channels for Vortex V1. More...
 
struct  CommChannelsManager::RuntimeI2cSlot
 

Enumerations

enum class  CommError : uint8_t {
  SUCCESS = 0 , NOT_INITIALIZED , INITIALIZATION_FAILED , BUS_NOT_AVAILABLE ,
  DEVICE_NOT_FOUND , INVALID_BUS_INDEX , INVALID_DEVICE_INDEX , DEVICE_ALREADY_EXISTS ,
  DEVICE_CREATION_FAILED , COMMUNICATION_FAILED , INVALID_PARAMETER , MUTEX_LOCK_FAILED
}
 Communication channels manager error codes for consistent error reporting. More...
 
enum class  SpiDeviceId : uint8_t {
  TMC9660_MOTOR_CONTROLLER = 0 , AS5047U_POSITION_ENCODER = 1 , EXTERNAL_DEVICE_1 = 2 , EXTERNAL_DEVICE_2 = 3 ,
  DEVICE_COUNT
}
 SPI device identifiers for the Vortex V1 board. More...
 
enum class  I2cDeviceId : uint8_t { BNO08X_IMU = 0 , PCAL9555_GPIO_EXPANDER = 1 , DEVICE_COUNT }
 I2C device identifiers for the Vortex V1 board (built-in devices). More...
 

Functions

constexpr const char * CommErrorToString (CommError error) noexcept
 Convert CommError to a human-readable string.
 
CommChannelsManager & GetCommChannelsManager () noexcept
 Convenience accessor — equivalent to CommChannelsManager::GetInstance().
 

Detailed Description

Communication channels manager for the HardFOC Vortex V1 platform.

Manages all board communication buses (SPI, I2C, UART, CAN) for the Vortex motor-control board. The Vortex board uses:

MCU-free: the bus objects are created by the board binding (bsp_bind/VortexBoardBind.h, ESP32-C6 implementation in bsp_bind/esp32c6/), which keeps them in static storage. This manager holds device indices and non-owning Base* pointers, and one RtosMutex.

Extends with runtime I2C device creation for ImuManager (external BNO08x devices).

Version
2.0

Enumeration Type Documentation

◆ CommError

enum class CommError : uint8_t
strong

Communication channels manager error codes for consistent error reporting.

Manager-layer errors for communication bus lifecycle and device operations. Covers SPI, I2C, UART, and CAN bus management failures.

Enumerator
SUCCESS 

Operation completed successfully.

NOT_INITIALIZED 

Manager not yet initialised.

INITIALIZATION_FAILED 

Bus or device initialisation failed.

BUS_NOT_AVAILABLE 

Requested bus is not present or not ready.

DEVICE_NOT_FOUND 

Device index or id not in registry.

INVALID_BUS_INDEX 

Bus index out of range.

INVALID_DEVICE_INDEX 

Device index out of range.

DEVICE_ALREADY_EXISTS 

A device at that address already exists.

DEVICE_CREATION_FAILED 

Heap allocation or driver init for device failed.

COMMUNICATION_FAILED 

A bus-level transfer failed.

INVALID_PARAMETER 

Null pointer or out-of-range argument.

MUTEX_LOCK_FAILED 

RTOS mutex acquire timed out.

◆ I2cDeviceId

enum class I2cDeviceId : uint8_t
strong

I2C device identifiers for the Vortex V1 board (built-in devices).

Enumerator
BNO08X_IMU 

BNO08x IMU sensor (address 0x4A)

PCAL9555_GPIO_EXPANDER 

PCAL95555 GPIO expander (address 0x20)

DEVICE_COUNT 

Sentinel — total number of built-in I2C devices.

◆ SpiDeviceId

enum class SpiDeviceId : uint8_t
strong

SPI device identifiers for the Vortex V1 board.

The order matches the CS pin configuration in the CommChannelsManager.

Enumerator
TMC9660_MOTOR_CONTROLLER 

TMC9660 motor controller (SPI Mode 3)

AS5047U_POSITION_ENCODER 

AS5047U position encoder (SPI Mode 1)

EXTERNAL_DEVICE_1 

External device slot 1 (SPI Mode 0)

EXTERNAL_DEVICE_2 

External device slot 2 (SPI Mode 0)

DEVICE_COUNT 

Sentinel — total number of SPI devices.

Function Documentation

◆ CommErrorToString()

constexpr const char * CommErrorToString ( CommError  error)
constexprnoexcept

Convert CommError to a human-readable string.

Parameters
errorError code to convert.
Returns
Null-terminated string representation.

◆ GetCommChannelsManager()

CommChannelsManager & GetCommChannelsManager ( )
inlinenoexcept

Convenience accessor — equivalent to CommChannelsManager::GetInstance().

Returns
Reference to the singleton CommChannelsManager.
Here is the call graph for this function: