|
|
@ -1,6 +1,6 @@ |
|
|
|
#include <cstdint> |
|
|
|
|
|
|
|
#include <stdio.h> |
|
|
|
|
|
|
|
#include <dirent.h> |
|
|
|
#include <dirent.h> |
|
|
|
|
|
|
|
#include <stdio.h> |
|
|
|
|
|
|
|
#include <cstdint> |
|
|
|
|
|
|
|
|
|
|
|
#include "battery.h" |
|
|
|
#include "battery.h" |
|
|
|
#include "dac.h" |
|
|
|
#include "dac.h" |
|
|
@ -21,9 +21,9 @@ |
|
|
|
#include "hal/spi_types.h" |
|
|
|
#include "hal/spi_types.h" |
|
|
|
#include "storage.h" |
|
|
|
#include "storage.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "audio_common.h" |
|
|
|
#include "audio_element.h" |
|
|
|
#include "audio_element.h" |
|
|
|
#include "audio_pipeline.h" |
|
|
|
#include "audio_pipeline.h" |
|
|
|
#include "audio_common.h" |
|
|
|
|
|
|
|
#include "fatfs_stream.h" |
|
|
|
#include "fatfs_stream.h" |
|
|
|
#include "i2s_stream.h" |
|
|
|
#include "i2s_stream.h" |
|
|
|
#include "mp3_decoder.h" |
|
|
|
#include "mp3_decoder.h" |
|
|
@ -53,7 +53,8 @@ esp_err_t init_i2c(void) { |
|
|
|
.scl_io_num = I2C_SCL_IO, |
|
|
|
.scl_io_num = I2C_SCL_IO, |
|
|
|
.sda_pullup_en = GPIO_PULLUP_ENABLE, |
|
|
|
.sda_pullup_en = GPIO_PULLUP_ENABLE, |
|
|
|
.scl_pullup_en = GPIO_PULLUP_ENABLE, |
|
|
|
.scl_pullup_en = GPIO_PULLUP_ENABLE, |
|
|
|
.master = { |
|
|
|
.master = |
|
|
|
|
|
|
|
{ |
|
|
|
.clk_speed = I2C_CLOCK_HZ, |
|
|
|
.clk_speed = I2C_CLOCK_HZ, |
|
|
|
}, |
|
|
|
}, |
|
|
|
// No requirements for the clock.
|
|
|
|
// No requirements for the clock.
|
|
|
@ -93,8 +94,7 @@ esp_err_t init_spi(void) { |
|
|
|
return ESP_OK; |
|
|
|
return ESP_OK; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
extern "C" void app_main(void) |
|
|
|
extern "C" void app_main(void) { |
|
|
|
{ |
|
|
|
|
|
|
|
ESP_LOGI(TAG, "Initialising peripherals"); |
|
|
|
ESP_LOGI(TAG, "Initialising peripherals"); |
|
|
|
|
|
|
|
|
|
|
|
ESP_ERROR_CHECK(gpio_install_isr_service(ESP_INTR_FLAG_LOWMED)); |
|
|
|
ESP_ERROR_CHECK(gpio_install_isr_service(ESP_INTR_FLAG_LOWMED)); |
|
|
@ -153,12 +153,14 @@ extern "C" void app_main(void) |
|
|
|
audio_pipeline_handle_t pipeline; |
|
|
|
audio_pipeline_handle_t pipeline; |
|
|
|
audio_element_handle_t fatfs_stream_reader, i2s_stream_writer, audio_decoder; |
|
|
|
audio_element_handle_t fatfs_stream_reader, i2s_stream_writer, audio_decoder; |
|
|
|
|
|
|
|
|
|
|
|
audio_pipeline_cfg_t pipeline_config = audio_pipeline_cfg_t(DEFAULT_AUDIO_PIPELINE_CONFIG()); |
|
|
|
audio_pipeline_cfg_t pipeline_config = |
|
|
|
|
|
|
|
audio_pipeline_cfg_t(DEFAULT_AUDIO_PIPELINE_CONFIG()); |
|
|
|
pipeline = audio_pipeline_init(&pipeline_config); |
|
|
|
pipeline = audio_pipeline_init(&pipeline_config); |
|
|
|
assert(pipeline != NULL); |
|
|
|
assert(pipeline != NULL); |
|
|
|
ESP_LOGI(TAG, "Made pipeline okay."); |
|
|
|
ESP_LOGI(TAG, "Made pipeline okay."); |
|
|
|
|
|
|
|
|
|
|
|
fatfs_stream_cfg_t fatfs_stream_config = fatfs_stream_cfg_t(FATFS_STREAM_CFG_DEFAULT()); |
|
|
|
fatfs_stream_cfg_t fatfs_stream_config = |
|
|
|
|
|
|
|
fatfs_stream_cfg_t(FATFS_STREAM_CFG_DEFAULT()); |
|
|
|
fatfs_stream_config.type = AUDIO_STREAM_READER; |
|
|
|
fatfs_stream_config.type = AUDIO_STREAM_READER; |
|
|
|
fatfs_stream_reader = fatfs_stream_init(&fatfs_stream_config); |
|
|
|
fatfs_stream_reader = fatfs_stream_init(&fatfs_stream_config); |
|
|
|
assert(fatfs_stream_reader != NULL); |
|
|
|
assert(fatfs_stream_reader != NULL); |
|
|
@ -185,19 +187,17 @@ extern "C" void app_main(void) |
|
|
|
assert(i2s_stream_writer != NULL); |
|
|
|
assert(i2s_stream_writer != NULL); |
|
|
|
ESP_LOGI(TAG, "Made i2s stream okay."); |
|
|
|
ESP_LOGI(TAG, "Made i2s stream okay."); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ESP_LOGI(TAG, "Init i2s pins"); |
|
|
|
ESP_LOGI(TAG, "Init i2s pins"); |
|
|
|
i2s_pin_config_t pin_config = { |
|
|
|
i2s_pin_config_t pin_config = {.mck_io_num = GPIO_NUM_0, |
|
|
|
.mck_io_num = GPIO_NUM_0, |
|
|
|
|
|
|
|
.bck_io_num = GPIO_NUM_26, |
|
|
|
.bck_io_num = GPIO_NUM_26, |
|
|
|
.ws_io_num = GPIO_NUM_27, |
|
|
|
.ws_io_num = GPIO_NUM_27, |
|
|
|
.data_out_num = GPIO_NUM_5, |
|
|
|
.data_out_num = GPIO_NUM_5, |
|
|
|
.data_in_num = I2S_PIN_NO_CHANGE |
|
|
|
.data_in_num = I2S_PIN_NO_CHANGE}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ESP_ERROR_CHECK(i2s_set_pin(port, &pin_config)); |
|
|
|
ESP_ERROR_CHECK(i2s_set_pin(port, &pin_config)); |
|
|
|
|
|
|
|
|
|
|
|
mp3_decoder_cfg_t decoder_config = mp3_decoder_cfg_t(DEFAULT_MP3_DECODER_CONFIG()); |
|
|
|
mp3_decoder_cfg_t decoder_config = |
|
|
|
|
|
|
|
mp3_decoder_cfg_t(DEFAULT_MP3_DECODER_CONFIG()); |
|
|
|
audio_decoder = mp3_decoder_init(&decoder_config); |
|
|
|
audio_decoder = mp3_decoder_init(&decoder_config); |
|
|
|
assert(audio_decoder != NULL); |
|
|
|
assert(audio_decoder != NULL); |
|
|
|
ESP_LOGI(TAG, "Made mp3 decoder okay."); |
|
|
|
ESP_LOGI(TAG, "Made mp3 decoder okay."); |
|
|
|