boards/xtensa/esp32-lyrat: Add support for audio input

This commit is contained in:
Lucas Saavedra Vaz 2023-03-16 22:54:50 -03:00 committed by Alan Carvalho de Assis
parent 326261dd7d
commit 2d5a9e72b2
3 changed files with 133 additions and 11 deletions

View File

@ -69,7 +69,7 @@ int board_i2sdev_initialize(int port, bool enable_tx, bool enable_rx)
struct audio_lowerhalf_s *audio_i2s;
struct i2s_dev_s *i2s;
char devname[8];
int ret;
int ret = OK;
ainfo("Initializing I2S\n");

View File

@ -49,6 +49,8 @@
* Private Data
****************************************************************************/
static struct es8388_lower_s g_es8388_lower[2];
/****************************************************************************
* Public Functions
****************************************************************************/
@ -78,7 +80,6 @@ int esp32_es8388_initialize(int i2c_port, uint8_t i2c_addr, int i2c_freq,
{
struct audio_lowerhalf_s *es8388;
struct audio_lowerhalf_s *pcm;
struct es8388_lower_s *lower;
struct i2s_dev_s *i2s;
struct i2c_master_s *i2c;
static bool initialized = false;
@ -134,17 +135,14 @@ int esp32_es8388_initialize(int i2c_port, uint8_t i2c_addr, int i2c_freq,
}
#endif
/* Now we can use this I2S interface to initialize the ES8388 which
* will return an audio interface.
/* Now we can use this I2S interface to initialize the ES8388 output
* which will return an audio interface.
*/
lower = (struct es8388_lower_s *)
kmm_zalloc(sizeof(struct es8388_lower_s));
g_es8388_lower[0].address = i2c_addr;
g_es8388_lower[0].frequency = i2c_freq;
lower->address = i2c_addr,
lower->frequency = i2c_freq,
es8388 = es8388_initialize(i2c, i2s, lower);
es8388 = es8388_initialize(i2c, i2s, &g_es8388_lower[0]);
if (es8388 == NULL)
{
auderr("ERROR: Failed to initialize the ES8388\n");
@ -167,7 +165,7 @@ int esp32_es8388_initialize(int i2c_port, uint8_t i2c_addr, int i2c_freq,
/* Create a device name */
snprintf(devname, 12, "pcm%d", i2s_port);
snprintf(devname, sizeof(devname), "pcm%d", i2s_port);
/* Finally, we can register the PCM/ES8388/I2S audio device. */
@ -179,6 +177,35 @@ int esp32_es8388_initialize(int i2c_port, uint8_t i2c_addr, int i2c_freq,
goto errout;
}
/* Now we can use this I2S interface to initialize the ES8388 input
* which will return an audio interface.
*/
g_es8388_lower[1].address = i2c_addr;
g_es8388_lower[1].frequency = i2c_freq;
es8388 = es8388_initialize(i2c, i2s, &g_es8388_lower[1]);
if (es8388 == NULL)
{
auderr("ERROR: Failed to initialize the ES8388\n");
ret = -ENODEV;
goto errout;
}
/* Create a device name */
snprintf(devname, sizeof(devname), "pcm_in%d", i2s_port);
/* Finally, we can register the PCM/ES8388/I2S audio device. */
ret = audio_register(devname, es8388);
if (ret < 0)
{
auderr("ERROR: Failed to register /dev/%s device: %d\n",
devname, ret);
goto errout;
}
/* Now we are initialized */
initialized = true;

View File

@ -0,0 +1,95 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_ARCH_LEDS is not set
# CONFIG_AUDIO_FORMAT_MP3 is not set
# CONFIG_ESP32_I2S0_TX is not set
# CONFIG_ESP32_SPI2_DMA is not set
# CONFIG_NSH_ARGCAT is not set
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
CONFIG_ALLOW_BSD_COMPONENTS=y
CONFIG_ARCH="xtensa"
CONFIG_ARCH_BOARD="esp32-lyrat"
CONFIG_ARCH_BOARD_COMMON=y
CONFIG_ARCH_BOARD_ESP32_LYRAT=y
CONFIG_ARCH_CHIP="esp32"
CONFIG_ARCH_CHIP_ESP32=y
CONFIG_ARCH_CHIP_ESP32WROVER=y
CONFIG_ARCH_INTERRUPTSTACK=4096
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_XTENSA=y
CONFIG_AUDIO=y
CONFIG_AUDIOUTILS_MMLPARSER_LIB=y
CONFIG_AUDIO_BUFFER_NUMBYTES=4096
CONFIG_AUDIO_ES8388=y
CONFIG_AUDIO_EXCLUDE_FFORWARD=y
CONFIG_AUDIO_EXCLUDE_TONE=y
CONFIG_AUDIO_I2S=y
CONFIG_AUDIO_NUM_BUFFERS=4
CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BUILTIN=y
CONFIG_DEFAULT_TASK_STACKSIZE=4096
CONFIG_DEV_URANDOM=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_AUDIO=y
CONFIG_ESP32_I2C0=y
CONFIG_ESP32_I2C0_SCLPIN=23
CONFIG_ESP32_I2C0_SDAPIN=18
CONFIG_ESP32_I2S0=y
CONFIG_ESP32_I2S0_BCLKPIN=5
CONFIG_ESP32_I2S0_DATA_BIT_WIDTH_16BIT=y
CONFIG_ESP32_I2S0_DINPIN=35
CONFIG_ESP32_I2S0_MCLK=y
CONFIG_ESP32_I2S0_WSPIN=25
CONFIG_ESP32_I2S=y
CONFIG_ESP32_SPI2=y
CONFIG_ESP32_SPI2_CSPIN=13
CONFIG_ESP32_SPI2_MISOPIN=2
CONFIG_ESP32_SPI2_MOSIPIN=15
CONFIG_ESP32_UART0=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
CONFIG_FS_FAT=y
CONFIG_FS_PROCFS=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_I2C=y
CONFIG_I2S_DMADESC_NUM=4
CONFIG_IDLETHREAD_STACKSIZE=3072
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=2048
CONFIG_INTELHEX_BINARY=y
CONFIG_MMCSD=y
CONFIG_MM_REGIONS=3
CONFIG_NAME_MAX=48
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=300
CONFIG_NSH_MMCSDSPIPORTNO=2
CONFIG_NSH_READLINE=y
CONFIG_NXRECORDER_RECORDTHREAD_STACKSIZE=4096
CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=2048
CONFIG_PREALLOC_TIMERS=4
CONFIG_PTHREAD_MUTEX_TYPES=y
CONFIG_PTHREAD_STACK_DEFAULT=2048
CONFIG_RAM_SIZE=114688
CONFIG_RAM_START=0x20000000
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_HPWORKSTACKSIZE=2048
CONFIG_SCHED_LPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SIG_DEFAULT=y
CONFIG_START_DAY=6
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2011
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_NSH_STACKSIZE=2048
CONFIG_SYSTEM_NXRECORDER=y
CONFIG_TLS_TASK_NELEM=4
CONFIG_UART0_SERIAL_CONSOLE=y