mirror of
https://github.com/apache/nuttx.git
synced 2026-05-24 16:11:56 +08:00
esp32s3-devkit: Provide audio support for ESP32-S3-DevKitC-1
Provide initial support for audio through the I2S peripheral to the CS4344 audio codec on ESP32-S3-DevKitC-1 board. Please check documentation for usage examples.
This commit is contained in:
committed by
Xiang Xiao
parent
8a51534903
commit
c92b3a90ac
@@ -40,6 +40,14 @@ ifeq ($(CONFIG_I2C_DRIVER),y)
|
||||
CSRCS += esp32s3_board_i2c.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP32S3_I2S),y)
|
||||
CSRCS += esp32s3_board_i2s.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_AUDIO_CS4344),y)
|
||||
CSRCS += esp32s3_cs4344.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_BMP180),y)
|
||||
CSRCS += esp32s3_board_bmp180.c
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s3/common/src/esp32s3_board_i2s.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/audio/audio.h>
|
||||
#include <nuttx/audio/audio_i2s.h>
|
||||
#include <nuttx/audio/i2s.h>
|
||||
#include <nuttx/audio/pcm.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "esp32s3_i2s.h"
|
||||
|
||||
#if (defined(CONFIG_ESP32S3_I2S0) && !defined(CONFIG_AUDIO_CS4344)) || \
|
||||
defined(CONFIG_ESP32S3_I2S1)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* 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
|
||||
* enable_tx - Register device as TX if true
|
||||
* enable_rx - Register device as RX if true
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success. Otherwise, a negated errno value is
|
||||
* returned to indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
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;
|
||||
|
||||
ainfo("Initializing I2S\n");
|
||||
|
||||
i2s = esp32s3_i2sbus_initialize(port);
|
||||
|
||||
#ifdef CONFIG_AUDIO_I2SCHAR
|
||||
ret = i2schar_register(i2s, port);
|
||||
if (ret < 0)
|
||||
{
|
||||
aerr("ERROR: i2schar_register failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (enable_tx)
|
||||
{
|
||||
/* Initialize audio output */
|
||||
|
||||
audio_i2s = audio_i2s_initialize(i2s, true);
|
||||
|
||||
if (audio_i2s == NULL)
|
||||
{
|
||||
auderr("ERROR: Failed to initialize I2S audio output\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
snprintf(devname, sizeof(devname), "pcm%d", port);
|
||||
|
||||
/* If nxlooper is selected, the playback buffer is not rendered as
|
||||
* a WAV file. Therefore, PCM decode will fail while processing such
|
||||
* output buffer. In such a case, we bypass the PCM decode.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_NXLOOPER
|
||||
ret = audio_register(devname, audio_i2s);
|
||||
#else
|
||||
struct audio_lowerhalf_s *pcm;
|
||||
|
||||
pcm = pcm_decode_initialize(audio_i2s);
|
||||
|
||||
if (pcm == NULL)
|
||||
{
|
||||
auderr("ERROR: Failed create the PCM decoder\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = audio_register(devname, pcm);
|
||||
#endif /* CONFIG_SYSTEM_NXLOOPER */
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
auderr("ERROR: Failed to register /dev/%s device: %d\n",
|
||||
devname, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (enable_rx)
|
||||
{
|
||||
/* Initialize audio input */
|
||||
|
||||
audio_i2s = audio_i2s_initialize(i2s, false);
|
||||
|
||||
if (audio_i2s == NULL)
|
||||
{
|
||||
auderr("ERROR: Failed to initialize I2S audio input\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
snprintf(devname, sizeof(devname), "pcm_in%d", port);
|
||||
|
||||
ret = audio_register(devname, audio_i2s);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
auderr("ERROR: Failed to register /dev/%s device: %d\n",
|
||||
devname, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* (CONFIG_ESP32S3_I2S) && !(CONFIG_AUDIO_CS4344) */
|
||||
@@ -0,0 +1,151 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s3/common/src/esp32s3_cs4344.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <debug.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/audio/i2s.h>
|
||||
#include <nuttx/audio/pcm.h>
|
||||
#include <nuttx/audio/cs4344.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "esp32s3_i2s.h"
|
||||
|
||||
#if defined(CONFIG_ESP32S3_I2S) && defined(CONFIG_AUDIO_CS4344)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s3_cs4344_initialize
|
||||
*
|
||||
* Description:
|
||||
* This function is called by platform-specific, setup logic to configure
|
||||
* and register the CS4344 device. 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int esp32s3_cs4344_initialize(int port)
|
||||
{
|
||||
struct audio_lowerhalf_s *cs4344;
|
||||
struct audio_lowerhalf_s *pcm;
|
||||
struct i2s_dev_s *i2s;
|
||||
static bool initialized = false;
|
||||
int ret;
|
||||
|
||||
/* Have we already initialized? Since we are already initialized we must
|
||||
* prevent multiple initializations.
|
||||
*/
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
/* Get an instance of the I2S interface for the CS4344 data channel */
|
||||
|
||||
i2s = esp32s3_i2sbus_initialize(port);
|
||||
if (!i2s)
|
||||
{
|
||||
auderr("ERROR: Failed to initialize I2S%d\n", port);
|
||||
ret = -ENODEV;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Check wheter to enable a simple character driver that supports I2S
|
||||
* transfers via a read() and write(). The intent of this driver is to
|
||||
* support I2S testing. It is not an audio driver but does conform to
|
||||
* some of the buffer management heuristics of an audio driver. It is
|
||||
* not suitable for use in any real driver application in its current
|
||||
* form. The i2schar driver will be initialized at /dev/i2schar0
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_AUDIO_I2SCHAR
|
||||
ret = i2schar_register(i2s, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
auderr("ERROR: i2schar_register failed: %d\n", ret);
|
||||
goto errout;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now we can use this I2S interface to initialize the CS4344 which
|
||||
* will return an audio interface.
|
||||
*/
|
||||
|
||||
cs4344 = cs4344_initialize(i2s);
|
||||
if (!cs4344)
|
||||
{
|
||||
auderr("ERROR: Failed to initialize the CS4344\n");
|
||||
ret = -ENODEV;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* No we can embed the CS4344/I2S conglomerate into a PCM decoder
|
||||
* instance so that we will have a PCM front end for the the CS4344
|
||||
* driver.
|
||||
*/
|
||||
|
||||
pcm = pcm_decode_initialize(cs4344);
|
||||
if (!pcm)
|
||||
{
|
||||
auderr("ERROR: Failed create the PCM decoder\n");
|
||||
ret = -ENODEV;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Finally, we can register the PCM/CS4344/I2S audio device */
|
||||
|
||||
ret = audio_register("pcm0", pcm);
|
||||
if (ret < 0)
|
||||
{
|
||||
auderr("ERROR: Failed to register /dev/pcm0 device: %d\n", ret);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Now we are initialized */
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
||||
errout:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ESP32S3_I2S && CONFIG_AUDIO_CS4344 */
|
||||
@@ -0,0 +1,104 @@
|
||||
#
|
||||
# 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_ESP32S3_I2S0_RX is not set
|
||||
# CONFIG_NDEBUG 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="esp32s3-devkit"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32S3_DEVKIT=y
|
||||
CONFIG_ARCH_CHIP="esp32s3"
|
||||
CONFIG_ARCH_CHIP_ESP32S3=y
|
||||
CONFIG_ARCH_CHIP_ESP32S3WROOM1=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_AUDIO=y
|
||||
CONFIG_AUDIO_CS4344=y
|
||||
CONFIG_AUDIO_EXCLUDE_BALANCE=y
|
||||
CONFIG_AUDIO_EXCLUDE_FFORWARD=y
|
||||
CONFIG_AUDIO_EXCLUDE_TONE=y
|
||||
CONFIG_AUDIO_EXCLUDE_VOLUME=y
|
||||
CONFIG_AUDIO_I2SCHAR=y
|
||||
CONFIG_AUDIO_NUM_BUFFERS=4
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_CS4344_INFLIGHT=4
|
||||
CONFIG_CS4344_NUM_BUFFERS=2
|
||||
CONFIG_CS4344_WORKER_STACKSIZE=2048
|
||||
CONFIG_DRIVERS_AUDIO=y
|
||||
CONFIG_DRIVERS_IEEE80211=y
|
||||
CONFIG_DRIVERS_WIRELESS=y
|
||||
CONFIG_ESP32S3_I2S0=y
|
||||
CONFIG_ESP32S3_I2S0_BCLKPIN=16
|
||||
CONFIG_ESP32S3_I2S0_DOUTPIN=6
|
||||
CONFIG_ESP32S3_I2S0_MCLK=y
|
||||
CONFIG_ESP32S3_I2S0_MCLKPIN=5
|
||||
CONFIG_ESP32S3_I2S0_WSPIN=7
|
||||
CONFIG_ESP32S3_I2S=y
|
||||
CONFIG_ESP32S3_SPIFLASH=y
|
||||
CONFIG_ESP32S3_SPIFLASH_SPIFFS=y
|
||||
CONFIG_ESP32S3_UART0=y
|
||||
CONFIG_ESP32S3_WIFI=y
|
||||
CONFIG_EXAMPLES_RANDOM=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_I2S_DMADESC_NUM=4
|
||||
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_IOB_NBUFFERS=124
|
||||
CONFIG_IOB_THROTTLE=24
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NETDEV_PHY_IOCTL=y
|
||||
CONFIG_NETDEV_WIRELESS_IOCTL=y
|
||||
CONFIG_NETUTILS_CJSON=y
|
||||
CONFIG_NET_BROADCAST=y
|
||||
CONFIG_NET_ETH_PKTSIZE=1518
|
||||
CONFIG_NET_ICMP=y
|
||||
CONFIG_NET_ICMP_SOCKET=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_TCP_DELAYED_ACK=y
|
||||
CONFIG_NET_TCP_WRITE_BUFFERS=y
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NET_UDP_WRITE_BUFFERS=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NXPLAYER_HTTP_STREAMING_SUPPORT=y
|
||||
CONFIG_NXPLAYER_MAINTHREAD_STACKSIZE=4096
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PTHREAD_MUTEX_TYPES=y
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SPIFFS_NAME_MAX=128
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_SYSLOG_BUFFER=y
|
||||
CONFIG_SYSTEM_DHCPC_RENEW=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_NXPLAYER=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_TIMER=y
|
||||
CONFIG_TLS_NELEM=4
|
||||
CONFIG_TLS_TASK_NELEM=4
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_WIRELESS=y
|
||||
CONFIG_WIRELESS_WAPI=y
|
||||
CONFIG_WIRELESS_WAPI_CMDTOOL=y
|
||||
CONFIG_WIRELESS_WAPI_INITCONF=y
|
||||
CONFIG_WIRELESS_WAPI_STACKSIZE=4096
|
||||
@@ -0,0 +1,79 @@
|
||||
#
|
||||
# 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_ESP32S3_I2S0_RX is not set
|
||||
# CONFIG_ESP32S3_I2S1_TX is not set
|
||||
# CONFIG_NDEBUG 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="esp32s3-devkit"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32S3_DEVKIT=y
|
||||
CONFIG_ARCH_CHIP="esp32s3"
|
||||
CONFIG_ARCH_CHIP_ESP32S3=y
|
||||
CONFIG_ARCH_CHIP_ESP32S3WROOM1=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=4096
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_AUDIO=y
|
||||
CONFIG_AUDIO_BUFFER_NUMBYTES=2048
|
||||
CONFIG_AUDIO_EXCLUDE_BALANCE=y
|
||||
CONFIG_AUDIO_EXCLUDE_FFORWARD=y
|
||||
CONFIG_AUDIO_EXCLUDE_TONE=y
|
||||
CONFIG_AUDIO_EXCLUDE_VOLUME=y
|
||||
CONFIG_AUDIO_I2S=y
|
||||
CONFIG_AUDIO_I2SCHAR=y
|
||||
CONFIG_AUDIO_NUM_BUFFERS=4
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DRIVERS_AUDIO=y
|
||||
CONFIG_ESP32S3_I2S0=y
|
||||
CONFIG_ESP32S3_I2S0_BCLKPIN=16
|
||||
CONFIG_ESP32S3_I2S0_DOUTPIN=6
|
||||
CONFIG_ESP32S3_I2S0_MCLK=y
|
||||
CONFIG_ESP32S3_I2S0_MCLKPIN=5
|
||||
CONFIG_ESP32S3_I2S0_WSPIN=7
|
||||
CONFIG_ESP32S3_I2S1=y
|
||||
CONFIG_ESP32S3_I2S1_BCLKPIN=18
|
||||
CONFIG_ESP32S3_I2S1_DINPIN=15
|
||||
CONFIG_ESP32S3_I2S1_ROLE_SLAVE=y
|
||||
CONFIG_ESP32S3_I2S1_WSPIN=17
|
||||
CONFIG_ESP32S3_I2S=y
|
||||
CONFIG_ESP32S3_UART0=y
|
||||
CONFIG_FS_LARGEFILE=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
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NXLOOPER_LOOPTHREAD_STACKSIZE=4096
|
||||
CONFIG_NXLOOPER_MAINTHREAD_STACKSIZE=4096
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PTHREAD_MUTEX_TYPES=y
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SIG_DEFAULT=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_SYSLOG_BUFFER=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_NXLOOPER=y
|
||||
CONFIG_TIMER=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
@@ -121,6 +121,51 @@ int board_i2c_init(void);
|
||||
int board_bmp180_initialize(int devno, int busno);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* 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
|
||||
* enable_tx - Register device as TX if true
|
||||
* enable_rx - Register device as RX if true
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success. Otherwise, a negated errno value is
|
||||
* returned to indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP32S3_I2S
|
||||
int board_i2sdev_initialize(int port, bool enable_tx, bool enable_rx);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s3_cs4344_initialize
|
||||
*
|
||||
* Description:
|
||||
* This function is called by platform-specific, setup logic to configure
|
||||
* and register the CS4344 device. 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_AUDIO_CS4344
|
||||
int esp32s3_cs4344_initialize(int port);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s3_djoy_initialize
|
||||
*
|
||||
|
||||
@@ -62,6 +62,10 @@
|
||||
# include "esp32s3_i2c.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S3_I2S
|
||||
# include "esp32s3_i2s.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WATCHDOG
|
||||
# include "esp32s3_board_wdt.h"
|
||||
#endif
|
||||
@@ -109,6 +113,11 @@
|
||||
int esp32s3_bringup(void)
|
||||
{
|
||||
int ret;
|
||||
#if (defined(CONFIG_ESP32S3_I2S0) && !defined(CONFIG_AUDIO_CS4344)) || \
|
||||
defined(CONFIG_ESP32S3_I2S1)
|
||||
bool i2s_enable_tx;
|
||||
bool i2s_enable_rx;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ESP32S3_EFUSE)
|
||||
ret = esp32s3_efuse_initialize("/dev/efuse");
|
||||
@@ -207,6 +216,67 @@ int esp32s3_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S3_I2S
|
||||
|
||||
#ifdef CONFIG_AUDIO_CS4344
|
||||
|
||||
/* Configure CS4344 audio on I2S0 */
|
||||
|
||||
ret = esp32s3_cs4344_initialize(ESP32S3_I2S0);
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize CS4344 audio: %d\n", ret);
|
||||
}
|
||||
#else
|
||||
|
||||
#ifdef CONFIG_ESP32S3_I2S0_TX
|
||||
i2s_enable_tx = true;
|
||||
#else
|
||||
i2s_enable_tx = false;
|
||||
#endif /* CONFIG_ESP32S3_I2S0_TX */
|
||||
|
||||
#ifdef CONFIG_ESP32S3_I2S0_RX
|
||||
i2s_enable_rx = true;
|
||||
#else
|
||||
i2s_enable_rx = false;
|
||||
#endif /* CONFIG_ESP32S3_I2S0_RX */
|
||||
|
||||
/* Configure I2S generic audio on I2S0 */
|
||||
|
||||
ret = board_i2sdev_initialize(ESP32S3_I2S0, i2s_enable_tx, i2s_enable_rx);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize I2S0 driver: %d\n", ret);
|
||||
}
|
||||
#endif /* CONFIG_AUDIO_CS4344 */
|
||||
|
||||
#ifdef CONFIG_ESP32S3_I2S1
|
||||
|
||||
#ifdef CONFIG_ESP32S3_I2S1_TX
|
||||
i2s_enable_tx = true;
|
||||
#else
|
||||
i2s_enable_tx = false;
|
||||
#endif /* CONFIG_ESP32S3_I2S1_TX */
|
||||
|
||||
#ifdef CONFIG_ESP32S3_I2S1_RX
|
||||
i2s_enable_rx = true;
|
||||
#else
|
||||
i2s_enable_rx = false;
|
||||
#endif /* CONFIG_ESP32S3_I2S1_RX */
|
||||
|
||||
/* Configure I2S generic audio on I2S1 */
|
||||
|
||||
ret = board_i2sdev_initialize(ESP32S3_I2S1, i2s_enable_tx, i2s_enable_rx);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize I2S%d driver: %d\n",
|
||||
CONFIG_ESP32S3_I2S1, ret);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ESP32S3_I2S1 */
|
||||
|
||||
#endif /* CONFIG_ESP32S3_I2S */
|
||||
|
||||
#ifdef CONFIG_INPUT_BUTTONS
|
||||
/* Register the BUTTON driver */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user