mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 14:17:13 +08:00
esp32-sparrow-kit: Add I2S support for the board's microphone
The board's microphone uses 24-bit i2s and this commit also fixes the segmentation fault caused by the audio buffer overflow. arch/xtensa/src/esp32/esp32_i2s.c: Fix bug regarding 24-bit audio and add AUDIOIOC_STOP to ioctl drivers/audio/audio_i2s.c: Report number of channels on AUDIOIOC_GETCAPS in boards/xtensa/esp32/esp32-sparrow-kit: /configs/nsh/defconfig: Add I2S configs /src/esp32-sparrow-kit.h: Add the signature of esp32_i2sdev_initialize() /src/esp32_bringup.c: Add call to esp32_i2sdev_initialize() Signed-off-by: simonatoaca <simona.alexandra2000@gmail.com>
This commit is contained in:
@@ -22,12 +22,26 @@ CONFIG_ARCH_CHIP_ESP32=y
|
||||
CONFIG_ARCH_CHIP_ESP32WROVER=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_AUDIO=y
|
||||
CONFIG_AUDIO_DMA=y
|
||||
CONFIG_AUDIO_FORMAT_RAW=y
|
||||
CONFIG_AUDIO_I2S=y
|
||||
CONFIG_BME680_ENABLE_IIR_FILTER=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DMA=y
|
||||
CONFIG_DMA_LINK=y
|
||||
CONFIG_DRIVERS_AUDIO=y
|
||||
CONFIG_DRIVERS_VIDEO=y
|
||||
CONFIG_ESP32_I2C0=y
|
||||
CONFIG_ESP32_I2C0_SDAPIN=21
|
||||
CONFIG_ESP32_I2S0=y
|
||||
CONFIG_ESP32_I2S0_BCLKPIN=25
|
||||
CONFIG_ESP32_I2S0_DATA_BIT_WIDTH_24BIT=y
|
||||
CONFIG_ESP32_I2S0_DINPIN=26
|
||||
CONFIG_ESP32_I2S0_SAMPLE_RATE=8000
|
||||
CONFIG_ESP32_I2S0_WSPIN=27
|
||||
CONFIG_ESP32_I2S=y
|
||||
CONFIG_ESP32_LEDC=y
|
||||
CONFIG_ESP32_LEDC_CHANNEL0_PIN=14
|
||||
CONFIG_ESP32_LEDC_CHANNEL1_PIN=13
|
||||
@@ -47,6 +61,7 @@ CONFIG_FS_FAT=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_I2S_DMADESC_NUM=4
|
||||
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
@@ -75,6 +90,7 @@ CONFIG_RGBLED_INVERT=y
|
||||
CONFIG_RGBLED_LIGHTNESS_CORRECTION=y
|
||||
CONFIG_RGBLED_PWM_FREQ=200
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SENSORS=y
|
||||
CONFIG_SENSORS_BME680=y
|
||||
|
||||
@@ -106,6 +106,28 @@ int esp32_mmcsd_initialize(int minor);
|
||||
|
||||
int esp32_spiflash_init(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_i2sdev_initialize
|
||||
*
|
||||
* Description:
|
||||
* This function is called by platform-specific, setup logic to configure
|
||||
* and register the generic I2S audio driver. This function will register
|
||||
* the driver as /dev/audio/pcm[x] where x is determined by the I2S port
|
||||
* number.
|
||||
*
|
||||
* Input Parameters:
|
||||
* port - The I2S port used for the device
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success. Otherwise, a negated errno value is
|
||||
* returned to indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined CONFIG_ESP32_I2S0 || defined CONFIG_ESP32_I2S1
|
||||
int board_i2sdev_initialize(int port);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_gpio_init
|
||||
****************************************************************************/
|
||||
|
||||
@@ -80,6 +80,10 @@
|
||||
# include "esp32_board_i2c.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32_I2S
|
||||
# include "esp32_i2s.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SENSORS_BMP180
|
||||
# include "esp32_bmp180.h"
|
||||
#endif
|
||||
@@ -343,6 +347,23 @@ int esp32_bringup(void)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32_I2S
|
||||
|
||||
#ifdef CONFIG_ESP32_I2S0
|
||||
|
||||
/* Configure I2S generic audio on I2S0 */
|
||||
|
||||
ret = board_i2sdev_initialize(ESP32_I2S0);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize I2S%d driver: %d\n",
|
||||
CONFIG_ESP32_I2S0, ret);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ESP32_I2S0 */
|
||||
|
||||
#endif /* CONFIG_ESP32_I2S */
|
||||
|
||||
#ifdef CONFIG_SENSORS_BMP180
|
||||
/* Try to register BMP180 device in I2C0 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user