add some code
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef _AUDIO_CODEC_CTRL_IF_H_
|
||||
#define _AUDIO_CODEC_CTRL_IF_H_
|
||||
|
||||
#include "esp_codec_dev_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct audio_codec_ctrl_if_t audio_codec_ctrl_if_t;
|
||||
|
||||
/**
|
||||
* @brief Audio codec control interface structure
|
||||
*/
|
||||
struct audio_codec_ctrl_if_t {
|
||||
int (*open)(const audio_codec_ctrl_if_t *ctrl, void *cfg, int cfg_size); /*!< Open codec control interface */
|
||||
bool (*is_open)(const audio_codec_ctrl_if_t *ctrl); /*!< Check whether codec control opened or not */
|
||||
int (*read_reg)(const audio_codec_ctrl_if_t *ctrl,
|
||||
int reg, int reg_len, void *data, int data_len); /*!< Read data from codec device register */
|
||||
int (*write_reg)(const audio_codec_ctrl_if_t *ctrl,
|
||||
int reg, int reg_len, void *data, int data_len); /*!< Write data to codec device register */
|
||||
int (*close)(const audio_codec_ctrl_if_t *ctrl); /*!< Close codec control interface */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Delete codec control interface instance
|
||||
* @param ctrl_if: Audio codec interface
|
||||
* @return ESP_CODEC_DEV_OK: Delete success
|
||||
* ESP_CODEC_DEV_INVALID_ARG: Input is NULL pointer
|
||||
*/
|
||||
int audio_codec_delete_ctrl_if(const audio_codec_ctrl_if_t *ctrl_if);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef _AUDIO_CODEC_DATA_IF_H_
|
||||
#define _AUDIO_CODEC_DATA_IF_H_
|
||||
|
||||
#include "esp_codec_dev_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct audio_codec_data_if_t audio_codec_data_if_t;
|
||||
|
||||
/**
|
||||
* @brief Audio codec data interface structure
|
||||
*/
|
||||
struct audio_codec_data_if_t {
|
||||
int (*open)(const audio_codec_data_if_t *h, void *data_cfg, int cfg_size); /*!< Open data interface */
|
||||
bool (*is_open)(const audio_codec_data_if_t *h); /*!< Check whether data interface is opened */
|
||||
int (*enable)(const audio_codec_data_if_t *h,
|
||||
esp_codec_dev_type_t dev_type,
|
||||
bool enable); /*!< Enable input or output channel */
|
||||
int (*set_fmt)(const audio_codec_data_if_t *h,
|
||||
esp_codec_dev_type_t dev_type,
|
||||
esp_codec_dev_sample_info_t *fs); /*!< Set audio format to data interface */
|
||||
int (*read)(const audio_codec_data_if_t *h, uint8_t *data, int size); /*!< Read data from data interface */
|
||||
int (*write)(const audio_codec_data_if_t *h, uint8_t *data, int size); /*!< Write data to data interface */
|
||||
int (*close)(const audio_codec_data_if_t *h); /*!< Close data interface */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Delete codec data interface instance
|
||||
* @param data_if: Codec data interface
|
||||
* @return ESP_CODEC_DEV_OK: Delete success
|
||||
* ESP_CODEC_DEV_INVALID_ARG: Input is NULL pointer
|
||||
*/
|
||||
int audio_codec_delete_data_if(const audio_codec_data_if_t *data_if);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef _AUDIO_CODEC_GPIO_IF_H_
|
||||
#define _AUDIO_CODEC_GPIO_IF_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief GPIO drive mode
|
||||
*/
|
||||
typedef enum {
|
||||
AUDIO_GPIO_MODE_FLOAT, /*!< Float */
|
||||
AUDIO_GPIO_MODE_PULL_UP = (1 << 0), /*!< Internally pullup */
|
||||
AUDIO_GPIO_MODE_PULL_DOWN = (1 << 1), /*!< Internally pulldown */
|
||||
} audio_gpio_mode_t;
|
||||
|
||||
/**
|
||||
* @brief GPIO direction type
|
||||
*/
|
||||
typedef enum {
|
||||
AUDIO_GPIO_DIR_OUT, /*!< Output GPIO */
|
||||
AUDIO_GPIO_DIR_IN, /*!< Input GPIO */
|
||||
} audio_gpio_dir_t;
|
||||
|
||||
/**
|
||||
* @brief Codec GPIO interface structure
|
||||
*/
|
||||
typedef struct {
|
||||
int (*setup)(int16_t gpio, audio_gpio_dir_t dir, audio_gpio_mode_t mode); /*!< Setup GPIO */
|
||||
int (*set)(int16_t gpio, bool high); /*!< Set GPIO level */
|
||||
bool (*get)(int16_t gpio); /*!< Get GPIO level */
|
||||
} audio_codec_gpio_if_t;
|
||||
|
||||
/**
|
||||
* @brief Delete GPIO interface instance
|
||||
* @param gpio_if: GPIO interface
|
||||
* @return ESP_CODEC_DEV_OK: Delete success
|
||||
* ESP_CODEC_DEV_INVALID_ARG: Input is NULL pointer
|
||||
*/
|
||||
int audio_codec_delete_gpio_if(const audio_codec_gpio_if_t *gpio_if);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef _AUDIO_CODEC_IF_H_
|
||||
#define _AUDIO_CODEC_IF_H_
|
||||
|
||||
#include "esp_codec_dev_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct audio_codec_if_t audio_codec_if_t;
|
||||
|
||||
/**
|
||||
* @brief Structure for codec interface
|
||||
*/
|
||||
struct audio_codec_if_t {
|
||||
int (*open)(const audio_codec_if_t *h, void *cfg, int cfg_size); /*!< Open codec */
|
||||
bool (*is_open)(const audio_codec_if_t *h); /*!< Check whether codec is opened */
|
||||
int (*enable)(const audio_codec_if_t *h, bool enable); /*!< Enable codec, when codec disabled it can use less power if provided */
|
||||
int (*set_fs)(const audio_codec_if_t *h, esp_codec_dev_sample_info_t *fs); /*!< Set audio format to codec */
|
||||
int (*mute)(const audio_codec_if_t *h, bool mute); /*!< Mute and un-mute DAC output */
|
||||
int (*set_vol)(const audio_codec_if_t *h, float db); /*!< Set DAC volume in decibel */
|
||||
int (*set_mic_gain)(const audio_codec_if_t *h, float db); /*!< Set microphone gain in decibel */
|
||||
int (*set_mic_channel_gain)(const audio_codec_if_t *h,
|
||||
uint16_t channel_mask, float db); /*!< Set microphone gain in decibel by channel */
|
||||
int (*mute_mic)(const audio_codec_if_t *h, bool mute); /*!< Mute and un-mute microphone */
|
||||
int (*set_reg)(const audio_codec_if_t *h, int reg, int value); /*!< Set register value to codec */
|
||||
int (*get_reg)(const audio_codec_if_t *h, int reg, int *value); /*!< Get register value from codec */
|
||||
void (*dump_reg)(const audio_codec_if_t *h); /*!< Dump all register settings */
|
||||
int (*close)(const audio_codec_if_t *h); /*!< Close codec */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Delete codec interface instance
|
||||
* @param codec_if: Codec interface
|
||||
* @return ESP_CODEC_DEV_OK: Delete success
|
||||
* ESP_CODEC_DEV_INVALID_ARG: Input is NULL pointer
|
||||
*/
|
||||
int audio_codec_delete_codec_if(const audio_codec_if_t *codec_if);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef _AUDIO_CODEC_VOL_IF_H_
|
||||
#define _AUDIO_CODEC_VOL_IF_H_
|
||||
|
||||
#include "esp_codec_dev_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct audio_codec_vol_if_t audio_codec_vol_if_t;
|
||||
|
||||
/**
|
||||
* @brief Structure for volume interface
|
||||
*/
|
||||
struct audio_codec_vol_if_t {
|
||||
int (*open)(const audio_codec_vol_if_t *h,
|
||||
esp_codec_dev_sample_info_t *fs, int fade_time); /*!< Open for software volume processor */
|
||||
int (*set_vol)(const audio_codec_vol_if_t *h, float db_value); /*!< Set volume in decibel unit */
|
||||
int (*process)(const audio_codec_vol_if_t *h,
|
||||
uint8_t *in, int len, uint8_t *out, int out_len); /*!< Process data */
|
||||
int (*close)(const audio_codec_vol_if_t *h); /*!< Close volume processor */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Delete volume interface instance
|
||||
* @param vol_if: Volume interface
|
||||
* @return ESP_CODEC_DEV_OK: Delete success
|
||||
* ESP_CODEC_DEV_INVALID_ARG: Input is NULL pointer
|
||||
*/
|
||||
int audio_codec_delete_vol_if(const audio_codec_vol_if_t *vol_if);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user