2525### Cmake minimum version
2626cmake_minimum_required (VERSION 3.17 )
2727
28+ ### Cmake compiler standard versions
29+ set (CMAKE_C_STANDARD 11)
30+ set (CMAKE_CXX_STANDARD 17)
31+
32+ ### CMake stuff for ZED
33+ set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
34+
2835### Project magic sprinkles
2936set (PROJECT_NAME usbsidpico)
3037set (PROJECT_MANUFACTURER "LouD" )
@@ -61,6 +68,9 @@ set(ONBOARD_SIDPLAYER 0 CACHE STRING "ONBOARD_SIDPLAYER")
6168### Enable/ Disable build with PIO Uart on unused pins 26/27
6269set (USE_PIO_UART 0)
6370
71+ ### Enable/ Disable build with Bluetooth on rp2350_w
72+ set (ENABLE_BLUETOOTH 0 CACHE STRING "ENABLE_BLUETOOTH" )
73+
6474### Information on the use of CDC callback
6575## This is turned on/off by changing USE_CDC_CALLBACK in globals.h
6676
@@ -175,10 +185,6 @@ else()
175185 set (PICO_COMPILER pico_arm_gcc) # required for mem_ops on rp2040
176186endif ()
177187
178- ### Cmake compiler standard versions
179- set (CMAKE_C_STANDARD 11)
180- set (CMAKE_CXX_STANDARD 17)
181-
182188### Target environment path
183189set (CMAKE_FIND_ROOT_PATH $ENV{PICO_ENV_PATH} )
184190set (TINYUSB_PATH ${PICO_SDK_PATH} /lib/tinyusb)
@@ -301,28 +307,39 @@ endif()
301307list (APPEND FILENAMES
302308 ${PROJECT_FILENAME} -v1.0
303309 ${PROJECT_FILENAME} -v1.3
310+ ${PROJECT_FILENAME} -v1.5
304311)
305312list (APPEND PICOTYPES
306313 "LED"
307- "LED_AUDIOSWITCH"
314+ "LED"
315+ "LED"
308316)
309317list (APPEND PCBVERSIONS
310318 "1.0"
311319 "1.3"
320+ "1.5"
312321)
313322if (${PICO_BOARD} STREQUAL "pico" OR ${PICO_BOARD} STREQUAL "pico2" )
314323 list (APPEND FILENAMES
315324 ${PROJECT_FILENAME} -v1.0-rgb
316325 ${PROJECT_FILENAME} -v1.3-rgb
326+ ${PROJECT_FILENAME} -v1.5-rgb
317327 )
318328 list (APPEND PICOTYPES
319329 "RGB"
320- "RGB_AUDIOSWITCH"
330+ "RGB"
331+ "RGB"
321332 )
322333 list (APPEND PCBVERSIONS
334+ # "0.1" ## Alpha builds only
335+ # "0.2" ## Unreliable
323336 "1.0"
337+ # "1.1" ## Never built
338+ # "1.2" ## Incorrect gpio pins placing
324339 "1.3"
325- )
340+ # "1.4" ## Power delivery issue
341+ "1.5"
342+ )
326343endif ()
327344
328345### Source files to compile
@@ -517,6 +534,27 @@ set(TARGET_LL
517534 tinyusb_board
518535)
519536
537+ ### Bluetooth control for _w boards
538+ if (ENABLE_BLUETOOTH EQUAL 1)
539+ if (${PICO_BOARD} STREQUAL "pico2_w" )
540+ set (SOURCEFILES
541+ ${SOURCEFILES}
542+ ${CMAKE_CURRENT_LIST_DIR } /src/bluetooth.c
543+ )
544+
545+ set (TARGET_LL
546+ ${TARGET_LL}
547+ pico_cyw43_arch_none # Select 'none', 'background', or 'rtos' architecture
548+ pico_btstack_classic # Main stack for Classic SPP Bluetooth
549+ pico_btstack_cyw43 # Ties BTstack to the onboard CYW chip
550+ )
551+
552+ set (BT_TARGET_PIO 2) # Use rp2350 pio2
553+ add_compile_definitions (USE_BLUETOOTH=1 )
554+ endif ()
555+ endif ()
556+
557+
520558### Pio files
521559set (PIO_BUS ${CMAKE_CURRENT_LIST_DIR } /src/pio/bus_control.pio)
522560set (PIO_CLOCK ${CMAKE_CURRENT_LIST_DIR } /src/pio/clock.pio)
@@ -626,17 +664,11 @@ foreach(FILENAME PICOTYPE PCBVERSION IN ZIP_LISTS FILENAMES PICOTYPES PCBVERSION
626664 # executable
627665 add_executable (${BUILD} ${SOURCEFILES} )
628666 # BUILD TYPES
667+ string (REPLACE "." "" PCBVER_INT "${PCBVERSION} " )
629668 if (PICOTYPE STREQUAL "RGB" )
630- target_compile_definitions (${BUILD} PRIVATE USBSID USBSID_PRODUCT= "${BUILD_VERSION} " USE_RGB=1 PCB_VERSION= "${PCBVERSION} " )
631- # add_compile_definitions(USE_RGB=1)
632- elseif (PICOTYPE STREQUAL "RGB_AUDIOSWITCH" )
633- target_compile_definitions (${BUILD} PRIVATE USBSID USBSID_PRODUCT= "${BUILD_VERSION} " USE_RGB=1 HAS_AUDIOSWITCH=1 PCB_VERSION= "${PCBVERSION} " )
634- # add_compile_definitions(USE_RGB=1 HAS_AUDIOSWITCH=1)
635- elseif (PICOTYPE STREQUAL "LED_AUDIOSWITCH" )
636- target_compile_definitions (${BUILD} PRIVATE USBSID USBSID_PRODUCT= "${BUILD_VERSION} " HAS_AUDIOSWITCH=1 PCB_VERSION= "${PCBVERSION} " )
637- # add_compile_definitions(HAS_AUDIOSWITCH=1)
669+ target_compile_definitions (${BUILD} PRIVATE USBSID USBSID_PRODUCT= "${BUILD_VERSION} " USE_RGB=1 PCB_VERSION= "${PCBVERSION} " PCB_VERSION_INT=${PCBVER_INT} )
638670 else ()
639- target_compile_definitions (${BUILD} PRIVATE USBSID USBSID_PRODUCT= "${BUILD_VERSION} " PCB_VERSION= "${PCBVERSION} " )
671+ target_compile_definitions (${BUILD} PRIVATE USBSID USBSID_PRODUCT= "${BUILD_VERSION} " PCB_VERSION= "${PCBVERSION} " PCB_VERSION_INT=${PCBVER_INT} )
640672 endif ()
641673 # pio addition
642674 pico_generate_pio_header (${BUILD} ${PIO_BUS} )
@@ -672,7 +704,12 @@ foreach(FILENAME PICOTYPE PCBVERSION IN ZIP_LISTS FILENAMES PICOTYPES PCBVERSION
672704 endif ()
673705 # tell the linker what libraries to link
674706 target_link_libraries (${BUILD} ${TARGET_LL} )
675- if (PICO_CYW43_SUPPORTED)
707+ if ((ENABLE_BLUETOOTH EQUAL 1) AND (${PICO_BOARD} STREQUAL "pico2_w" ))
708+ # Redirect the CYW43 wireless driver to use the third PIO block (PIO2)
709+ target_compile_definitions (${BUILD} PRIVATE
710+ CYW43_SPI_PIO_PREFERRED_PIO=${BT_TARGET_PIO}
711+ )
712+ elseif (PICO_CYW43_SUPPORTED AND NOT (ENABLE_BLUETOOTH EQUAL 1))
676713 target_link_libraries (${BUILD} pico_cyw43_arch_none )
677714 endif ()
678715 # target usbsid types
@@ -684,4 +721,7 @@ foreach(FILENAME PICOTYPE PCBVERSION IN ZIP_LISTS FILENAMES PICOTYPES PCBVERSION
684721 # enable uart output, disable usb output
685722 pico_enable_stdio_uart (${BUILD} 1 ) # essentialy the same as LL pico_stdio_uart
686723 pico_enable_stdio_usb (${BUILD} 0 )
724+ if (${PICO_BOARD} STREQUAL "pico2_w" )
725+ pico_add_extra_outputs (${BUILD} )
726+ endif ()
687727endforeach ()
0 commit comments