boards/raspberrypi-pico: Pico Audio Pack (I2S) support

This commit is contained in:
Yuichi Nakamura
2021-04-18 19:05:37 +09:00
committed by Masayuki Ishikawa
parent 048802bcd2
commit 7fb73dba1c
7 changed files with 269 additions and 0 deletions
+4
View File
@@ -26,6 +26,10 @@ ifeq ($(CONFIG_RP2040_SPI_DRIVER),y)
CSRCS += rp2040_spidev.c
endif
ifeq ($(CONFIG_RP2040_I2S),y)
CSRCS += rp2040_i2sdev.c
endif
ifeq ($(CONFIG_LCD_SSD1306),y)
CSRCS += rp2040_ssd1306.c
endif
@@ -0,0 +1,95 @@
/****************************************************************************
* boards/arm/rp2040/common/src/rp2040_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 "arm_arch.h"
#include "rp2040_i2s.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_i2sdev_initialize
*
* Description:
* Initialize i2s driver and register the /dev/audio/pcm0 device.
*
****************************************************************************/
int board_i2sdev_initialize(int port)
{
FAR struct audio_lowerhalf_s *audio_i2s;
FAR struct audio_lowerhalf_s *pcm;
FAR struct i2s_dev_s *i2s;
char devname[12];
int ret;
ainfo("Initializing I2S\n");
i2s = rp2040_i2sbus_initialize(port);
#ifdef CONFIG_AUDIO_I2SCHAR
i2schar_register(i2s, 0);
#endif
audio_i2s = audio_i2s_initialize(i2s, true);
if (!audio_i2s)
{
auderr("ERROR: Failed to initialize I2S\n");
return -ENODEV;
}
pcm = pcm_decode_initialize(audio_i2s);
if (!pcm)
{
auderr("ERROR: Failed create the PCM decoder\n");
return -ENODEV;
}
snprintf(devname, 12, "pcm%d", port);
ret = audio_register(devname, pcm);
if (ret < 0)
{
auderr("ERROR: Failed to register /dev/%s device: %d\n", devname, ret);
}
return 0;
}
@@ -13,6 +13,7 @@ Currently only the following devices are suppored.
- I2C
- SPI
- DMAC
- PIO (RP2040 Programmable I/O)
- Flash ROM Boot
- SRAM Boot
- If Pico SDK is available, nuttx.uf2 file which can be used in
@@ -21,6 +22,8 @@ Currently only the following devices are suppored.
- INA219 sensor / module (don't forget to define I2C0 GPIOs at "I2C0 GPIO pin assign" in Board Selection menu)
- Pico Display Pack (ST7789 LCD)
- RGB leds and buttons are not supported yet.
- Pico Audio Pack (PCM5100A I2S DAC)
- I2S interface is realized by PIO.
Not supported:
- All other devices
@@ -109,6 +112,12 @@ Defconfigs
See the following page for connection:
https://shop.pimoroni.com/products/pico-display-pack
- audiopack
Pico Audio Pack support
See the following page for connection:
https://shop.pimoroni.com/products/pico-audio-pack
SD card interface is also enabled.
License exceptions
==================
@@ -120,5 +129,10 @@ So, the files are licensed under 3-Clause BSD same as Pico SDK.
- arch/arm/src/rp2040/rp2040_xosc.c
- These are created by referring the Pico SDK clock initialization.
- arch/arm/src/rp2040/rp2040_pio.c
- arch/arm/src/rp2040/rp2040_pio.h
- arch/arm/src/rp2040/rp2040_pio_instructions.h
- These provide the similar APIs to Pico SDK's hardware_pio APIs.
- arch/arm/src/rp2040/hardware/*.h
- These are generated from rp2040.svd originally provided in Pico SDK.
@@ -0,0 +1,75 @@
#
# 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_AUDIO_FORMAT_MP3 is not set
# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set
# CONFIG_LIBC_LONG_LONG is not set
# CONFIG_MMCSD_HAVE_CARDDETECT is not set
# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set
# CONFIG_NSH_ARGCAT is not set
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
# CONFIG_NSH_DISABLE_DATE is not set
# CONFIG_NSH_DISABLE_LOSMART is not set
# CONFIG_NSH_DISABLE_MB is not set
# CONFIG_NSH_DISABLE_MH is not set
# CONFIG_NSH_DISABLE_MW is not set
# CONFIG_NSH_DISABLE_PRINTF is not set
# CONFIG_NSH_DISABLE_TRUNCATE is not set
# CONFIG_SPI_CALLBACK is not set
# CONFIG_STANDARD_SERIAL is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="raspberrypi-pico"
CONFIG_ARCH_BOARD_RASPBERRYPI_PICO=y
CONFIG_ARCH_CHIP="rp2040"
CONFIG_ARCH_CHIP_RP2040=y
CONFIG_ARCH_RAMVECTORS=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_AUDIO=y
CONFIG_AUDIO_I2S=y
CONFIG_AUDIO_I2SCHAR=y
CONFIG_BOARDCTL_RESET=y
CONFIG_BOARD_LOOPSPERMSEC=10450
CONFIG_BUILTIN=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DISABLE_POSIX_TIMERS=y
CONFIG_DRIVERS_AUDIO=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
CONFIG_FS_FAT=y
CONFIG_FS_PROCFS=y
CONFIG_FS_PROCFS_REGISTER=y
CONFIG_MAX_TASKS=8
CONFIG_MMCSD=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_READLINE=y
CONFIG_NXPLAYER_DEFAULT_MEDIADIR="/mnt/sd0"
CONFIG_RAM_SIZE=270336
CONFIG_RAM_START=0x20000000
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_RP2040_I2S=y
CONFIG_RP2040_SPI0=y
CONFIG_RP2040_SPI0_GPIO=16
CONFIG_RP2040_SPI=y
CONFIG_RP2040_SPISD=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=9
CONFIG_START_MONTH=2
CONFIG_START_YEAR=2021
CONFIG_SYSLOG_CONSOLE=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_NXPLAYER=y
CONFIG_SYSTEM_SPITOOL=y
CONFIG_TESTING_GETPRIME=y
CONFIG_TESTING_OSTEST=y
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
@@ -29,6 +29,7 @@
#include "rp2040_i2cdev.h"
#include "rp2040_spidev.h"
#include "rp2040_i2sdev.h"
#include "rp2040_spisd.h"
@@ -0,0 +1,72 @@
/****************************************************************************
* boards/arm/rp2040/raspberrypi-pico/include/rp2040_i2sdev.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 __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_INCLUDE_RP2040_I2SDEV_H
#define __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_INCLUDE_RP2040_I2SDEV_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: board_i2sdev_initialize
*
* Description:
* Initialize i2s driver and register the /dev/audio/pcm0 device.
*
****************************************************************************/
#ifdef CONFIG_RP2040_I2S
int board_i2sdev_initialize(int bus);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_INCLUDE_RP2040_I2SDEV_H */
@@ -134,5 +134,13 @@ int rp2040_bringup(void)
}
#endif
#ifdef CONFIG_RP2040_I2S
ret = board_i2sdev_initialize(0);
if (ret < 0)
{
_err("ERROR: Failed to initialize I2S.\n");
}
#endif
return ret;
}