Skip to content

Commit

Permalink
change into library
Browse files Browse the repository at this point in the history
  • Loading branch information
elehobica committed Mar 10, 2024
1 parent 5e14108 commit 80cbbdf
Show file tree
Hide file tree
Showing 18 changed files with 439 additions and 331 deletions.
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

63 changes: 24 additions & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,24 @@
cmake_minimum_required(VERSION 3.12)

set(PICO_SDK_PATH ${CMAKE_CURRENT_LIST_DIR}/../pico-sdk)

# Pull in PICO SDK (must be before project)
include(pico_sdk_import.cmake)

# We also need PICO EXTRAS
include(pico_extras_import.cmake)

set(project_name "sine_wave" C CXX)
project(${project_name})
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

pico_sdk_init()

add_subdirectory(my_pico_audio)
add_subdirectory(my_pico_audio_i2s)

set(bin_name "sine_wave")
add_executable(${bin_name}
sine_wave.c
)

pico_enable_stdio_usb(${bin_name} 1)
pico_enable_stdio_uart(${bin_name} 1)

target_link_libraries(${bin_name} PRIVATE
pico_stdlib
my_pico_audio_i2s
)

target_compile_definitions(${bin_name} PRIVATE
#define for our example code
USE_AUDIO_I2S=1
)

pico_add_extra_outputs(${bin_name})
if (NOT TARGET pico_audio_i2s_32b)
add_library(pico_audio_i2s_32b INTERFACE)

pico_generate_pio_header(pico_audio_i2s_32b
${CMAKE_CURRENT_LIST_DIR}/src/audio_i2s.pio
)

target_sources(pico_audio_i2s_32b INTERFACE
${CMAKE_CURRENT_LIST_DIR}/src/audio_i2s.c
)

target_link_libraries(pico_audio_i2s_32b INTERFACE
pico_stdlib
pico_multicore
hardware_dma
hardware_pio
hardware_irq
pico_audio_32b
)

target_include_directories(pico_audio_i2s_32b INTERFACE
${CMAKE_CURRENT_LIST_DIR}/src/include
)
endif()
37 changes: 16 additions & 21 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# Raspberry Pi Pico sine_wave with 32bit I2S DAC
# Raspberry Pi Pico 32bit I2S DAC Library

## Overview
This project is an example for Raspberry Pi Pico to support 32bit/Stereo I2S DAC.
The sample project included in [pico-playground/audio/sine_wave](https://github.com/raspberrypi/pico-playground/tree/master/audio/sine_wave) supports only 16bit I2S DAC in mono to stereo copy mode.
This project supports:
* 32bit Stereo I2S (PCM5102)
* jitter-less bit clock frequency for 44.1KHz sampling rate (44118Hz)
This library is for Raspberry Pi Pico to support 32bit/Stereo I2S DAC.

## Supported Board and Peripheral Devices
* Raspberry Pi Pico
* PCM5102 32bit I2S Audio DAC
* ES9023 24bit I2S Audio DAC (not tested yet)
* ES9023 24bit I2S Audio DAC

## Pin Assignment
In addition to original connection
Expand All @@ -34,32 +30,31 @@ In addition to original connection

## How to build
* See ["Getting started with Raspberry Pi Pico"](https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf)
* Build is confirmed only in Developer Command Prompt for VS 2019 and Visual Studio Code on Windows enviroment
* Put "pico-sdk", "pico-examples", "pico-extras" and "pico-playground" on the same level with this project folder.
* Put "pico-sdk", "pico-examples" and "pico-extras" on the same level with this project folder.
* Set environmental variables for PICO_SDK_PATH, PICO_EXTRAS_PATH
* Build is confirmed in Developer Command Prompt for VS 2022 and Visual Studio Code on Windows enviroment
* Confirmed with Pico SDK 1.5.1, cmake-3.27.2-windows-x86_64 and gcc-arm-none-eabi-10.3-2021.10-win32
```
> git clone -b master https://github.com/raspberrypi/pico-sdk.git
> git clone -b 1.5.1 https://github.com/raspberrypi/pico-sdk.git
> cd pico-sdk
> git submodule update -i
> cd ..
> git clone -b master https://github.com/raspberrypi/pico-examples.git
> git clone -b sdk-1.5.1 https://github.com/raspberrypi/pico-examples.git
>
> git clone -b sdk-1.5.1 https://github.com/raspberrypi/pico-extras.git
>
> git clone https://github.com/raspberrypi/pico-extras.git
> cd pico-extras
> git submodule update -i
> cd ..
> git clone https://github.com/raspberrypi/pico-playground.git
>
> git clone -b main https://github.com/elehobica/rasp_pi_pico_sine_wave_i2s_32bit.git
> git clone -b main https://github.com/elehobica/pico_audio_i2s_32b.git
```
* Lanuch "Developer Command Prompt for VS 2019"
* Lanuch "Developer Command Prompt for VS 2022"
```
> cd rasp_pi_pico_sine_wave_i2s_32bit
> cd pico_audio_i2s_32b
> cd samples/xxxxx # sample project directory
> mkdir build
> cd build
> cmake -G "NMake Makefiles" ..
> nmake
```
* Put "sine_wave.uf2" on RPI-RP2 drive
* Put "xxxxx.uf2" on RPI-RP2 drive

## Macro Definitions in audio_i2s.c
### CORE1_PROCESS_I2S_CALLBACK
Expand Down
16 changes: 0 additions & 16 deletions my_pico_audio/CMakeLists.txt

This file was deleted.

19 changes: 0 additions & 19 deletions my_pico_audio_i2s/CMakeLists.txt

This file was deleted.

62 changes: 0 additions & 62 deletions pico_extras_import.cmake

This file was deleted.

62 changes: 0 additions & 62 deletions pico_sdk_import.cmake

This file was deleted.

40 changes: 40 additions & 0 deletions samples/sine_wave_i2s_32b/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
cmake_minimum_required(VERSION 3.13)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)
include($ENV{PICO_EXTRAS_PATH}/external/pico_extras_import.cmake)

set(project_name "sine_wave_i2s_32b" C CXX ASM)
project(${project_name})
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

pico_sdk_init()

add_subdirectory(../../src/pico_audio_32b pico_audio_32b)
add_subdirectory(../.. pico_audio_i2s_32b)

set(bin_name ${PROJECT_NAME})
add_executable(${PROJECT_NAME}
sine_wave.cpp
)

pico_enable_stdio_usb(${bin_name} 1)
pico_enable_stdio_uart(${bin_name} 1)

target_link_libraries(${bin_name} PRIVATE
pico_stdlib
pico_audio_32b
pico_audio_i2s_32b
)

# set PIO and DMA for I2S
# set core1 process i2s_callback
#target_compile_definitions(${PROJECT_NAME} PRIVATE
# PICO_AUDIO_I2S_PIO=1
# PICO_AUDIO_I2S_DMA_IRQ=1
# CORE1_PROCESS_I2S_CALLBACK
#)

pico_add_extra_outputs(${bin_name})
Loading

0 comments on commit 80cbbdf

Please sign in to comment.