cmake_minimum_required(VERSION 3.12)

set(PICO_BOARD pico CACHE STRING "Board type")
set(TOP ${PICO_TINYUSB_PATH})
include(pico_sdk_import.cmake)    

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

project(wheelbase C CXX ASM)

pico_sdk_init()


add_executable(wheelbase
    src/quadrature.c
    src/main.c 
    src/stepper.c
    tusb/tusb_descriptors.c
    tusb/tusb_stdio_driver.c
    )

pico_set_program_name(wheelbase "wheelbase")
pico_set_program_version(wheelbase "0.1")

pico_enable_stdio_uart(wheelbase 0)
pico_enable_stdio_usb(wheelbase 1)

pico_generate_pio_header(wheelbase ${CMAKE_CURRENT_LIST_DIR}/pio/quadrature.pio)
pico_generate_pio_header(wheelbase ${CMAKE_CURRENT_LIST_DIR}/pio/blink.pio)

target_link_libraries(wheelbase
    pico_stdlib
    pico_stdio
    pico_time
    pico_multicore
    hardware_pio
    hardware_clocks
    hardware_gpio
    hardware_sync
    tinyusb_board
    tinyusb_device)

target_include_directories(wheelbase PRIVATE
  ${CMAKE_CURRENT_LIST_DIR}
  src/
  tusb/
)

pico_add_extra_outputs(wheelbase)