The Foundation has a wealth of Pico C programming examples over at GitHub. The Pico’s BOOTSEL-ect button - press and insert a USB cable to mount its Flash storage Examples If you have already copied a file over, you’ll need to hold down the BOOTSEL button while you connect the Pico to a Mac USB port, and then release it. On a raw board, this will mount automatically. Assuming that completes without error, you’ll have a build directory under ~/git/PicoTest/ and inside that a PicoTest.uf2 that you can drag to the Pico’s mounted storage. c file and then you just click Build in the status bar at the bottom to compile it. With the project in view in Visual Studio Code, you can write some code in your. c) and configure a CMakeLists.txt for you. It will create the folder, add stub source files (. Just run it in the Terminal as follows with a path to the project folder you’d like to create - makepico takes the project name from the last item on the path: makepico ~/my_pico_projects/killer_iot_device So I just turned it into a shell script, which you can find in my pi-pico repository on GitHub. Once the toolchain is in place, setting up a project - step 4 - is straightforward. The library names are listed in the Pico C/C++ SDK documentation. For example, to use I☬, you add #include "hardware/i2c.h" to your source, but the name you add to target_link_libraries() is hardware_i2c. There’s not a 1:1 correspondence between the library name and the relevant #include. You can tell when you have forgotten to do this: compiling will fail with an error at one of your #include lines. Make sure you add them to the CMakeLists.txt file’s target_link_libraries() call. When you go beyond the basic Hello, World examples in the manual, you’ll start using other Pico libraries. Here is some boilerplate for the project’s CMakeLists.txt file: The CMakeLists.txt file mentioned in step 4.4 is the configuration file for CMake, which organises the compiling and linking of the code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |