-
Notifications
You must be signed in to change notification settings - Fork 704
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/support_esp32p4_board' into 'master'
audio_board: Support esp32-p4-function-ev-board See merge request adf/esp-adf-internal!1330
- Loading branch information
Showing
209 changed files
with
3,169 additions
and
498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
114
components/audio_board/esp32_p4_function_ev_board/board.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_ */ |
Oops, something went wrong.