CL-WIRINGPI2 - CFFI bindings to WiringPi 2.
A set of lispified bindings to Wiring Pi 2 - a popular library for controlling GPIOs on Raspberry Pi.
The project intention is to provide a Lisp-friendly version of Wiring Pi 2. That means the library’s primary API does not correspond 1 to 1 with Wiring Pi 2. Changes have been made to make it follow the Lisp style of things.
Note that the CFFI bindings themselves have been separated to another package (cl-wiringpi2-ffi); you can use them instead if you prefer the original flavour of the library.
The simplest way is via QuickLisp. Clone the repo somewhere, and then symlink that folder
in ~/quicklisp/local-projects/. Inside your Lisp run
cl-wiringpi2 should now show on the list outputed by
Then, just execute
(ql:quickload :cl-wiringpi2) and you’re good to go.
Note that for most functions, Wiring Pi 2 requires to run with superuser privileges. It means your Lisp image will have to be started as such. For example, I run my CCL with:
sudo -E /path/to/ccl/armcl
-E ensures that the environmental variables of your user are retained, so you don’t have to set up separate init file and QuickLisp for the root user.
See the package.lisp file in the main folder for the list of exported symbols. Those are the functions that currently should work.
At the moment the bindings are only to the main Wiring Pi 2 functions, i.e. those contained in the wiringPi.h header.
Currently the documentation is available in docstrings of functions in the source files. Consult the Wiring Pi 2 official documentation; most available functions match the originals by name (albeit a bit lispified).
Examples are contained in cl-wiringpi2-examples system / package. A simple blink example is available. More to come.
To run blink, connect an LED and a 330Ω resistor to the GPIO 0 (physical pin: 11), like on this image, and execute:
The library hasn’t been tested very much. The bindings are pretty straightforward though, so there shouldn’t be surprises. Present API seems to work, but please report any issues.
Bug reports and pull requests always welcome :).
I did take a quick peek at the bindings to Wiring Pi by Jeremiah LaRocco.