Skip to content

EmbeddedNim/picostdlib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raspberry Pi Pico SDK for Nim

This library provides the library and build system necessary to write programs for RP2040 based devices (such as the Raspberry Pi Pico) in the Nim programming language

The libary provides wrappers for the original Raspberry Pi Pico SDK. The following features are currently implemented:

  • Automatic project scaffolding using the piconim tool
  • Standard library features such as GPIO, time, ADC, PWM and many more
  • Rudimentary TinyUSB support: USB device, HID and CDC (serial port) classes

Table of Contents

Setup

Building

Examples

Contributing

License

Setup

The following steps will install piconim and create a new project

  1. First, you will need to have the Nim compiler installed. If you don't already have it, consider using choosenim

  2. Since this is just a wrapper for the original pico-sdk, you will need to install the C library dependencies (Step 1 in the quick start section)

  3. From the terminal, run nimble install https://github.com/EmbeddedNim/picostdlib.

  4. Run piconim init <project-name> to create a new project directory from a template. This will create a new folder, so make sure you are in the parent folder. You can also provide the following options to the subcommand:

    • (--sdk, -s) -> specify the path to a locally installed pico-sdk repository, ex. --sdk:/home/casey/pico-sdk
    • (--overwrite, -O) -> a flag to specify overwriting an exisiting directory with the <project-name> already created. Be careful with this. ex. piconim myProject --overwrite will replace a folder named myProject

Building

Now you can work on your project. When you are ready to build the .uf2 file (which will be copied to the Raspberry Pi Pico), you can use the build subcommand:

piconim build <main-program>

Where <main-program> is the main module in your src folder. (ex. piconim build myProject if the main nim file is myProject.nim). You can also specify an output directory, otherwise it will be placed in csource/build

piconim setup

If a piconim project is cloned fresh, or if git clean is ran, then the csource/build directory will need to be re-generated by CMake. This can be accomplished with the piconim setup command. The setup command takes an optional --sdk argument that works exactly like for the init command, described above.

Examples:

# Run these commands from the project root.

# Re-run CMake, download Pico SDK from Github
piconim setup

# Re-run CMake, use existing SDK
piconim setup --sdk:/home/casey/pico-sdk

Contributing

Please contribute.