Skip to content
This repository was archived by the owner on Apr 1, 2024. It is now read-only.

Commit 9f7e7c2

Browse files
committed
Support for Arduino ESP 3.0.0
1 parent 6001584 commit 9f7e7c2

File tree

6 files changed

+40
-17
lines changed

6 files changed

+40
-17
lines changed

src/AudioKitHAL.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct AudioKitConfig {
4141
/// @brief driver which selects the codec implementation: AUDIO_CODEC_ES8388_DEFAULT_HANDLE, AUDIO_CODEC_AC101_CODEC_HANDLE, AUDIO_CODEC_ES8311_DEFAULT_HANDLE, AUDIO_CODEC_ES7243_DEFAULT_HANDLE
4242
audio_hal_func_t driver = AUDIO_DRIVER;
4343

44-
i2s_port_t i2s_num = (i2s_port_t)pins.i2s_num;
44+
int i2s_num = pins.i2s_num;
4545
bool sd_active = true;
4646
bool auto_clear = true;
4747
bool use_apll = true;
@@ -291,7 +291,7 @@ class AudioKit {
291291
#if AUDIOKIT_ESP32_I2S && defined(ESP32)
292292
if (cfg.i2s_active) {
293293
// uninstall i2s driver
294-
i2s_driver_uninstall(cfg.i2s_num);
294+
i2s_driver_uninstall((i2s_port_t)cfg.i2s_num);
295295
}
296296
#endif
297297
// stop codec driver
@@ -343,7 +343,7 @@ class AudioKit {
343343
{
344344
KIT_LOGD("write: %zu", size);
345345
size_t bytes_written = 0;
346-
if (i2s_write(cfg.i2s_num, src, size, &bytes_written, ticks_to_wait) != ESP_OK) {
346+
if (i2s_write((i2s_port_t)cfg.i2s_num, src, size, &bytes_written, ticks_to_wait) != ESP_OK) {
347347
KIT_LOGE("i2s_write");
348348
}
349349
return bytes_written;
@@ -354,7 +354,7 @@ class AudioKit {
354354
{
355355
KIT_LOGD("read: %zu", size);
356356
size_t bytes_read = 0;
357-
if (i2s_read(cfg.i2s_num, dest, size, &bytes_read, ticks_to_wait) != ESP_OK) {
357+
if (i2s_read((i2s_port_t)cfg.i2s_num, dest, size, &bytes_read, ticks_to_wait) != ESP_OK) {
358358
KIT_LOGE("i2s_read");
359359
}
360360
return bytes_read;
@@ -383,7 +383,7 @@ class AudioKit {
383383
#if AUDIOKIT_ESP32_I2S && defined(ESP32)
384384
// update I2S
385385
if (cfg.i2s_active) {
386-
if (i2s_set_sample_rates(cfg.i2s_num, cfg.sampleRate()) != ESP_OK) {
386+
if (i2s_set_sample_rates((i2s_port_t)cfg.i2s_num, cfg.sampleRate()) != ESP_OK) {
387387
KIT_LOGE("i2s_set_sample_rates");
388388
result = false;
389389
}
@@ -636,8 +636,7 @@ class AudioKit {
636636
}
637637
#else
638638
#if defined(ARDUINO)
639-
#warning \
640-
"SPI initialization for the SD drive not supported - you might need to take care of this yourself"
639+
#warning "SPI initialization for the SD drive not supported - you might need to take care of this yourself"
641640
#endif
642641
cfg.sd_active = false;
643642
#endif
@@ -650,7 +649,7 @@ class AudioKit {
650649
KIT_LOGD("setupI2S");
651650
// setup i2s driver - with no queue
652651
i2s_config_t i2s_config = cfg.i2sConfig();
653-
if (i2s_driver_install(cfg.i2s_num, &i2s_config, 0, NULL) != ESP_OK) {
652+
if (i2s_driver_install((i2s_port_t)cfg.i2s_num, &i2s_config, 0, NULL) != ESP_OK) {
654653
KIT_LOGE("i2s_driver_install");
655654
return false;
656655
}
@@ -667,7 +666,7 @@ class AudioKit {
667666
KIT_LOGI("- mck_io_num: %d", pin_config.mck_io_num);
668667
#endif
669668

670-
if (i2s_set_pin(cfg.i2s_num, &pin_config) != ESP_OK) {
669+
if (i2s_set_pin((i2s_port_t)cfg.i2s_num, &pin_config) != ESP_OK) {
671670
KIT_LOGE("i2s_set_pin");
672671
return false;
673672
}

src/AudioKitSettings.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222

2323
#pragma once
24+
#include "esp_idf_version.h"
2425

2526
// Select your specific board
2627
#ifndef AUDIOKIT_BOARD
@@ -56,14 +57,19 @@
5657
# define WORKAROUND_ES8388_LINE1_GAIN 0
5758
#endif
5859

59-
// Special rules for IDF build
60-
#if defined(AUDIOKIT_USE_IDF)
60+
// Special rules for IDF build
61+
#if defined(AUDIOKIT_USE_IDF)
6162
#define AUDIOKIT_SETUP_SD 0
6263
#define AUDIOKIT_FREE_RTOS 1
6364
#define AUDIOKIT_ESP32_I2S 0
6465
#define AUDIOKIT_ESP32_AUDIOKIT_USE_WIRE 0
6566
#endif
6667

68+
// Special rules for IDF 5
69+
#if defined(ARDUINO) && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
70+
#define AUDIOKIT_ESP32_I2S 0
71+
#endif
72+
6773
// 1 = Using Arduino Wire Library; 0 = Use ESP32 I2C API
6874
#ifndef AUDIOKIT_USE_WIRE
6975
#define AUDIOKIT_USE_WIRE 1

src/audio_driver/es7243/es7243.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ esp_err_t es7243_adc_set_addr(int addr)
8181

8282
static esp_err_t es7243_mclk_active(uint8_t mclk_gpio)
8383
{
84-
#ifdef ESP32
84+
#ifdef ARDUINO
85+
pinMode(mclk_gpio, OUTPUT);
86+
#elif defined(ESP32)
8587
gpio_pad_select_gpio(mclk_gpio);
8688
gpio_set_direction(mclk_gpio, GPIO_MODE_OUTPUT);
87-
#else
88-
pinMode(mclk_gpio, OUTPUT);
8989
#endif
9090
/*
9191
Before initializing es7243, it is necessary to output

src/audio_hal/audiokit_board.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include "driver/spi_slave.h"
1515
#include "driver/spi_master.h"
1616
#include "driver/i2c.h"
17-
#include "driver/i2s.h"
1817
#endif
18+
1919
#include <string.h>
2020
#include "AudioKitSettings.h"
2121
#include "audio_hal/audio_error.h"
@@ -157,7 +157,7 @@ class board_driver {
157157
return ESP_OK;
158158
}
159159

160-
esp_err_t get_i2s_pins(i2s_port_t port, i2s_pin_config_t* i2s_config)
160+
esp_err_t get_i2s_pins(int port, i2s_pin_config_t* i2s_config)
161161
{
162162
AUDIO_NULL_CHECK(TAG, i2s_config, return ESP_FAIL);
163163
if (port == I2S_NUM_0) {
@@ -188,6 +188,7 @@ class board_driver {
188188
return ESP_OK;
189189
}
190190

191+
191192
esp_err_t get_spi_pins(
192193
spi_bus_config_t* spi_config, spi_device_interface_config_t* spi_device_interface_config)
193194
{

src/audio_hal/common_defines.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# include "audio_hal/audio_system.h"
1515
# include "audio_hal/audio_type_def.h"
1616
# include "audio_hal/audio_version.h"
17-
# include "driver/i2s.h"
1817
# if !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32S2) \
1918
&& !defined(CONFIG_IDF_TARGET_ESP32C3)
2019
SPIClass SPI_VSPI(VSPI);

src/audio_hal/driver_pins.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,31 @@
88
* @copyright Copyright (c) 2021
99
*/
1010
#pragma once
11+
1112
#include "audio_hal/audio_gpio.h"
1213
#ifdef ESP32
1314
#include "hal/spi_types.h"
1415
#include "driver/spi_slave.h"
1516
#include "driver/spi_master.h"
1617
#include "driver/i2c.h"
18+
19+
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
1720
#include "driver/i2s.h"
21+
#else
22+
#define I2S_NUM_0 0
23+
#ifndef I2S_PIN_NO_CHANGE
24+
#define I2S_PIN_NO_CHANGE -1
25+
#endif
26+
typedef struct {
27+
int mck_io_num;
28+
int bck_io_num; /*!< BCK in out pin*/
29+
int ws_io_num; /*!< WS in out pin*/
30+
int data_out_num; /*!< DATA out pin*/
31+
int data_in_num; /*!< DATA in pin*/
32+
} i2s_pin_config_t;
33+
34+
#endif
35+
1836
#endif
1937

2038
#ifdef __cplusplus

0 commit comments

Comments
 (0)