2024-01-28 05:38:46 +08:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
2023-12-25 06:22:05 +08:00
|
|
|
|
|
|
|
set(PICO_SDK_FETCH_FROM_GIT off)
|
|
|
|
set(PICO_BOARD=pico)
|
|
|
|
|
|
|
|
include(pico_sdk_import.cmake)
|
2024-01-28 05:38:46 +08:00
|
|
|
set(CMAKE_C_FLAGS "-Ofast -Wall -mcpu=cortex-m0plus -mtune=cortex-m0plus -funroll-loops")
|
2023-12-25 06:22:05 +08:00
|
|
|
|
2024-01-03 17:48:34 +08:00
|
|
|
set(PICO_COPY_TO_RAM 1)
|
|
|
|
|
2023-12-25 06:22:05 +08:00
|
|
|
project(deskhop_project C CXX ASM)
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2024-01-28 05:38:46 +08:00
|
|
|
|
2023-12-25 06:22:05 +08:00
|
|
|
pico_sdk_init()
|
|
|
|
|
|
|
|
set(PICO_PIO_USB_DIR ${CMAKE_CURRENT_LIST_DIR}/Pico-PIO-USB)
|
|
|
|
|
|
|
|
add_library(Pico-PIO-USB STATIC
|
|
|
|
${PICO_PIO_USB_DIR}/src/pio_usb.c
|
|
|
|
${PICO_PIO_USB_DIR}/src/pio_usb_host.c
|
|
|
|
${PICO_PIO_USB_DIR}/src/usb_crc.c
|
|
|
|
)
|
|
|
|
pico_generate_pio_header(Pico-PIO-USB ${PICO_PIO_USB_DIR}/src/usb_tx.pio)
|
|
|
|
pico_generate_pio_header(Pico-PIO-USB ${PICO_PIO_USB_DIR}/src/usb_rx.pio)
|
|
|
|
|
|
|
|
target_link_libraries(Pico-PIO-USB PRIVATE
|
|
|
|
pico_stdlib
|
|
|
|
pico_multicore
|
|
|
|
hardware_pio
|
|
|
|
hardware_dma
|
|
|
|
)
|
|
|
|
target_include_directories(Pico-PIO-USB PRIVATE ${PICO_PIO_USB_DIR})
|
|
|
|
|
|
|
|
set(COMMON_SOURCES
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/usb_descriptors.c
|
2024-01-17 01:38:24 +08:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/defaults.c
|
2024-01-03 17:48:34 +08:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/hid_parser.c
|
2023-12-25 06:22:05 +08:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/utils.c
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/handlers.c
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/setup.c
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/keyboard.c
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/mouse.c
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/led.c
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/uart.c
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/usb.c
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/main.c
|
2024-01-03 17:48:34 +08:00
|
|
|
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/pio_usb/dcd_pio_usb.c
|
|
|
|
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/pio_usb/hcd_pio_usb.c
|
2023-12-25 06:22:05 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
set(COMMON_INCLUDES
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src
|
|
|
|
${PICO_PIO_USB_DIR}/src
|
|
|
|
)
|
|
|
|
|
|
|
|
set(COMMON_LINK_LIBRARIES
|
|
|
|
pico_stdlib
|
2024-01-17 01:38:24 +08:00
|
|
|
hardware_flash
|
2023-12-25 06:22:05 +08:00
|
|
|
hardware_uart
|
|
|
|
hardware_gpio
|
2024-01-03 17:48:34 +08:00
|
|
|
hardware_pio
|
2023-12-25 06:22:05 +08:00
|
|
|
|
|
|
|
tinyusb_device
|
2024-01-03 17:48:34 +08:00
|
|
|
tinyusb_host
|
2023-12-25 06:22:05 +08:00
|
|
|
pico_multicore
|
|
|
|
Pico-PIO-USB
|
|
|
|
)
|
|
|
|
|
2024-01-28 05:38:46 +08:00
|
|
|
# Pico A - Keyboard (board_role = 0)
|
|
|
|
# B - Mouse (board_role = 1)
|
2023-12-25 06:22:05 +08:00
|
|
|
|
2024-01-28 05:38:46 +08:00
|
|
|
set(binaries board_A board_B)
|
2023-12-25 06:22:05 +08:00
|
|
|
|
2024-01-28 05:38:46 +08:00
|
|
|
foreach(board_role RANGE 0 1)
|
|
|
|
list (GET binaries ${board_role} binary)
|
2023-12-25 06:22:05 +08:00
|
|
|
|
2024-01-28 05:38:46 +08:00
|
|
|
add_executable(${binary})
|
2023-12-25 06:22:05 +08:00
|
|
|
|
2024-01-28 05:38:46 +08:00
|
|
|
target_sources(${binary} PUBLIC ${COMMON_SOURCES})
|
|
|
|
target_compile_definitions(${binary} PRIVATE BOARD_ROLE=${board_role} PIO_USB_USE_TINYUSB=1 PIO_USB_DP_PIN_DEFAULT=14)
|
|
|
|
target_include_directories(${binary} PUBLIC ${COMMON_INCLUDES})
|
|
|
|
target_link_libraries(${binary} PUBLIC ${COMMON_LINK_LIBRARIES})
|
2023-12-25 06:22:05 +08:00
|
|
|
|
2024-01-28 05:38:46 +08:00
|
|
|
pico_enable_stdio_usb(${binary} 0)
|
|
|
|
pico_add_extra_outputs(${binary})
|
2024-01-12 00:57:29 +08:00
|
|
|
|
2024-01-28 05:38:46 +08:00
|
|
|
target_link_options(${binary} PRIVATE
|
|
|
|
-Xlinker
|
|
|
|
--print-memory-usage
|
|
|
|
)
|
2024-01-12 00:57:29 +08:00
|
|
|
|
2024-01-28 05:38:46 +08:00
|
|
|
pico_set_linker_script(${binary} ${CMAKE_SOURCE_DIR}/memory_map.ld)
|
2024-01-17 01:38:24 +08:00
|
|
|
|
2024-01-28 05:38:46 +08:00
|
|
|
endforeach()
|