Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Raspberry Pi Gforth GPIO Library using C function wrappers
C Forth C++ Makefile
Branch: master

README

##################################################
This is a Gforth library that gives low level access to Raspberry Pi GPIO Header!
The access is done in C via Wrapper functions that are written in the Gforth library.
The C code is included with a Makefile that creates a shared library. 
The C code it self is mostly from Alanbarr/RaspberryPi-GPIO git repository.
***** Note the gpio.c code is updated to have pin number error detection on Rev 2 
***** Raspberry Pi boards.  This means it will not work on Rev 1 boards with out changing code back.
This library now has I2C working on P1-03(as I2C1_SDA) P1-05(as I2C1_SCL) and again this is Rev 2 board only!
The C shared library is now version 0.0.2 ( more testing is needed! )
I added a DS1307 Real time clock library in Gforth what works via I2C.
I added a Pi_pinouts file for the Rev 2 Raspberry Pi P1 header.
##################################################
To use first you need to compile the c code and library and install like follows:
	$ cd c_src
	$ sudo make 
	$ sudo make install
Now that you have the c shared library installed do the following
	$ cd ..
	$ sudo gforth
	include rpi_GPIO_lib.fs		# note this line is entered in the gforth program and there is no prompt for this
Now at this moment Gforth has words to do GPIO stuff.  See the code itself for some information oh how to use it!
##################################################
If you change any c code and need to test you will need to clear the gforth library stuff out and recompile the c library.
Here are the commands:
	$ cd c_src
	$ sudo make uninstall
	$ sudo make clean
	$ sudo make 
	$ sudo make install
	$ cd ..
Now you will need to update the rpi_GPIO_lib.fs file to use the new code that you changed or added.
Once the rpi_GPIO_lib.fs file is complete save it and let gforth compile it to use ... this is done as follows:

	$ ./clean		# this is a simple batch type file that simply removes the internal gforth library
				# Note that it removes the library created with the name of mygpio so if you changed 
				# that name in rpi_GPIO_lib.fs then you need to change that in the clean file
	$ sudo gforth
	include rpi_GPIO_lib.fs		
Now the gforth has your new words and any updates or changes you made.  
##################################################
The file rpiGpio.h in c_src directory has a #define macro called DBG_INFO.
This will need to be changed before compiling the code depending on if you want debug info on stderr output or not!
See rpiGpio.h for what to change.  Default is set to not put output on stderr.
Note the c functions all return an error code and that also is returned in the gforth wrapers so the error status is still reported just not to stderr file.

Something went wrong with that request. Please try again.