User Manual

13
Macro name
T
Explanation
Page no.
INP_GPIO(n)
E
activates GPIO pin number n
(for input)
13
OUT_GPIO(n)
E
used after above, sets pin n for output
13
SET_GPIO_ALT(n, a)
E
used after INP_GPIO, select alternate function for pin
29
GPIO_PULL
W
set pull code
19
GPIO_PULLCCLK0
W
select which pins pull code is applied to
19
GPIO_IN0
R
get input values
19
GPIO_SET0
W
select which pins are set high
21
GPIO_CLR0
W
select which pins are set low
21
Table 2: Commonly used macros, their type, purpose, and location within this manual.
Table 2 shows a summary of the more commonly used macros and gives the page number on which
its use is explained in more detail. The T column below gives the „type‟ of the macro. This shows how
the macro is used. E‟ means that the command is executed, as in:
INP_GPIO(17);
„W‟ means that that the command is written to (assigned), as in:
GPIO_PULL = 2;
„R‟ means that that the command is read from, as in:
data = GPIO_IN0;
The macro INP_GPIO(n) must be called for a pin number n to allow this pin to be used. By default
its mode is set up as an input. If it is required that the pin is used for an output, OUT_GPIO(n)must
be called after INP_GPIO(n).
Python Code Overview
The Python software (along with the bits of this manual describing the Python programs) was written
by Alex Eames of Raspi.TV. We are very grateful to him for his help.
This software is written in Python 2.7 and is compatible with all current revisions of the Raspberry Pi
computer and Gertboard. It requires sudo user privileges to use the SPI and GPIO ports.
The Python code relies on several packages to access the various functions of the Gertboard. To use
the GPIO ports you need to have either RPi.GPIO or WiringPi for Python installed (or both). To use
the digital to analogue and analogue to digital converters, which use the SPI bus, you need to install a
module called py-spidev. Instructions for how to do this are included with the Python programs.
Downloading the Software
To obtain the Python Gertboard software with a browser or on a computer other than your Raspberry
Pi, visit http://raspi.tv/downloads. To get it directly on your internet-connected Raspberry Pi, first
change directory to where you want the programs installed, then from the command line type:
wget http://raspi.tv/download/GB_Python.zip
This should download the small file GB_Python.zip. Then type: