Audio subystem update from Ken Pettit. Plus moved some header files
This commit is contained in:
parent
75aecb4490
commit
2a6675599b
@ -94,6 +94,10 @@ ifeq ($(CONFIG_LCD_MIO283QT2),y)
|
||||
CSRCS += up_mio283qt2.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_VS1053),y)
|
||||
CSRCS += up_vs1053.c
|
||||
endif
|
||||
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
|
@ -92,7 +92,9 @@
|
||||
GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN3)
|
||||
#define GPIO_CS_FLASH (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN7)
|
||||
#define GPIO_CS_MP3 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
#define GPIO_CS_MP3_DATA (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN9)
|
||||
#define GPIO_CS_MP3_CMD (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN8)
|
||||
#define GPIO_CS_EXP_SPI3 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN0)
|
||||
@ -182,6 +184,13 @@
|
||||
|
||||
#define GPIO_TP_XL (GPIO_ANALOG|GPIO_PORTB|GPIO_PIN1)
|
||||
|
||||
/* MP3 Codec control pins */
|
||||
|
||||
#define GPIO_VS1053_RST (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN7)
|
||||
#define GPIO_VS1053_DREQ (GPIO_INPUT|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN6)
|
||||
|
||||
|
||||
/****************************************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************************************/
|
||||
@ -258,5 +267,17 @@ void stm32_lcdinitialize(void);
|
||||
int up_lcdinitialize(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************************************
|
||||
* Name: up_vs1053initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the VS1053 Audio CODEC hardware.
|
||||
*
|
||||
****************************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_VS1053
|
||||
void up_vs1053initialize(FAR struct spi_dev_s *spi);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __CONFIGS_MIKROE_STM32F4_SRC_MIKROE_STM32F4_INTERNAL_H */
|
||||
|
@ -64,7 +64,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_AUDIO
|
||||
# include "nuttx/audio.h"
|
||||
# include "nuttx/audio/audio.h"
|
||||
#endif
|
||||
|
||||
#include "stm32.h"
|
||||
@ -181,9 +181,6 @@ int nsh_archinitialize(void)
|
||||
#ifdef CONFIG_STM32_SPI3
|
||||
FAR struct spi_dev_s *spi;
|
||||
FAR struct mtd_dev_s *mtd;
|
||||
#endif
|
||||
#ifdef CONFIG_AUDIO
|
||||
FAR struct audio_lowerhalf_s *pVs1053;
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
@ -351,21 +348,13 @@ int nsh_archinitialize(void)
|
||||
|
||||
#endif
|
||||
|
||||
/* Configure the Audio sub-system if enabled */
|
||||
/* Configure the Audio sub-system if enabled and bind it to SPI 3 */
|
||||
|
||||
#ifdef CONFIG_AUDIO
|
||||
pVs1053 = vs1053_initialize(0);
|
||||
if (pVs1053 == NULL)
|
||||
{
|
||||
message("nsh_archinitialize: Failed to initialize VS1053 Audio module\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Bind the vs1053 to the audio upper-half driver */
|
||||
|
||||
audio_register("mp30", pVs1053);
|
||||
}
|
||||
up_vs1053initialize(spi);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_AUDIO */
|
||||
return OK;
|
||||
}
|
||||
|
@ -114,8 +114,10 @@ void weak_function stm32_spiinitialize(void)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_AUDIO_MP3_CODEC
|
||||
(void)stm32_configgpio(GPIO_CS_MP3); /* MP3 codec chip select */
|
||||
stm32_gpiowrite(GPIO_CS_MP3, 1); /* Ensure the CS is inactive */
|
||||
(void)stm32_configgpio(GPIO_CS_MP3_DATA); /* MP3 codec chip select for DATA */
|
||||
(void)stm32_configgpio(GPIO_CS_MP3_CMD); /* MP3 codec chip select for CMD */
|
||||
stm32_gpiowrite(GPIO_CS_MP3_DATA, 1); /* Ensure the CS is inactive */
|
||||
stm32_gpiowrite(GPIO_CS_MP3_CMD, 1); /* Ensure the CS is inactive */
|
||||
#endif
|
||||
|
||||
/* Configure the EXP I/O cs for SPI3 */
|
||||
@ -172,11 +174,16 @@ void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool sele
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_AUDIO_MP3_CODEC)
|
||||
if (devid == SPIDEV_AUDIO)
|
||||
if (devid == SPIDEV_AUDIO_DATA)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_CS_MP3, !selected);
|
||||
stm32_gpiowrite(GPIO_CS_MP3_DATA, !selected);
|
||||
}
|
||||
else if (devid == SPIDEV_AUDIO_CTRL)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_CS_MP3_CMD, !selected);
|
||||
}
|
||||
else
|
||||
|
||||
#endif
|
||||
|
||||
/* Must be the expansion header device */
|
||||
|
200
configs/mikroe-stm32f4/src/up_vs1053.c
Normal file
200
configs/mikroe-stm32f4/src/up_vs1053.c
Normal file
@ -0,0 +1,200 @@
|
||||
/****************************************************************************
|
||||
* configs/mikroe-stm32f4/src/up_vs1053.c
|
||||
*
|
||||
* Copyright (C) 2013 Ken Pettit. All rights reserved.
|
||||
* Author: Ken Pettit <pettitkd@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/spi.h>
|
||||
#include <nuttx/audio/audio.h>
|
||||
#include <nuttx/audio/vs1053.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "up_arch.h"
|
||||
#include "mikroe-stm32f4-internal.h"
|
||||
|
||||
#ifdef CONFIG_VS1053
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* VS1053 is on SPI3 */
|
||||
|
||||
#ifndef CONFIG_STM32_SPI3
|
||||
# error "Need CONFIG_STM32_SPI3 in the configuration"
|
||||
#endif
|
||||
|
||||
/* SPI Assumptions **********************************************************/
|
||||
|
||||
#define VS1053_SPI_PORTNO 3 /* On SPI3 */
|
||||
#define VS1053_DEVNO 0 /* Only one VS1053 */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct stm32_lower_s
|
||||
{
|
||||
const struct vs1053_lower_s lower; /* Low-level MCU interface */
|
||||
xcpt_t handler; /* VS1053 interrupt handler */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static int up_attach(FAR const struct vs1053_lower_s *lower, xcpt_t handler);
|
||||
static void up_enable(FAR const struct vs1053_lower_s *lower);
|
||||
static void up_disable(FAR const struct vs1053_lower_s *lower);
|
||||
static void up_reset(FAR const struct vs1053_lower_s *lower, bool state);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* The VS1053 provides interrupts to the MCU via a GPIO pin. The
|
||||
* following structure provides an MCU-independent mechanixm for controlling
|
||||
* the VS1053 GPIO interrupt.
|
||||
*/
|
||||
|
||||
static struct stm32_lower_s g_vs1053lower =
|
||||
{
|
||||
.lower =
|
||||
{
|
||||
.attach = up_attach,
|
||||
.enable = up_enable,
|
||||
.disable = up_disable,
|
||||
.reset = up_reset
|
||||
},
|
||||
.handler = NULL,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: struct vs1053_lower_s methods
|
||||
****************************************************************************/
|
||||
|
||||
static int up_attach(FAR const struct vs1053_lower_s *lower, xcpt_t handler)
|
||||
{
|
||||
FAR struct stm32_lower_s *priv = (FAR struct stm32_lower_s *)lower;
|
||||
|
||||
/* Just save the handler for use when the interrupt is enabled */
|
||||
|
||||
priv->handler = handler;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static void up_enable(FAR const struct vs1053_lower_s *lower)
|
||||
{
|
||||
FAR struct stm32_lower_s *priv = (FAR struct stm32_lower_s *)lower;
|
||||
|
||||
DEBUGASSERT(priv->handler);
|
||||
(void)stm32_gpiosetevent(GPIO_VS1053_DREQ, false, true, true, priv->handler);
|
||||
}
|
||||
|
||||
static void up_disable(FAR const struct vs1053_lower_s *lower)
|
||||
{
|
||||
(void)stm32_gpiosetevent(GPIO_VS1053_DREQ, false, true, true, NULL);
|
||||
}
|
||||
|
||||
static void up_reset(FAR const struct vs1053_lower_s *lower, bool state)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_VS1053_RST, state);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_netinitialize
|
||||
****************************************************************************/
|
||||
|
||||
void up_vs1053initialize(FAR struct spi_dev_s* spi)
|
||||
{
|
||||
int ret;
|
||||
int x;
|
||||
char name[8];
|
||||
FAR struct audio_lowerhalf_s *pVs1053;
|
||||
|
||||
/* Assumptions:
|
||||
* 1) SPI pins were configured in up_spi.c early in the boot-up phase.
|
||||
* 2) Clocking for the SPI1 peripheral was also provided earlier in boot-up.
|
||||
*/
|
||||
|
||||
/* Take VS1053 out of reset (active low)*/
|
||||
|
||||
(void)stm32_configgpio(GPIO_VS1053_RST);
|
||||
(void)stm32_configgpio(GPIO_VS1053_DREQ);
|
||||
|
||||
stm32_gpiowrite(GPIO_VS1053_RST, 0);
|
||||
for (x = 0; x < 10000; x++);
|
||||
stm32_gpiowrite(GPIO_VS1053_RST, 1);
|
||||
|
||||
/* Bind the SPI port to the VS1053 driver */
|
||||
|
||||
pVs1053 = vs1053_initialize(spi, &g_vs1053lower.lower, VS1053_DEVNO);
|
||||
if (ret < 0)
|
||||
{
|
||||
audlldbg("Failed to bind SPI port %d VS1053 device: %d\n",
|
||||
VS1053_DEVNO, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Now register the audio device */
|
||||
|
||||
sprintf(name, "mp3%d", VS1053_DEVNO);
|
||||
ret = audio_register(name, pVs1053);
|
||||
if (ret < 0)
|
||||
{
|
||||
auddbg("up_vs1053initialize: Failed to register VS1053 Audio device\n");
|
||||
}
|
||||
|
||||
audllvdbg("Bound SPI port to VS1053 device %s\n", name);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_VS1053 */
|
@ -120,7 +120,7 @@ FPU
|
||||
If you are using a toolchain other than the Atollic toolchain, then to use the FPU
|
||||
you will also have to modify the CFLAGS to enable compiler support for the ARMv7-M
|
||||
FPU. As of this writing, there are not many GCC toolchains that will support the
|
||||
ARMv7-M FPU.
|
||||
ARMv7-M FPU.
|
||||
|
||||
As a minimum you will need to add CFLAG options to (1) enable hardware floating point
|
||||
code generation, and to (2) select the FPU implementation. You might try the same
|
||||
@ -211,7 +211,7 @@ Using OpenOCD with the Olimex ARM-USB-OCD
|
||||
|
||||
I have been using the Olimex ARM-USB-OCD debugger. OpenOCD
|
||||
requires a configuration file. I keep the one I used last here:
|
||||
|
||||
|
||||
configs/open1788/tools/open1788.cfg
|
||||
|
||||
However, the "correct" configuration script to use with OpenOCD may
|
||||
@ -240,7 +240,7 @@ Using OpenOCD with the Olimex ARM-USB-OCD
|
||||
NOTE: These files could also be located under /usr/share in some
|
||||
installations. They could be most anywhwere if you are using a
|
||||
windows version of OpenOCD.
|
||||
|
||||
|
||||
configs/open1788/tools/open1788.cfg
|
||||
This is simply openocd-usb.cfg, lpc1788.cfg, and lpc17xx.cfg
|
||||
concatenated into one file for convenience. Don't use it
|
||||
@ -249,7 +249,7 @@ Using OpenOCD with the Olimex ARM-USB-OCD
|
||||
There is also a script on the tools/ directory that I use to start
|
||||
the OpenOCD daemon on my system called oocd.sh. That script will
|
||||
probably require some modifications to work in another environment:
|
||||
|
||||
|
||||
- Possibly the value of OPENOCD_PATH and TARGET_PATH
|
||||
- It assumes that the correct script to use is the one at
|
||||
configs/open1788/tools/open1788.cfg
|
||||
@ -283,7 +283,7 @@ Using OpenOCD with the Olimex ARM-USB-OCD
|
||||
use the 'monitor' (or simply 'mon') command to invoke these sub-
|
||||
commands. These GDB commands will send comments to the OpenOCD monitor.
|
||||
Here are a couple that you will need to use:
|
||||
|
||||
|
||||
(gdb) monitor reset
|
||||
(gdb) monitor halt
|
||||
|
||||
@ -309,17 +309,17 @@ Using OpenOCD with the Olimex ARM-USB-OCD
|
||||
|
||||
3. I find that there are often undetected write failures when using
|
||||
the Olimex ARM-USB-OCD debugber and that if you start the program
|
||||
with a bad FLASH failure, it will lock up OpenOCD. I usually
|
||||
with a bad FLASH failure, it will lock up OpenOCD. I usually
|
||||
oad nuttx twice, restarting OpenOCD in between in order to assure
|
||||
good FLASH contents:
|
||||
|
||||
|
||||
(gdb) mon halt
|
||||
(gdb) load nuttx
|
||||
(gdb) mon reset
|
||||
|
||||
Exit GDB, kill the OpenOCD server, recycle power on the board,
|
||||
restart the OpenOCD server and GDB, then:
|
||||
|
||||
|
||||
(gdb) mon halt
|
||||
(gdb) load nuttx
|
||||
(gdb) mon reset
|
||||
@ -340,12 +340,12 @@ CONFIGURATION
|
||||
=============
|
||||
|
||||
ostest
|
||||
------
|
||||
------
|
||||
This configuration directory, performs a simple OS test using
|
||||
apps/examples/ostest.
|
||||
|
||||
NOTES:
|
||||
|
||||
|
||||
1. This configuration uses the mconf-based configuration tool. To
|
||||
change this configuration using that tool, you should:
|
||||
|
||||
@ -377,7 +377,7 @@ CONFIGURATION
|
||||
binaries (pass2)
|
||||
|
||||
NOTES:
|
||||
|
||||
|
||||
1. This configuration uses the mconf-based configuration tool. To
|
||||
change this configuration using that tool, you should:
|
||||
|
||||
@ -475,7 +475,7 @@ CONFIGURATION
|
||||
Configuration enables only the serial NSH interface.
|
||||
|
||||
NOTES:
|
||||
|
||||
|
||||
1. This configuration uses the mconf-based configuration tool. To
|
||||
change this configuration using that tool, you should:
|
||||
|
||||
@ -539,7 +539,7 @@ CONFIGURATION
|
||||
System Type:
|
||||
CONFIG_GPIO_IRQ=y : GPIO interrupt support
|
||||
CONFIG_LPC17_SSP1=y : Enable support for SSP1
|
||||
|
||||
|
||||
Applicaton Configuration:
|
||||
CONFIG_EXAMPLES_TOUCHSCREEN=y : Enable the touchscreen built-int test
|
||||
CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN=y
|
||||
@ -596,7 +596,7 @@ CONFIGURATION
|
||||
CONFIG_EXAMPLES_BUTTONS_NAME5="JOYSTICK_C"
|
||||
CONFIG_EXAMPLES_BUTTONS_NAME6="JOYSTICK_D"
|
||||
CONFIG_EXAMPLES_BUTTONS_NAME7="JOYSTICK_CTR"
|
||||
|
||||
|
||||
nxlines
|
||||
-------
|
||||
Configures the graphics example located at examples/nsh. This
|
||||
@ -605,7 +605,7 @@ CONFIGURATION
|
||||
panel.
|
||||
|
||||
NOTES:
|
||||
|
||||
|
||||
1. This configuration uses the mconf-based configuration tool. To
|
||||
change this configuration using that tool, you should:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user