add some code

This commit is contained in:
2025-09-05 13:25:11 +08:00
parent 9ff0a99e7a
commit 3cf1229a85
8911 changed files with 2535396 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _AW88298_DAC_H_
#define _AW88298_DAC_H_
#include "audio_codec_if.h"
#include "audio_codec_ctrl_if.h"
#include "audio_codec_gpio_if.h"
#include "esp_codec_dev_vol.h"
#ifdef __cplusplus
extern "C" {
#endif
#define AW88298_CODEC_DEFAULT_ADDR (0x36 << 1)
/**
* @brief AW88298 codec configuration
*/
typedef struct {
const audio_codec_ctrl_if_t *ctrl_if; /*!< Codec Control interface */
const audio_codec_gpio_if_t *gpio_if; /*!< Codec GPIO interface */
int16_t reset_pin; /*!< Reset pin */
esp_codec_dev_hw_gain_t hw_gain; /*!< Hardware gain */
} aw88298_codec_cfg_t;
/**
* @brief New AW88298 codec interface
* @attention Need set mclk_multiple to I2S_MCLK_MULTIPLE_384 in esp_codec_dev_sample_info_t to support 44100
* @param codec_cfg: AW88298 codec configuration
* @return NULL: Fail to new AW88298 codec interface
* -Others: AW88298 codec interface
*/
const audio_codec_if_t *aw88298_codec_new(aw88298_codec_cfg_t *codec_cfg);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,51 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _CJC8910_CODEC_H_
#define _CJC8910_CODEC_H_
#include "audio_codec_if.h"
#include "audio_codec_ctrl_if.h"
#include "audio_codec_gpio_if.h"
#include "esp_codec_dev_vol.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define CJC8910_CODEC_DEFAULT_ADDR (0x30)
/**
* @brief CJC8910 codec configuration
*
* @note This driver only supports codec work in slave mode
*/
typedef struct {
const audio_codec_ctrl_if_t *ctrl_if; /*!< Codec Control interface */
const audio_codec_gpio_if_t *gpio_if; /*!< Codec GPIO interface */
esp_codec_dec_work_mode_t codec_mode; /*!< Codec work mode: ADC or DAC */
int16_t pa_pin; /*!< PA chip power pin */
bool pa_reverted; /*!< false: enable PA when pin set to 1, true: enable PA when pin set to 0 */
bool invert_lr; /*!< Left/Right channel inverted or not */
bool invert_sclk; /*!< SCLK clock signal inverted or not */
esp_codec_dev_hw_gain_t hw_gain; /*!< Hardware gain */
} cjc8910_codec_cfg_t;
/**
* @brief New CJC8910 codec interface
*
* @param codec_cfg CJC8910 codec configuration
*
* @return
* - NULL Not enough memory or codec failed to open
* - Others CJC8910 codec interface
*/
const audio_codec_if_t *cjc8910_codec_new(cjc8910_codec_cfg_t *codec_cfg);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _CJC8910_CODEC_H_ */

View File

@@ -0,0 +1,54 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _ES7210_ADC_H_
#define _ES7210_ADC_H_
#include "audio_codec_if.h"
#include "audio_codec_ctrl_if.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ES7210_CODEC_DEFAULT_ADDR (0x80)
#define ES7210_SEL_MIC1 (uint8_t)(1 << 0)
#define ES7210_SEL_MIC2 (uint8_t)(1 << 1)
#define ES7210_SEL_MIC3 (uint8_t)(1 << 2)
#define ES7210_SEL_MIC4 (uint8_t)(1 << 3)
/**
* @brief ES7210 MCLK clock source when work in master mode
*/
typedef enum {
ES7210_MCLK_FROM_PAD,
ES7210_MCLK_FROM_CLOCK_DOUBLER,
} es7210_mclk_src_t;
/**
* @brief ES7210 codec configuration, only support ADC feature
*/
typedef struct {
const audio_codec_ctrl_if_t *ctrl_if; /*!< Codec Control interface */
bool master_mode; /*!< Whether codec works as I2S master or not */
uint8_t mic_selected; /*!< Selected microphone */
es7210_mclk_src_t mclk_src; /*!< MCLK clock source in master mode */
uint16_t mclk_div; /*!< MCLK/LRCK default is 256 if not provided */
} es7210_codec_cfg_t;
/**
* @brief New ES7210 codec interface
* @param codec_cfg: ES7210 codec configuration
* @return NULL: Fail to new ES7210 codec interface
* -Others: ES7210 codec interface
*/
const audio_codec_if_t *es7210_codec_new(es7210_codec_cfg_t *codec_cfg);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,39 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _ES7243_ADC_H_
#define _ES7243_ADC_H_
#include "audio_codec_if.h"
#include "audio_codec_ctrl_if.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ES7243_CODEC_DEFAULT_ADDR (0x26)
/**
* @brief ES7243 codec configuration, only support ADC feature
*/
typedef struct {
const audio_codec_ctrl_if_t *ctrl_if; /*!< Codec Control interface */
} es7243_codec_cfg_t;
/**
* @brief New ES7243 codec interface
* Notes: this API should called after I2S clock ready
* Or else write register may fail
* @param codec_cfg: ES7243 codec configuration
* @return NULL: Fail to new ES7243 codec interface
* -Others: ES7243 codec interface
*/
const audio_codec_if_t *es7243_codec_new(es7243_codec_cfg_t *codec_cfg);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,37 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _ES7243E_ADC_H_
#define _ES7243E_ADC_H_
#include "audio_codec_if.h"
#include "audio_codec_ctrl_if.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ES7243E_CODEC_DEFAULT_ADDR (0x20)
/**
* @brief ES7243E codec configuration
*/
typedef struct {
const audio_codec_ctrl_if_t *ctrl_if; /*!< Codec Control interface */
} es7243e_codec_cfg_t;
/**
* @brief New ES7243E codec interface
* @param codec_cfg: ES7243E codec configuration
* @return NULL: Fail to new ES7243E codec interface
* -Others: ES7243E codec interface
*/
const audio_codec_if_t *es7243e_codec_new(es7243e_codec_cfg_t *codec_cfg);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,43 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _ES8156_DAC_H_
#define _ES8156_DAC_H_
#include "audio_codec_if.h"
#include "audio_codec_ctrl_if.h"
#include "audio_codec_gpio_if.h"
#include "esp_codec_dev_vol.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ES8156_CODEC_DEFAULT_ADDR (0x10)
/**
* @brief ES8156 codec configuration
*/
typedef struct {
const audio_codec_ctrl_if_t *ctrl_if; /*!< Codec Control interface */
const audio_codec_gpio_if_t *gpio_if; /*!< Codec GPIO interface */
int16_t pa_pin; /*!< PA chip power pin */
bool pa_reverted; /*!< false: enable PA when pin set to 1, true: enable PA when pin set to 0 */
esp_codec_dev_hw_gain_t hw_gain; /*!< Hardware gain */
} es8156_codec_cfg_t;
/**
* @brief New ES8156 codec interface
* @param codec_cfg: ES8156 codec configuration
* @return NULL: Fail to new ES8156 codec interface
* -Others: ES8156 codec interface
*/
const audio_codec_if_t *es8156_codec_new(es8156_codec_cfg_t *codec_cfg);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,54 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _ES8311_CODEC_H_
#define _ES8311_CODEC_H_
#include "audio_codec_if.h"
#include "audio_codec_ctrl_if.h"
#include "audio_codec_gpio_if.h"
#include "esp_codec_dev_vol.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ES8311_CODEC_DEFAULT_ADDR (0x30)
/**
* @brief ES8311 codec configuration
*/
typedef struct {
const audio_codec_ctrl_if_t *ctrl_if; /*!< Codec Control interface */
const audio_codec_gpio_if_t *gpio_if; /*!< Codec GPIO interface */
esp_codec_dec_work_mode_t codec_mode; /*!< Codec work mode: ADC or DAC */
int16_t pa_pin; /*!< PA chip power pin */
bool pa_reverted; /*!< false: enable PA when pin set to 1, true: enable PA when pin set to 0 */
bool master_mode; /*!< Whether codec works as I2S master or not */
bool use_mclk; /*!< Whether use external MCLK clock */
bool digital_mic; /*!< Whether use digital microphone */
bool invert_mclk; /*!< MCLK clock signal inverted or not */
bool invert_sclk; /*!< SCLK clock signal inverted or not */
esp_codec_dev_hw_gain_t hw_gain; /*!< Hardware gain */
bool no_dac_ref; /*!< When record 2 channel data
false: right channel filled with dac output
true: right channel leave empty
*/
uint16_t mclk_div; /*!< MCLK/LRCK default is 256 if not provided */
} es8311_codec_cfg_t;
/**
* @brief New ES8311 codec interface
* @param codec_cfg: ES8311 codec configuration
* @return NULL: Fail to new ES8311 codec interface
* -Others: ES8311 codec interface
*/
const audio_codec_if_t *es8311_codec_new(es8311_codec_cfg_t *codec_cfg);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,44 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _ES8374_CODEC_H_
#define _ES8374_CODEC_H_
#include "audio_codec_if.h"
#include "audio_codec_ctrl_if.h"
#include "audio_codec_gpio_if.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ES8374_CODEC_DEFAULT_ADDR (0x20)
#define ES8374_CODEC_DEFAULT_ADDR_1 (0x21)
/**
* @brief ES8374 codec configuration
*/
typedef struct {
const audio_codec_ctrl_if_t *ctrl_if; /*!< Codec Control interface */
const audio_codec_gpio_if_t *gpio_if; /*!< Codec GPIO interface */
esp_codec_dec_work_mode_t codec_mode; /*!< Codec work mode: ADC or DAC */
bool master_mode; /*!< Whether codec works as I2S master or not */
int16_t pa_pin; /*!< PA chip power pin */
bool pa_reverted; /*!< false: enable PA when pin set to 1, true: enable PA when pin set to 0 */
} es8374_codec_cfg_t;
/**
* @brief New ES8374 codec interface
* @param codec_cfg: ES8374 codec configuration
* @return NULL: Fail to new ES8374 codec interface
* -Others: ES8374 codec interface
*/
const audio_codec_if_t *es8374_codec_new(es8374_codec_cfg_t *codec_cfg);
#ifdef __cplusplus
}
#endif
#endif //__ES8374_H__

View File

@@ -0,0 +1,48 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _ES8388_CODEC_H_
#define _ES8388_CODEC_H_
#include "audio_codec_if.h"
#include "audio_codec_ctrl_if.h"
#include "audio_codec_gpio_if.h"
#include "esp_codec_dev_vol.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief ES8388 default I2C address
*/
#define ES8388_CODEC_DEFAULT_ADDR (0x20)
#define ES8388_CODEC_DEFAULT_ADDR_1 (0x22)
/**
* @brief ES8388 codec configuration
*/
typedef struct {
const audio_codec_ctrl_if_t *ctrl_if; /*!< Codec Control interface */
const audio_codec_gpio_if_t *gpio_if; /*!< Codec GPIO interface */
esp_codec_dec_work_mode_t codec_mode; /*!< Codec work mode on ADC or DAC */
bool master_mode; /*!< Whether codec works as I2S master or not */
int16_t pa_pin; /*!< PA chip power pin */
bool pa_reverted; /*!< false: enable PA when pin set to 1, true: enable PA when pin set to 0 */
esp_codec_dev_hw_gain_t hw_gain; /*!< Hardware gain */
} es8388_codec_cfg_t;
/**
* @brief New ES8388 codec interface
* @param codec_cfg: ES8388 codec configuration
* @return NULL: Fail to new ES8388 codec interface
* -Others: ES8388 codec interface
*/
const audio_codec_if_t *es8388_codec_new(es8388_codec_cfg_t *codec_cfg);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,55 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _ES8389_CODEC_H_
#define _ES8389_CODEC_H_
#include "audio_codec_if.h"
#include "audio_codec_ctrl_if.h"
#include "audio_codec_gpio_if.h"
#include "esp_codec_dev_vol.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ES8389_CODEC_DEFAULT_ADDR (0x20)
/**
* @brief ES8389 codec configuration
*/
typedef struct {
const audio_codec_ctrl_if_t *ctrl_if; /*!< Codec Control interface */
const audio_codec_gpio_if_t *gpio_if; /*!< Codec GPIO interface */
esp_codec_dec_work_mode_t codec_mode; /*!< Codec work mode: ADC or DAC */
int16_t pa_pin; /*!< PA chip power pin */
bool pa_reverted; /*!< false: enable PA when pin set to 1, true: enable PA when pin set to 0 */
bool master_mode; /*!< Whether codec works as I2S master or not */
bool use_mclk; /*!< Whether use external MCLK clock */
bool digital_mic; /*!< Whether use digital microphone */
bool invert_mclk; /*!< MCLK clock signal inverted or not */
bool invert_sclk; /*!< SCLK clock signal inverted or not */
esp_codec_dev_hw_gain_t hw_gain; /*!< Hardware gain */
bool no_dac_ref; /*!< When record 2 channel data
false: right channel filled with dac output
true: right channel leave empty
*/
uint16_t mclk_div; /*!< MCLK/LRCK default is 256 if not provided */
} es8389_codec_cfg_t;
/**
* @brief New ES8389 codec interface
* @param codec_cfg: ES8389 codec configuration
* @return NULL: Fail to new ES8389 codec interface
* -Others: ES8389 codec interface
*/
const audio_codec_if_t *es8389_codec_new(es8389_codec_cfg_t *codec_cfg);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,44 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _TAS5805M_DAC_H_
#define _TAS5805M_DAC_H_
#include "audio_codec_if.h"
#include "audio_codec_ctrl_if.h"
#include "audio_codec_gpio_if.h"
#include "esp_codec_dev_vol.h"
#ifdef __cplusplus
extern "C" {
#endif
#define TAS5805M_CODEC_DEFAULT_ADDR (0x5c)
/**
* @brief TAS5805M codec configuration
*/
typedef struct {
const audio_codec_ctrl_if_t *ctrl_if; /*!< Codec Control interface */
const audio_codec_gpio_if_t *gpio_if; /*!< Codec GPIO interface */
esp_codec_dec_work_mode_t codec_mode; /*!< Codec work mode: ADC or DAC */
bool master_mode; /*!< Whether codec works as I2S master or not */
int16_t reset_pin; /*!< Reset pin */
esp_codec_dev_hw_gain_t hw_gain; /*!< Hardware gain */
} tas5805m_codec_cfg_t;
/**
* @brief New TAS5805M codec interface
* @param codec_cfg: TAS5805M codec configuration
* @return NULL: Fail to new TAS5805M codec interface
* -Others: TAS5805M codec interface
*/
const audio_codec_if_t *tas5805m_codec_new(tas5805m_codec_cfg_t *codec_cfg);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,46 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _ZL38063_CODEC_H_
#define _ZL38063_CODEC_H_
#include "audio_codec_if.h"
#include "audio_codec_ctrl_if.h"
#include "audio_codec_gpio_if.h"
#include "esp_codec_dev_vol.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief ZL38063 codec configuration
* Notes: ZL38063 codec driver provide default configuration of I2S settings in firmware.
* Defaults are 48khz, 16 bits, 2 channels
* To playback other sample rate need do resampling firstly
*/
typedef struct {
const audio_codec_ctrl_if_t *ctrl_if; /*!< Codec Control interface */
const audio_codec_gpio_if_t *gpio_if; /*!< Codec GPIO interface */
esp_codec_dec_work_mode_t codec_mode; /*!< Codec work mode: ADC or DAC */
int16_t pa_pin; /*!< PA chip power pin */
bool pa_reverted; /*!< false: enable PA when pin set to 1, true: enable PA when pin set to 0 */
int16_t reset_pin; /*!< Reset pin */
esp_codec_dev_hw_gain_t hw_gain; /*!< Hardware gain */
} zl38063_codec_cfg_t;
/**
* @brief New ZL38063 codec interface
* @param codec_cfg: ZL38063 codec configuration
* @return NULL: Fail to new ZL38063 codec interface
* -Others: ZL38063 codec interface
*/
const audio_codec_if_t *zl38063_codec_new(zl38063_codec_cfg_t *codec_cfg);
#ifdef __cplusplus
}
#endif
#endif