mirror of
https://github.com/apache/nuttx.git
synced 2026-05-20 04:16:35 +08:00
boards/esp32-lyrat: Add support for the ES8388 codec
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
fa0ccce046
commit
bcafc77cf8
BIN
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
@@ -126,6 +126,10 @@ between speakers and headphones is under software control instead of using
|
||||
mechanical contacts that would disconnect speakers once a headphone jack is
|
||||
inserted.
|
||||
|
||||
.. note::
|
||||
The codec implementation on the LyraT board was validated using 16-bit,
|
||||
44.1kHz WAV files. Other configurations might not work as expected.
|
||||
|
||||
SD card
|
||||
=======
|
||||
|
||||
@@ -386,6 +390,49 @@ JTAG Header / JP7
|
||||
Configurations
|
||||
==============
|
||||
|
||||
audio
|
||||
-----
|
||||
|
||||
This configuration uses the I2S0 peripheral and the ES8388 audio codec
|
||||
present on the LyraT board to play an audio file streamed over HTTP
|
||||
while connected to a Wi-Fi network.
|
||||
|
||||
**Simple HTTP server**
|
||||
|
||||
Prepare a PCM-encoded (`.wav`) audio file with 16 bits/sample (sampled at
|
||||
44.1kHz). This file must be placed into a folder in a computer that could
|
||||
be accessed on the same Wi-Fi network the ESP32 will be connecting to.
|
||||
|
||||
Python provides a simple HTTP server. `cd` to the audio file folder on the
|
||||
PC and run::
|
||||
|
||||
$ python3 -m http.server
|
||||
|
||||
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/)
|
||||
|
||||
Look for your PC IP address and test playing the prepared audio on your
|
||||
browser:
|
||||
|
||||
.. figure:: esp32-lyrat-v4.3-audio-config-file.png
|
||||
:align: center
|
||||
|
||||
After successfully built and flashed, connect the board to the Wi-Fi network::
|
||||
|
||||
$ nsh> wapi psk wlan0 mypasswd 1
|
||||
$ nsh> wapi essid wlan0 myssid 1
|
||||
$ nsh> renew wlan0
|
||||
|
||||
Once connected, open NuttX's player and play the file according to its file
|
||||
name and the IP address of the HTTP server (For example `tones.wav` and
|
||||
`192.168.1.239:8000`, respectively)::
|
||||
|
||||
$ nsh> nxplayer
|
||||
$ nxplayer> play http://192.168.1.239:8000/tones.wav
|
||||
|
||||
.. note::
|
||||
The codec implementation on the LyraT board was validated using 16-bit,
|
||||
44.1kHz WAV files. Other configurations might not work as expected.
|
||||
|
||||
nsh
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/common/include/esp32_es8388.h
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_ESP32_ES8388_H
|
||||
#define __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_ESP32_ES8388_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_es8388_initialize
|
||||
*
|
||||
* Description:
|
||||
* This function is called by platform-specific, setup logic to configure
|
||||
* and register the ES8388 device. This function will register the driver
|
||||
* as /dev/audio/pcm[x] where x is determined by the I2S port number.
|
||||
*
|
||||
* Input Parameters:
|
||||
* i2c_port - The I2C port used for the device
|
||||
* i2c_addr - The I2C address used by the device
|
||||
* i2c_freq - The I2C frequency used for the device
|
||||
* i2s_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 esp32_es8388_initialize(int i2c_port, uint8_t i2c_addr, int i2c_freq,
|
||||
int i2s_port);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_ESP32_ES8388_H */
|
||||
@@ -48,6 +48,10 @@ ifeq ($(CONFIG_AUDIO_CS4344),y)
|
||||
CSRCS += esp32_cs4344.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_AUDIO_ES8388),y)
|
||||
CSRCS += esp32_es8388.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_I2CMULTIPLEXER_TCA9548A),y)
|
||||
CSRCS += esp32_tca9548a.c
|
||||
endif
|
||||
|
||||
@@ -37,8 +37,8 @@
|
||||
|
||||
#include "esp32_i2s.h"
|
||||
|
||||
#if defined(CONFIG_ESP32_I2S0) && !defined(CONFIG_AUDIO_CS4344) || \
|
||||
defined(CONFIG_ESP32_I2S1)
|
||||
#if defined(CONFIG_ESP32_I2S0) && !defined(CONFIG_AUDIO_CS4344) && \
|
||||
!defined(CONFIG_AUDIO_ES8388) || defined(CONFIG_ESP32_I2S1)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@@ -111,4 +111,5 @@ int board_i2sdev_initialize(int port)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ESP32_I2S0 && !CONFIG_AUDIO_CS4344 || CONFIG_ESP32_I2S1 */
|
||||
#endif /* CONFIG_ESP32_I2S0 && !CONFIG_AUDIO_CS4344 && \ *
|
||||
* !CONFIG_AUDIO_ES8388 || CONFIG_ESP32_I2S1 */
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/common/src/esp32_es8388.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/es8388.h>
|
||||
#include <nuttx/i2c/i2c_master.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "esp32_board_i2c.h"
|
||||
#include "esp32_i2c.h"
|
||||
#include "esp32_i2s.h"
|
||||
|
||||
#if defined(CONFIG_ESP32_I2S) && defined(CONFIG_AUDIO_ES8388)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_es8388_initialize
|
||||
*
|
||||
* Description:
|
||||
* This function is called by platform-specific, setup logic to configure
|
||||
* and register the ES8388 device. This function will register the driver
|
||||
* as /dev/audio/pcm[x] where x is determined by the I2S port number.
|
||||
*
|
||||
* Input Parameters:
|
||||
* i2c_port - The I2C port used for the device
|
||||
* i2c_addr - The I2C address used by the device
|
||||
* i2c_freq - The I2C frequency used for the device
|
||||
* i2s_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 esp32_es8388_initialize(int i2c_port, uint8_t i2c_addr, int i2c_freq,
|
||||
int i2s_port)
|
||||
{
|
||||
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;
|
||||
char devname[12];
|
||||
int ret;
|
||||
|
||||
audinfo("i2s_port %d\ni2c_port %d, i2c_addr %d, i2c_freq %d\n",
|
||||
i2s_port, i2c_port, i2c_addr, i2c_freq);
|
||||
DEBUGASSERT(i2s_port >= 0 && i2s_port <= 1 && \
|
||||
i2c_port >= 0 && i2c_port <= 1);
|
||||
|
||||
/* Have we already initialized? Since we never uninitialize we must
|
||||
* prevent multiple initializations. This is necessary, for example,
|
||||
* when the touchscreen example is used as a built-in application in
|
||||
* NSH and can be called numerous time. It will attempt to initialize
|
||||
* each time.
|
||||
*/
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
/* Get an instance of the I2S interface for the ES8388 data channel */
|
||||
|
||||
i2s = esp32_i2sbus_initialize(i2s_port);
|
||||
if (i2s == NULL)
|
||||
{
|
||||
auderr("ERROR: Failed to initialize I2S%d\n", i2s_port);
|
||||
ret = -ENODEV;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
i2c = esp32_i2cbus_initialize(i2c_port);
|
||||
if (i2c == NULL)
|
||||
{
|
||||
auderr("ERROR: Failed to initialize I2C%d\n", i2c_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 ES8388 which
|
||||
* will return an audio interface.
|
||||
*/
|
||||
|
||||
lower = (FAR struct es8388_lower_s *)
|
||||
kmm_zalloc(sizeof(struct es8388_lower_s));
|
||||
|
||||
lower->address = i2c_addr,
|
||||
lower->frequency = i2c_freq,
|
||||
|
||||
es8388 = es8388_initialize(i2c, i2s, lower);
|
||||
if (es8388 == NULL)
|
||||
{
|
||||
auderr("ERROR: Failed to initialize the ES8388\n");
|
||||
ret = -ENODEV;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Now we can embed the ES8388/I2S conglomerate into a PCM decoder
|
||||
* instance so that we will have a PCM front end for the the ES8388
|
||||
* driver.
|
||||
*/
|
||||
|
||||
pcm = pcm_decode_initialize(es8388);
|
||||
if (pcm == NULL)
|
||||
{
|
||||
auderr("ERROR: Failed create the PCM decoder\n");
|
||||
ret = -ENODEV;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Create a device name */
|
||||
|
||||
snprintf(devname, 12, "pcm%d", i2s_port);
|
||||
|
||||
/* Finally, we can register the PCM/ES8388/I2S audio device. */
|
||||
|
||||
ret = audio_register(devname, pcm);
|
||||
if (ret < 0)
|
||||
{
|
||||
auderr("ERROR: Failed to register /dev/%s device: %d\n",
|
||||
devname, ret);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Now we are initialized */
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
||||
errout:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ESP32_I2S && CONFIG_AUDIO_ES8388 */
|
||||
@@ -0,0 +1,127 @@
|
||||
#
|
||||
# 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_ESP32_I2S0_RX is not set
|
||||
# CONFIG_NDEBUG is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS 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_I2SCHAR=y
|
||||
CONFIG_AUDIO_NUM_BUFFERS=4
|
||||
CONFIG_BOARDCTL_ROMDISK=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_NOOPT=y
|
||||
CONFIG_DEFAULT_TASK_STACKSIZE=4096
|
||||
CONFIG_DEV_URANDOM=y
|
||||
CONFIG_DRIVERS_AUDIO=y
|
||||
CONFIG_DRIVERS_IEEE80211=y
|
||||
CONFIG_DRIVERS_WIRELESS=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_DOUTPIN=26
|
||||
CONFIG_ESP32_I2S0_MCLK=y
|
||||
CONFIG_ESP32_I2S0_WSPIN=25
|
||||
CONFIG_ESP32_I2S=y
|
||||
CONFIG_ESP32_SPIFLASH=y
|
||||
CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000
|
||||
CONFIG_ESP32_UART0=y
|
||||
CONFIG_ESP32_WIFI=y
|
||||
CONFIG_ESP32_WIFI_SAVE_PARAM=y
|
||||
CONFIG_EXAMPLES_I2SCHAR=y
|
||||
CONFIG_EXAMPLES_I2SCHAR_TX=y
|
||||
CONFIG_EXAMPLES_I2SCHAR_TXBUFFERS=2
|
||||
CONFIG_EXAMPLES_I2SCHAR_TXSTACKSIZE=2048
|
||||
CONFIG_EXAMPLES_ROMFS=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_FS_ROMFS=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_INTELHEX_BINARY=y
|
||||
CONFIG_IOB_NBUFFERS=24
|
||||
CONFIG_IOB_THROTTLE=0
|
||||
CONFIG_MM_CIRCBUF=y
|
||||
CONFIG_MM_REGIONS=3
|
||||
CONFIG_NAME_MAX=48
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETDB_DNSCLIENT_NAMESIZE=64
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NETDEV_PHY_IOCTL=y
|
||||
CONFIG_NETDEV_WIRELESS_IOCTL=y
|
||||
CONFIG_NETINIT_WAPI_ALG=1
|
||||
CONFIG_NETUTILS_IPERF=y
|
||||
CONFIG_NETUTILS_TELNETD=y
|
||||
CONFIG_NET_BROADCAST=y
|
||||
CONFIG_NET_ETH_PKTSIZE=1518
|
||||
CONFIG_NET_ICMP=y
|
||||
CONFIG_NET_ICMP_SOCKET=y
|
||||
CONFIG_NET_NACTIVESOCKETS=32
|
||||
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_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=300
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NXPLAYER_HTTP_STREAMING_SUPPORT=y
|
||||
CONFIG_NXPLAYER_PLAYTHREAD_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_SPI=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_SYSTEM_DHCPC_RENEW=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_NXPLAYER=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_TELNET_CHARACTER_MODE=y
|
||||
CONFIG_TLS_TASK_NELEM=4
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_WIRELESS=y
|
||||
CONFIG_WIRELESS_WAPI=y
|
||||
CONFIG_WIRELESS_WAPI_CMDTOOL=y
|
||||
@@ -17,10 +17,17 @@ CONFIG_ARCH_BOARD_ESP32_LYRAT=y
|
||||
CONFIG_ARCH_CHIP="esp32"
|
||||
CONFIG_ARCH_CHIP_ESP32=y
|
||||
CONFIG_ARCH_CHIP_ESP32WROVER=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_ASSERTIONS=y
|
||||
CONFIG_DEBUG_FEATURES=y
|
||||
CONFIG_DEBUG_FULLOPT=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DEFAULT_TASK_STACKSIZE=4096
|
||||
CONFIG_DEV_URANDOM=y
|
||||
CONFIG_DRIVERS_IEEE80211=y
|
||||
CONFIG_DRIVERS_WIRELESS=y
|
||||
CONFIG_ESP32_SPIFLASH=y
|
||||
@@ -30,28 +37,34 @@ CONFIG_ESP32_UART0=y
|
||||
CONFIG_ESP32_WIFI=y
|
||||
CONFIG_ESP32_WIFI_SAVE_PARAM=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=3072
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_MM_REGIONS=3
|
||||
CONFIG_NAME_MAX=48
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETDB_DNSCLIENT_NAMESIZE=64
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NETDEV_PHY_IOCTL=y
|
||||
CONFIG_NETDEV_WIRELESS_IOCTL=y
|
||||
CONFIG_NETUTILS_IPERF=y
|
||||
CONFIG_NETUTILS_TELNETD=y
|
||||
CONFIG_NET_BROADCAST=y
|
||||
CONFIG_NET_ETH_PKTSIZE=1518
|
||||
CONFIG_NET_ICMP=y
|
||||
CONFIG_NET_ICMP_SOCKET=y
|
||||
CONFIG_NET_NACTIVESOCKETS=32
|
||||
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_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_LINELEN=300
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=2048
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PTHREAD_MUTEX_TYPES=y
|
||||
CONFIG_RAM_SIZE=114688
|
||||
@@ -62,15 +75,17 @@ CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SIG_DEFAULT=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_SPIFFS_NAME_MAX=48
|
||||
CONFIG_STACK_COLORATION=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_SYSTEM_DHCPC_RENEW=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_SYSTEM_STACKMONITOR=y
|
||||
CONFIG_TELNET_CHARACTER_MODE=y
|
||||
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_STACKSIZE=4096
|
||||
|
||||
@@ -56,13 +56,14 @@
|
||||
|
||||
/* ES8388 CODEC */
|
||||
|
||||
#define ES8388_CCLK 23
|
||||
#define ES8388_CDATA 18
|
||||
#define ES8388_MCLK 0
|
||||
#define ES8388_SCLK 5
|
||||
#define ES8388_LRCK 25
|
||||
#define ES8388_DSDIN 26
|
||||
#define ES8388_ASDOUT 35
|
||||
#define ES8388_I2C_CCLK 23 /* SCL */
|
||||
#define ES8388_I2C_CDATA 18 /* SDA */
|
||||
|
||||
#define ES8388_I2S_MCLK 0 /* Master clock */
|
||||
#define ES8388_I2S_SCLK 5 /* Audio data bit clock */
|
||||
#define ES8388_I2S_LRCK 25 /* Audio data left and right clock */
|
||||
#define ES8388_I2S_DSDIN 26 /* DAC audio data (to speakers) */
|
||||
#define ES8388_I2S_ASDOUT 35 /* ADC audio data (from microphone) */
|
||||
|
||||
/* LED definitions **********************************************************/
|
||||
|
||||
@@ -76,4 +77,11 @@
|
||||
#define BOARD_NGPIOIN 1 /* Amount of GPIO Input without Interruption */
|
||||
#define BOARD_NGPIOINT 1 /* Amount of GPIO Input w/ Interruption pins */
|
||||
|
||||
/* Peripherals definitions **************************************************/
|
||||
|
||||
/* ES8388 CODEC */
|
||||
|
||||
#define ES8388_I2C_FREQ 400000
|
||||
#define ES8388_I2C_ADDR 0x10
|
||||
|
||||
#endif /* __BOARDS_XTENSA_ESP32_ESP32_LYRAT_INCLUDE_BOARD_H */
|
||||
|
||||
@@ -39,6 +39,10 @@
|
||||
|
||||
#define GPIO_LED1 22
|
||||
|
||||
/* Audio Amplifier */
|
||||
|
||||
#define SPEAKER_ENABLE_GPIO 21
|
||||
|
||||
/* Buttons */
|
||||
|
||||
/* As BOOT_BUTTON shares pins with I2S and the SD card it cannot be used
|
||||
@@ -92,6 +96,52 @@
|
||||
|
||||
int esp32_bringup(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_es8388_initialize
|
||||
*
|
||||
* Description:
|
||||
* This function is called by platform-specific, setup logic to configure
|
||||
* and register the ES8388 device. This function will register the driver
|
||||
* as /dev/audio/pcm[x] where x is determined by the I2S port number.
|
||||
*
|
||||
* Input Parameters:
|
||||
* i2c_port - The I2C port used for the device
|
||||
* i2c_addr - The I2C address used by the device
|
||||
* i2c_freq - The I2C frequency used for the device
|
||||
* i2s_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 esp32_es8388_initialize(int i2c_port, uint8_t i2c_addr, int i2c_freq,
|
||||
int i2s_port);
|
||||
|
||||
/****************************************************************************
|
||||
* 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_AUDIO_ES8388 || \
|
||||
defined CONFIG_ESP32_I2S1
|
||||
int board_i2sdev_initialize(int port);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_mmcsd_initialize
|
||||
*
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/himem/himem.h>
|
||||
|
||||
#include "esp32_i2c.h"
|
||||
#include "esp32_gpio.h"
|
||||
#include "esp32_partition.h"
|
||||
|
||||
#include <arch/board/board.h>
|
||||
@@ -76,6 +78,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
|
||||
@@ -331,6 +337,54 @@ int esp32_bringup(void)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32_I2S
|
||||
|
||||
#ifdef CONFIG_ESP32_I2S0
|
||||
|
||||
/* Configure I2S0 */
|
||||
|
||||
#ifdef CONFIG_AUDIO_ES8388
|
||||
|
||||
/* Configure ES8388 audio on I2C0 and I2S0 */
|
||||
|
||||
esp32_configgpio(SPEAKER_ENABLE_GPIO, OUTPUT);
|
||||
esp32_gpiowrite(SPEAKER_ENABLE_GPIO, true);
|
||||
|
||||
ret = esp32_es8388_initialize(ESP32_I2C0, ES8388_I2C_ADDR,
|
||||
ES8388_I2C_FREQ, ESP32_I2S0);
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize ES8388 audio: %d\n", ret);
|
||||
}
|
||||
#else
|
||||
|
||||
/* 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_AUDIO_ES8388 */
|
||||
|
||||
#endif /* CONFIG_ESP32_I2S0 */
|
||||
|
||||
#ifdef CONFIG_ESP32_I2S1
|
||||
|
||||
/* Configure I2S generic audio on I2S1 */
|
||||
|
||||
ret = board_i2sdev_initialize(ESP32_I2S1);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize I2S%d driver: %d\n",
|
||||
CONFIG_ESP32_I2S0, ret);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ESP32_I2S1 */
|
||||
|
||||
#endif /* CONFIG_ESP32_I2S */
|
||||
|
||||
#ifdef CONFIG_SENSORS_BMP180
|
||||
/* Try to register BMP180 device in I2C0 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user