| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- #pragma once
- #include "driver/gpio.h"
- #include "driver/i2s_std.h"
- #include "driver/i2c_master.h"
- #include "soc/soc_caps.h"
- #include "esp_idf_version.h"
- #include "esp_codec_dev.h"
- #include "esp_codec_dev_defaults.h"
- #include "esp_codec_dev_os.h"
- #include "sdkconfig.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define I2C_NUM (0)
- #define GPIO_I2C_SCL (GPIO_NUM_10)
- #define GPIO_I2C_SDA (GPIO_NUM_11)
- #define FUNC_I2S_EN (1)
- #define GPIO_I2S_LRCK (GPIO_NUM_14)
- #define GPIO_I2S_MCLK (GPIO_NUM_12)
- #define GPIO_I2S_SCLK (GPIO_NUM_13)
- #define GPIO_I2S_SDIN (GPIO_NUM_15)
- #define GPIO_I2S_DOUT (GPIO_NUM_16)
- #define RECORD_VOLUME (30.0)
- #define PLAYER_VOLUME (60)
- #define GPIO_PWR_CTRL (-1)
- #define GPIO_PWR_ON_LEVEL (1)
- #define KEY_VOLUME_UP_PIN (1ULL << 9) /* K1, TCA9555 expander pin 9 */
- #define KEY_VOLUME_DOWN_PIN (1ULL << 11) /* K3, TCA9555 expander pin 11 */
- #define VOLUME_BUTTON_POLL_MS (50)
- #define VOLUME_STEP (2)
- #define VOLUME_MIN_LEVEL (0)
- #define VOLUME_MAX_LEVEL (100)
- #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
- #define I2S_CONFIG_DEFAULT(sample_rate, channel_fmt, bits_per_chan) { \
- .clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(16000), \
- .slot_cfg = I2S_STD_PHILIPS_SLOT_DEFAULT_CONFIG(32, I2S_SLOT_MODE_STEREO), \
- .gpio_cfg = { \
- .mclk = GPIO_I2S_MCLK, \
- .bclk = GPIO_I2S_SCLK, \
- .ws = GPIO_I2S_LRCK, \
- .dout = GPIO_I2S_DOUT, \
- .din = GPIO_I2S_SDIN, \
- }, \
- }
- #else
- #define I2S_CONFIG_DEFAULT(sample_rate, channel_fmt, bits_per_chan) { \
- .mode = I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_TX, \
- .sample_rate = 16000, \
- .bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT, \
- .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, \
- .communication_format = I2S_COMM_FORMAT_STAND_I2S, \
- .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, \
- .dma_buf_count = 6, \
- .dma_buf_len = 160, \
- .use_apll = false, \
- .tx_desc_auto_clear = true, \
- .fixed_mclk = 0, \
- .mclk_multiple = I2S_MCLK_MULTIPLE_DEFAULT, \
- .bits_per_chan = I2S_BITS_PER_CHAN_32BIT, \
- }
- #endif
- esp_err_t esp_board_init(uint32_t sample_rate, int channel_format, int bits_per_chan);
- esp_err_t esp_audio_play(const int16_t* data, int length, uint32_t ticks_to_wait);
- int bsp_aec_get_frame_size(void);
- esp_err_t bsp_aec_process_frame(const int16_t *near_end,
- const int16_t *far_end,
- int16_t *processed);
- esp_err_t bsp_aec_reset(void);
- esp_err_t esp_get_feed_data(bool is_get_raw_channel, int16_t *buffer, int buffer_len);
- esp_err_t esp_audio_set_play_vol(int volume);
- esp_err_t esp_audio_get_play_vol(int *volume);
- i2c_master_bus_handle_t esp_ret_i2c_handle(void);
- esp_codec_dev_handle_t esp_ret_play_dev();
- #ifdef __cplusplus
- }
- #endif
|