Skip to content

Commit

Permalink
Merge branch 'feature/support_esp32p4_board' into 'master'
Browse files Browse the repository at this point in the history
audio_board: Support esp32-p4-function-ev-board

See merge request adf/esp-adf-internal!1330
  • Loading branch information
jason-mao committed Sep 5, 2024
2 parents ae0ff05 + 6aa84d2 commit c601c04
Show file tree
Hide file tree
Showing 209 changed files with 3,169 additions and 498 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ Espressif Systems has released a number of boards for ESP-ADF to develop audio a

It is recommended to use the ESP-ADF master branch, as it has the latest bugfixes and the new features.

| | [ESP32-LyraT](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/get-started-esp32-lyrat.html) | [ESP32-LyraTD-MSC](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/get-started-esp32-lyratd-msc.html) | [ESP32-LyraT-Mini](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/get-started-esp32-lyrat-mini.html) | [ESP32-Korvo-DU1906](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/get-started-esp32-korvo-du1906.html) | [ESP32-S2-Kaluga-1 Kit](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-esp32-s2-kaluga-1-kit.html)|[ESP32-S3-Korvo-2](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/user-guide-esp32-s3-korvo-2.html)|[ESP32-C3-Lyra](https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/dev-boards/user-guide-esp32-c3-lyra.html)| [ESP32-S3-Box Serials](https://github.com/espressif/esp-box/tree/master)|
|:----------- |:---------------------: | :---------------------:| :---------------------:|:---------------------: | :---------------------:| :---------------------:| :---------------------:| :---------------------:|
| | [<img src="docs/_static/esp32-lyrat-v4.2-side.jpg" width="120" alt ="ESP32-LyraT Development Board" align="center" />](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/get-started-esp32-lyrat.html) <sup> **2** </sup> | [<img src="docs/_static/esp32-lyratd-msc-v2.2.jpg" width="120" alt ="ESP32-LyraTD-MSC Development Board" align="center" />](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/get-started-esp32-lyratd-msc.html) <sup> **2** </sup> | [<img src="docs/_static/esp32-lyrat-mini-v1.2.png" width="110" alt ="ESP32-LyraT-Mini Development Board" align="center" />](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/get-started-esp32-lyrat-mini.html) | [<img src="docs/_static/esp32-korvo-du1906-v1.1.png" width="110" alt ="ESP32-Korvo-DU1906 Development Board" align="center" />](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/get-started-esp32-korvo-du1906.html) <sup> **2** </sup> | [<img src="docs/_static/esp32-s2-kaluga-1-kit.png" width="100" alt ="ESP32-LyraT-Mini Development Board" align="center" />](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-esp32-s2-kaluga-1-kit.html) <sup> **2** </sup> | [<img src="docs/_static/esp32-s3-korvo-2-v3.0-overview.png" width="120" alt ="ESP32-S3-Korvo-2 Development Board" align="center" />](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/user-guide-esp32-s3-korvo-2.html) | [<img src="docs/_static/esp32-c3-lyra-v2.0-small.png" width="120" alt ="ESP32-C3-Lyra Development Board" align="center" />](https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/dev-boards/user-guide-esp32-c3-lyra.html) | [<img src="docs/_static/esp32_s3_box_3.jpg" width="100" alt ="ESP32-S3-Box Development Board" align="center" />](https://github.com/espressif/esp-box/tree/master) |
| ESP-ADF Master | ![alt text](docs/_static/no-icon.png) | ![alt text](docs/_static/no-icon.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/no-icon.png) | ![alt text](docs/_static/no-icon.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) <sup> **1** </sup> |
| ESP-ADF Release/v2.7 | ![alt text](docs/_static/no-icon.png) | ![alt text](docs/_static/no-icon.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/no-icon.png) | ![alt text](docs/_static/no-icon.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) <sup> **1** </sup> |
| ESP-ADF Release/v2.6 | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) <sup> **1** </sup> |
| | [ESP32-LyraT](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/get-started-esp32-lyrat.html) | [ESP32-LyraTD-MSC](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/get-started-esp32-lyratd-msc.html) | [ESP32-LyraT-Mini](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/get-started-esp32-lyrat-mini.html) | [ESP32-Korvo-DU1906](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/get-started-esp32-korvo-du1906.html) | [ESP32-S2-Kaluga-1 Kit](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-esp32-s2-kaluga-1-kit.html)|[ESP32-S3-Korvo-2](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/user-guide-esp32-s3-korvo-2.html)|[ESP32-C3-Lyra](https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/dev-boards/user-guide-esp32-c3-lyra.html)| [ESP32-S3-Box Serials](https://github.com/espressif/esp-box/tree/master)| [ESP32-P4-function-ev-Board](https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32-p4-function-ev-board/index.html)|
|:----------- |:---------------------: | :---------------------:| :---------------------:|:---------------------: | :---------------------:| :---------------------:| :---------------------:| :---------------------:| :---------------------:|
| | [<img src="docs/_static/esp32-lyrat-v4.2-side.jpg" width="120" alt ="ESP32-LyraT Development Board" align="center" />](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/get-started-esp32-lyrat.html) <sup> **2** </sup> | [<img src="docs/_static/esp32-lyratd-msc-v2.2.jpg" width="120" alt ="ESP32-LyraTD-MSC Development Board" align="center" />](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/get-started-esp32-lyratd-msc.html) <sup> **2** </sup> | [<img src="docs/_static/esp32-lyrat-mini-v1.2.png" width="110" alt ="ESP32-LyraT-Mini Development Board" align="center" />](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/get-started-esp32-lyrat-mini.html) | [<img src="docs/_static/esp32-korvo-du1906-v1.1.png" width="110" alt ="ESP32-Korvo-DU1906 Development Board" align="center" />](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/get-started-esp32-korvo-du1906.html) <sup> **2** </sup> | [<img src="docs/_static/esp32-s2-kaluga-1-kit.png" width="100" alt ="ESP32-LyraT-Mini Development Board" align="center" />](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-esp32-s2-kaluga-1-kit.html) <sup> **2** </sup> | [<img src="docs/_static/esp32-s3-korvo-2-v3.0-overview.png" width="120" alt ="ESP32-S3-Korvo-2 Development Board" align="center" />](https://docs.espressif.com/projects/esp-adf/en/latest/get-started/user-guide-esp32-s3-korvo-2.html) | [<img src="docs/_static/esp32-c3-lyra-v2.0-small.png" width="120" alt ="ESP32-C3-Lyra Development Board" align="center" />](https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/dev-boards/user-guide-esp32-c3-lyra.html) | [<img src="docs/_static/esp32_s3_box_3.jpg" width="100" alt ="ESP32-S3-Box Development Board" align="center" />](https://github.com/espressif/esp-box/tree/master) | [<img src="docs/_static/esp32-p4-function-ev-board.jpg" width="100" alt ="" align="center" />](https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32-p4-function-ev-board/index.html) |
| ESP-ADF Master | ![alt text](docs/_static/no-icon.png) | ![alt text](docs/_static/no-icon.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/no-icon.png) | ![alt text](docs/_static/no-icon.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) <sup> **1** </sup> | ![alt text](docs/_static/yes-checkm.png) |
| ESP-ADF Release/v2.7 | ![alt text](docs/_static/no-icon.png) | ![alt text](docs/_static/no-icon.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/no-icon.png) | ![alt text](docs/_static/no-icon.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) <sup> **1** </sup> | ![alt text](docs/_static/yes-checkm.png) |
| ESP-ADF Release/v2.6 | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) | ![alt text](docs/_static/yes-checkm.png) <sup> **1** </sup> | ![alt text](docs/_static/no-icon.png) |

**Note 1:** For the development board of [esp-box series](https://github.com/espressif/esp-box), only [esp32-s3-box](https://github.com/espressif/esp-box/blob/master/docs/hardware_overview/esp32_s3_box/hardware_overview_for_box.md) and [esp32-s3-box-lite](https://github.com/espressif/esp-box/blob/master/docs/hardware_overview/esp32_s3_box_lite/hardware_overview_for_lite.md) are supported in *ESP-ADF*.

Expand Down
9 changes: 9 additions & 0 deletions components/audio_board/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,13 @@ set(COMPONENT_SRCS
)
endif()

if (CONFIG_ESP32_P4_FUNCTION_EV_BOARD)
message(STATUS "Current board name is " CONFIG_ESP32_P4_FUNCTION_EV_BOARD)
list(APPEND COMPONENT_ADD_INCLUDEDIRS ./esp32_p4_function_ev_board)
set(COMPONENT_SRCS
./esp32_p4_function_ev_board/board.c
./esp32_p4_function_ev_board/board_pins_config.c
)
endif()

register_component()
2 changes: 2 additions & 0 deletions components/audio_board/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ config ESP32_C3_LYRA_V2_BOARD
bool "ESP32-C3-Lyra-v2.0"
config ESP32_C6_DEVKIT_BOARD
bool "ESP32-C6-DEVKIT"
config ESP32_P4_FUNCTION_EV_BOARD
bool "ESP32-P4-FUNCTION-EV-BOARD"

endchoice

Expand Down
99 changes: 99 additions & 0 deletions components/audio_board/esp32_p4_function_ev_board/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* ESPRESSIF MIT License
*
* Copyright (c) 2024 <ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD>
*
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
* it is free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/

#include "esp_log.h"
#include "board.h"
#include "audio_mem.h"
#include "periph_sdcard.h"
#include "periph_adc_button.h"

static const char *TAG = "AUDIO_BOARD";

static audio_board_handle_t board_handle = 0;

audio_board_handle_t audio_board_init(void)
{
if (board_handle) {
ESP_LOGW(TAG, "The board has already been initialized!");
return board_handle;
}
board_handle = (audio_board_handle_t)audio_calloc(1, sizeof(struct audio_board_handle));
AUDIO_MEM_CHECK(TAG, board_handle, return NULL);
board_handle->audio_hal = audio_board_codec_init();
return board_handle;
}

audio_hal_handle_t audio_board_codec_init(void)
{
audio_hal_codec_config_t audio_codec_cfg = AUDIO_CODEC_DEFAULT_CONFIG();
audio_hal_handle_t codec_hal = audio_hal_init(&audio_codec_cfg, &AUDIO_CODEC_ES8311_DEFAULT_HANDLE);
AUDIO_NULL_CHECK(TAG, codec_hal, return NULL);
return codec_hal;
}

esp_err_t audio_board_sdcard_init(esp_periph_set_handle_t set, periph_sdcard_mode_t mode)
{
periph_sdcard_cfg_t sdcard_cfg = {
.root = "/sdcard",
.card_detect_pin = get_sdcard_intr_gpio(),
.mode = mode
};
esp_periph_handle_t sdcard_handle = periph_sdcard_init(&sdcard_cfg);
esp_err_t ret = esp_periph_start(set, sdcard_handle);
int retry_time = 5;
bool mount_flag = false;
while (retry_time--) {
if (periph_sdcard_is_mounted(sdcard_handle)) {
mount_flag = true;
break;
} else {
vTaskDelay(500 / portTICK_PERIOD_MS);
}
}
if (mount_flag == false) {
ESP_LOGE(TAG, "Sdcard mount failed");
return ESP_FAIL;
}
return ret;
}

esp_err_t audio_board_key_init(esp_periph_set_handle_t set)
{
ESP_LOGE(TAG, "esp32_p4_function_ev_board not support key");
return ESP_FAIL;
}

audio_board_handle_t audio_board_get_handle(void)
{
return board_handle;
}

esp_err_t audio_board_deinit(audio_board_handle_t audio_board)
{
esp_err_t ret = ESP_OK;
ret |= audio_hal_deinit(audio_board->audio_hal);
audio_free(audio_board);
board_handle = NULL;
return ret;
}
114 changes: 114 additions & 0 deletions components/audio_board/esp32_p4_function_ev_board/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* ESPRESSIF MIT License
*
* Copyright (c) 2024 <ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD>
*
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
* it is free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/

#ifndef _AUDIO_BOARD_H_
#define _AUDIO_BOARD_H_

#include "audio_hal.h"
#include "board_def.h"
#include "board_pins_config.h"
#include "esp_peripherals.h"
#include "display_service.h"
#include "periph_sdcard.h"
#include "periph_lcd.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/**
* @brief Audio board handle
*/
struct audio_board_handle {
audio_hal_handle_t audio_hal; /*!< audio hardware abstract layer handle */
};

typedef struct audio_board_handle *audio_board_handle_t;

/**
* @brief Initialize audio board
*
* @return
* - NULL If initialization failed
* - Others The audio board handle
*/
audio_board_handle_t audio_board_init(void);

/**
* @brief Initialize codec chip
*
* @return
* - NULL If initialization failed
* - Others The audio hal handle
*/
audio_hal_handle_t audio_board_codec_init(void);

/**
* @brief Initialize sdcard peripheral
*
* @param[in] set The handle of esp_periph_set_handle_t
* @param[in] mode SDCard mode
*
* @return
* - ESP_OK On success
* - Others On failure
*/
esp_err_t audio_board_sdcard_init(esp_periph_set_handle_t set, periph_sdcard_mode_t mode);

/**
* @brief Initialize key peripheral
*
* @param[in] set The handle of esp_periph_set_handle_t
*
* @return
* - ESP_OK On success
* - Others On failure
*/
esp_err_t audio_board_key_init(esp_periph_set_handle_t set);

/**
* @brief Query audio_board_handle
*
* @return
* - NULL If board not initialized
* - Others The audio board handle
*/
audio_board_handle_t audio_board_get_handle(void);

/**
* @brief Uninitialize the audio board
*
* @param[in] audio_board The handle of audio board
*
* @return
* - ESP_OK On success
* - Others On failure
*/
esp_err_t audio_board_deinit(audio_board_handle_t audio_board);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* _AUDIO_BOARD_H_ */
Loading

0 comments on commit c601c04

Please sign in to comment.