Pi gforth interface

Here is a gforth interface for the bcm2835 C library as used in Raspberry Pi.

Version 125 defines gforth interfaces for all of the functions in the bcm2835-1.25 library, with gforth names like pi_gpio_write corresponding to the C function name bcm2835_gpio_write. gforth words are also defined to retrieve the base addresses of the peripheral registers: pi_gpio, pi_pwm, pi_clk, pi_pads, pi_spi0, pi_st, pi_bsc0, pi_bsc1.

Installation (creates /usr/local/lib/libpi.so, /usr/local/include/pi.h, and /usr/share/gforth/site-forth/pi-125.fs):

  tar zxvf pi-125.tar.gz
  cd pi-125
  make
  sudo make install
After installation, start gforth as root:
  sudo gforth
  require pi-125.fs
  ...
The first time you use the pi-125 library, you may notice a startup delay as gforth will create pi_125 C and object files in your ~/.gforth/libcc-named/ directory. Thereafter, there will be no startup delay as these files will be used automatically whenever you require pi-125.fs.

Example using blink.fs (which provides a blink command to turn pin P1-11 (GPIO 17) on/off once per second, 10 times), and spi.fs (which provides a spi command to transfer a byte to and from an SPI device):

  sudo gforth blink.fs spi.fs
  blink
  spi
pi-125.tar.gz - download

src - browse files

References:
http://www.open.com.au/mikem/bcm2835/ - C library for Broadcom BCM 2835 as used in Raspberry Pi
http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/ - Gforth Manual
  section 5.25 - C Interface