Two C programs are now available to control the Adaptive Interfaces DAAC-100 Data Acquisition
and Control Board, an Add-On board for the Raspberry Pi 2. These programs are called
DAAC_Dashboard, a GUI created with xlib, and DAAC_Command, a command line program run
from the Raspbian terminal. Executables and Source Code files for these programs can be
downloaded from the http://www.adaptint.com website. Just go to the New Products page and look
for the Free Downloads section near the bottom. Both programs are good examples of using
memory mapping to access the registers of the BCM2836, especially the chip's GPIO and SPI
registers.
When I first started development of these programs, I had trouble using and understanding
some of the available C library functions for BCM2835/BCM2836 register access and decided
to start from scratch. Using examples from other programmers, I was able to write my own
functions using a memory map structure and the open("/dev/mem") function. From there, I
was able to create and use functions to access and control the Rapberry Pi's SPI, GPIO
and INTR registers. These registers and their addresses are described in the BCM2835 ARM
Peripherals manual, available from Raspberry Pi, Adafruit and others. The registers are
the same on both the BCM2835 and the BCM2836 with the exception of their Base Address. The
BCM2835 uses a Base Address of 0x7E000000 for its peripherals and the BCM2836 uses a Base
Address of 0x3F000000. Although I believe the Raspberry Pi 3 uses the same peripheral
Base Address as the RPi2, I have have yet to confirm this and have not purchased an RPi3
to test the code.
The DAAC-100 board features multiple digital and analog inputs and outputs and is controlled
over the SPI bus. I chose the SPI bus because I have used it on past projects and it
appeared to be easier to code. An I2C version of the board is in the works. Communication
is with a packet of 4 SPI bytes. The first byte is always 0xEA and is used to identify the
start of a packet and for verification by the DAAC-100. The second byte is a command byte.
A list of the command bytes is available on the website. After a 1.3 ms delay, two data
bytes are sent and received.
To make the DAAC-100 usable right out of the box, I felt a GUI program would work best. To
keep things as simple as possible, at least for me, I downloaded the X Windows library, xlib,
to my RPi2 and began creating simple graphics elements, such as bar graphs, slider controls,
value display boxes and buttons. Then it was a matter of using the X Windows' events to
coordinate everything and to send and process commands.
As I have claimed in previous posts, I'm not the greatest C programmer so any ideas on
improving the code would be welcome. Also, if you have any questions about the code or the
DAAC-100 board, I'll try my best to answer them here or at info@adaptint.com .
Mark