Skip to content

Commit

Permalink
stm32f777zit6-meadow: Add support to audio using I2S interface
Browse files Browse the repository at this point in the history
  • Loading branch information
acassis committed Mar 17, 2024
1 parent 6d8c794 commit 353034e
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
79 changes: 79 additions & 0 deletions boards/arm/stm32f7/stm32f777zit6-meadow/configs/i2s/defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_STM32F7_USE_LEGACY_PINMAP is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="stm32f777zit6-meadow"
CONFIG_ARCH_BOARD_MEADOW_F7MICRO=y
CONFIG_ARCH_CHIP="stm32f7"
CONFIG_ARCH_CHIP_STM32F777ZI=y
CONFIG_ARCH_CHIP_STM32F7=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV7M_DCACHE=y
CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y
CONFIG_ARMV7M_DTCM=y
CONFIG_ARMV7M_ICACHE=y
CONFIG_AUDIO=y
CONFIG_AUDIO_CS4344=y
CONFIG_AUDIO_EXCLUDE_TONE=y
CONFIG_AUDIO_EXCLUDE_VOLUME=y
CONFIG_AUDIO_I2S=y
CONFIG_BCH=y
CONFIG_BOARDCTL_USBDEVCTRL=y
CONFIG_BOARD_LATE_INITIALIZE=y
CONFIG_BOARD_LOOPSPERMSEC=43103
CONFIG_BUILTIN=y
CONFIG_CDCACM=y
CONFIG_CDCACM_CONSOLE=y
CONFIG_CDCACM_PRODUCTID=0x0001
CONFIG_CDCACM_PRODUCTSTR="Wilderness Labs"
CONFIG_CDCACM_VENDORID=0x2E6A
CONFIG_CDCACM_VENDORSTR="Meadow F7 Micro"
CONFIG_CRYPTO=y
CONFIG_CRYPTO_RANDOM_POOL=y
CONFIG_DEV_URANDOM=y
CONFIG_DEV_URANDOM_RANDOM_POOL=y
CONFIG_DRIVERS_AUDIO=y
CONFIG_FS_LITTLEFS=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_I2S=y
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INTELHEX_BINARY=y
CONFIG_MM_REGIONS=3
CONFIG_MTD=y
CONFIG_MTD_BYTE_WRITE=y
CONFIG_MTD_PARTITION=y
CONFIG_MTD_SECT512=y
CONFIG_MTD_W25QXXXJV=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=245760
CONFIG_RAM_START=0x20010000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SPI=y
CONFIG_START_DAY=14
CONFIG_STM32F7_DMA1=y
CONFIG_STM32F7_I2S2=y
CONFIG_STM32F7_I2S2_MCK=y
CONFIG_STM32F7_I2S2_TX=y
CONFIG_STM32F7_OTGFS=y
CONFIG_STM32F7_QSPI_POLLING=y
CONFIG_STM32F7_QUADSPI=y
CONFIG_STM32F7_USART1=y
CONFIG_SYSTEM_FLASH_ERASEALL=y
CONFIG_SYSTEM_NSH=y
CONFIG_TASK_NAME_SIZE=64
CONFIG_USBDEV=y
CONFIG_W25QXXXJV_QSPI_FREQUENCY=64000000
21 changes: 21 additions & 0 deletions boards/arm/stm32f7/stm32f777zit6-meadow/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@
#define STM32_RCC_PLLSAICFGR_PLLSAIQ RCC_PLLSAICFGR_PLLSAIQ(2)
#define STM32_RCC_PLLSAICFGR_PLLSAIR RCC_PLLSAICFGR_PLLSAIR(2)

/* SAIx input frequency = 25 / M * N / Q / P
* 25000000 / 25 * 384 / 2 / 8
*/

#define STM32F7_SAI1_FREQUENCY (49142857)
#define STM32F7_SAI2_FREQUENCY (49142857)

/* Configure Dedicated Clock Configuration Register */

#define STM32_RCC_DCKCFGR1_PLLI2SDIVQ RCC_DCKCFGR1_PLLI2SDIVQ(1)
Expand Down Expand Up @@ -377,6 +384,10 @@

/* DMA Channel/Stream Selections ********************************************/

#define DMACHAN_SAI2_A DMAMAP_SAI2_A
#define DMACHAN_SAI2_B DMAMAP_SAI2_B
#define DMACHAN_SAI1_B DMAMAP_SAI1_B

/* SDMMC */

/* Stream selections are arbitrary for now but might become important in the
Expand Down Expand Up @@ -470,6 +481,16 @@
#define GPIO_I2C1_SCL (GPIO_I2C1_SCL_1|GPIO_SPEED_50MHz)
#define GPIO_I2C1_SDA (GPIO_I2C1_SDA_1|GPIO_SPEED_50MHz)

/* I2S2 - CS4344 configuration uses I2S2 */

#define GPIO_I2S2_SD (GPIO_I2S2_SD_1 | GPIO_SPEED_100MHz) /* PB15 */
#define GPIO_I2S2_CK (GPIO_I2S2_CK_3 | GPIO_SPEED_100MHz) /* PB13 */
#define GPIO_I2S2_WS (GPIO_I2S2_WS_1 | GPIO_SPEED_100MHz) /* PB12 */
#define GPIO_I2S2_MCK (GPIO_I2S2_MCK_0 | GPIO_SPEED_100MHz) /* PC6 */

#define DMACHAN_I2S3_RX DMAMAP_SPI3_RX_2
#define DMACHAN_I2S3_TX DMAMAP_SPI3_TX_2

/* QSPI Mapping */

#define GPIO_QSPI_CS (GPIO_QUADSPI_BK1_NCS_2 | GPIO_FLOAT | GPIO_PUSHPULL | GPIO_SPEED_100MHz)
Expand Down
14 changes: 14 additions & 0 deletions boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32_bringup.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
#include <nuttx/fs/fs.h>
#include <nuttx/i2c/i2c_master.h>

#ifdef CONFIG_AUDIO_CS4344
# include "stm32_cs4344.h"
#endif

#include "stm32f777zit6-meadow.h"

/****************************************************************************
Expand Down Expand Up @@ -139,6 +143,16 @@ int stm32_bringup(void)
}
#endif

#ifdef CONFIG_AUDIO_CS4344
/* Configure CS4344 audio as /dev/pcm0 on I2S2 */

ret = board_cs4344_initialize(0, 2);
if (ret != OK)
{
syslog(LOG_ERR, "Failed to initialize CS4344 audio: %d\n", ret);
}
#endif

#ifdef CONFIG_BOARD_MEADOW_F7_CORE_COMPUTE
/* Initialize all devices in the F7 Core Compute */

Expand Down

0 comments on commit 353034e

Please sign in to comment.