Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ coverage.info
coverage_report/

.vscode
examples/rtc-aigc-embedded-demo/
18 changes: 18 additions & 0 deletions components/audio_board/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,22 @@ set(COMPONENT_SRCS
)
endif()

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

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

register_component()
5 changes: 4 additions & 1 deletion components/audio_board/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ config ESP32_P4_FUNCTION_EV_BOARD
bool "ESP32-P4-FUNCTION-EV-BOARD"
config ESP32_P4_FUNCTION_EV_SUB_BOARD
bool "ESP32-P4-FUNCTION-EV-SUB-BOARD"

config DFROBOT_ESP32S3_AI_CAM
bool "DFROBOT-ESP32S3-AI-CAM"
config UNIHIKER_K10
bool "UNIHIKER-K10"
endchoice

choice ESP32_KORVO_DU1906_DAC
Expand Down
10 changes: 10 additions & 0 deletions components/audio_board/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,14 @@ endif
ifdef CONFIG_ESP32_C3_LYRA_V2_BOARD
COMPONENT_ADD_INCLUDEDIRS += ./esp32_c3_lyra
COMPONENT_SRCDIRS += ./esp32_c3_lyra
endif

ifdef CONFIG_DFROBOT_ESP32S3_AI_CAM
COMPONENT_ADD_INCLUDEDIRS += ./dfrobot_esp32_s3_ai_cam
COMPONENT_SRCDIRS += ./dfrobot_esp32_s3_ai_cam
endif

ifdef CONFIG_UNIHIKER_K10
COMPONENT_ADD_INCLUDEDIRS += ./unihiker_k10
COMPONENT_SRCDIRS += ./unihiker_k10
endif
88 changes: 88 additions & 0 deletions components/audio_board/dfrobot_esp32_s3_ai_cam/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* ESPRESSIF MIT License
*
* Copyright (c) 2025 <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"

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);
return board_handle;
}

esp_err_t audio_board_sdcard_init(esp_periph_set_handle_t set, periph_sdcard_mode_t mode)
{
if (mode != SD_MODE_SPI) {
ESP_LOGE(TAG, "Current board only support SPI SD mode!");
return ESP_FAIL;
}
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;
}

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);
ret |= audio_hal_deinit(audio_board->adc_hal);
audio_free(audio_board);
board_handle = NULL;
return ret;
}
87 changes: 87 additions & 0 deletions components/audio_board/dfrobot_esp32_s3_ai_cam/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* ESPRESSIF MIT License
*
* Copyright (c) 2025 <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 "periph_sdcard.h"

#ifdef __cplusplus
extern "C" {
#endif

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

typedef struct audio_board_handle *audio_board_handle_t;

/**
* @brief Initialize audio board
*
* @return The audio board handle
*/
audio_board_handle_t audio_board_init(void);

/**
* @brief Initialize sdcard peripheral
*
* @param set The handle of esp_periph_set_handle_t
*
* @return
* - ESP_OK, success
* - Others, fail
*/
esp_err_t audio_board_sdcard_init(esp_periph_set_handle_t set, periph_sdcard_mode_t mode);

/**
* @brief Query audio_board_handle
*
* @return The audio board handle
*/
audio_board_handle_t audio_board_get_handle(void);

/**
* @brief Uninitialize the audio board
*
* @param audio_board The handle of audio board
*
* @return 0 success,
* others fail
*/
esp_err_t audio_board_deinit(audio_board_handle_t audio_board);

#ifdef __cplusplus
}
#endif

#endif
105 changes: 105 additions & 0 deletions components/audio_board/dfrobot_esp32_s3_ai_cam/board_def.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* ESPRESSIF MIT License
*
* Copyright (c) 2025 <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_DEFINITION_H_
#define _AUDIO_BOARD_DEFINITION_H_

/**
* @brief SDCARD Function Definition
*/
#define FUNC_SDCARD_EN (1)
#define SDCARD_OPEN_FILE_NUM_MAX (5)
#define SDCARD_INTR_GPIO GPIO_NUM_NC
#define SDCARD_PWR_CTRL GPIO_NUM_NC

#define ESP_SD_PIN_CLK GPIO_NUM_12
#define ESP_SD_PIN_CMD GPIO_NUM_11
#define ESP_SD_PIN_D0 GPIO_NUM_13
#define ESP_SD_PIN_D1 GPIO_NUM_NC
#define ESP_SD_PIN_D2 GPIO_NUM_NC
#define ESP_SD_PIN_D3 GPIO_NUM_10
#define ESP_SD_PIN_D4 GPIO_NUM_NC
#define ESP_SD_PIN_D5 GPIO_NUM_NC
#define ESP_SD_PIN_D6 GPIO_NUM_NC
#define ESP_SD_PIN_D7 GPIO_NUM_NC
#define ESP_SD_PIN_CD GPIO_NUM_NC
#define ESP_SD_PIN_WP GPIO_NUM_NC


/**
* @brief Camera Function Definition
*/
#define FUNC_CAMERA_EN (1)
#define CAM_PIN_PWDN GPIO_NUM_NC
#define CAM_PIN_RESET GPIO_NUM_NC
#define CAM_PIN_XCLK GPIO_NUM_40
#define CAM_PIN_SIOD GPIO_NUM_17
#define CAM_PIN_SIOC GPIO_NUM_18

#define CAM_PIN_D7 GPIO_NUM_39
#define CAM_PIN_D6 GPIO_NUM_41
#define CAM_PIN_D5 GPIO_NUM_42
#define CAM_PIN_D4 GPIO_NUM_12
#define CAM_PIN_D3 GPIO_NUM_3
#define CAM_PIN_D2 GPIO_NUM_14
#define CAM_PIN_D1 GPIO_NUM_47
#define CAM_PIN_D0 GPIO_NUM_13
#define CAM_PIN_VSYNC GPIO_NUM_21
#define CAM_PIN_HREF GPIO_NUM_38
#define CAM_PIN_PCLK GPIO_NUM_11

/**
* @brief Audio Codec Chip Function Definition
*/
#define FUNC_AUDIO_CODEC_EN (0)
#define HEADPHONE_DETECT (-1)
#define PA_ENABLE_GPIO GPIO_NUM_NC
#define CODEC_ADC_I2S_PORT ((i2s_port_t)0)
#define CODEC_ADC_BITS_PER_SAMPLE ((i2s_data_bit_width_t)I2S_BITS_PER_SAMPLE_32BIT)
#define CODEC_ADC_SAMPLE_RATE (48000)
#define RECORD_HARDWARE_AEC (false)
#define BOARD_PA_GAIN (0) /* Power amplifier gain defined by board (dB) */



/**
* @brief ADC input data format
*/
#define AUDIO_ADC_INPUT_CH_FORMAT "N"

#define AUDIO_CODEC_DEFAULT_CONFIG(){ \
.adc_input = AUDIO_HAL_ADC_INPUT_LINE1, \
.dac_output = AUDIO_HAL_DAC_OUTPUT_ALL, \
.codec_mode = AUDIO_HAL_CODEC_MODE_BOTH, \
.i2s_iface = { \
.mode = AUDIO_HAL_MODE_SLAVE, \
.fmt = AUDIO_HAL_I2S_NORMAL, \
.samples = AUDIO_HAL_48K_SAMPLES, \
.bits = AUDIO_HAL_BIT_LENGTH_16BITS, \
}, \
};



#endif
Loading