esp_board_manager.h

[English]

Header File

Functions

esp_err_t esp_board_runtime_pre_init(void)

Board runtime pre-init customization hook.

    Weak default returns ESP_OK. A final application may provide exactly
    one strong definition to apply BOARD-layer overrides. Multiple strong
    definitions fail at link time; there is no function-pointer registry.

    Board Manager automatically invokes this hook through
    esp_board_manager_prepare() before device or peripheral initialization.

    During the hook, only the prepare-owner task may call override/set_ops.
    The hook may edit writable descriptor/handle tables, apply generated
    board revisions, and initialize temporary resources for hardware
    detection.

    Resources created by the hook must be deinitialized before returning
    an error; prepare rollback does not release hardware resources.
    If resources remain after failure, BMGR preserves the current tables
    and configuration and rejects further runtime operations until restart.
    C-defined nodes and referenced data must remain valid until restart.

备注

Applications should implement this hook only when board-specific runtime customization is required. Do not call this hook directly. Normal device/peripheral initialization automatically triggers it.

返回:

  • ESP_OK On success

  • Others Propagated to esp_board_manager_prepare()

esp_err_t esp_board_manager_prepare(void)

Prepare board runtime overrides.

Call this API explicitly only when runtime preparation must be completed before normal device or peripheral initialization. Do not add explicit prepare calls to the normal initialization flow.

The pre-init hook runs once when unprepared. Subsequent calls are idempotent after successful preparation.

A nested call from the prepare-owner task is an idempotent no-op. Calls from other tasks while preparing are rejected, as are calls made before a FreeRTOS task exists.

On hook failure, BMGR rolls back table and configuration changes if no hardware resources remain, allowing a later retry. If resources remain, BMGR preserves the current topology and configuration, rejects further runtime operations, and requires a restart.

备注

Applications normally do not need to call this API. Board Manager automatically performs runtime preparation before device or peripheral initialization, including individual and bulk initialization.

返回:

  • ESP_OK On success or already prepared

  • ESP_ERR_INVALID_STATE If called by a non-owner task while preparing, without a current task, or after a failure that requires a restart

  • Others Error codes from the pre-init hook

esp_err_t esp_board_manager_init(void)

Initialize the board manager.

    Runs prepare and descriptor preflight, then initializes all peripherals
    first, then all devices. If device initialization fails, peripherals are
    deinitialized to maintain consistency. The manager can only be initialized once

备注

Device initialization strictly follows the order defined in board_devices.yaml Peripheral initialization strictly follows the order defined in board_peripherals.yaml If a device depends on a peripheral for power-on, it must be initialized after that peripheral For example, the LCD power control device should be listed before the Display LCD device in board_devices.yaml

返回:

  • ESP_OK On success

  • ESP_BOARD_ERR_MANAGER_ALREADY_INIT If manager already initialized

  • Others Error codes from peripheral or device initialization

esp_err_t esp_board_manager_get_periph_handle(const char *periph_name, void **periph_handle)

Get peripheral handle by name.

    Retrieves a peripheral handle that has been initialized by the board manager
    The board manager must be initialized before calling this function
参数:
  • periph_name – [in] Peripheral name

  • periph_handle – [out] Pointer to store the peripheral handle

返回:

  • ESP_OK On success

  • ESP_BOARD_ERR_MANAGER_INVALID_ARG If periph_name or periph_handle is NULL

  • ESP_BOARD_ERR_MANAGER_PERIPH_NOT_FOUND If peripheral not found

esp_err_t esp_board_manager_get_device_handle(const char *dev_name, void **device_handle)

Get device handle by name.

    Retrieves a device handle that has been initialized by the board manager
    The board manager must be initialized before calling this function
参数:
  • dev_name – [in] Device name

  • device_handle – [out] Pointer to store the device handle

返回:

  • ESP_OK On success

  • ESP_BOARD_ERR_MANAGER_INVALID_ARG If dev_name or device_handle is NULL

  • ESP_BOARD_ERR_MANAGER_DEVICE_NOT_FOUND If device not found

bool esp_board_manager_check_name(const char *name)

Check whether a device or peripheral name exists.

    This function checks whether the given name is declared as either a
    device or a peripheral in the current board configuration. It does
    not initialize anything and does not emit error logs when the name
    does not exist
参数:

name – [in] Device or peripheral name

返回:

  • true If the name exists in the current board configuration

  • false If the name does not exist or name is NULL

esp_err_t esp_board_manager_get_device_config(const char *dev_name, void **config)

Query device configuration.

    Retrieves the configuration data for a specific device. This function
    returns the raw configuration data that was used to initialize the device
参数:
  • dev_name – [in] Device name

  • config – [out] Pointer to store the device configuration

返回:

  • ESP_OK On success

  • ESP_BOARD_ERR_MANAGER_INVALID_ARG If dev_name or config is NULL

  • ESP_BOARD_ERR_MANAGER_DEVICE_NOT_FOUND If device not found

  • ESP_BOARD_ERR_DEVICE_NOT_SUPPORTED If device has no configuration

esp_err_t esp_board_manager_get_periph_config(const char *periph_name, void **config)

Get peripheral configuration by name.

参数:
  • periph_name – [in] Peripheral name

  • config – [out] Pointer to store the peripheral configuration

返回:

  • ESP_OK On success

  • ESP_BOARD_ERR_MANAGER_INVALID_ARG If periph_name or config is NULL

  • ESP_BOARD_ERR_PERIPH_NOT_FOUND If peripheral configuration not found

  • ESP_BOARD_ERR_PERIPH_NOT_SUPPORTED If peripheral has no configuration

esp_err_t esp_board_manager_get_board_info(esp_board_info_t *board_info)

Retrieves the board information.

    This function can be called without initializing the board manager
参数:

board_info – [out] Pointer to store the board information

返回:

  • ESP_OK On success

  • ESP_BOARD_ERR_MANAGER_INVALID_ARG If board_info is NULL

esp_err_t esp_board_manager_register_device_handle(esp_board_device_handle_t *reg_handle)

Register a user-defined device handle (legacy)

    Legacy ABI: splices a caller-owned handle node into the generated device
    handle list. It bypasses the descriptor table and APP/BOARD sidecar layers
    (no effective config/ops, no sidecar entry). For an existing device name,
    change init/deinit with :c:func:`esp_board_device_set_ops`. Do not inject
    unknown devices through this function; new devices must go through the
    descriptor/generator path.
参数:

reg_handle – [in] Pointer to the device handle to register

返回:

  • ESP_OK On success

  • ESP_BOARD_ERR_MANAGER_INVALID_ARG If reg_handle is NULL

esp_err_t esp_board_manager_init_device_by_name(const char *dev_name)

Initialize a specific device by name.

    Initializes a single device by name. The device must exist in the board
    configuration. This function is useful for lazy initialization of devices
参数:

dev_name – [in] Device name to initialize

返回:

  • ESP_OK On success

  • ESP_BOARD_ERR_MANAGER_INVALID_ARG If dev_name is NULL

  • ESP_BOARD_ERR_MANAGER_DEVICE_NOT_FOUND If device not found

  • Others Error codes from device initialization

esp_err_t esp_board_manager_deinit_device_by_name(const char *dev_name)

Deinitialize a specific device by name.

    Deinitializes a single device by name. The device must exist and be
    initialized. This function is useful for selective cleanup
参数:

dev_name – [in] Device name to deinitialize

返回:

  • ESP_OK On success

  • ESP_BOARD_ERR_MANAGER_INVALID_ARG If dev_name is NULL

  • Others Error codes from device deinitialization

esp_err_t esp_board_manager_print(void)

Print board manager status information.

    Displays comprehensive status information including all peripherals,
    devices, and their associations. The board manager must be initialized
返回:

  • ESP_OK On success

esp_err_t esp_board_manager_print_board_info(void)

Print board information.

    Displays board metadata including name, chip type, version, description,
    and manufacturer. This function can be called without initializing the
    board manager
返回:

  • ESP_OK On success

esp_err_t esp_board_manager_deinit(void)

Deinitialize the board manager.

    Deinitializes all devices first, then all peripherals. This destroys
    driver handles only; BOARD/APP overrides and prepare state are kept.
    The manager init flag is cleared so init may run again.
返回:

  • ESP_OK On success

  • ESP_BOARD_ERR_MANAGER_NOT_INIT If board manager not initialized

  • Others Error codes from device or peripheral deinitialization

Structures

struct esp_board_info

Board information structure.

Public Members

const char *name

Board name

const char *chip

Chip type

const char *version

Board version

const char *description

Board description

const char *manufacturer

Board manufacturer

Type Definitions

typedef struct esp_board_info esp_board_info_t

Board information structure.


此文档对您有帮助吗?