# Staapl

## About

Staapl is a collection of abstractions for metaprogramming microcontrollers from within PLT Scheme. The core of the system is a programmable code generator structured around a functional concatenative macro language with partial evaluation. On top of this it includes a syntax frontend for creating Forth style languages, a backend code generator for the Microchip PIC18 microcontroller architecture, and interaction tools for a productive edit-compile-run cycle.

## Status

The phase I goal - to build a practical, well-factored, easily extensible base system - is completed and put in maintenance mode. It will serve as the basis for phase II: further experiments with domain specific languages for DSP and embedded control and more elaborate compilation techniques to implement them.

## Documentation

- The general idea behind Staapl metaprogramming for PLT Scheme.
- An overview of the PIC18 macro Forth dialect.
- A practical tutorial about interactive tethered development.
- A tutorial about writing a low-level DSL using bottom up programming with procedures and macros.
- Some articles on the blog.
- The excellent PLT Scheme documentation.
- Interactive documentation on the mailing list.

Since this is a developer-oriented project with a lot of effort put into clean organization, I suggest looking at the source code to pierce through the top-layer of workflow glue. Staapl is structured as a library with multiple entry points, not a monolithic application. I encourage you to build your own workflow on top of it, and integrate it with other tools. (And share that code!).

## Projects

I am currently looking for projects that apply Staapl to practical problems in the embedded DSP/control field. I am particularly interested in adding backends for other architectures. Staapl contains a preliminary port for the 12 and 14 bit PIC cores, and I've been looking into porting staapl to dsPIC. While Staapl's niche is microcontrollers, larger 32 bit machines are intended to be supported through a C backend for which there is preliminary code. For more information please contact me directly.

The PIC18 Forth language has been used in:

- The Sheep sound synthesizer.
- The ForthTV B/W composite video generator.
- The CATkit and KRIkit boards.
- Several hands-on workshops.

## Download

Staapl is part of Planet. To compile the test suite (the the Sheep sound synth), install PLT Scheme 4 (only MzScheme is required) and type

      mzscheme -p zwizwa/staapl/examples/build-synth

This will produce a `synth.hex` and `synth.dict` in the local directory.

The same version is also available as staapl-0.5.4.tar.gz. For the latest changes track the darcs archive (hashed darcs-2 format). The Staapl source code, including that of its subprojects, is released to the public under the terms of the GPL v2. Staapl is written by Tom Schouten.

    Thu Aug  7 10:12:59 BST 2008