| 🔢 CAPABILITIES | 💾 SD CARD AND SPIFFS | 🎵 AUDIO | 📟 DISPLAY AND TOUCH | 🔘 BUTTONS | 🔌 USB |
|---|
This document provides an overview of the ESP-BSP (Board Support Package) API as implemented by this board.
While the ESP-BSP framework defines a unified API shared across multiple boards, this documentation focuses only on the APIs supported by the current board. Any APIs not applicable to this board's hardware are excluded or may not be functional.
The goal of this document is to make it easier for developers to understand the available APIs and how to use them consistently across different boards.
Each BSP defines a set of macros for default pin assignments used by its hardware peripherals. These macros allow users to configure or reference standard interfaces like I2C, SPI, LCD, audio, or SD cards easily.
- I2C:
BSP_I2C_* - Display:
BSP_LCD_* - Audio I2S:
BSP_I2S_* - USB:
BSP_USB_* - SD Card (MMC):
BSP_SD_* - SD Card (SPI):
BSP_SD_SPI_*
Note
Not all boards support all interfaces. You should always check if the related capability macro (e.g., BSP_CAPS_SDCARD) is defined.
Some devices included in BSPs (e.g., sensors, displays, audio codecs) communicate via the I2C interface. In many cases, I2C is initialized automatically as part of the device setup. However, you can manually initialize or deinitialize the I2C peripheral using the following API:
/* Initialize the default I2C bus used by the BSP */
bsp_i2c_init();
...
/* Deinitialize the I2C bus */
bsp_i2c_deinit();
If you need direct access to the initialized I2C bus (e.g., to communicate with an external peripheral not handled by the BSP), you can retrieve the I2C bus handle:
i2c_master_bus_handle_t i2c = bsp_i2c_get_handle();
Note
The BSP ensures that I2C initialization is performed only once, even if called multiple times. This helps avoid conflicts when multiple components rely on the same I2C bus.
Some devices included in BSPs (such as buttons, battery monitoring, etc.) use the ADC peripheral. In most cases, the ADC is automatically initialized as part of the specific device setup. However, you can manually initialize the ADC using the following API:
/* Initialize the ADC peripheral */
bsp_adc_initialize();
If you need direct access to the ADC instance (e.g., for custom measurements), you can retrieve the handle:
adc_oneshot_unit_handle_t adc = bsp_adc_get_handle();
Note
The BSP ensures the ADC is initialized only once, even if bsp_adc_initialize() is called multiple times.
Some boards support enabling or disabling specific hardware features (such as LCD, SD card, camera, etc.) to reduce power consumption or manage shared resources. The BSP provides a unified API to control these features:
/* Enable the LCD feature */
bsp_feature_enable(BSP_FEATURE_LCD, true);
/* Disable the speaker to reduce power usage */
bsp_feature_enable(BSP_FEATURE_SPEAKER, false);
Supported feature flags (may vary depending on the board):
BSP_FEATURE_LCD- Display moduleBSP_FEATURE_TOUCH- Touch controllerBSP_FEATURE_SD- SD card interfaceBSP_FEATURE_SPEAKER- Audio speakerBSP_FEATURE_BATTERY- Battery monitoringBSP_FEATURE_VIBRATION- Vibration motor
Note
Not all BSPs support feature toggling, and some features may not be available or controllable via this API. Always check the BSP header or documentation for supported features.
Tip
Disabling unused features can help reduce power consumption, especially in battery-powered applications.
Each BSP defines an identifier macro in the form of BSP_BOARD_*.
| Type | Name |
|---|---|
| define | BSP_BOARD_ESP32_S3_LCD_EV_BOARD |
Each BSP defines a set of capability macros that indicate which features are supported. The list may look like this. You can use these macros to conditionally compile code depending on feature availability.
| Type | Name |
|---|---|
| define | BSP_CAPS_AUDIO 1 |
| define | BSP_CAPS_AUDIO_MIC 1 |
| define | BSP_CAPS_AUDIO_SPEAKER 1 |
| define | BSP_CAPS_BUTTONS 1 |
| define | BSP_CAPS_DISPLAY 1 |
| define | BSP_CAPS_IMU 0 |
| define | BSP_CAPS_SDCARD 0 |
| define | BSP_CAPS_TOUCH 1 |
| Type | Name |
|---|---|
| adc_oneshot_unit_handle_t | bsp_adc_get_handle (void) Get ADC handle. |
| esp_err_t | bsp_adc_initialize (void) Initialize ADC. |
| Type | Name |
|---|---|
| define | BSP_ADC_UNIT ADC_UNIT_1 |
Get ADC handle.
adc_oneshot_unit_handle_t bsp_adc_get_handle (
void
) Note:
This function is available only in IDF5 and higher
Returns:
ADC handle
Initialize ADC.
esp_err_t bsp_adc_initialize (
void
) The ADC can be initialized inside BSP, when needed.
| Type | Name |
|---|---|
| esp_err_t | bsp_i2c_deinit (void) Deinit I2C driver and free its resources. |
| i2c_master_bus_handle_t | bsp_i2c_get_handle (void) Get I2C driver handle. |
| esp_err_t | bsp_i2c_init (void) Init I2C driver. |
| Type | Name |
|---|---|
| define | BSP_I2C_NUM (CONFIG_BSP_I2C_NUM) |
| define | BSP_I2C_SCL (GPIO_NUM_18) |
| define | BSP_I2C_SCL_R16 (GPIO_NUM_48) |
| define | BSP_I2C_SDA (GPIO_NUM_8) |
| define | BSP_I2C_SDA_R16 (GPIO_NUM_47) |
Deinit I2C driver and free its resources.
esp_err_t bsp_i2c_deinit (
void
) Returns:
- ESP_OK: On success
- ESP_ERR_INVALID_ARG: I2C parameter error
Get I2C driver handle.
i2c_master_bus_handle_t bsp_i2c_get_handle (
void
) Returns:
- I2C handle
Init I2C driver.
esp_err_t bsp_i2c_init (
void
) Returns:
- ESP_OK: On success
- ESP_ERR_INVALID_ARG: I2C parameter error
- ESP_FAIL: I2C driver installation error
Each BSP provides a simple API for mounting and unmounting the SPI Flash File System (SPIFFS).
/* Mount SPIFFS to the virtual file system */
bsp_spiffs_mount();
/* ... perform file operations ... */
/* Unmount SPIFFS from the virtual file system */
bsp_spiffs_unmount();
The BSP offers a flexible API for working with SD cards. In addition to the default mount and unmount functions, you can also use a configuration structure or access preconfigured host and slot structures.
Mount with Default Configuration
/* Mount microSD card to the virtual file system */
bsp_sdcard_mount();
/* ... perform file operations ... */
/* Unmount microSD card */
bsp_sdcard_unmount();
Mount with Custom Configuration
Some BSPs allow selecting between SDMMC and SPI interfaces for the SD card. Use the appropriate API function based on your hardware:
bsp_sdcard_cfg_t cfg = {0};
/* Mount SD card using SDMMC interface */
bsp_sdcard_sdmmc_mount(&cfg);
or
bsp_sdcard_cfg_t cfg = {0};
/* Mount SD card using SPI interface */
bsp_sdcard_sdspi_mount(&cfg)
Note
Not all BSPs support both SDMMC and SPI modes. Check the board documentation to see which interfaces are available.
If an unsupported interface is used, the API will return ESP_ERR_NOT_SUPPORTED error.
Once the SD card or SPIFFS is mounted, you can use standard file I/O functions (fopen, fread, fwrite, fclose, etc.) provided by ESP-IDF's VFS (Virtual File System).
To print basic SD card information (after mounting), you can use:
sdmmc_card_t *sdcard = bsp_sdcard_get_handle();
sdmmc_card_print_info(stdout, sdcard);
Tip
The bsp_sdcard_get_handle() function returns a pointer to the sdmmc_card_t structure, which contains detailed information about the connected SD card.
| Type | Name |
|---|---|
| esp_err_t | bsp_spiffs_mount (void) Mount SPIFFS to virtual file system. |
| esp_err_t | bsp_spiffs_unmount (void) Unmount SPIFFS from virtual file system. |
| Type | Name |
|---|---|
| define | BSP_SPIFFS_MOUNT_POINT CONFIG_BSP_SPIFFS_MOUNT_POINT |
Mount SPIFFS to virtual file system.
esp_err_t bsp_spiffs_mount (
void
) Returns:
- ESP_OK on success
- ESP_ERR_INVALID_STATE if esp_vfs_spiffs_register was already called
- ESP_ERR_NO_MEM if memory can not be allocated
- ESP_FAIL if partition can not be mounted
- other error codes
Unmount SPIFFS from virtual file system.
esp_err_t bsp_spiffs_unmount (
void
) Returns:
- ESP_OK on success
- ESP_ERR_NOT_FOUND if the partition table does not contain SPIFFS partition with given label
- ESP_ERR_INVALID_STATE if esp_vfs_spiffs_unregister was already called
- ESP_ERR_NO_MEM if memory can not be allocated
- ESP_FAIL if partition can not be mounted
- other error codes
Before using speaker or microphone features, the audio codec must be initialized.
/* Initialize the speaker codec */
esp_codec_dev_handle_t spk_codec_dev = bsp_audio_codec_speaker_init();
/* Initialize the microphone codec */
esp_codec_dev_handle_t mic_codec_dev = bsp_audio_codec_microphone_init();
After initialization, the esp_codec_dev API can be used to control playback and recording.
Note
Some BSPs may only support playback (speaker) or only input (microphone). Use the capability macros (BSP_CAPS_AUDIO, BSP_CAPS_AUDIO_SPEAKER, BSP_CAPS_AUDIO_MIC) to check supported features.
Below is an example of audio playback using the speaker (source data not included):
/* Set volume to 50% */
esp_codec_dev_set_out_vol(spk_codec_dev, 50);
/* Define audio format */
esp_codec_dev_sample_info_t fs = {
.sample_rate = wav_header.sample_rate,
.channel = wav_header.num_channels,
.bits_per_sample = wav_header.bits_per_sample,
};
/* Open speaker stream */
esp_codec_dev_open(spk_codec_dev, &fs);
...
/* Play audio data */
esp_codec_dev_write(spk_codec_dev, wav_bytes, wav_bytes_len);
...
/* Close stream when done */
esp_codec_dev_close(spk_codec_dev);
Tip
Audio data must be in raw PCM format. Use a decoder if playing compressed formats (e.g., WAV, MP3).
Below is an example of recording audio using the microphone (destination buffer not included):
/* Set input gain (optional) */
esp_codec_dev_set_in_gain(mic_codec_dev, 42.0);
/* Define audio format */
esp_codec_dev_sample_info_t fs = {
.sample_rate = 16000,
.channel = 1,
.bits_per_sample = 16,
};
/* Open microphone stream */
esp_codec_dev_open(mic_codec_dev, &fs);
/* Read recorded data */
esp_codec_dev_read(mic_codec_dev, recording_buffer, BUFFER_SIZE)
...
/* Close stream when done */
esp_codec_dev_close(mic_codec_dev);
| Type | Name |
|---|---|
| esp_codec_dev_handle_t | bsp_audio_codec_microphone_init (void) Initialize microphone codec device. |
| esp_codec_dev_handle_t | bsp_audio_codec_speaker_init (void) Initialize speaker codec device. |
| esp_err_t | bsp_audio_init (const i2s_std_config_t *i2s_config) Init audio. |
| esp_err_t | bsp_audio_poweramp_enable (bool enable) Enable/disable audio power amplifier (deprecated) |
| Type | Name |
|---|---|
| define | BSP_I2S_DOUT (GPIO_NUM_6) |
| define | BSP_I2S_DSIN (GPIO_NUM_15) |
| define | BSP_I2S_LCLK (GPIO_NUM_7) |
| define | BSP_I2S_MCLK (GPIO_NUM_5) |
| define | BSP_I2S_SCLK (GPIO_NUM_16) |
| define | BSP_POWER_AMP_IO (IO_EXPANDER_PIN_NUM_0) |
Initialize microphone codec device.
esp_codec_dev_handle_t bsp_audio_codec_microphone_init (
void
) Note:
This function will call bsp_audio_init() if it has not been called already.
Returns:
Pointer to codec device handle or NULL when error occurred
Initialize speaker codec device.
esp_codec_dev_handle_t bsp_audio_codec_speaker_init (
void
) Note:
This function will call bsp_audio_init() if it has not been called already.
Returns:
Pointer to codec device handle or NULL when error occurred
Init audio.
esp_err_t bsp_audio_init (
const i2s_std_config_t *i2s_config
) Note:
There is no deinit audio function. Users can free audio resources by calling i2s_del_channel().
Note:
This function wiil call bsp_io_expander_init() to setup and enable the control pin of audio power amplifier.
Note:
This function will be called in bsp_audio_codec_speaker_init() andbsp_audio_codec_microphone_init().
Parameters:
i2s_configI2S configuration. Pass NULL to use default values (Mono, duplex, 16bit, 22050 Hz)
Returns:
- ESP_OK On success
- ESP_ERR_NOT_SUPPORTED The communication mode is not supported on the current chip
- ESP_ERR_INVALID_ARG NULL pointer or invalid configuration
- ESP_ERR_NOT_FOUND No available I2S channel found
- ESP_ERR_NO_MEM No memory for storing the channel information
- ESP_ERR_INVALID_STATE This channel has not initialized or already started
- other error codes
Enable/disable audio power amplifier (deprecated)
esp_err_t bsp_audio_poweramp_enable (
bool enable
) Parameters:
enableEnable/disable audio power amplifier
Returns:
- ESP_OK: On success
- ESP_ERR_INVALID_ARG: Invalid GPIO number
ESP-BSP provides two ways to initialize the display, touch and LVGL.
Simple method:
/* Initialize display, touch, and LVGL */
lv_display_t display = bsp_display_start();
Configurable method:
bsp_display_cfg_t cfg = {
.lvgl_port_cfg = ESP_LVGL_PORT_INIT_CONFIG(), /* See LVGL Port for more info */
.buffer_size = BSP_LCD_V_RES * BSP_LCD_H_RES, /* Screen buffer size in pixels */
.double_buffer = true, /* Allocate two buffers if true */
.flags = {
.buff_dma = true, /* Use DMA-capable LVGL buffer */
.buff_spiram = false, /* Allocate buffer in PSRAM if true */
}
};
cfg.lvgl_port_cfg.task_stack = 10000; /* Example: change LVGL task stack size */
/* Initialize display, touch, and LVGL */
lv_display_t display = bsp_display_start_with_config(&cfg);
After initialization, you can use the LVGL API or LVGL Port API.
To initialize the LCD without LVGL, use:
esp_lcd_panel_handle_t panel_handle;
esp_lcd_panel_io_handle_t io_handle;
const bsp_display_config_t bsp_disp_cfg = {
.max_transfer_sz = (BSP_LCD_H_RES * 100) * sizeof(uint16_t),
};
BSP_ERROR_CHECK_RETURN_NULL(bsp_display_new(&bsp_disp_cfg, &panel_handle, &io_handle));
To initialize the LCD touch without LVGL, use:
esp_lcd_touch_handle_t tp;
bsp_touch_new(NULL, &tp);
After initialization, you can use the ESP-LCD API and ESP-LCD Touch API.
/* Set display brightness to 100% */
bsp_display_backlight_on();
/* Set display brightness to 0% */
bsp_display_backlight_off();
/* Set display brightness to 50% */
bsp_display_brightness_set(50);
Note
Some boards do not support changing brightness. They return an ESP_ERR_NOT_SUPPORTED error.
All LVGL calls must be protected using lock/unlock:
/* Wait until other tasks finish screen operations */
bsp_display_lock(0);
...
lv_obj_t * screen = lv_disp_get_scr_act(disp_handle);
lv_obj_t * obj = lv_label_create(screen);
...
/* Unlock after screen operations are done */
bsp_display_unlock();
bsp_display_lock(0);
/* Rotate display to 90 */
bsp_display_rotate(display, LV_DISPLAY_ROTATION_90);
bsp_display_unlock();
Note
Some LCDs do not support hardware rotation and instead use software rotation, which consumes more memory.
Constants like screen resolution, pin configuration, and other options are defined in the BSP header files ({bsp_name}.h, display.h, touch.h).
Below are some of the most relevant predefined constants:
BSP_LCD_H_RES- Horizontal resolution in pixelsBSP_LCD_V_RES- Vertical resolution in pixelsBSP_LCD_SPI_NUM- SPI bus used by the LCD (if applicable)
| Type | Name |
|---|---|
| struct | bsp_display_cfg_t BSP display configuration structure. |
| struct | bsp_display_config_t BSP display configuration structure. |
| struct | bsp_touch_config_t BSP touch configuration structure. |
| Type | Name |
|---|---|
| esp_err_t | bsp_display_backlight_off (void) Turn off display backlight (Useless, just for compatibility) |
| esp_err_t | bsp_display_backlight_on (void) Turn on display backlight (Useless, just for compatibility) |
| esp_err_t | bsp_display_brightness_init (void) Initialize display's brightness (Useless, just for compatibility) |
| esp_err_t | bsp_display_brightness_set (int brightness_percent) Set display's brightness (Useless, just for compatibility) |
| uint16_t | bsp_display_get_h_res (void) Get display horizontal resolution. |
| lv_indev_t * | bsp_display_get_input_dev (void) Get pointer to input device (touch, buttons, ...) |
| uint16_t | bsp_display_get_v_res (void) Get display vertical resolution. |
| bool | bsp_display_lock (uint32_t timeout_ms) Take LVGL mutex. |
| esp_err_t | bsp_display_new (const bsp_display_config_t *config, esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io) Create new display panel. |
| void | bsp_display_rotate (lv_display_t *disp, lv_display_rotation_t rotation) Rotate screen. |
| lv_display_t * | bsp_display_start (void) Initialize display. |
| lv_display_t * | bsp_display_start_with_config (const bsp_display_cfg_t *cfg) Initialize display. |
| void | bsp_display_unlock (void) Give LVGL mutex. |
| esp_err_t | bsp_touch_new (const bsp_touch_config_t *config, esp_lcd_touch_handle_t *ret_touch) Create new touchscreen. |
BSP display configuration structure.
Variables:
- lvgl_port_cfg_t lvgl_port_cfg
BSP display configuration structure.
Variables:
- int max_transfer_sz
Maximum transfer size, in bytes.
BSP touch configuration structure.
Variables:
- void * dummy
Prepared for future use.
Turn off display backlight (Useless, just for compatibility)
esp_err_t bsp_display_backlight_off (
void
) Returns:
- ESP_ERR_NOT_SUPPORTED: Always
Turn on display backlight (Useless, just for compatibility)
esp_err_t bsp_display_backlight_on (
void
) Returns:
- ESP_ERR_NOT_SUPPORTED: Always
Initialize display's brightness (Useless, just for compatibility)
esp_err_t bsp_display_brightness_init (
void
) Returns:
- ESP_ERR_NOT_SUPPORTED: Always
Set display's brightness (Useless, just for compatibility)
esp_err_t bsp_display_brightness_set (
int brightness_percent
) Parameters:
brightness_percentBrightness in [%]
Returns:
- ESP_ERR_NOT_SUPPORTED: Always
Get display horizontal resolution.
uint16_t bsp_display_get_h_res (
void
) Note:
This function should be called after calling bsp_display_new() orbsp_display_start()
Returns:
Horizontal resolution. Return 0 if error occurred.
Get pointer to input device (touch, buttons, ...)
lv_indev_t * bsp_display_get_input_dev (
void
) Note:
The LVGL input device is initialized in bsp_display_start() function.
Note:
This function should be called after calling bsp_display_start().
Returns:
Pointer to LVGL input device or NULL when not initialized
Get display vertical resolution.
uint16_t bsp_display_get_v_res (
void
) Note:
This function should be called after calling bsp_display_new() orbsp_display_start()
Returns:
Vertical resolution. Return 0 if error occurred.
Take LVGL mutex.
bool bsp_display_lock (
uint32_t timeout_ms
) Note:
Display must be already initialized by calling bsp_display_start()
Parameters:
timeout_msTimeout in [ms]. 0 will block indefinitely.
Returns:
- true: Mutex was taken
- false: Mutex was NOT taken
Create new display panel.
esp_err_t bsp_display_new (
const bsp_display_config_t *config,
esp_lcd_panel_handle_t *ret_panel,
esp_lcd_panel_io_handle_t *ret_io
) For maximum flexibility, this function performs only reset and initialization of the display. You must turn on the display explicitly by calling esp_lcd_panel_disp_on_off(). The display's backlight is not turned on either. You can use bsp_display_backlight_on/off(), bsp_display_brightness_set() (on supported boards) or implement your own backlight control.
If you want to free resources allocated by this function, you can use esp_lcd API, ie.:
esp_lcd_panel_del(panel);
esp_lcd_panel_io_del(io);
spi_bus_free(spi_num_from_configuration);Parameters:
configdisplay configuration. Set to NULL if not needed.ret_panelesp_lcd panel handle. Set to NULL if not needed.ret_ioesp_lcd IO handle. Set to NULL if not needed.
Returns:
- ESP_OK On success
- Else esp_lcd failure
Rotate screen.
void bsp_display_rotate (
lv_display_t *disp,
lv_display_rotation_t rotation
) Note:
Display must be already initialized by calling bsp_display_start()
Note:
This function can't work with the anti-tearing function. Please use the BSP_DISPLAY_LVGL_ROTATION configuration instead.
Parameters:
dispPointer to LVGL displayrotationAngle of the display rotation
Initialize display.
lv_display_t * bsp_display_start (
void
) Note:
This function initializes display controller and starts LVGL handling task.
Note:
Users can get LCD panel handle from user_data in returned display.
Returns:
Pointer to LVGL display or NULL when error occurred
Initialize display.
lv_display_t * bsp_display_start_with_config (
const bsp_display_cfg_t *cfg
) This function initializes SPI, display controller and starts LVGL handling task. LCD backlight must be enabled separately by calling bsp_display_brightness_set()
Parameters:
cfgdisplay configuration
Returns:
Pointer to LVGL display or NULL when error occurred
Give LVGL mutex.
void bsp_display_unlock (
void
) Note:
Display must be already initialized by calling bsp_display_start()
Create new touchscreen.
esp_err_t bsp_touch_new (
const bsp_touch_config_t *config,
esp_lcd_touch_handle_t *ret_touch
) If you want to free resources allocated by this function, you can use esp_lcd_touch API, ie.:
esp_lcd_touch_del(tp);Parameters:
configtouch configuration. Set to NULL if not needed.ret_touchesp_lcd_touch touchscreen handle. Set to NULL if not needed.
Returns:
- ESP_OK On success
- Else esp_lcd_touch failure
Most boards include one or more user buttons. The BSP provides a simple API to initialize and use them. Internally, it utilizes the button component for event handling and debouncing.
/* Initialize all available buttons */
button_handle_t btns[BSP_BUTTON_NUM] = {NULL};
bsp_iot_button_create(btns, NULL, BSP_BUTTON_NUM);
/* Register a callback for button press */
for (int i = 0; i < BSP_BUTTON_NUM; i++) {
iot_button_register_cb(btns[i], BUTTON_PRESS_DOWN, NULL, btn_handler, (void *) i);
}
/* Called on button press */
static void btn_handler(void *button_handle, void *usr_data)
{
int button_index = (int)usr_data;
ESP_LOGI(TAG, "Button %d pressed", button_index);
}
Notes:
-
BSP_BUTTON_NUMdefines the number of available buttons on the board -
Instead of relying on a numeric index, you can use the
bsp_button_tstructure defined in the BSP header to reference buttons by name (e.g., BSP_BUTTON_MUTE, BSP_BUTTON_MAIN, BSP_BUTTON_BOOT, etc.) -
The callback can be registered for different button events, such as
BUTTON_PRESS_DOWN,BUTTON_PRESS_UP, orBUTTON_LONG_PRESS_START,BUTTON_DOUBLE_CLICK, ... -
Button features (e.g. long-press support, active level) are configured automatically by the BSP.
| Type | Name |
|---|---|
| enum | bsp_button_t |
| Type | Name |
|---|---|
| bool | bsp_button_get (const bsp_button_t btn) Get button's state. |
| esp_err_t | bsp_button_init (const bsp_button_t btn) Set button's GPIO as input. |
| esp_err_t | bsp_iot_button_create (button_handle_t btn_array, int *btn_cnt, int btn_array_size) Initialize all buttons. |
| Type | Name |
|---|---|
| define | BSP_BUTTON_BOOT_IO (GPIO_NUM_0) |
enum bsp_button_t {
BSP_BUTTON_BOOT = 0,
BSP_BUTTON_NUM
};Get button's state.
bool bsp_button_get (
const bsp_button_t btn
) Parameters:
btnButton to read
Returns:
- true: Button pressed
- false: Button released
Set button's GPIO as input.
esp_err_t bsp_button_init (
const bsp_button_t btn
) Parameters:
btnButton to be initialized
Returns:
- ESP_OK: Success
- ESP_ERR_INVALID_ARG: Parameter error
Initialize all buttons.
esp_err_t bsp_iot_button_create (
button_handle_t btn_array,
int *btn_cnt,
int btn_array_size
) Returned button handlers must be used with espressif/button component API
Note:
For LCD panel button which is defined as BSP_BUTTON_MAIN, bsp_display_start should be called before call this function.
Parameters:
btn_arrayOutput button arraybtn_cntNumber of button handlers saved to btn_array, can be NULLbtn_array_sizeSize of output button array. Must be at least BSP_BUTTON_NUM
Returns:
- ESP_OK All buttons initialized
- ESP_ERR_INVALID_ARG btn_array is too small or NULL
- ESP_FAIL Underlaying iot_button_create failed
Boards with USB support define macros for USB pins, such as BSP_USB_POS and BSP_USB_NEG, and may also provide control APIs for enabling or disabling USB functionality.
/* Initialize USB in device mode and enable power */
bsp_usb_host_start(BSP_USB_HOST_POWER_MODE_USB_DEV, true);
...
/* Deinitialize and stop USB */
bsp_usb_host_stop();
Note
Not all BSPs implement USB support or provide power control. Refer to the board's documentation and the BSP header files for available functions and supported modes.
For more USB-related APIs and configuration options, check the corresponding BSP header files.
| Type | Name |
|---|---|
| define | BSP_USB_NEG ((GPIO_NUM_19)) |
| define | BSP_USB_POS ((GPIO_NUM_20)) |
| Type | Name |
|---|---|
| esp_io_expander_handle_t | bsp_io_expander_init (void) Init IO expander chip TCA9554. |
| Type | Name |
|---|---|
| define | BSP_IO_EXPANDER_I2C_ADDRESS (ESP_IO_EXPANDER_I2C_TCA9554_ADDRESS_000) |
Init IO expander chip TCA9554.
esp_io_expander_handle_t bsp_io_expander_init (
void
) Note:
If the device was already initialized, users can also use it to get handle.
Note:
This function will be called in bsp_display_start() when using LCD sub-board 2 with the resolution of 480x480.
Note:
This function will be called in bsp_audio_init().
Returns:
Pointer to device handle or NULL when error occurred