Skip to content

Commit f5c7be9

Browse files
committed
Initial Release
0 parents  commit f5c7be9

File tree

93 files changed

+15120
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+15120
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
.vscode
3+
cmake-*

.gitmodules

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[submodule "lwip"]
2+
path = lib/lwip
3+
url = https://git.savannah.nongnu.org/git/lwip.git
4+
[submodule "lib/lwip"]
5+
url = git://git.savannah.nongnu.org/lwip.git

CMakeLists.txt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
cmake_minimum_required(VERSION 3.12)
2+
3+
# Pull in PICO SDK (must be before project)
4+
include(pico_sdk_import.cmake)
5+
6+
project(pico_extras C CXX)
7+
8+
set(CMAKE_C_STANDARD 11)
9+
set(CMAKE_CXX_STANDARD 17)
10+
11+
# Initialize the SDK
12+
pico_sdk_init()
13+
14+
pico_is_top_level_project(PICO_EXTRAS_TOP_LEVEL_PROJECT)
15+
16+
add_library(pico_extras_included INTERFACE)
17+
target_compile_definitions(pico_extras_included INTERFACE
18+
-DPICO_EXTRAS=1
19+
)
20+
21+
pico_add_platform_library(pico_extras_included)
22+
23+
if (NOT PICO_EXTRAS_PATH)
24+
set(PICO_EXTRAS_PATH ${CMAKE_CURRENT_LIST_DIR})
25+
endif()
26+
set(PICO_EXTRAS_PATH "${PICO_EXTRAS_PATH}" CACHE PATH "Path to Pico Extras")
27+
28+
add_subdirectory(src)
29+
30+
if (PICO_EXTRAS_TESTS_ENABLED OR PICO_EXTRAS_TOP_LEVEL_PROJECT)
31+
add_subdirectory(test)
32+
endif ()

LICENSE.TXT

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright 2020 (c) 2020 Raspberry Pi (Trading) Ltd.
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
4+
following conditions are met:
5+
6+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
7+
disclaimer.
8+
9+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
10+
disclaimer in the documentation and/or other materials provided with the distribution.
11+
12+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
13+
derived from this software without specific prior written permission.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
16+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
This repo has additional libraries that are not yet ready for inclusion the Pico SDK proper,
2+
or are just useful but don't necessarily belong in the Pico SDK.
3+
4+
Note that any API here is a work in progress and subject to change.
5+
6+
See [pico-playground](https://github.com/raspberrypi/pico-playground) for buildable example code using these extra libraries.
7+
8+
9+
Library|Description
10+
---|---
11+
[hardware_rosc](src/rp2_common/hardware_rosc)| API for the ring oscillator
12+
[lwip](src/rp2_common/lwip)| [LWIP Lightweight IP Library](https://savannah.nongnu.org/projects/lwip/) packed as an INTERFACE library for use with the Pico SDK
13+
[pico_audio](src/common/pico_audio)|Audio output support; this is highly functional, but the API is subject to change
14+
   [pico_audio_i2s](src/rp2_common/pico_audio_spdif)|Audio output via I2S on 3 GPIOs using PIO. Arbitrary frequency
15+
   [pico_audio_pwm](src/rp2_common/pico_audio_spdif)|Audio output via (PIO) PWM. Currently a bit limited in frequency support (it was developed on FPGA to do 22050Hz at 48Mhz system clock). It does however support error diffusion dithering and noise shaping with 16x oversampling to give surprsingly good audio quality. This code will be split to provide both a fixed frequencie(s) version and a slightly slower but rather better arbitrary frequency version supporting ever higher carrier frequencies
16+
   [pico_audio_spdif](src/rp2_common/pico_audio_spdif)|Audio output in S/PDIF on a GPIO using PIO. Supports up to 192khz stereo. Consumed OK in test, haven't tried it with real hardware
17+
[pico_sd_card](src/rp2_common/pico_sd_card)|1 and 4 bit SDIO support using PIO. This is functional (currently writing is only 1 bit), but the the code is very much prototype and the API is just a placeholder - the command set needs to be separated from the SDIO and shared with SPI
18+
[pico_sleep](src/rp2_common/pico_sleep)|Low power related APIs, WIP because they are not sufficiently generic and also only handle core 0
19+
[pico_scanvideo](src/common/pico_scanvideo)|Support for video output where every pixel is _scanned out_ everry frame. VGA/DPI support is highgly functional and stable, but the API is subject to change
20+
   [pico_scanvideo_dbi](src/rp2_common/pico_scanvideo_dbi)| currently non-compiling... placeholder for adding scanvideo over MIPI DBI support.
21+
   [pico_scanvideo_dpi](src/rp2_common/pico_scanvideo_dbi)| Highly functional and stable support for parallel RGB output and VSYNC/HSYNC/DEN/CLOCK for VGA/DPI.
22+
[pico_util_buffer](src/common/pico_util_buffer)|Rather incomplete buffer abstraction, used by pico_audio and pico_scanvideo
23+
[platypus](src/common/platypus)| Decoder for a custom image compression format suitable for dithered images (good for RGB555) and suitable for decoding on RP2040 at scanline speeds ... i.e you can easily decode a 320x240 image 60x per second to avoid storing the uncompressed image for scanout video. It gets about 50% compression (but is designed only for 4x4 fixed dithered RGB555 images, so is somewhat specific!). TODO add the encoder here :-)
24+
[usb_device](src/rp2_common/usb_device), [usb_common](src/rp2_common/usb_common)| The custom and somewhat minimal USB device stack used in the bootrom. We now use TinyUSB in the Pico SDK but kep here for posterit
25+
[usb_device_msc](src/rp2_common/usb_device_msc)| USB Mass Storage Class implementation using _usb_device_
26+
27+
28+
You can add Pico Extras to your project similarly to the SDK (copying [external/pico_extras_import.cmake](external/pico_extras_import.cmake) into your project)
29+
having set the `PICO_EXTRAS_PATH` variable in your environment or via cmake variable.
30+
31+
```cmake
32+
cmake_minimum_required(VERSION 3.12)
33+
34+
# Pull in PICO SDK (must be before project)
35+
include(pico_sdk_import.cmake)
36+
37+
# We also need PICO EXTRAS
38+
include(pico_extras_import.cmake)
39+
40+
project(pico_playground C CXX)
41+
set(CMAKE_C_STANDARD 11)
42+
set(CMAKE_CXX_STANDARD 17)
43+
```
44+
45+
Alternative you can inject it into an existing project without modifying it via `PICO_CMAKE_POST_LIST_DIRS`
46+
by passing `-DPICO_SDK_POST_LIST_DIRS=/path/to/pico_extras` to cmake

external/pico_extras_import.cmake

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# This is a copy of <PICO_EXTRAS_PATH>/external/pico_extras_import.cmake
2+
3+
# This can be dropped into an external project to help locate pico-extras
4+
# It should be include()ed prior to project()
5+
6+
if (DEFINED ENV{PICO_EXTRAS_PATH} AND (NOT PICO_EXTRAS_PATH))
7+
set(PICO_EXTRAS_PATH $ENV{PICO_EXTRAS_PATH})
8+
message("Using PICO_EXTRAS_PATH from environment ('${PICO_EXTRAS_PATH}')")
9+
endif ()
10+
11+
if (DEFINED ENV{PICO_EXTRAS_FETCH_FROM_GIT} AND (NOT PICO_EXTRAS_FETCH_FROM_GIT))
12+
set(PICO_EXTRAS_FETCH_FROM_GIT $ENV{PICO_EXTRAS_FETCH_FROM_GIT})
13+
message("Using PICO_EXTRAS_FETCH_FROM_GIT from environment ('${PICO_EXTRAS_FETCH_FROM_GIT}')")
14+
endif ()
15+
16+
if (DEFINED ENV{PICO_EXTRAS_FETCH_FROM_GIT_PATH} AND (NOT PICO_EXTRAS_FETCH_FROM_GIT_PATH))
17+
set(PICO_EXTRAS_FETCH_FROM_GIT_PATH $ENV{PICO_EXTRAS_FETCH_FROM_GIT_PATH})
18+
message("Using PICO_EXTRAS_FETCH_FROM_GIT_PATH from environment ('${PICO_EXTRAS_FETCH_FROM_GIT_PATH}')")
19+
endif ()
20+
21+
if (NOT PICO_EXTRAS_PATH)
22+
if (PICO_EXTRAS_FETCH_FROM_GIT)
23+
include(FetchContent)
24+
set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR})
25+
if (PICO_EXTRAS_FETCH_FROM_GIT_PATH)
26+
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_EXTRAS_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
27+
endif ()
28+
FetchContent_Declare(
29+
PICO_EXTRAS
30+
GIT_REPOSITORY https://github.com/raspberrypi/pico-extras
31+
GIT_TAG master
32+
)
33+
if (NOT PICO_EXTRAS)
34+
message("Downloading PICO EXTRAS")
35+
FetchContent_Populate(PICO_EXTRAS)
36+
set(PICO_EXTRAS_PATH ${PICO_EXTRAS_SOURCE_DIR})
37+
endif ()
38+
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
39+
else ()
40+
if (PICO_SDK_PATH AND EXISTS "${PICO_SDK_PATH}/../pico-extras")
41+
set(PICO_EXTRAS_PATH ${PICO_SDK_PATH}/../pico-extras)
42+
message("Defaulting PICO_EXTRAS_PATH as sibling of PICO_SDK_PATH: ${PICO_EXTRAS_PATH}")
43+
else()
44+
message(FATAL_ERROR
45+
"PICO EXTRAS location was not specified. Please set PICO_EXTRAS_PATH or set PICO_EXTRAS_FETCH_FROM_GIT to on to fetch from git."
46+
)
47+
endif()
48+
endif ()
49+
endif ()
50+
51+
set(PICO_EXTRAS_PATH "${PICO_EXTRAS_PATH}" CACHE PATH "Path to the PICO EXTRAS")
52+
set(PICO_EXTRAS_FETCH_FROM_GIT "${PICO_EXTRAS_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of PICO EXTRAS from git if not otherwise locatable")
53+
set(PICO_EXTRAS_FETCH_FROM_GIT_PATH "${PICO_EXTRAS_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download EXTRAS")
54+
55+
get_filename_component(PICO_EXTRAS_PATH "${PICO_EXTRAS_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
56+
if (NOT EXISTS ${PICO_EXTRAS_PATH})
57+
message(FATAL_ERROR "Directory '${PICO_EXTRAS_PATH}' not found")
58+
endif ()
59+
60+
set(PICO_EXTRAS_PATH ${PICO_EXTRAS_PATH} CACHE PATH "Path to the PICO EXTRAS" FORCE)
61+
62+
add_subdirectory(${PICO_EXTRAS_PATH} pico_extras)

lib/lwip

Submodule lwip added at c385f31

pico_sdk_import.cmake

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# This is a copy of <PICO_SDK_PATH>/external/pico_sdk_import.cmake
2+
3+
# This can be dropped into an external project to help locate this SDK
4+
# It should be include()ed prior to project()
5+
6+
if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
7+
set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
8+
message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")
9+
endif ()
10+
11+
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT))
12+
set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT})
13+
message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')")
14+
endif ()
15+
16+
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH))
17+
set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH})
18+
message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
19+
endif ()
20+
21+
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the PICO SDK")
22+
set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of PICO SDK from git if not otherwise locatable")
23+
set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK")
24+
25+
if (NOT PICO_SDK_PATH)
26+
if (PICO_SDK_FETCH_FROM_GIT)
27+
include(FetchContent)
28+
set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR})
29+
if (PICO_SDK_FETCH_FROM_GIT_PATH)
30+
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
31+
endif ()
32+
FetchContent_Declare(
33+
pico_sdk
34+
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
35+
GIT_TAG master
36+
)
37+
if (NOT pico_sdk)
38+
message("Downloading PICO SDK")
39+
FetchContent_Populate(pico_sdk)
40+
set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR})
41+
endif ()
42+
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
43+
else ()
44+
message(FATAL_ERROR
45+
"PICO SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git."
46+
)
47+
endif ()
48+
endif ()
49+
50+
get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
51+
if (NOT EXISTS ${PICO_SDK_PATH})
52+
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found")
53+
endif ()
54+
55+
set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake)
56+
if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE})
57+
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the PICO SDK")
58+
endif ()
59+
60+
set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the PICO SDK" FORCE)
61+
62+
include(${PICO_SDK_INIT_CMAKE_FILE})

src/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
add_subdirectory(common)
2+
if (PICO_ON_DEVICE)
3+
add_subdirectory(rp2_common)
4+
endif()

src/common/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
add_subdirectory(pico_audio)
2+
add_subdirectory(pico_scanvideo)
3+
add_subdirectory(pico_sd_card)
4+
add_subdirectory(pico_util_buffer)
5+
add_subdirectory(platypus)

src/common/pico_audio/CMakeLists.txt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
if (NOT TARGET pico_audio_headers)
2+
add_library(pico_audio_headers INTERFACE)
3+
target_include_directories(pico_audio_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
4+
target_link_libraries(pico_audio_headers INTERFACE pico_util_buffer)
5+
endif()
6+
7+
if (NOT TARGET pico_audio)
8+
add_library(pico_audio INTERFACE)
9+
10+
target_sources(pico_audio INTERFACE
11+
${CMAKE_CURRENT_LIST_DIR}/audio.cpp
12+
$<$<NOT:$<BOOL:${PICO_NO_HARDWARE}>>:${CMAKE_CURRENT_LIST_DIR}/audio_utils.S>
13+
)
14+
15+
target_link_libraries(pico_audio INTERFACE pico_audio_headers pico_sync)
16+
endif()

0 commit comments

Comments
 (0)