|
1 |
| -add_executable(prawnblaster |
2 |
| - prawnblaster.cpp |
3 |
| - fast_serial.c |
4 |
| - ) |
5 |
| - |
6 |
| -pico_generate_pio_header(prawnblaster ${CMAKE_CURRENT_LIST_DIR}/pseudoclock.pio) |
7 |
| - |
8 |
| - |
9 |
| -# Pull in our pico_stdlib which aggregates commonly used features |
10 |
| -target_link_libraries(prawnblaster pico_stdlib hardware_pio pico_multicore pico_unique_id hardware_clocks hardware_dma tinyusb_device tinyusb_board) |
11 |
| -target_include_directories(prawnblaster PRIVATE .) |
12 |
| - |
13 |
| -# create map/bin/hex/uf2 file etc. |
14 |
| -pico_add_extra_outputs(prawnblaster) |
15 |
| - |
16 |
| -add_executable(prawnblasteroverclock |
17 |
| - prawnblaster.cpp |
18 |
| - fast_serial.c |
19 |
| - ) |
20 |
| - |
21 |
| -pico_generate_pio_header(prawnblasteroverclock ${CMAKE_CURRENT_LIST_DIR}/pseudoclock.pio) |
22 |
| - |
23 |
| -set_target_properties(prawnblasteroverclock PROPERTIES COMPILE_DEFINITIONS PRAWNBLASTER_OVERCLOCK=1) |
24 |
| - |
25 |
| -# Pull in our pico_stdlib which aggregates commonly used features |
26 |
| -target_link_libraries(prawnblasteroverclock pico_stdlib hardware_pio pico_multicore pico_unique_id hardware_clocks hardware_dma tinyusb_device tinyusb_board) |
27 |
| -target_include_directories(prawnblasteroverclock PRIVATE .) |
28 |
| - |
29 |
| -# create map/bin/hex/uf2 file etc. |
30 |
| -pico_add_extra_outputs(prawnblasteroverclock) |
| 1 | +set(overclocks 0;1) |
| 2 | + |
| 3 | +foreach (overclock IN LISTS overclocks) |
| 4 | + # Compute firmware name |
| 5 | + set(firmware_name prawnblaster) |
| 6 | + if(PICO_PLATFORM MATCHES "^rp2350") |
| 7 | + set(firmware_name "${firmware_name}_rp2350") |
| 8 | + else() |
| 9 | + set(firmware_name "${firmware_name}_${PICO_PLATFORM}") |
| 10 | + endif() |
| 11 | + if(overclock) |
| 12 | + set(firmware_name "${firmware_name}_overclock") |
| 13 | + endif() |
| 14 | + |
| 15 | + add_executable(${firmware_name} prawnblaster.cpp fast_serial.c) |
| 16 | + |
| 17 | + pico_generate_pio_header(${firmware_name} ${CMAKE_CURRENT_LIST_DIR}/pseudoclock.pio) |
| 18 | + |
| 19 | + # Pass in number of instructions to firmware as a compiler definition |
| 20 | + set(num_instructions 30000) |
| 21 | + if(PICO_PLATFORM MATCHES "^rp2350") |
| 22 | + set(num_instructions 60000) |
| 23 | + endif() |
| 24 | + target_compile_definitions(${firmware_name} PUBLIC "PRAWNBLASTER_NUM_INSTRUCTIONS=${num_instructions}") |
| 25 | + |
| 26 | + # Pass in board type to firmware as a compiler definition. Note that PICO_BOARD is passed in by the SDK, but it's passed in a string which isn't valid and so I can't use it... |
| 27 | + # This is also, to some extent, a duplicate of the above PRAWNBLASTER_NUM_INSTRUCTIONS but I think it makes sense to keep these seperate. |
| 28 | + if (PICO_BOARD STREQUAL "pico") |
| 29 | + target_compile_definitions(${firmware_name} PUBLIC "PRAWNBLASTER_PICO_BOARD=1") |
| 30 | + elseif (PICO_BOARD STREQUAL "pico2") |
| 31 | + target_compile_definitions(${firmware_name} PUBLIC "PRAWNBLASTER_PICO_BOARD=2") |
| 32 | + else () |
| 33 | + message(FATAL_ERROR "Unsupported PICO_BOARD") |
| 34 | + endif() |
| 35 | + |
| 36 | + |
| 37 | + # Pass in overclock state to firmware as a compiler definition |
| 38 | + if(overclock) |
| 39 | + target_compile_definitions(${firmware_name} PUBLIC "PRAWNBLASTER_OVERCLOCK=1") |
| 40 | + endif() |
| 41 | + |
| 42 | + # Pull in our pico_stdlib which aggregates commonly used features |
| 43 | + target_link_libraries(${firmware_name} pico_stdlib hardware_pio pico_multicore pico_unique_id hardware_clocks hardware_dma tinyusb_device tinyusb_board) |
| 44 | + target_include_directories(${firmware_name} PRIVATE .) |
| 45 | + |
| 46 | + # create map/bin/hex/uf2 file etc. |
| 47 | + pico_add_extra_outputs(${firmware_name}) |
| 48 | + |
| 49 | +endforeach() |
0 commit comments