サンプルコードを直接変更するのも何なので「Getting started with Raspberry Pi Pico」の「Chapter 7. Creating your own Project」の感じで新規プロジェクトを作成します。
ドキュメントではLinux環境で説明されているのでWindows用に読み替えていきます。
pico-examples/
pico-sdk/
test/
ここにtestフォルダを作成してソースコード(test.c)とCMakeLists.txt、pico_sdk_import.cmakeをコピーします。
CMakeLists.txtの中身はこんな感じ
cmake_minimum_required(VERSION 3.12)
include(pico_sdk_import.cmake)
project(test_project)
pico_sdk_init()
add_executable(test
test.c
)
pico_enable_stdio_usb(test 1)
pico_add_extra_outputs(test)
target_link_libraries(test pico_stdlib)
pico_sdk_import.cmakeは pico-sdk/external/pico_sdk_import.cmake にあります。
testフォルダ内にbuildフォルダを作成してそこから下記のようにmakeを実行します。
cmake -G "NMake Makefiles" ..
nmake
これでtest.uf2まで作成できます。
ちなみにファイルを追加する場合はCMakeLists.txtにファイル名を追加します。
add_executable(test
test.c
add_file.c
)
0 件のコメント:
コメントを投稿