pschatzmann / arduino-audiokit

Arduino ADF/Audiokit HAL (support for ESP32-A1S, AI-Thinker, LyraT for ES7148, ES7210, ES7243, ES8311, ES8347, ES8388, TAS5805M, AC101 audio chips)
GNU General Public License v3.0
157 stars 42 forks source link

How to set pin for ES8311 #68

Closed uldara1 closed 1 year ago

uldara1 commented 1 year ago

dear sir. i have esp32S3 connected with es8311 module. how to assigned pin for I2S ?

my mapping pin // I2C pin

define GPIO_I2C_SCL (GPIO_NUM_39)

define GPIO_I2C_SDA (GPIO_NUM_40)

// I2S pin

define GPIO_I2S_MCLK (GPIO_NUM_45)

define GPIO_I2S_SCLK (GPIO_NUM_42)

define GPIO_I2S_LRCK (GPIO_NUM_48)

define GPIO_I2S_DIN (GPIO_NUM_41)

define GPIO_I2S_DOUT (GPIO_NUM_47)

thank

pschatzmann commented 1 year ago

You can find the pin assignments in the Wiki!

So far only the lyrat_mini_v1_1 was using the es8311, but this was with an ESP32! Therefore I created a new generic variant 11 for ES8311 where you can reassign your own pins...

uldara1 commented 1 year ago

Dear @pschatzmann

i have try your output code but i have error please check

/Users/uldara/Documents/Arduino/libraries/audiokit/src/audio_board/generic_es8311/board_pins_config.c:30:
/Users/uldara/Documents/Arduino/libraries/audiokit/src/audio_board/generic_es8311/board_def.h:163:8: error: unknown type name 'audio_hal_func_t'
 extern audio_hal_func_t AUDIO_CODEC_ES8311_DEFAULT_HANDLE;
        ^~~~~~~~~~~~~~~~
/Users/uldara/Documents/Arduino/libraries/audiokit/src/audio_board/generic_es8311/board_def.h:164:8: error: unknown type name 'audio_hal_func_t'
 extern audio_hal_func_t AUDIO_CODEC_ES7243_DEFAULT_HANDLE;
        ^~~~~~~~~~~~~~~~
exit status 1
Error compiling for board ESP32S3 Dev Module.
pschatzmann commented 1 year ago

I could reproduce your issue. The correction has been committed...

uldara1 commented 1 year ago

dear @pschatzmann i have try your code already compile without error. but seem not work even input or output my device is esp32s3 , your library support for ESP32S3 or not ? thank

pschatzmann commented 1 year ago

I expect that it will only run if you define the proper pins which are relevant for the esp32s3! Please use kit_custom_pins.h or platformio.h as described in the Wiki if you cannot use the standard ESP32 pins.

Since I do not have any ES8311 I can't test this myself...

uldara1 commented 1 year ago

dear @pschatzmann

i have try with es8311 and es8388 please check my configure correct or not

define AUDIOKIT_BOARD 10

for generic_es8388 board_def.h

for other don't use pin i replace by -1

ZX3D95CE01S-AR.pdf

#ifndef _AUDIO_BOARD_DEFINITION_H_
#define _AUDIO_BOARD_DEFINITION_H_

#if __has_include("kit_custom_pins.h") 
# include "kit_custom_pins.h"
#endif
#include "audio_hal/audio_hal.h" // for audio_hal_func_t

#define ES8388

// SD Card
#ifndef PIN_AUDIO_KIT_SD_CARD_CS
#  define PIN_AUDIO_KIT_SD_CARD_CS -1
#endif
#ifndef PIN_AUDIO_KIT_SD_CARD_MISO
#  define PIN_AUDIO_KIT_SD_CARD_MISO -1
#endif
#ifndef PIN_AUDIO_KIT_SD_CARD_MOSI
#  define PIN_AUDIO_KIT_SD_CARD_MOSI -1
#endif
#ifndef PIN_AUDIO_KIT_SD_CARD_CLK
#  define PIN_AUDIO_KIT_SD_CARD_CLK  -1
#endif

// I2S
#ifndef PIN_I2S_AUDIO_KIT_MCLK
#  define PIN_I2S_AUDIO_KIT_MCLK 38
#endif
#ifndef PIN_I2S_AUDIO_KIT_BCK
#  define PIN_I2S_AUDIO_KIT_BCK 48
#endif
#ifndef PIN_I2S_AUDIO_KIT_WS
#  define PIN_I2S_AUDIO_KIT_WS 47
#endif
#ifndef PIN_I2S_AUDIO_KIT_DATA_OUT
#  define PIN_I2S_AUDIO_KIT_DATA_OUT 21
#endif
#ifndef PIN_I2S_AUDIO_KIT_DATA_IN
#  define PIN_I2S_AUDIO_KIT_DATA_IN 39
#endif

// I2C
#ifndef I2C_MASTER_NUM
#  define I2C_MASTER_NUM I2C_NUM_0 /*!< I2C port number for master dev */
#endif
#ifndef I2C_MASTER_SCL_IO
#  define I2C_MASTER_SCL_IO 6   
#endif
#ifndef I2C_MASTER_SDA_IO
#  define I2C_MASTER_SDA_IO 7   
#endif
#ifndef I2C_MASTER_ADDR
#  define I2C_MASTER_ADDR 0x10
#endif

#ifndef SDCARD_OPEN_FILE_NUM_MAX
#  define SDCARD_OPEN_FILE_NUM_MAX  5
#endif
#ifndef SDCARD_INTR_GPIO
#  define SDCARD_INTR_GPIO          -1
#endif

#ifndef PIN_KEY1
#  define PIN_KEY1 -1
#endif
#ifndef PIN_KEY2
#  define PIN_KEY2 -1
#endif
#ifndef PIN_KEY3
#  define PIN_KEY3 -1
#endif
#ifndef PIN_KEY4
#  define PIN_KEY4 -1
#endif
#ifndef PIN_KEY5
#  define PIN_KEY5 -1
#endif
#ifndef PIN_KEY6
#  define PIN_KEY6 -1
#endif

#define BUTTON_REC_ID             PIN_KEY1
#define BUTTON_MODE_ID            PIN_KEY2
#define BUTTON_SET_ID             PIN_KEY3
#define BUTTON_PLAY_ID            PIN_KEY4
#define BUTTON_VOLDOWN_ID         PIN_KEY5
#define BUTTON_VOLUP_ID           PIN_KEY6

#ifndef AUXIN_DETECT_GPIO
#  define AUXIN_DETECT_GPIO         -1
#endif
#ifndef HEADPHONE_DETECT
#  define HEADPHONE_DETECT          -1
#endif
#ifndef PA_ENABLE_GPIO
#  define PA_ENABLE_GPIO            -1
#endif

#ifndef GREEN_LED_GPIO
#  define GREEN_LED_GPIO            -1
#endif

extern audio_hal_func_t AUDIO_CODEC_ES8388_DEFAULT_HANDLE;

#define AUDIO_CODEC_DEFAULT_CONFIG(){                   \
        .adc_input  = AUDIO_HAL_ADC_INPUT_LINE1,        \
        .dac_output = AUDIO_HAL_DAC_OUTPUT_ALL,         \
        .codec_mode = AUDIO_HAL_CODEC_MODE_BOTH,        \
        .i2s_iface = {                                  \
            .mode = AUDIO_HAL_MODE_SLAVE,               \
            .fmt = AUDIO_HAL_I2S_NORMAL,                \
            .samples = AUDIO_HAL_48K_SAMPLES,           \
            .bits = AUDIO_HAL_BIT_LENGTH_16BITS,        \
        },                                              \
};

#ifndef INPUT_KEY_NUM
#  define   INPUT_KEY_NUM     -1
#endif

#define INPUT_KEY_DEFAULT_INFO() {                      \
     {                                                  \
        .type = PERIPH_ID_BUTTON,                       \
        .user_id = INPUT_KEY_USER_ID_REC,               \
        .act_id = BUTTON_REC_ID,                        \
    },                                                  \
    {                                                   \
        .type = PERIPH_ID_BUTTON,                       \
        .user_id = INPUT_KEY_USER_ID_MODE,              \
        .act_id = BUTTON_MODE_ID,                       \
    },                                                  \
    {                                                   \
        .type = PERIPH_ID_TOUCH,                        \
        .user_id = INPUT_KEY_USER_ID_SET,               \
        .act_id = BUTTON_SET_ID,                        \
    },                                                  \
    {                                                   \
        .type = PERIPH_ID_TOUCH,                        \
        .user_id = INPUT_KEY_USER_ID_PLAY,              \
        .act_id = BUTTON_PLAY_ID,                       \
    },                                                  \
    {                                                   \
        .type = PERIPH_ID_TOUCH,                        \
        .user_id = INPUT_KEY_USER_ID_VOLUP,             \
        .act_id = BUTTON_VOLUP_ID,                      \
    },                                                  \
    {                                                   \
        .type = PERIPH_ID_TOUCH,                        \
        .user_id = INPUT_KEY_USER_ID_VOLDOWN,           \
        .act_id = BUTTON_VOLDOWN_ID,                    \
    }                                                   \
}

#endif

thank you

pschatzmann commented 1 year ago

Now you have me totally confused. You were writing that you use an ES8311 and send me a drawing with an ES8388!

I assume that you use Arduino and the defines you above are for the kit_custom_pins.h. Please remove all the ifdefs and and make sure that you include only pins which are overwritable as the example below. If you do not use any SD card, deactivate in the AudioKitSettings.h. I am not sure if the proposal below (to add it to kit_custom_pins.h) is working so you will need to test it.

You were never writing what error message you were getting!

To debug the functionlalty

Did you test with an oscilloscope that you are getting a signal on the relevant pins ?

//content of kit_custom_pins.h
#pragma once

#define AUDIOKIT_SETUP_SD 0

// I2S
#  define PIN_I2S_AUDIO_KIT_MCLK 38
#  define PIN_I2S_AUDIO_KIT_BCK 48
#  define PIN_I2S_AUDIO_KIT_WS 47
#  define PIN_I2S_AUDIO_KIT_DATA_OUT 21
#  define PIN_I2S_AUDIO_KIT_DATA_IN 39

// I2C
#  define I2C_MASTER_NUM I2C_NUM_0 /*!< I2C port number for master dev */
#  define I2C_MASTER_SCL_IO 6   
#  define I2C_MASTER_SDA_IO 7   

// setting this to -1 will not disturb
#  define PIN_KEY1 -1
#  define PIN_KEY2 -1
#  define PIN_KEY3 -1
#  define PIN_KEY4 -1
#  define PIN_KEY5 -1
#  define PIN_KEY6 -1

// Setting below to -1 should not create any problems as well
#  define AUXIN_DETECT_GPIO         -1
#  define HEADPHONE_DETECT          -1
#  define PA_ENABLE_GPIO            -1
#  define GREEN_LED_GPIO            -1
uldara1 commented 1 year ago

dear @pschatzmann it working now thank you

pschatzmann commented 1 year ago

What was the problem ?

uldara1 commented 1 year ago

@pschatzmann I swapped dio and dout pin