mirror of
https://github.com/apache/nuttx.git
synced 2026-05-19 11:53:25 +08:00
arch/arm/src/stm32: Include needed headers to get stm32_i2s.c compiled
configs/stm32f4discovery/include/board.h: Add SPI DMA pins definitions to get CS43L22 audio DAC working configs/stm32f4discovery/audio: Add board configuration for CS43L22 audio example configs/stm32f4discovery: Update README
This commit is contained in:
committed by
Gregory Nutt
parent
2366c13f87
commit
cc1d68bd92
@@ -85,6 +85,10 @@
|
||||
#include "up_internal.h"
|
||||
#include "up_arch.h"
|
||||
|
||||
#include "stm32_dma.h"
|
||||
#include "stm32_spi.h"
|
||||
#include "stm32_rcc.h"
|
||||
|
||||
#if defined(CONFIG_STM32_I2S2) || defined(CONFIG_STM32_I2S3)
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/************************************************************************************
|
||||
* arch/arm/src/stm32/stm32_i2s.h
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2017-2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -1188,6 +1188,85 @@ Where <subdir> is one of the sub-directories listed in the next paragraph
|
||||
Configuration Sub-directories
|
||||
-------------------------
|
||||
|
||||
audio:
|
||||
-----
|
||||
|
||||
This configuration is a variant of the NSH configuration used for
|
||||
demonstrating PCM audio using the CS43L22 stereo DAC/amplifier on board
|
||||
the STM32F4 Discovery and the STM32 I2S DMA interface. In uses the
|
||||
file player at apps/system/nxplayer.
|
||||
|
||||
The original CS43L22 and STM32 I2S drivers were contribued by Taras
|
||||
Drozdovsky in May of 2017. The audio configuration was contributed by
|
||||
Alan Carvalho de Assis and derives, in part, from the work of Taras at https://github.com/tdrozdovskiy/CS43L22-Audio-driver.
|
||||
|
||||
Usage instructions from the README file at the location:
|
||||
|
||||
1. Prepare USB flash storage. This configuration depends on .WAV files
|
||||
provided to the system via a USB flash stick. There are some sample
|
||||
audio files at https://github.com/tdrozdovskiy/CS43L22-Audio-driver
|
||||
and these steps will put those sample .WAV files onto the USB flash:
|
||||
|
||||
a. Format the USB flash storage into FAT. For example by next command
|
||||
|
||||
$ mkfs.vfat /dev/sdb1
|
||||
|
||||
b. Create folder /music
|
||||
|
||||
$ mkdir music
|
||||
|
||||
c. Copy files from /audio_samples/ to /music folder of USB flash storage
|
||||
|
||||
$ cp <repo>/audio_samples/* /mnt/media/music/
|
||||
|
||||
2. Example usage CS43L22 Audio driver
|
||||
|
||||
a. Power On or reset the STM32F4 Discovery board. We can see the Nuttx
|
||||
command line prompt:
|
||||
|
||||
NuttShell (NSH)
|
||||
nsh>
|
||||
|
||||
b. Mount the usb flash device into our file system
|
||||
|
||||
nsh> mount -t vfat /dev/sda/ /mnt/sda
|
||||
|
||||
c. Start the NxPlayer program and Enter the help command to view the list
|
||||
of commands
|
||||
|
||||
nsh> nxplayer
|
||||
NxPlayer version 1.04
|
||||
h for commands, q to exit
|
||||
nxplayer> h
|
||||
NxPlayer commands
|
||||
================
|
||||
balance d% : Set balance percentage (< 50% means more left)
|
||||
device devfile : Specify a preferred audio device
|
||||
h : Display help for commands
|
||||
help : Display help for commands
|
||||
mediadir path : Change the media directory
|
||||
play filename : Play a media file
|
||||
pause : Pause playback
|
||||
resume : Resume playback
|
||||
stop : Stop playback
|
||||
tone freq secs : Produce a pure tone
|
||||
q : Exit NxPlayer
|
||||
quit : Exit NxPlayer
|
||||
volume d% : Set volume to level specified
|
||||
|
||||
d. Play the test sample track (cu44k.wav - 44100Hz, 16bit, stereo).
|
||||
|
||||
nxplayer> play cu44k.wav
|
||||
|
||||
e. Set the volume value to 50%.
|
||||
|
||||
nxplayer> volume 50
|
||||
|
||||
f. Stop the current track and play another one
|
||||
|
||||
nxplayer> stop
|
||||
nxplayer> play hn.wav
|
||||
|
||||
cxxtest:
|
||||
-------
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
# CONFIG_ARCH_FPU is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="stm32f4discovery"
|
||||
CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F407VG=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_AUDIO=y
|
||||
CONFIG_AUDIO_CS43L22=y
|
||||
CONFIG_AUDIO_CUSTOM_DEV_PATH=y
|
||||
CONFIG_AUDIO_EXCLUDE_TONE=y
|
||||
CONFIG_BOARD_INITIALIZE=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DISABLE_POLL=y
|
||||
CONFIG_DRIVERS_AUDIO=y
|
||||
CONFIG_EXAMPLES_NSH=y
|
||||
CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
|
||||
CONFIG_FAT_LCNAMES=y
|
||||
CONFIG_FAT_LFN=y
|
||||
CONFIG_FS_FAT=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_I2C_DRIVER=y
|
||||
CONFIG_I2C_POLLED=y
|
||||
CONFIG_I2C_RESET=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MAX_WDOGPARMS=2
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NFILE_STREAMS=8
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NXPLAYER_DEFAULT_MEDIADIR="/mnt/music"
|
||||
CONFIG_PREALLOC_MQ_MSGS=4
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PREALLOC_WDOGS=16
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_STM32_DMA1=y
|
||||
CONFIG_STM32_DMACAPABLE=y
|
||||
CONFIG_STM32_I2C1=y
|
||||
CONFIG_STM32_I2S3=y
|
||||
CONFIG_STM32_I2S3_TX=y
|
||||
CONFIG_STM32_I2S_MCK=y
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_OTGFS=y
|
||||
CONFIG_STM32_OTGFS_SOFINTR=y
|
||||
CONFIG_STM32_PWR=y
|
||||
CONFIG_STM32_SPI1=y
|
||||
CONFIG_STM32_SPI3=y
|
||||
CONFIG_STM32_SPI_DMA=y
|
||||
CONFIG_STM32_USART2=y
|
||||
CONFIG_SYSTEM_NXPLAYER=y
|
||||
CONFIG_USART2_RXBUFSIZE=128
|
||||
CONFIG_USART2_SERIAL_CONSOLE=y
|
||||
CONFIG_USART2_TXBUFSIZE=128
|
||||
CONFIG_USBHOST=y
|
||||
CONFIG_USBHOST_ISOC_DISABLE=y
|
||||
CONFIG_USBHOST_MSC=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
@@ -1,7 +1,7 @@
|
||||
/************************************************************************************
|
||||
* configs/stm32f4discovery/include/board.h
|
||||
*
|
||||
* Copyright (C) 2012, 2014-2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2012, 2014-2016, 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -314,12 +314,26 @@
|
||||
#define GPIO_SPI1_MOSI GPIO_SPI1_MOSI_1
|
||||
#define GPIO_SPI1_SCK GPIO_SPI1_SCK_1
|
||||
|
||||
/* SPI DMA -- As used for I2S DMA transfer with the audio configuration */
|
||||
|
||||
#define DMACHAN_SPI1_RX DMAMAP_SPI1_RX_1
|
||||
#define DMACHAN_SPI1_TX DMAMAP_SPI1_TX_1
|
||||
|
||||
/* SPI2 - Test MAX31855 on SPI2 PB10 = SCK, PB14 = MISO */
|
||||
|
||||
#define GPIO_SPI2_MISO GPIO_SPI2_MISO_1
|
||||
#define GPIO_SPI2_MOSI GPIO_SPI2_MOSI_1
|
||||
#define GPIO_SPI2_SCK GPIO_SPI2_SCK_1
|
||||
|
||||
/* SPI3 DMA -- As used for I2S DMA transfer with the audio configuration */
|
||||
|
||||
#define GPIO_SPI3_MISO GPIO_SPI3_MISO_1
|
||||
#define GPIO_SPI3_MOSI GPIO_SPI3_MOSI_1
|
||||
#define GPIO_SPI3_SCK GPIO_SPI3_SCK_1
|
||||
|
||||
#define DMACHAN_SPI3_RX DMAMAP_SPI3_RX_1
|
||||
#define DMACHAN_SPI3_TX DMAMAP_SPI3_TX_1
|
||||
|
||||
/* I2S3 - CS43L22 configuration uses I2S3 */
|
||||
|
||||
#define GPIO_I2S3_SD GPIO_I2S3_SD_2
|
||||
|
||||
Reference in New Issue
Block a user