xtensa/esp32s2: add initial support for I2S
Add initial support for the I2S peripheral on ESP32S2. Add I2S character driver and generic I2S audio driver. Include i2schar defconfig for ESP32-S2-Saola-1 board.
This commit is contained in:
parent
1c416b1712
commit
16b99ee013
@ -205,7 +205,7 @@ choice ESP32S2_FLASH_FREQ
|
||||
default ESP32S2_FLASH_FREQ_40M
|
||||
---help---
|
||||
SPI FLASH frequency
|
||||
|
||||
|
||||
config ESP32S2_FLASH_FREQ_80M
|
||||
bool "80 MHz"
|
||||
|
||||
@ -256,6 +256,126 @@ config ESP32S2_RNG
|
||||
---help---
|
||||
ESP32-S2 supports a RNG that passed on Dieharder test suite.
|
||||
|
||||
config ESP32S2_I2S
|
||||
bool "I2S"
|
||||
default n
|
||||
select I2S
|
||||
select ARCH_DMA
|
||||
select ESP32S2_GPIO_IRQ
|
||||
---help---
|
||||
See the Board Selection menu to configure the pins used by I2S.
|
||||
|
||||
if ESP32S2_I2S
|
||||
|
||||
config ESP32S2_I2S_RX
|
||||
bool "Enable I2S receiver"
|
||||
default y
|
||||
---help---
|
||||
Enable I2S receive logic
|
||||
|
||||
config ESP32S2_I2S_TX
|
||||
bool "Enable I2S transmitter"
|
||||
default y
|
||||
---help---
|
||||
Enable I2S transmit logic
|
||||
|
||||
choice
|
||||
prompt "I2S role"
|
||||
default ESP32S2_I2S_ROLE_MASTER
|
||||
---help---
|
||||
Selects the operation role of the I2S.
|
||||
|
||||
config ESP32S2_I2S_ROLE_MASTER
|
||||
bool "Master"
|
||||
|
||||
config ESP32S2_I2S_ROLE_SLAVE
|
||||
bool "Slave"
|
||||
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "Bit width"
|
||||
---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 ESP32S2_I2S_DATA_BIT_WIDTH_8BIT
|
||||
bool "8 bits"
|
||||
|
||||
config ESP32S2_I2S_DATA_BIT_WIDTH_16BIT
|
||||
bool "16 bits"
|
||||
|
||||
config ESP32S2_I2S_DATA_BIT_WIDTH_24BIT
|
||||
bool "24 bits"
|
||||
|
||||
config ESP32S2_I2S_DATA_BIT_WIDTH_32BIT
|
||||
bool "32 bits"
|
||||
|
||||
endchoice
|
||||
|
||||
config ESP32S2_I2S_DATA_BIT_WIDTH
|
||||
int
|
||||
default 8 if ESP32S2_I2S_DATA_BIT_WIDTH_8BIT
|
||||
default 16 if ESP32S2_I2S_DATA_BIT_WIDTH_16BIT
|
||||
default 24 if ESP32S2_I2S_DATA_BIT_WIDTH_24BIT
|
||||
default 32 if ESP32S2_I2S_DATA_BIT_WIDTH_32BIT
|
||||
|
||||
config ESP32S2_I2S_SAMPLE_RATE
|
||||
int "I2S 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 ESP32S2_I2S_BCLKPIN
|
||||
int "I2S BCLK pin"
|
||||
default 35
|
||||
range 0 45 if ESP32S2_I2S_ROLE_MASTER
|
||||
range 0 46 if ESP32S2_I2S_ROLE_SLAVE
|
||||
|
||||
config ESP32S2_I2S_WSPIN
|
||||
int "I2S WS pin"
|
||||
default 34
|
||||
range 0 45 if ESP32S2_I2S_ROLE_MASTER
|
||||
range 0 46 if ESP32S2_I2S_ROLE_SLAVE
|
||||
|
||||
config ESP32S2_I2S_DINPIN
|
||||
int "I2S DOUT pin"
|
||||
depends on ESP32S2_I2S_RX
|
||||
default 37
|
||||
range 0 46
|
||||
|
||||
config ESP32S2_I2S_DOUTPIN
|
||||
int "I2S DOUT pin"
|
||||
depends on ESP32S2_I2S_TX
|
||||
default 36
|
||||
range 0 45
|
||||
|
||||
config ESP32S2_I2S_MCLK
|
||||
bool "Enable I2S Master Clock"
|
||||
depends on ESP32S2_I2S_ROLE_MASTER
|
||||
default n
|
||||
---help---
|
||||
Enable I2S master clock
|
||||
|
||||
config ESP32S2_I2S_MCLKPIN
|
||||
int "I2S MCLK pin"
|
||||
depends on ESP32S2_I2S_MCLK
|
||||
default 33
|
||||
range 0 45
|
||||
|
||||
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 a I2S DMA transfer.
|
||||
|
||||
endif #ESP32S2_I2S
|
||||
|
||||
config ESP32S2_SPI2
|
||||
bool "SPI 2"
|
||||
default n
|
||||
|
@ -30,6 +30,7 @@ HEAD_CSRC = esp32s2_start.c esp32s2_wdt.c
|
||||
CHIP_CSRCS = esp32s2_allocateheap.c esp32s2_clockconfig.c esp32s2_irq.c
|
||||
CHIP_CSRCS += esp32s2_gpio.c esp32s2_region.c esp32s2_user.c
|
||||
CHIP_CSRCS += esp32s2_timerisr.c esp32s2_lowputc.c esp32s2_systemreset.c
|
||||
CHIP_CSRCS += esp32s2_dma.c
|
||||
|
||||
# Configuration-dependent ESP32-S2 files
|
||||
|
||||
@ -49,6 +50,10 @@ ifeq ($(CONFIG_ESP32S2_I2C),y)
|
||||
CHIP_CSRCS += esp32s2_i2c.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP32S2_I2S),y)
|
||||
CHIP_CSRCS += esp32s2_i2s.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP32S2_SPI),y)
|
||||
CHIP_CSRCS += esp32s2_spi.c
|
||||
endif
|
||||
|
186
arch/xtensa/src/esp32s2/esp32s2_dma.c
Normal file
186
arch/xtensa/src/esp32s2/esp32s2_dma.c
Normal file
@ -0,0 +1,186 @@
|
||||
/****************************************************************************
|
||||
* arch/xtensa/src/esp32s2/esp32s2_dma.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 <assert.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "hardware/esp32s2_dma.h"
|
||||
#include "esp32s2_dma.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Preprocessor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef ALIGN_UP
|
||||
# define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2_dma_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize DMA outlink descriptors and bind the target buffer to
|
||||
* these DMA descriptors.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dmadesc - Pointer to the DMA descriptors
|
||||
* num - Number of DMA descriptors
|
||||
* pbuf - RX/TX buffer pointer
|
||||
* len - RX/TX buffer length
|
||||
*
|
||||
* Returned Value:
|
||||
* Bound pbuf data bytes
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t esp32s2_dma_init(struct esp32s2_dmadesc_s *dmadesc, uint32_t num,
|
||||
uint8_t *pbuf, uint32_t len)
|
||||
{
|
||||
int i;
|
||||
uint32_t bytes = len;
|
||||
uint8_t *pdata = pbuf;
|
||||
uint32_t data_len;
|
||||
uint32_t buf_len;
|
||||
|
||||
DEBUGASSERT(dmadesc != NULL);
|
||||
DEBUGASSERT(pbuf != NULL);
|
||||
DEBUGASSERT(len > 0);
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
data_len = MIN(bytes, ESP32S2_DMA_DATALEN_MAX);
|
||||
|
||||
/* Buffer length must be rounded to next 32-bit boundary. */
|
||||
|
||||
buf_len = ALIGN_UP(data_len, sizeof(uintptr_t));
|
||||
|
||||
dmadesc[i].ctrl = (data_len << DMA_CTRL_DATALEN_S) |
|
||||
(buf_len << DMA_CTRL_BUFLEN_S) |
|
||||
DMA_CTRL_OWN;
|
||||
dmadesc[i].pbuf = pdata;
|
||||
dmadesc[i].next = &dmadesc[i + 1];
|
||||
|
||||
bytes -= data_len;
|
||||
if (bytes == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
pdata += data_len;
|
||||
}
|
||||
|
||||
dmadesc[i].ctrl |= DMA_CTRL_EOF;
|
||||
dmadesc[i].next = NULL;
|
||||
|
||||
return len - bytes;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2_dma_init_with_padding
|
||||
*
|
||||
* Description:
|
||||
* Initialize DMA outlink descriptors and bind the target buffer to
|
||||
* these DMA descriptors. If len is not word-aligned, add a new descriptor
|
||||
* containing a 4-byte variable to make the outlink data world-aligned.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dmadesc - Pointer to the DMA descriptors
|
||||
* num - Number of DMA descriptors
|
||||
* pbuf - RX/TX buffer pointer
|
||||
* len - RX/TX buffer length
|
||||
* stuff - Value to be padded with the buffer
|
||||
*
|
||||
* Returned Value:
|
||||
* Bound pbuf data bytes
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t esp32s2_dma_init_with_padding(struct esp32s2_dmadesc_s *dmadesc,
|
||||
uint32_t num,
|
||||
uint8_t *pbuf,
|
||||
uint32_t len,
|
||||
uint32_t *stuff)
|
||||
{
|
||||
int i;
|
||||
uint32_t bytes = len;
|
||||
uint8_t *pdata = pbuf;
|
||||
uint32_t data_len = 0;
|
||||
uint32_t buf_len = 0;
|
||||
|
||||
DEBUGASSERT(dmadesc != NULL);
|
||||
DEBUGASSERT(pbuf != NULL);
|
||||
DEBUGASSERT(len > 0);
|
||||
|
||||
for (i = 0; i < num - 1; i++)
|
||||
{
|
||||
data_len = MIN(bytes, ESP32S2_DMA_DATALEN_MAX);
|
||||
|
||||
/* Buffer length must be rounded to next 32-bit boundary. */
|
||||
|
||||
buf_len = ALIGN_UP(data_len, sizeof(uintptr_t));
|
||||
|
||||
dmadesc[i].ctrl = (data_len << DMA_CTRL_DATALEN_S) |
|
||||
(buf_len << DMA_CTRL_BUFLEN_S) |
|
||||
DMA_CTRL_OWN;
|
||||
dmadesc[i].pbuf = pdata;
|
||||
dmadesc[i].next = &dmadesc[i + 1];
|
||||
|
||||
bytes -= data_len;
|
||||
if (bytes == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
pdata += data_len;
|
||||
}
|
||||
|
||||
/* Check if the data_len of the last descriptor is different from buf_len.
|
||||
* If so, it's necessary to add the padding bytes to a new descriptor on
|
||||
* outlink.
|
||||
*/
|
||||
|
||||
if (data_len != buf_len)
|
||||
{
|
||||
i++;
|
||||
dmadesc[i].ctrl = ((buf_len - data_len) << DMA_CTRL_DATALEN_S) |
|
||||
(4 << DMA_CTRL_BUFLEN_S) |
|
||||
DMA_CTRL_OWN;
|
||||
dmadesc[i].pbuf = (uint8_t *)stuff;
|
||||
}
|
||||
|
||||
dmadesc[i].ctrl |= DMA_CTRL_EOF;
|
||||
dmadesc[i].next = NULL;
|
||||
|
||||
return len - bytes;
|
||||
}
|
124
arch/xtensa/src/esp32s2/esp32s2_dma.h
Normal file
124
arch/xtensa/src/esp32s2/esp32s2_dma.h
Normal file
@ -0,0 +1,124 @@
|
||||
/****************************************************************************
|
||||
* arch/xtensa/src/esp32s2/esp32s2_dma.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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_XTENSA_SRC_ESP32S2_ESP32S2_DMA_H
|
||||
#define __ARCH_XTENSA_SRC_ESP32S2_ESP32S2_DMA_H
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Macros
|
||||
****************************************************************************/
|
||||
|
||||
/* DMA max data length */
|
||||
|
||||
#define ESP32S2_DMA_DATALEN_MAX (0x1000 - 4)
|
||||
|
||||
/* DMA max buffer length */
|
||||
|
||||
#define ESP32S2_DMA_BUFLEN_MAX ESP32S2_DMA_DATALEN_MAX
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* DMA descriptor type */
|
||||
|
||||
struct esp32s2_dmadesc_s
|
||||
{
|
||||
uint32_t ctrl; /* DMA control block */
|
||||
uint8_t *pbuf; /* DMA TX/RX buffer address */
|
||||
struct esp32s2_dmadesc_s *next; /* Next DMA descriptor address */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2_dma_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize DMA outlink descriptors and bind the target buffer to
|
||||
* these DMA descriptors.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dmadesc - Pointer to the DMA descriptors
|
||||
* num - Number of DMA descriptors
|
||||
* pbuf - RX/TX buffer pointer
|
||||
* len - RX/TX buffer length
|
||||
*
|
||||
* Returned Value:
|
||||
* Bound pbuf data bytes
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t esp32s2_dma_init(struct esp32s2_dmadesc_s *dmadesc, uint32_t num,
|
||||
uint8_t *pbuf, uint32_t len);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2_dma_init_with_padding
|
||||
*
|
||||
* Description:
|
||||
* Initialize DMA outlink descriptors and bind the target buffer to
|
||||
* these DMA descriptors. If len is not word-aligned, add a new descriptor
|
||||
* containing a 4-byte variable to make the outlink data world-aligned.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dmadesc - Pointer to the DMA descriptors
|
||||
* num - Number of DMA descriptors
|
||||
* pbuf - RX/TX buffer pointer
|
||||
* len - RX/TX buffer length
|
||||
* stuff - Value to be padded with the buffer
|
||||
*
|
||||
* Returned Value:
|
||||
* Bound pbuf data bytes
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t esp32s2_dma_init_with_padding(struct esp32s2_dmadesc_s *dmadesc,
|
||||
uint32_t num,
|
||||
uint8_t *pbuf,
|
||||
uint32_t len,
|
||||
uint32_t *stuff);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#undef EXTERN
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ARCH_XTENSA_SRC_ESP32S2_ESP32S2_DMA_H */
|
1507
arch/xtensa/src/esp32s2/esp32s2_i2s.c
Normal file
1507
arch/xtensa/src/esp32s2/esp32s2_i2s.c
Normal file
File diff suppressed because it is too large
Load Diff
74
arch/xtensa/src/esp32s2/esp32s2_i2s.h
Normal file
74
arch/xtensa/src/esp32s2/esp32s2_i2s.h
Normal file
@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
* arch/xtensa/src/esp32s2/esp32s2_i2s.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 __ARCH_XTENSA_SRC_ESP32S2_ESP32S2_I2S_H
|
||||
#define __ARCH_XTENSA_SRC_ESP32S2_ESP32S2_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_ESP32S2_I2S
|
||||
|
||||
#define ESP32S2_I2S0 0
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2_i2sbus_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the selected I2S port
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Valid I2S device structure reference on success; a NULL on failure
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct i2s_dev_s *esp32s2_i2sbus_initialize(void);
|
||||
|
||||
#endif /* CONFIG_ESP32S2_I2S */
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ARCH_XTENSA_SRC_ESP32S2_ESP32S2_I2S_H */
|
36
arch/xtensa/src/esp32s2/hardware/esp32s2_dma.h
Normal file
36
arch/xtensa/src/esp32s2/hardware/esp32s2_dma.h
Normal file
@ -0,0 +1,36 @@
|
||||
/****************************************************************************
|
||||
* arch/xtensa/src/esp32s2/hardware/esp32s2_dma.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 __ARCH_XTENSA_SRC_ESP32S2_HARDWARE_ESP32S2_DMA_H
|
||||
#define __ARCH_XTENSA_SRC_ESP32S2_HARDWARE_ESP32S2_DMA_H
|
||||
|
||||
/* DMA descriptor */
|
||||
|
||||
#define DMA_CTRL_OWN (1 << 31) /* Owned by DMA */
|
||||
#define DMA_CTRL_EOF (1 << 30) /* End of frame */
|
||||
#define DMA_CTRL_SOSF (1 << 29) /* Start of sub-frame */
|
||||
#define DMA_CTRL_OFFSET_S (24) /* buffer offset shift */
|
||||
#define DMA_CTRL_OFFSET_V (0x1f) /* buffer offset value */
|
||||
#define DMA_CTRL_DATALEN_S (12) /* received/sent data length shift */
|
||||
#define DMA_CTRL_DATALEN_V (0xfff) /* received/sent data length value */
|
||||
#define DMA_CTRL_BUFLEN_S (0) /* received/sent buffer length shift */
|
||||
#define DMA_CTRL_BUFLEN_V (0xfff) /* received/sent buffer length value */
|
||||
|
||||
#endif /* __ARCH_XTENSA_SRC_ESP32S2_HARDWARE_ESP32S2_DMA_H */
|
File diff suppressed because it is too large
Load Diff
@ -28,6 +28,10 @@ ifeq ($(CONFIG_SENSORS_MAX6675),y)
|
||||
CSRCS += esp32s2_max6675.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP32S2_I2S),y)
|
||||
CSRCS += esp32s2_board_i2sdev.c
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path src
|
||||
VPATH += :src
|
||||
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src)
|
||||
|
113
boards/xtensa/esp32s2/common/src/esp32s2_board_i2sdev.c
Normal file
113
boards/xtensa/esp32s2/common/src/esp32s2_board_i2sdev.c
Normal file
@ -0,0 +1,113 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s2/common/src/esp32s2_board_i2sdev.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 "esp32s2_i2s.h"
|
||||
|
||||
#if defined(CONFIG_ESP32S2_I2S) && !defined(CONFIG_AUDIO_CS4344)
|
||||
|
||||
/****************************************************************************
|
||||
* 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:
|
||||
* None
|
||||
*
|
||||
* 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(void)
|
||||
{
|
||||
struct audio_lowerhalf_s *audio_i2s;
|
||||
struct audio_lowerhalf_s *pcm;
|
||||
struct i2s_dev_s *i2s;
|
||||
char devname[5];
|
||||
int ret;
|
||||
|
||||
ainfo("Initializing I2S\n");
|
||||
|
||||
i2s = esp32s2_i2sbus_initialize();
|
||||
|
||||
#ifdef CONFIG_AUDIO_I2SCHAR
|
||||
ret = i2schar_register(i2s, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
aerr("ERROR: i2schar_register failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
audio_i2s = audio_i2s_initialize(i2s, true);
|
||||
|
||||
if (!audio_i2s)
|
||||
{
|
||||
auderr("ERROR: Failed to initialize the Generic I2S audio driver\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
pcm = pcm_decode_initialize(audio_i2s);
|
||||
|
||||
if (!pcm)
|
||||
{
|
||||
auderr("ERROR: Failed create the PCM decoder\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
snprintf(devname, 5, "pcm0");
|
||||
|
||||
ret = audio_register(devname, pcm);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
auderr("ERROR: Failed to register /dev/%s device: %d\n", devname, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* (CONFIG_ESP32S2_I2S) && !defined (CONFIG_AUDIO_CS4344) */
|
@ -0,0 +1,60 @@
|
||||
#
|
||||
# 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_ESP32S2_I2S_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_ARCH="xtensa"
|
||||
CONFIG_ARCH_BOARD="esp32s2-saola-1"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32S2_SAOLA_1=y
|
||||
CONFIG_ARCH_CHIP="esp32s2"
|
||||
CONFIG_ARCH_CHIP_ESP32S2=y
|
||||
CONFIG_ARCH_CHIP_ESP32S2WROVER=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_AUDIO=y
|
||||
CONFIG_AUDIO_I2S=y
|
||||
CONFIG_AUDIO_I2SCHAR=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_FULLOPT=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DRIVERS_AUDIO=y
|
||||
CONFIG_ESP32S2_I2S=y
|
||||
CONFIG_ESP32S2_I2S_MCLK=y
|
||||
CONFIG_ESP32S2_UART0=y
|
||||
CONFIG_EXAMPLES_I2SCHAR=y
|
||||
CONFIG_EXAMPLES_I2SCHAR_TX=y
|
||||
CONFIG_EXAMPLES_I2SCHAR_TXSTACKSIZE=4096
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=4096
|
||||
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_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
@ -152,5 +152,27 @@ 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:
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success. Otherwise, a negated errno value is
|
||||
* returned to indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP32S2_I2S
|
||||
int board_i2sdev_initialize(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_XTENSA_ESP32S2_ESP32S2_SAOLA_1_SRC_ESP32S2_SAOLA_1_H */
|
||||
|
@ -229,6 +229,18 @@ int esp32s2_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S2_I2S
|
||||
|
||||
/* Configure I2S generic audio on I2S0 */
|
||||
|
||||
ret = board_i2sdev_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize I2S0 driver: %d\n", ret);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ESP32S2_I2S */
|
||||
|
||||
/* If we got here then perhaps not all initialization was successful, but
|
||||
* at least enough succeeded to bring-up NSH with perhaps reduced
|
||||
* capabilities.
|
||||
|
Loading…
Reference in New Issue
Block a user