esp32[c3|c6|h2]: Add I2S support
Add I2S support for risc-v based Espressif devices Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
This commit is contained in:
parent
f286a63223
commit
3661cdeed9
30 changed files with 4390 additions and 2 deletions
|
|
@ -208,6 +208,29 @@ You can scan for all I2C devices using the following command::
|
|||
|
||||
nsh> i2c dev 0x00 0x7f
|
||||
|
||||
i2schar
|
||||
-------
|
||||
|
||||
This configuration enables the I2S character device and the i2schar example
|
||||
app, which provides an easy-to-use way of testing the I2S peripheral,
|
||||
enabling both the TX and the RX for those peripherals.
|
||||
|
||||
**I2S pinout**
|
||||
|
||||
============ ========== =========================================
|
||||
ESP32-C3 Pin Signal Pin Description
|
||||
============ ========== =========================================
|
||||
0 MCLK Master Clock
|
||||
4 SCLK Bit Clock (SCLK)
|
||||
5 LRCK Word Select (LRCLK)
|
||||
18 DOUT Data Out
|
||||
19 DIN Data In
|
||||
============ ========== =========================================
|
||||
|
||||
After successfully built and flashed, run on the boards's terminal::
|
||||
|
||||
nsh> i2schar
|
||||
|
||||
nimble
|
||||
------
|
||||
|
||||
|
|
|
|||
|
|
@ -191,6 +191,29 @@ You can scan for all I2C devices using the following command::
|
|||
|
||||
nsh> i2c dev 0x00 0x7f
|
||||
|
||||
i2schar
|
||||
-------
|
||||
|
||||
This configuration enables the I2S character device and the i2schar example
|
||||
app, which provides an easy-to-use way of testing the I2S peripheral,
|
||||
enabling both the TX and the RX for those peripherals.
|
||||
|
||||
**I2S pinout**
|
||||
|
||||
============ ========== =========================================
|
||||
ESP32-C3 Pin Signal Pin Description
|
||||
============ ========== =========================================
|
||||
0 MCLK Master Clock
|
||||
4 SCLK Bit Clock (SCLK)
|
||||
5 LRCK Word Select (LRCLK)
|
||||
18 DOUT Data Out
|
||||
19 DIN Data In
|
||||
============ ========== =========================================
|
||||
|
||||
After successfully built and flashed, run on the boards's terminal::
|
||||
|
||||
nsh> i2schar
|
||||
|
||||
motor
|
||||
-------
|
||||
|
||||
|
|
|
|||
|
|
@ -175,6 +175,29 @@ You can scan for all I2C devices using the following command::
|
|||
|
||||
nsh> i2c dev 0x00 0x7f
|
||||
|
||||
i2schar
|
||||
-------
|
||||
|
||||
This configuration enables the I2S character device and the i2schar example
|
||||
app, which provides an easy-to-use way of testing the I2S peripheral,
|
||||
enabling both the TX and the RX for those peripherals.
|
||||
|
||||
**I2S pinout**
|
||||
|
||||
============ ========== =========================================
|
||||
ESP32-C3 Pin Signal Pin Description
|
||||
============ ========== =========================================
|
||||
0 MCLK Master Clock
|
||||
4 SCLK Bit Clock (SCLK)
|
||||
5 LRCK Word Select (LRCLK)
|
||||
18 DOUT Data Out
|
||||
19 DIN Data In
|
||||
============ ========== =========================================
|
||||
|
||||
After successfully built and flashed, run on the boards's terminal::
|
||||
|
||||
nsh> i2schar
|
||||
|
||||
mcuboot_nsh
|
||||
--------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ eFuse Yes
|
|||
GPIO Yes
|
||||
HMAC No
|
||||
I2C Yes
|
||||
I2S No
|
||||
I2S Yes
|
||||
Int. Temp. Yes
|
||||
LED No
|
||||
LED_PWM Yes
|
||||
|
|
|
|||
|
|
@ -174,6 +174,29 @@ You can scan for all I2C devices using the following command::
|
|||
|
||||
nsh> i2c dev 0x00 0x7f
|
||||
|
||||
i2schar
|
||||
-------
|
||||
|
||||
This configuration enables the I2S character device and the i2schar example
|
||||
app, which provides an easy-to-use way of testing the I2S peripheral,
|
||||
enabling both the TX and the RX for those peripherals.
|
||||
|
||||
**I2S pinout**
|
||||
|
||||
============ ========== =========================================
|
||||
ESP32-C3 Pin Signal Pin Description
|
||||
============ ========== =========================================
|
||||
0 MCLK Master Clock
|
||||
4 SCLK Bit Clock (SCLK)
|
||||
5 LRCK Word Select (LRCLK)
|
||||
10 DOUT Data Out
|
||||
11 DIN Data In
|
||||
============ ========== =========================================
|
||||
|
||||
After successfully built and flashed, run on the boards's terminal::
|
||||
|
||||
nsh> i2schar
|
||||
|
||||
mcuboot_nsh
|
||||
--------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ eFuse Yes
|
|||
GPIO Yes
|
||||
HMAC No
|
||||
I2C Yes
|
||||
I2S No
|
||||
I2S Yes
|
||||
Int. Temp. Yes
|
||||
LED No
|
||||
LED_PWM Yes
|
||||
|
|
|
|||
|
|
@ -321,6 +321,19 @@ config ESPRESSIF_LEDC
|
|||
select PWM
|
||||
select ARCH_HAVE_PWM_MULTICHAN
|
||||
|
||||
config ESPRESSIF_I2S
|
||||
bool
|
||||
default n
|
||||
|
||||
config ESPRESSIF_I2S0
|
||||
bool "I2S 0"
|
||||
default n
|
||||
select ESPRESSIF_I2S
|
||||
select I2S
|
||||
select ESPRESSIF_DMA
|
||||
select ESPRESSIF_GPIO_IRQ
|
||||
select SCHED_HPWORK
|
||||
|
||||
config ESPRESSIF_I2C
|
||||
bool
|
||||
default n
|
||||
|
|
@ -1647,6 +1660,125 @@ endif # PWM_MULTICHAN && PWM_NCHANNELS > 1
|
|||
|
||||
endmenu # LEDC configuration
|
||||
|
||||
menu "I2S Configuration"
|
||||
depends on ESPRESSIF_I2S
|
||||
|
||||
config ESPRESSIF_I2S_MAXINFLIGHT
|
||||
int "I2S queue size"
|
||||
default 4
|
||||
---help---
|
||||
This is the total number of transfers, both RX and TX, that can be
|
||||
enqueued before the caller is required to wait. This setting
|
||||
determines the number certain queue data structures that will be
|
||||
pre-allocated.
|
||||
|
||||
if ESPRESSIF_I2S0
|
||||
|
||||
config ESPRESSIF_I2S0_RX
|
||||
bool "Enable I2S receiver"
|
||||
default y
|
||||
---help---
|
||||
Enable I2S receiver (port 0)
|
||||
|
||||
config ESPRESSIF_I2S0_TX
|
||||
bool "Enable I2S transmitter"
|
||||
default y
|
||||
---help---
|
||||
Enable I2S transmitter (port 0)
|
||||
|
||||
choice ESPRESSIF_I2S0_ROLE
|
||||
prompt "I2S0 role"
|
||||
default ESPRESSIF_I2S0_ROLE_MASTER
|
||||
---help---
|
||||
Selects the operation role of the I2S0.
|
||||
|
||||
config ESPRESSIF_I2S0_ROLE_MASTER
|
||||
bool "Master"
|
||||
|
||||
config ESPRESSIF_I2S0_ROLE_SLAVE
|
||||
bool "Slave"
|
||||
|
||||
endchoice # I2S0 role
|
||||
|
||||
choice ESPRESSIF_I2S0_DATA_BIT_WIDTH
|
||||
prompt "Bit width"
|
||||
default ESPRESSIF_I2S0_DATA_BIT_WIDTH_16BIT
|
||||
---help---
|
||||
Selects the valid data bits per sample.
|
||||
Note that this option may be overwritten by the audio
|
||||
according to the bit width of the file being played
|
||||
|
||||
config ESPRESSIF_I2S0_DATA_BIT_WIDTH_8BIT
|
||||
bool "8 bits"
|
||||
|
||||
config ESPRESSIF_I2S0_DATA_BIT_WIDTH_16BIT
|
||||
bool "16 bits"
|
||||
|
||||
config ESPRESSIF_I2S0_DATA_BIT_WIDTH_24BIT
|
||||
bool "24 bits"
|
||||
|
||||
config ESPRESSIF_I2S0_DATA_BIT_WIDTH_32BIT
|
||||
bool "32 bits"
|
||||
|
||||
endchoice # Bit width
|
||||
|
||||
config ESPRESSIF_I2S0_SAMPLE_RATE
|
||||
int "I2S0 sample rate"
|
||||
default 44100
|
||||
range 8000 48000
|
||||
---help---
|
||||
Selects the sample rate.
|
||||
Note that this option may be overwritten by the audio
|
||||
according to the bit width of the file being played
|
||||
|
||||
config ESPRESSIF_I2S0_BCLKPIN
|
||||
int "I2S0 BCLK pin"
|
||||
default 4
|
||||
range 0 48
|
||||
|
||||
config ESPRESSIF_I2S0_WSPIN
|
||||
int "I2S0 WS pin"
|
||||
default 5
|
||||
range 0 48
|
||||
|
||||
config ESPRESSIF_I2S0_DINPIN
|
||||
int "I2S0 DIN pin"
|
||||
depends on ESPRESSIF_I2S0_RX
|
||||
default 19 if !ESPRESSIF_ESP32H2
|
||||
default 11 if ESPRESSIF_ESP32H2
|
||||
range 0 48
|
||||
|
||||
config ESPRESSIF_I2S0_DOUTPIN
|
||||
int "I2S0 DOUT pin"
|
||||
depends on ESPRESSIF_I2S0_TX
|
||||
default 18 if !ESPRESSIF_ESP32H2
|
||||
default 10 if ESPRESSIF_ESP32H2
|
||||
range 0 48
|
||||
|
||||
config ESPRESSIF_I2S0_MCLK
|
||||
bool "Enable I2S Master Clock"
|
||||
depends on ESPRESSIF_I2S0_ROLE_MASTER
|
||||
default n
|
||||
---help---
|
||||
Enable I2S master clock
|
||||
|
||||
config ESPRESSIF_I2S0_MCLKPIN
|
||||
int "I2S MCLK pin"
|
||||
depends on ESPRESSIF_I2S0_MCLK
|
||||
default 0
|
||||
range 0 48
|
||||
|
||||
endif # ESPRESSIF_I2S0
|
||||
|
||||
config I2S_DMADESC_NUM
|
||||
int "I2S DMA maximum number of descriptors"
|
||||
default 2
|
||||
---help---
|
||||
Configure the maximum number of out-link/in-link descriptors to
|
||||
be chained for an I2S DMA transfer.
|
||||
|
||||
endmenu # I2S configuration
|
||||
|
||||
menu "I2C Configuration"
|
||||
depends on ESPRESSIF_I2C
|
||||
|
||||
|
|
|
|||
|
|
@ -116,6 +116,10 @@ ifeq ($(CONFIG_ESPRESSIF_I2C),y)
|
|||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESPRESSIF_I2S),y)
|
||||
CHIP_CSRCS += esp_i2s.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESPRESSIF_SPI),y)
|
||||
ifeq ($(CONFIG_ESPRESSIF_SPI_PERIPH),y)
|
||||
CHIP_CSRCS += esp_spi.c
|
||||
|
|
|
|||
2926
arch/risc-v/src/common/espressif/esp_i2s.c
Normal file
2926
arch/risc-v/src/common/espressif/esp_i2s.c
Normal file
File diff suppressed because it is too large
Load diff
76
arch/risc-v/src/common/espressif/esp_i2s.h
Normal file
76
arch/risc-v/src/common/espressif/esp_i2s.h
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/****************************************************************************
|
||||
* arch/risc-v/src/common/espressif/esp_i2s.h
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* 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 __ARCH_RISCV_SRC_COMMON_ESPRESSIF_ESP_I2S_H
|
||||
#define __ARCH_RISCV_SRC_COMMON_ESPRESSIF_ESP_I2S_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/audio/i2s.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S
|
||||
|
||||
#define ESPRESSIF_I2S0 0
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_i2sbus_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the selected I2S port
|
||||
*
|
||||
* Input Parameters:
|
||||
* port - Port number (for hardware that has multiple I2S interfaces)
|
||||
*
|
||||
* Returned Value:
|
||||
* Valid I2S device structure reference on success; a NULL on failure
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct i2s_dev_s *esp_i2sbus_initialize(int port);
|
||||
|
||||
#endif /* CONFIG_ESPRESSIF_I2S */
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ARCH_RISCV_SRC_COMMON_ESPRESSIF_ESP_I2S_H */
|
||||
|
|
@ -133,6 +133,7 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$
|
|||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)mmu_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)rmt_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)i2c_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)i2s_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)spi_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)spi_hal_iram.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)twai_hal.c
|
||||
|
|
@ -149,10 +150,12 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)log$
|
|||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)log$(DELIM)log_noos.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)riscv$(DELIM)interrupt.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)lldesc.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)gdma_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)gpio_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)ledc_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)rmt_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)i2c_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)i2s_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)temperature_sensor_periph.c
|
||||
|
||||
ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y)
|
||||
|
|
|
|||
|
|
@ -134,6 +134,7 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$
|
|||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)pcnt_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)rmt_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)i2c_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)i2s_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)spi_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)spi_hal_iram.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)timer_hal.c
|
||||
|
|
@ -155,11 +156,13 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)log$
|
|||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)log$(DELIM)log_noos.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)riscv$(DELIM)interrupt.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)lldesc.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)gdma_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)gpio_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)ledc_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)pcnt_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)rmt_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)i2c_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)i2s_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)mcpwm_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)temperature_sensor_periph.c
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$
|
|||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)pcnt_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)rmt_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)i2c_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)i2s_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)spi_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)spi_hal_iram.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)timer_hal.c
|
||||
|
|
@ -139,11 +140,13 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)log$
|
|||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)log$(DELIM)log_noos.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)riscv$(DELIM)interrupt.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)lldesc.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)gdma_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)gpio_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)ledc_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)pcnt_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)rmt_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)i2c_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)i2s_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)mcpwm_periph.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)temperature_sensor_periph.c
|
||||
|
||||
|
|
|
|||
76
boards/risc-v/esp32c3/common/include/esp_board_i2s.h
Normal file
76
boards/risc-v/esp32c3/common/include/esp_board_i2s.h
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/****************************************************************************
|
||||
* boards/risc-v/esp32c3/common/include/esp_board_i2s.h
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* 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_RISCV_ESP32C3_COMMON_INCLUDE_ESP_BOARD_I2S_H
|
||||
#define __BOARDS_RISCV_ESP32C3_COMMON_INCLUDE_ESP_BOARD_I2S_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_i2s_init
|
||||
*
|
||||
* Description:
|
||||
* Configure the I2S driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* to indicate the nature of any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S
|
||||
int board_i2s_init(void);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_RISCV_ESP32C3_COMMON_INCLUDE_ESP_BOARD_I2S_H */
|
||||
|
|
@ -46,6 +46,10 @@ ifeq ($(CONFIG_I2C_DRIVER),y)
|
|||
CSRCS += esp_board_i2c.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESPRESSIF_I2S),y)
|
||||
CSRCS += esp_board_i2s.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESPRESSIF_SPIFLASH),y)
|
||||
CSRCS += esp_board_spiflash.c
|
||||
endif
|
||||
|
|
|
|||
200
boards/risc-v/esp32c3/common/src/esp_board_i2s.c
Normal file
200
boards/risc-v/esp32c3/common/src/esp_board_i2s.c
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
/****************************************************************************
|
||||
* boards/risc-v/esp32c3/common/src/esp_board_i2s.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* 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 <debug.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.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 "espressif/esp_i2s.h"
|
||||
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
|
||||
audinfo("Initializing I2S\n");
|
||||
|
||||
i2s = esp_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;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_i2s_init
|
||||
*
|
||||
* Description:
|
||||
* Configure the I2S driver.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* to indicate the nature of any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_i2s_init(void)
|
||||
{
|
||||
int ret = OK;
|
||||
#if defined(CONFIG_ESPRESSIF_I2S0)
|
||||
bool i2s_enable_tx;
|
||||
bool i2s_enable_rx;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S0_TX
|
||||
i2s_enable_tx = true;
|
||||
#else
|
||||
i2s_enable_tx = false;
|
||||
#endif /* CONFIG_ESPRESSIF_I2S0_TX */
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S0_RX
|
||||
i2s_enable_rx = true;
|
||||
#else
|
||||
i2s_enable_rx = false;
|
||||
#endif /* CONFIG_ESPRESSIF_I2S0_RX */
|
||||
|
||||
/* Configure I2S generic audio on I2S0 */
|
||||
|
||||
ret = board_i2sdev_initialize(ESPRESSIF_I2S0,
|
||||
i2s_enable_tx,
|
||||
i2s_enable_rx);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize I2S0 driver: %d\n", ret);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ESPRESSIF_I2S */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
#
|
||||
# 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_NDEBUG is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
CONFIG_ARCH="risc-v"
|
||||
CONFIG_ARCH_BOARD="esp32c3-generic"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32C3_GENERIC=y
|
||||
CONFIG_ARCH_CHIP="esp32c3"
|
||||
CONFIG_ARCH_CHIP_ESP32C3_GENERIC=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=1536
|
||||
CONFIG_ARCH_RISCV=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_AUDIO=y
|
||||
CONFIG_AUDIO_I2S=y
|
||||
CONFIG_AUDIO_I2SCHAR=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=15000
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DRIVERS_AUDIO=y
|
||||
CONFIG_ESPRESSIF_I2S0=y
|
||||
CONFIG_ESPRESSIF_I2S0_MCLK=y
|
||||
CONFIG_EXAMPLES_I2SCHAR=y
|
||||
CONFIG_EXAMPLES_I2SCHAR_BUFSIZE=1024
|
||||
CONFIG_EXAMPLES_I2SCHAR_RX=y
|
||||
CONFIG_EXAMPLES_I2SCHAR_RXBUFFERS=2
|
||||
CONFIG_EXAMPLES_I2SCHAR_RXSTACKSIZE=4096
|
||||
CONFIG_EXAMPLES_I2SCHAR_TX=y
|
||||
CONFIG_EXAMPLES_I2SCHAR_TXBUFFERS=2
|
||||
CONFIG_EXAMPLES_I2SCHAR_TXSTACKSIZE=4096
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=4096
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_PERROR_STDOUT=y
|
||||
CONFIG_LIBC_STRERROR=y
|
||||
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NSH_STRERROR=y
|
||||
CONFIG_PREALLOC_TIMERS=0
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_BACKTRACE=y
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=29
|
||||
CONFIG_START_MONTH=11
|
||||
CONFIG_START_YEAR=2019
|
||||
CONFIG_SYSTEM_DUMPSTACK=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TESTING_GETPRIME=y
|
||||
CONFIG_TESTING_OSTEST=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
|
|
@ -73,6 +73,10 @@
|
|||
# include "esp_board_rmt.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S
|
||||
# include "esp_board_i2s.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_SPI
|
||||
# include "espressif/esp_spi.h"
|
||||
# include "esp_board_spidev.h"
|
||||
|
|
@ -317,6 +321,16 @@ int esp_bringup(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ESPRESSIF_I2S)
|
||||
/* Configure I2S peripheral interfaces */
|
||||
|
||||
ret = board_i2s_init();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize I2S driver: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_I2C_DRIVER)
|
||||
/* Configure I2C peripheral interfaces */
|
||||
|
||||
|
|
|
|||
76
boards/risc-v/esp32c6/common/include/esp_board_i2s.h
Normal file
76
boards/risc-v/esp32c6/common/include/esp_board_i2s.h
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/****************************************************************************
|
||||
* boards/risc-v/esp32c6/common/include/esp_board_i2s.h
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* 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_RISCV_ESP32C6_COMMON_INCLUDE_ESP_BOARD_I2S_H
|
||||
#define __BOARDS_RISCV_ESP32C3_COMMON_INCLUDE_ESP_BOARD_I2S_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_i2s_init
|
||||
*
|
||||
* Description:
|
||||
* Configure the I2S driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* to indicate the nature of any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S
|
||||
int board_i2s_init(void);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_RISCV_ESP32C6_COMMON_INCLUDE_ESP_BOARD_I2S_H */
|
||||
|
|
@ -46,6 +46,10 @@ ifeq ($(CONFIG_I2C_DRIVER),y)
|
|||
CSRCS += esp_board_i2c.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESPRESSIF_I2S),y)
|
||||
CSRCS += esp_board_i2s.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESPRESSIF_SPIFLASH),y)
|
||||
CSRCS += esp_board_spiflash.c
|
||||
endif
|
||||
|
|
|
|||
200
boards/risc-v/esp32c6/common/src/esp_board_i2s.c
Normal file
200
boards/risc-v/esp32c6/common/src/esp_board_i2s.c
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
/****************************************************************************
|
||||
* boards/risc-v/esp32c6/common/src/esp_board_i2s.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* 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 <debug.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.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 "espressif/esp_i2s.h"
|
||||
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
|
||||
audinfo("Initializing I2S\n");
|
||||
|
||||
i2s = esp_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;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_i2s_init
|
||||
*
|
||||
* Description:
|
||||
* Configure the I2S driver.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* to indicate the nature of any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_i2s_init(void)
|
||||
{
|
||||
int ret = OK;
|
||||
#if defined(CONFIG_ESPRESSIF_I2S0)
|
||||
bool i2s_enable_tx;
|
||||
bool i2s_enable_rx;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S0_TX
|
||||
i2s_enable_tx = true;
|
||||
#else
|
||||
i2s_enable_tx = false;
|
||||
#endif /* CONFIG_ESPRESSIF_I2S0_TX */
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S0_RX
|
||||
i2s_enable_rx = true;
|
||||
#else
|
||||
i2s_enable_rx = false;
|
||||
#endif /* CONFIG_ESPRESSIF_I2S0_RX */
|
||||
|
||||
/* Configure I2S generic audio on I2S0 */
|
||||
|
||||
ret = board_i2sdev_initialize(ESPRESSIF_I2S0,
|
||||
i2s_enable_tx,
|
||||
i2s_enable_rx);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize I2S0 driver: %d\n", ret);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ESPRESSIF_I2S */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
#
|
||||
# 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_NDEBUG is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
CONFIG_ARCH="risc-v"
|
||||
CONFIG_ARCH_BOARD="esp32c6-devkitc"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32C6_DEVKITC=y
|
||||
CONFIG_ARCH_CHIP="esp32c6"
|
||||
CONFIG_ARCH_CHIP_ESP32C6=y
|
||||
CONFIG_ARCH_CHIP_ESP32C6WROOM1=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_RISCV=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_AUDIO=y
|
||||
CONFIG_AUDIO_I2S=y
|
||||
CONFIG_AUDIO_I2SCHAR=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=15000
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DRIVERS_AUDIO=y
|
||||
CONFIG_ESPRESSIF_ESP32C6=y
|
||||
CONFIG_ESPRESSIF_I2S0=y
|
||||
CONFIG_ESPRESSIF_I2S0_MCLK=y
|
||||
CONFIG_EXAMPLES_I2SCHAR=y
|
||||
CONFIG_EXAMPLES_I2SCHAR_BUFSIZE=1024
|
||||
CONFIG_EXAMPLES_I2SCHAR_RX=y
|
||||
CONFIG_EXAMPLES_I2SCHAR_RXBUFFERS=2
|
||||
CONFIG_EXAMPLES_I2SCHAR_RXSTACKSIZE=4096
|
||||
CONFIG_EXAMPLES_I2SCHAR_TX=y
|
||||
CONFIG_EXAMPLES_I2SCHAR_TXBUFFERS=2
|
||||
CONFIG_EXAMPLES_I2SCHAR_TXSTACKSIZE=4096
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=4096
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_PERROR_STDOUT=y
|
||||
CONFIG_LIBC_STRERROR=y
|
||||
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NSH_STRERROR=y
|
||||
CONFIG_PREALLOC_TIMERS=0
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_BACKTRACE=y
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=29
|
||||
CONFIG_START_MONTH=11
|
||||
CONFIG_START_YEAR=2019
|
||||
CONFIG_SYSTEM_DUMPSTACK=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TESTING_GETPRIME=y
|
||||
CONFIG_TESTING_OSTEST=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
|
|
@ -73,6 +73,10 @@
|
|||
# include "esp_board_rmt.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S
|
||||
# include "esp_board_i2s.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_SPI
|
||||
# include "espressif/esp_spi.h"
|
||||
# include "esp_board_spidev.h"
|
||||
|
|
@ -270,6 +274,16 @@ int esp_bringup(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ESPRESSIF_I2S)
|
||||
/* Configure I2S peripheral interfaces */
|
||||
|
||||
ret = board_i2s_init();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize I2S driver: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_I2C_DRIVER)
|
||||
/* Configure I2C peripheral interfaces */
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
#
|
||||
# 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_NDEBUG is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
CONFIG_ARCH="risc-v"
|
||||
CONFIG_ARCH_BOARD="esp32c6-devkitm"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32C6_DEVKITM=y
|
||||
CONFIG_ARCH_CHIP="esp32c6"
|
||||
CONFIG_ARCH_CHIP_ESP32C6=y
|
||||
CONFIG_ARCH_CHIP_ESP32C6MINI1=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_RISCV=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_AUDIO=y
|
||||
CONFIG_AUDIO_I2S=y
|
||||
CONFIG_AUDIO_I2SCHAR=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=15000
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DRIVERS_AUDIO=y
|
||||
CONFIG_ESPRESSIF_ESP32C6=y
|
||||
CONFIG_ESPRESSIF_I2S0=y
|
||||
CONFIG_ESPRESSIF_I2S0_MCLK=y
|
||||
CONFIG_EXAMPLES_I2SCHAR=y
|
||||
CONFIG_EXAMPLES_I2SCHAR_BUFSIZE=1024
|
||||
CONFIG_EXAMPLES_I2SCHAR_RX=y
|
||||
CONFIG_EXAMPLES_I2SCHAR_RXBUFFERS=2
|
||||
CONFIG_EXAMPLES_I2SCHAR_RXSTACKSIZE=4096
|
||||
CONFIG_EXAMPLES_I2SCHAR_TX=y
|
||||
CONFIG_EXAMPLES_I2SCHAR_TXBUFFERS=2
|
||||
CONFIG_EXAMPLES_I2SCHAR_TXSTACKSIZE=4096
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=4096
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_PERROR_STDOUT=y
|
||||
CONFIG_LIBC_STRERROR=y
|
||||
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NSH_STRERROR=y
|
||||
CONFIG_PREALLOC_TIMERS=0
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_BACKTRACE=y
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=29
|
||||
CONFIG_START_MONTH=11
|
||||
CONFIG_START_YEAR=2019
|
||||
CONFIG_SYSTEM_DUMPSTACK=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TESTING_GETPRIME=y
|
||||
CONFIG_TESTING_OSTEST=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
|
|
@ -73,6 +73,10 @@
|
|||
# include "esp_board_rmt.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S
|
||||
# include "esp_board_i2s.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_SPI
|
||||
# include "espressif/esp_spi.h"
|
||||
# include "esp_board_spidev.h"
|
||||
|
|
@ -266,6 +270,16 @@ int esp_bringup(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ESPRESSIF_I2S)
|
||||
/* Configure I2S peripheral interfaces */
|
||||
|
||||
ret = board_i2s_init();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize I2S driver: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_I2C_DRIVER)
|
||||
/* Configure I2C peripheral interfaces */
|
||||
|
||||
|
|
|
|||
76
boards/risc-v/esp32h2/common/include/esp_board_i2s.h
Normal file
76
boards/risc-v/esp32h2/common/include/esp_board_i2s.h
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/****************************************************************************
|
||||
* boards/risc-v/esp32h2/common/include/esp_board_i2s.h
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* 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_RISCV_ESP32H2_COMMON_INCLUDE_ESP_BOARD_I2S_H
|
||||
#define __BOARDS_RISCV_ESP32H2_COMMON_INCLUDE_ESP_BOARD_I2S_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_i2s_init
|
||||
*
|
||||
* Description:
|
||||
* Configure the I2S driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* to indicate the nature of any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S
|
||||
int board_i2s_init(void);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_RISCV_ESP32H2_COMMON_INCLUDE_ESP_BOARD_I2S_H */
|
||||
|
|
@ -46,6 +46,10 @@ ifeq ($(CONFIG_I2C_DRIVER),y)
|
|||
CSRCS += esp_board_i2c.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESPRESSIF_I2S),y)
|
||||
CSRCS += esp_board_i2s.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESPRESSIF_SPIFLASH),y)
|
||||
CSRCS += esp_board_spiflash.c
|
||||
endif
|
||||
|
|
|
|||
200
boards/risc-v/esp32h2/common/src/esp_board_i2s.c
Normal file
200
boards/risc-v/esp32h2/common/src/esp_board_i2s.c
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
/****************************************************************************
|
||||
* boards/risc-v/esp32h2/common/src/esp_board_i2s.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* 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 <debug.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.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 "espressif/esp_i2s.h"
|
||||
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
|
||||
audinfo("Initializing I2S\n");
|
||||
|
||||
i2s = esp_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;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_i2s_init
|
||||
*
|
||||
* Description:
|
||||
* Configure the I2S driver.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* to indicate the nature of any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_i2s_init(void)
|
||||
{
|
||||
int ret = OK;
|
||||
#if defined(CONFIG_ESPRESSIF_I2S0)
|
||||
bool i2s_enable_tx;
|
||||
bool i2s_enable_rx;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S0_TX
|
||||
i2s_enable_tx = true;
|
||||
#else
|
||||
i2s_enable_tx = false;
|
||||
#endif /* CONFIG_ESPRESSIF_I2S0_TX */
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S0_RX
|
||||
i2s_enable_rx = true;
|
||||
#else
|
||||
i2s_enable_rx = false;
|
||||
#endif /* CONFIG_ESPRESSIF_I2S0_RX */
|
||||
|
||||
/* Configure I2S generic audio on I2S0 */
|
||||
|
||||
ret = board_i2sdev_initialize(ESPRESSIF_I2S0,
|
||||
i2s_enable_tx,
|
||||
i2s_enable_rx);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize I2S0 driver: %d\n", ret);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ESPRESSIF_I2S */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
#
|
||||
# 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_NDEBUG is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
CONFIG_ARCH="risc-v"
|
||||
CONFIG_ARCH_BOARD="esp32h2-devkit"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32H2_DEVKIT=y
|
||||
CONFIG_ARCH_CHIP="esp32h2"
|
||||
CONFIG_ARCH_CHIP_ESP32H2=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_RISCV=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_AUDIO=y
|
||||
CONFIG_AUDIO_I2S=y
|
||||
CONFIG_AUDIO_I2SCHAR=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=15000
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DRIVERS_AUDIO=y
|
||||
CONFIG_ESPRESSIF_ESP32H2=y
|
||||
CONFIG_ESPRESSIF_I2S0=y
|
||||
CONFIG_ESPRESSIF_I2S0_MCLK=y
|
||||
CONFIG_EXAMPLES_I2SCHAR=y
|
||||
CONFIG_EXAMPLES_I2SCHAR_BUFSIZE=1024
|
||||
CONFIG_EXAMPLES_I2SCHAR_RX=y
|
||||
CONFIG_EXAMPLES_I2SCHAR_RXBUFFERS=2
|
||||
CONFIG_EXAMPLES_I2SCHAR_RXSTACKSIZE=4096
|
||||
CONFIG_EXAMPLES_I2SCHAR_TX=y
|
||||
CONFIG_EXAMPLES_I2SCHAR_TXBUFFERS=2
|
||||
CONFIG_EXAMPLES_I2SCHAR_TXSTACKSIZE=4096
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=4096
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_PERROR_STDOUT=y
|
||||
CONFIG_LIBC_STRERROR=y
|
||||
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NSH_STRERROR=y
|
||||
CONFIG_PREALLOC_TIMERS=0
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_BACKTRACE=y
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=29
|
||||
CONFIG_START_MONTH=11
|
||||
CONFIG_START_YEAR=2019
|
||||
CONFIG_SYSTEM_DUMPSTACK=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TESTING_GETPRIME=y
|
||||
CONFIG_TESTING_OSTEST=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
|
|
@ -73,6 +73,10 @@
|
|||
# include "esp_board_rmt.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_I2S
|
||||
# include "esp_board_i2s.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_SPI
|
||||
# include "espressif/esp_spi.h"
|
||||
# include "esp_board_spidev.h"
|
||||
|
|
@ -264,6 +268,16 @@ int esp_bringup(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ESPRESSIF_I2S)
|
||||
/* Configure I2S peripheral interfaces */
|
||||
|
||||
ret = board_i2s_init();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize I2S driver: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_I2C_DRIVER)
|
||||
/* Configure I2C peripheral interfaces */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue