From f6342ac01e46d2f65add7a545d8755fe49ca920c Mon Sep 17 00:00:00 2001 From: Phil Date: Wed, 21 Sep 2022 19:34:57 +0100 Subject: [PATCH] prepare for Pimoroni Pico VGA --- CMakeLists.txt | 6 ++++-- pico_sdk_import.cmake | 35 ++++++++++++++++++++++------------- src/picovga/CMakeLists.txt | 1 + src/picovga/main.cpp | 4 ++++ 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11ad553..4f09952 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 3.12) + +# Pull in PICO SDK (must be before project) include(pico_sdk_import.cmake) + +# We also need PICO EXTRAS include(pico_extras_import.cmake) project(picodvi C CXX ASM) @@ -9,7 +13,6 @@ pico_sdk_init() add_compile_options(-Wall) - set(DVI_DEFAULT_SERIAL_CONFIG "pico_sock_cfg" CACHE STRING "Select a default pin configuration from common_dvi_pin_configs.h") @@ -19,7 +22,6 @@ include_directories( ${PICO_FOLDER}/PicoDVI/software/include ) - add_subdirectory(${PICO_FOLDER}/PicoDVI/software/libdvi "${CMAKE_CURRENT_BINARY_DIR}/libdvi") add_subdirectory(${PICO_FOLDER}/PicoDVI/software/libsprite "${CMAKE_CURRENT_BINARY_DIR}/libsprite") add_subdirectory(${PICO_FOLDER}/pico-vga-332/ "${CMAKE_CURRENT_BINARY_DIR}/pico-vga-332") diff --git a/pico_sdk_import.cmake b/pico_sdk_import.cmake index 2548382..65f8a6f 100644 --- a/pico_sdk_import.cmake +++ b/pico_sdk_import.cmake @@ -3,8 +3,6 @@ # This can be dropped into an external project to help locate this SDK # It should be include()ed prior to project() -# todo document - if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH)) set(PICO_SDK_PATH $ENV{PICO_SDK_PATH}) message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')") @@ -20,8 +18,8 @@ if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_P message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')") endif () -set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the PICO SDK") -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") +set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK") +set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable") set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK") if (NOT PICO_SDK_PATH) @@ -31,20 +29,31 @@ if (NOT PICO_SDK_PATH) if (PICO_SDK_FETCH_FROM_GIT_PATH) get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}") endif () - FetchContent_Declare( - pico_sdk - GIT_REPOSITORY git@asic-git.pitowers.org:projectmu/pico_sdk.git - GIT_TAG master - ) + # GIT_SUBMODULES_RECURSE was added in 3.17 + if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0") + FetchContent_Declare( + pico_sdk + GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk + GIT_TAG master + GIT_SUBMODULES_RECURSE FALSE + ) + else () + FetchContent_Declare( + pico_sdk + GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk + GIT_TAG master + ) + endif () + if (NOT pico_sdk) - message("Downloading PICO SDK") + message("Downloading Raspberry Pi Pico SDK") FetchContent_Populate(pico_sdk) set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR}) endif () set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE}) else () message(FATAL_ERROR - "PICO SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git." + "SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git." ) endif () endif () @@ -56,9 +65,9 @@ endif () set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake) if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE}) - message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the PICO SDK") + message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK") endif () -set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the PICO SDK" FORCE) +set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE) include(${PICO_SDK_INIT_CMAKE_FILE}) diff --git a/src/picovga/CMakeLists.txt b/src/picovga/CMakeLists.txt index 5f82c3c..4edfb2a 100644 --- a/src/picovga/CMakeLists.txt +++ b/src/picovga/CMakeLists.txt @@ -42,6 +42,7 @@ target_link_libraries(ZxSpectrumPicoVga tinyusb_board hardware_pio hardware_pwm + pico_scanvideo_dpi ) pico_enable_stdio_usb(ZxSpectrumPicoVga 0) diff --git a/src/picovga/main.cpp b/src/picovga/main.cpp index 3138024..6805fa3 100644 --- a/src/picovga/main.cpp +++ b/src/picovga/main.cpp @@ -8,6 +8,9 @@ #endif // TODO need a 16bit version // #include "vga.h" +#include "pico/scanvideo.h" +#include "pico/scanvideo/composable_scanline.h" +#include "pico/sync.h" #include "ZxSpectrumPrepareRgb16Scanline.h" #include "PicoCharRendererVga16.h" @@ -37,6 +40,7 @@ #define LED_PIN 25 #define SPK_PIN 9 +#define vga_mode vga_mode_640x320_60 #define VREG_VSEL VREG_VOLTAGE_1_10