Skip to content

Commit 9930bb0

Browse files
committed
RP2350 and SDK 2.0.0
1 parent b1294e8 commit 9930bb0

26 files changed

+1376
-53
lines changed

CMakeLists.txt

+21
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,27 @@ set(CMAKE_CXX_STANDARD 17)
1313
# Initialize the Pico SDK
1414
pico_sdk_init()
1515

16+
if (PICO_SDK_VERSION_STRING VERSION_LESS "2.0.0")
17+
message(FATAL_ERROR "Require at least Raspberry Pi Pico SDK version 2.0.0")
18+
endif()
19+
20+
function(add_subdirectory_exclude_platforms NAME)
21+
if (ARGN)
22+
if (PICO_PLATFORM IN_LIST ARGN)
23+
message("Skipping ${NAME} example which is unsupported on this platform")
24+
return()
25+
endif()
26+
foreach(PATTERN IN LISTS ARGN)
27+
string(REGEX MATCH "${PATTERN}" MATCHED "${PICO_PLATFORM}")
28+
if (MATCHED)
29+
message("Skipping ${NAME} example which is unsupported on this platform")
30+
return()
31+
endif()
32+
endforeach()
33+
endif()
34+
add_subdirectory(${NAME})
35+
endfunction()
36+
1637
add_subdirectory(audio)
1738
add_subdirectory(apps)
1839
add_subdirectory(reset)

README.md

+14-13
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,20 @@ is useful when you only have 264K of RAM).
3232

3333
For a fuller description of scanout video see [here](https://github.com/raspberrypi/pico-extras/blob/master/src/common/pico_scanvideo/README.adoc)
3434

35-
Name|Screenshot|Description
36-
---|---|---
37-
[demo1](scanvideo/demo1)|![](scanvideo/demo1/screenshot.jpg)| So named because it was the first demo program written that used video.. it is a bit dated now and hails from a time where there was _much_ less RAM on the RP2040
38-
[flash_stream](scanvideo/flash_stream)|![](scanvideo/flash_stream/screenshot.jpg)| Streams video data out of flash fast enough to drive 640x480x60fps bitmap display
39-
[hscroll_dma_tiles](scanvideo/hscroll_dma_tiles)|![](scanvideo/hscroll_dma_tiles/screenshot.jpg)| A horizontal scrolling test app which uses a second video plane (PIO) to overlay sprites
40-
[mandelbrot](scanvideo/mandelbrot)|![](scanvideo/mandelbrot/screenshot.jpg)| A mandelbrot generator using a 320x240x16 framebuffer
41-
[mario_tiles](scanvideo/mario_tiles)|![](scanvideo/mario_tiles/screenshot.jpg)| Confusingly named as a reference to Super Mario Kart's tiled psuedo-3D rendering. This is similar to [hscroll_dma_tiles](scanvideo/hscroll_dma_tiles) except the whole tiled scrolling area is now rotated and zoomed.
42-
[scanvideo_minimal](scanvideo/scanvideo_minimal)|![](scanvideo/scanvideo_minimal/screenshot.jpg)| A very basic video output generator which generates a test pattern
43-
[render](scanvideo/render)| | A very dated rendering library used by [demo1](scanvideo/demo1) - avoid!
44-
[sprite](scanvideo/sprite)| | A small sprite library used by [sprite_demo](scanvideo/scanvideo_minimal)
45-
[sprite_demo](scanvideo/sprite_demo)|![](scanvideo/sprite_demo/screenshot.jpg)| Some bouncing Eben heads
46-
[test_pattern](scanvideo/test_pattern)|![](scanvideo/test_pattern/screenshot.jpg)| Display color bars
47-
[textmode](scanvideo/textmode)|![](scanvideo/textmode/screenshot.jpg)| Shows off chained DMA to generate scanlines out of glyph fragments via DMA/PIO
35+
Name| Screenshot |Description
36+
---|-------------------------------------------------|---
37+
[demo1](scanvideo/demo1)| ![](scanvideo/demo1/screenshot.jpg) | So named because it was the first demo program written that used video.. it is a bit dated now and hails from a time where there was _much_ less RAM on the RP2040
38+
[demo2](scanvideo/demo2)| ![](scanvideo/demo2/screenshot.jpg) | A little variation on `demo1` for RP2350. Displays a RISC-V logo also; if built for RISC-V the RISC-V logo is in front; if built for Arm, it is behind
39+
[flash_stream](scanvideo/flash_stream)| ![](scanvideo/flash_stream/screenshot.jpg) | Streams video data out of flash fast enough to drive 640x480x60fps bitmap display
40+
[hscroll_dma_tiles](scanvideo/hscroll_dma_tiles)| ![](scanvideo/hscroll_dma_tiles/screenshot.jpg) | A horizontal scrolling test app which uses a second video plane (PIO) to overlay sprites
41+
[mandelbrot](scanvideo/mandelbrot)| ![](scanvideo/mandelbrot/screenshot.jpg) | A mandelbrot generator using a 320x240x16 framebuffer
42+
[mario_tiles](scanvideo/mario_tiles)| ![](scanvideo/mario_tiles/screenshot.jpg) | Confusingly named as a reference to Super Mario Kart's tiled psuedo-3D rendering. This is similar to [hscroll_dma_tiles](scanvideo/hscroll_dma_tiles) except the whole tiled scrolling area is now rotated and zoomed.
43+
[scanvideo_minimal](scanvideo/scanvideo_minimal)| ![](scanvideo/scanvideo_minimal/screenshot.jpg) | A very basic video output generator which generates a test pattern
44+
[render](scanvideo/render)| | A very dated rendering library used by [demo1](scanvideo/demo1) - avoid!
45+
[sprite](scanvideo/sprite)| | A small sprite library used by [sprite_demo](scanvideo/scanvideo_minimal)
46+
[sprite_demo](scanvideo/sprite_demo)| ![](scanvideo/sprite_demo/screenshot.jpg) | Some bouncing Eben heads
47+
[test_pattern](scanvideo/test_pattern)| ![](scanvideo/test_pattern/screenshot.jpg) | Display color bars
48+
[textmode](scanvideo/textmode)| ![](scanvideo/textmode/screenshot.jpg) | Shows off chained DMA to generate scanlines out of glyph fragments via DMA/PIO
4849

4950
The above are intended to be used with the VGA demo board as described in [Hardware Design with RP2040](https://rptl.io/rp2040-design) however it is possible to wire your own VGA output according to the following schematic:
5051
![](scanvideo/Raspberry%20Pi%20Pico%20to%20VGA%20Connection%20Schematic.png)

apps/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
add_subdirectory(popcorn)
2-
add_subdirectory(usb_sound_card)
1+
add_subdirectory_exclude_platforms(popcorn "rp2350-riscv")
2+
add_subdirectory_exclude_platforms(usb_sound_card)

apps/popcorn/CMakeLists.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if (PICO_ON_DEVICE)
77
lcd18.c
88
)
99

10-
add_compile_definitions(popcorn
10+
target_compile_definitions(popcorn PRIVATE
1111
PICO_SCANVIDEO_MAX_SCANLINE_BUFFER_WORDS=164
1212
# seems fine without 16 (maybe need for overlay)
1313
PICO_SCANVIDEO_SCANLINE_BUFFER_COUNT=16
@@ -28,6 +28,12 @@ if (PICO_ON_DEVICE)
2828
#PICO_SCANVIDEO_48MHZ # still uses this for now
2929
)
3030

31+
if (PICO_RP2350)
32+
target_compile_definitions(popcorn PRIVATE
33+
#PICO_SCANVIDEO_48MHZ=1
34+
PLATYPUS_TABLES_MAIN_RAM=1 #todo not enough space in scratch (we can fixup tables tho later)
35+
)
36+
endif()
3137
target_link_libraries(popcorn
3238
pico_multicore
3339
pico_stdlib

apps/popcorn/converter/src/convert.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <cstdint>
88
#include <cassert>
9+
#include <cstddef>
910
#include <algorithm>
1011
#include <map>
1112
#include <set>

apps/popcorn/popcorn.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "pico/sd_card.h"
2323
#include "hardware/divider.h"
2424
#include "hardware/irq.h"
25+
#include "hardware/clocks.h"
2526
#include "platypus.h"
2627
#include "font.h"
2728

@@ -698,7 +699,7 @@ static void __time_critical_func(handle_audio_buffer_ready)(const struct frame_h
698699

699700
static void __time_critical_func(handle_need_frame_header_sector)(struct frame_header *head) {
700701
head->mark0 = 0; // mark as invalid
701-
popcorn_debug("starting scatter read %d\n", (uint) vs.sector_num);
702+
popcorn_debug("starting scatter read %d\n", (uint) head->sector_number);
702703
const int sector_count = 1;
703704
assert(sector_count <= PICO_SD_MAX_BLOCK_COUNT);
704705
uint32_t *p = scatter;

apps/usb_sound_card/usb_sound_card.c

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "pico/audio.h"
1212
#include "pico/audio_i2s.h"
1313
#include "pico/multicore.h"
14+
#include "hardware/clocks.h"
1415
#include "lufa/AudioClassCommon.h"
1516

1617
// todo forget why this is using core 1 for sound: presumably not necessary

reset/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
add_subdirectory(hello_reset)
1+
add_subdirectory_exclude_platforms(hello_reset)

scanvideo/CMakeLists.txt

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
if (TARGET pico_scanvideo) # not all build types support it
22
# Libs
3-
add_subdirectory(render)
4-
add_subdirectory(sprite)
3+
add_subdirectory_exclude_platforms(render)
4+
add_subdirectory_exclude_platforms(sprite)
55
# Apps
6-
add_subdirectory(demo1)
7-
add_subdirectory(hscroll_dma_tiles)
8-
add_subdirectory(flash_stream)
9-
add_subdirectory(mandelbrot)
10-
add_subdirectory(mario_tiles)
11-
add_subdirectory(scanvideo_minimal)
12-
add_subdirectory(sprite_demo)
13-
add_subdirectory(test_pattern)
14-
add_subdirectory(textmode)
6+
add_subdirectory_exclude_platforms(demo1)
7+
add_subdirectory_exclude_platforms(demo2 "rp2040")
8+
add_subdirectory_exclude_platforms(flash_stream "rp2350.*")
9+
add_subdirectory_exclude_platforms(hscroll_dma_tiles)
10+
add_subdirectory_exclude_platforms(mandelbrot)
11+
add_subdirectory_exclude_platforms(mario_tiles)
12+
add_subdirectory_exclude_platforms(scanvideo_minimal)
13+
add_subdirectory_exclude_platforms(sprite_demo "rp2350-riscv")
14+
add_subdirectory_exclude_platforms(test_pattern)
15+
add_subdirectory_exclude_platforms(textmode)
1516
endif()

scanvideo/demo1/CMakeLists.txt

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ if (TARGET pico_scanvideo_dpi)
77

88
target_compile_definitions(demo1
99
PRIVATE
10-
#PICO_SCANVIDEO_48MHZ
11-
# video overlay is distracting
12-
# PICO_SCANVIDEO_PLANE_COUNT=3
10+
#PICO_SCANVIDEO_48MHZ=1
11+
# commented out as video overlay is distracting
12+
# PICO_SCANVIDEO_PLANE_COUNT=3
1313
)
1414

15+
if (PICO_RP2350)
16+
target_compile_definitions(demo1 PRIVATE
17+
PICO_USE_SW_SPIN_LOCKS=0
18+
)
19+
endif()
1520
target_link_libraries(demo1 PRIVATE pico_stdlib pico_scanvideo_dpi render pico_multicore)
1621
pico_add_extra_outputs(demo1)
1722
endif()

scanvideo/demo1/demo1.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ int vga_main(void) {
411411

412412
sem_init(&video_setup_complete, 0, 1);
413413

414-
init_render_state(0);
414+
init_render_state(get_core_num());
415415

416416
#ifdef RENDER_ON_CORE1
417417
init_render_state(1);
@@ -617,6 +617,11 @@ int main(void) {
617617

618618
// Re init uart now that clk_peri has changed
619619
setup_default_uart();
620+
#ifdef __riscv
621+
printf("This is RISCV\n");
622+
#else
623+
printf("This is ARM\n");
624+
#endif
620625

621626
return vga_main();
622627
}

scanvideo/demo2/CMakeLists.txt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
if (TARGET pico_scanvideo_dpi)
2+
add_executable(demo2 demo2.c data2.c)
3+
4+
if (PICO_RP2350)
5+
target_compile_definitions(demo2 PRIVATE
6+
#PICO_SCANVIDEO_48MHZ=1
7+
PICO_USE_SW_SPIN_LOCKS=0
8+
PICO_SCANVIDEO_SCANLINE_BUFFER_COUNT=16 # a few extra for amortization
9+
)
10+
endif()
11+
target_link_libraries(demo2 PRIVATE pico_stdlib pico_scanvideo_dpi pico_multicore render)
12+
pico_add_extra_outputs(demo2)
13+
endif()

0 commit comments

Comments
 (0)