HAL 适配
公共头文件:
#include "brookesia/hal_adaptor.hpp"
概述
brookesia_hal_adaptor 是 ESP-Brookesia 的板级 HAL 适配实现,基于 HAL 接口 的设备/接口模型,通过 esp_board_manager 初始化真实外设,并将 音频 、 显示 、 存储 三类能力注册到全局 HAL 表,供上层按名称发现和使用。
功能特性
内置设备
本组件提供三台板级设备,每台设备以单例形式注册,初始化后将对应的接口发布到全局表:
设备类(逻辑名) |
注册的接口实现 |
说明 |
|---|---|---|
|
|
播放经板级 Audio DAC;录音经 Audio ADC。子实现可在 Kconfig 中独立关闭,并依赖板级能力符号 |
|
|
LEDC 背光、LCD 面板、I2C 触摸可分别开关;分别依赖 |
|
|
通用文件系统实现,支持 SPIFFS(依赖 |
配置与参数
各子接口可在 menuconfig 的 ESP-Brookesia: Hal Adaptor Configurations 中独立开启或关闭;默认能力参数(音量范围、录音格式、背光亮度范围等)也可在 menuconfig 中调整,由 macro_configs.h 映射为编译宏供实现使用。
若需在初始化前覆盖默认能力参数,可在对应设备单例上调用 set_codec_player_info、set_codec_recorder_info 或 set_ledc_backlight_info。初始化完成后再调用通常不会生效。
API 参考
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 Functions
-
bool set_ledc_backlight_info(DisplayBacklightIface::Info info)
Overrides default static backlight capability information used when constructing the LEDC backlight implementation.
- 参数
info – [in] Backlight capability descriptor (brightness range and default).
- 返回
trueif the value was stored;falseon invalid input or if backlight is already initialized.
Public Static Functions
-
static inline DisplayDevice &get_instance()
Returns the process-wide singleton display device.
- 返回
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").
-
bool set_ledc_backlight_info(DisplayBacklightIface::Info info)
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_player_info(AudioCodecPlayerIface::Info info)
Overrides default static playback capability information used when constructing the codec player implementation.
- 参数
info – [in] Codec player capability descriptor (volume range and default).
- 返回
trueif the value was stored;falseon invalid input or if the player is already initialized.
-
bool set_codec_recorder_info(AudioCodecRecorderIface::Info info)
Overrides default static recording capability information used when constructing the codec recorder implementation.
- 参数
info – [in] Codec recorder capability descriptor (format, channels, gains, etc.).
- 返回
trueif the value was stored;falseon invalid input or if the recorder is already initialized.
Public Static Functions
-
static inline AudioDevice &get_instance()
Returns the process-wide singleton audio device.
- 返回
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").
-
bool set_codec_player_info(AudioCodecPlayerIface::Info info)
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.
- 返回
Reference to the unique StorageDevice instance.
-
static inline StorageDevice &get_instance()