HAL Adaptor

[中文]

Overview

brookesia_hal_adaptor is the board-level HAL adaptor of ESP-Brookesia. Based on the device/interface model in HAL Interface, it initialises real peripherals via esp_board_manager and registers general information, audio, display, storage, and power capabilities into the global HAL table for upper layers to discover by name.

Features

Built-In Devices

The component ships multiple board-level devices, each registered as a singleton; after initialisation they publish their interfaces into the global table:

Device class (logical name)

Registered interface implementations

Notes

GeneralDevice ("General")

BoardInfoIface (BOARD_INFO_IMPL_NAME)

Reads static board metadata such as board name, chip, version, description, and manufacturer from board-level configuration for device identification and information display.

AudioDevice ("Audio")

AudioCodecPlayerIface (CODEC_PLAYER_IMPL_NAME), AudioCodecRecorderIface (CODEC_RECORDER_IMPL_NAME)

Playback via board Audio DAC; recording via Audio ADC. Each sub-implementation can be disabled in Kconfig; requires board capability ESP_BOARD_DEV_AUDIO_CODEC_SUPPORT.

DisplayDevice ("Display")

DisplayBacklightIface (LEDC_BACKLIGHT_IMPL_NAME), DisplayPanelIface (LCD_PANEL_IMPL_NAME), DisplayTouchIface (LCD_TOUCH_IMPL_NAME)

LEDC backlight, LCD panel, and I2C touch can each be disabled; require ESP_BOARD_DEV_LEDC_CTRL_SUPPORT, ESP_BOARD_DEV_DISPLAY_LCD_SUPPORT, ESP_BOARD_DEV_LCD_TOUCH_I2C_SUPPORT respectively.

StorageDevice ("Storage")

StorageFsIface (GENERAL_FS_IMPL_NAME)

General filesystem implementation; supports SPIFFS (ESP_BOARD_DEV_FS_SPIFFS_SUPPORT) and SD card / FATFS (ESP_BOARD_DEV_FS_FAT_SUPPORT), enabled per Kconfig.

PowerDevice ("Power")

PowerBatteryIface (BATTERY_IMPL_NAME)

Battery and charger capability implementation. Supports ADC voltage estimation or AXP2101 power-management-chip backends; can query level, voltage, power source, and charge state, and control charger configuration when supported by the underlying hardware.

Configuration

Each device and sub-interface can be enabled or disabled individually under ESP-Brookesia: Hal Adaptor Configurations in menuconfig; default capability parameters (volume range, recording format, backlight range, battery low-level thresholds, ADC voltage conversion parameters, etc.) are also adjustable there, and are mapped to compile-time macros by macro_configs.h.

To override default capability parameters before initialisation, call set_codec_player_info, set_codec_recorder_info, or set_ledc_backlight_info on the corresponding device singleton. Calls after initialisation typically have no effect.

API Reference

Header File

Classes

class GeneralDevice : public esp_brookesia::hal::Device

Board-backed metadata device: publishes a board information HAL interface.

Obtained via get_instance(). Not copyable or movable.

Public Static Functions

static inline GeneralDevice &get_instance()

Returns the process-wide singleton board device.

Returns

Reference to the unique GeneralDevice instance.

Public Static Attributes

static constexpr const char *DEVICE_NAME = "General"

Logical device name passed to the base Device constructor.

static constexpr const char *BOARD_INFO_IMPL_NAME = "General:BoardInfo"

Registry key for the board information HAL interface ("General:BoardInfo").

Header File

Classes

class DisplayDevice : public esp_brookesia::hal::Device

Board-backed display device: registers panel, touch, and backlight HAL interfaces after board bring-up.

Obtained via get_instance(). Not copyable or movable.

Public Static Functions

static inline DisplayDevice &get_instance()

Returns the process-wide singleton display device.

Returns

Reference to the unique DisplayDevice instance.

Public Static Attributes

static constexpr const char *DEVICE_NAME = "Display"

Logical device name passed to the base Device constructor.

static constexpr const char *LEDC_BACKLIGHT_IMPL_NAME = "Display:LedcBacklight"

Registry key for the LEDC-based backlight HAL implementation ("Display:LedcBacklight").

static constexpr const char *LCD_PANEL_IMPL_NAME = "Display:LcdPanel"

Registry key for the LCD panel HAL implementation ("Display:LcdPanel").

static constexpr const char *LCD_TOUCH_IMPL_NAME = "Display:LcdTouch"

Registry key for the LCD touch HAL implementation ("Display:LcdTouch").

Header File

Classes

class AudioDevice : public esp_brookesia::hal::Device

Board-backed audio device: registers codec player and recorder HAL interfaces after board bring-up.

Obtained via get_instance(). Not copyable or movable.

Public Functions

bool set_codec_recorder_info(AudioCodecRecorderIface::Info info)

Overrides default static recording capability information used when constructing the codec recorder implementation.

Parameters

info -- [in] Codec recorder capability descriptor (format, channels, gains, etc.).

Returns

true if the value was stored; false on invalid input or if the recorder is already initialized.

Public Static Functions

static inline AudioDevice &get_instance()

Returns the process-wide singleton audio device.

Returns

Reference to the unique AudioDevice instance.

Public Static Attributes

static constexpr const char *DEVICE_NAME = "Audio"

Logical device name passed to the base Device constructor.

static constexpr const char *CODEC_PLAYER_IMPL_NAME = "Audio:CodecPlayer"

Registry key for the codec player HAL implementation ("Audio:CodecPlayer").

static constexpr const char *CODEC_RECORDER_IMPL_NAME = "Audio:CodecRecorder"

Registry key for the codec recorder HAL implementation ("Audio:CodecRecorder").

Header File

Classes

class StorageDevice : public esp_brookesia::hal::Device

Board-backed storage device: publishes a general filesystem HAL interface after bring-up.

Obtained via get_instance(). Not copyable or movable.

Public Static Functions

static inline StorageDevice &get_instance()

Returns the process-wide singleton storage device.

Returns

Reference to the unique StorageDevice instance.

Public Static Attributes

static constexpr const char *DEVICE_NAME = "Storage"

Logical device name passed to the base Device constructor.

static constexpr const char *GENERAL_FS_IMPL_NAME = "Storage:GenralFS"

Registry key for the general filesystem HAL interface ("Storage:GenralFS").

Header File

Classes

class PowerDevice : public esp_brookesia::hal::Device

Power-backed metadata device: publishes a power HAL interface.

Obtained via get_instance(). Not copyable or movable.

Public Static Functions

static inline PowerDevice &get_instance()

Returns the process-wide singleton power device.

Returns

Reference to the unique PowerDevice instance.

Public Static Attributes

static constexpr const char *DEVICE_NAME = "Power"

Logical device name passed to the base Device constructor.

static constexpr const char *BATTERY_IMPL_NAME = "Power:Battery"

Registry key for the power HAL interface ("Power:Battery").