Skip to content

Nim wrapper for the raspberry pi stdlib

License

Notifications You must be signed in to change notification settings

auxym/picostdlib

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 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/beef331/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
    • (--nimbase, -n) -> similarly, you can provide the path to a locally installed nimbase.h file. Otherwise, the program attempts to download the file from the nim-lang github repository. ex. -n:/path/to/nimbase.h
    • (--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. myProject.nim). You can also specify an output directory, otherwise it will be placed in csource/builds

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.

About

Nim wrapper for the raspberry pi stdlib

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Nim 95.5%
  • CMake 4.5%