You are on page 1of 3

28/8/2014 freebasic.

net View topic - libpruio (BB D/A - I/O fast and easy)
http://www.freebasic.net/forum/viewtopic.php?f=14&t=22501#p198419 1/3
Re: libpruio (BB D/A - I/O fast and easy)
by rvega Jun 21, 2014 22:37
Hello, I'll post this here in case it's useful for others:
1. Install FreeBasic compiler in BBB
1.1. Download package from http://www.freebasic-portal.de/download ... k-283.html
CODE: [SELECT ALL] [EXPAND/COLLAPSE] [DOWNLOAD] (UNTITLED.BAS)
wget http://www.freebasic-portal.de/dlfiles/452/bbb_fbc-0.0.2.tar.xz
GeSHi
1.2. Uncompress and copy files
CODE: [SELECT ALL] [EXPAND/COLLAPSE] [DOWNLOAD] (UNTITLED.BAS)
cd bbb_fbc-0.0.2
cp usr/local/bin/fbc /usr/local/bin/
cp -R usr/local/lib/freebasic /usr/local/lib/
GeSHi
2. Install pruss driver kit for freebasic and BBB.
2.1. Download and uncompress package from http://www.freebasic-portal.de/dlfiles/ ...
.0.tar.bz2
2.2. Copy files
CODE: [SELECT ALL] [EXPAND/COLLAPSE] [DOWNLOAD] (UNTITLED.BAS)
cd FB_prussdrv-0.0
cp bin/libprussdrv.* /usr/local/lib
ldconfig
mkdir /usr/local/include/freebasic/BBB
cp include/* /usr/local/include/freebasic/BBB
cp bin/pasm/usr/local/bin
cp bin/PRUSSDRV-00A0.dtbo /lib/firmware

GeSHi
2.3. Install am335x-pru-package
CODE: [SELECT ALL] [EXPAND/COLLAPSE] [DOWNLOAD] (UNTITLED.BAS)
apt-get install am335x-pru-package
GeSHi
2.4. Activate the PRUSS by enabling the tree overlay. This must be done everytime, after each
28/8/2014 freebasic.net View topic - libpruio (BB D/A - I/O fast and easy)
http://www.freebasic.net/forum/viewtopic.php?f=14&t=22501#p198419 2/3
boot or before running your programs.
CODE: [SELECT ALL] [EXPAND/COLLAPSE] [DOWNLOAD] (UNTITLED.BAS)
echo PRUSSDRV> /sys/devices/bone_capemgr.9/slots
GeSHi
3. Install libpruio
3.1. Download and uncompress package from http://www.freebasic-portal.de/dlfiles/ ...
.2.tar.bz2
3.2. Copy files
CODE: [SELECT ALL] [EXPAND/COLLAPSE] [DOWNLOAD] (UNTITLED.BAS)
cd libpruio-0.0.2
cd src/c_wrapper/
cp libpruio.so /usr/local/lib
cp libpruio.a /usr/local/lib
ldconfig
cd ../pruio/
cp pruio.bi /usr/local/include/freebasic/BBB
cp pruio.hp /usr/local/include/freebasic/BBB
cp pruio_pins.bi /usr/local/include/freebasic/BBB

GeSHi
4. Here's a simple example C program that uses the library
CODE: [SELECT ALL] [EXPAND/COLLAPSE] [DOWNLOAD] (UNTITLED.BAS)
#include <stdio.h>
#include <unistd.h>
#include "pruio_c_wrapper.h"
#include "pruio_pins.h"
int main(int argc, const char *argv[]) {
PruIo *io = pruio_new(0, 0x98, 0, 1);
if (io->Errr) {
printf("Initialisation failed (%s)\n", io->Errr);
return 1;
}
if(pruio_config(io, 0, 0x1FE, 0, 4, 0)){
printf("Config failed (%s)\n", io->Errr);
return 1;
}
int a = 0;
int i;
while(1){
printf"\r%12o %12o %12o %12o %4X %4X %4X %4X %4X %4X
%4X %4X\n", io->Gpio[0].Stat, io->Gpio[1].Stat, io->Gpio[2].Stat,
28/8/2014 freebasic.net View topic - libpruio (BB D/A - I/O fast and easy)
http://www.freebasic.net/forum/viewtopic.php?f=14&t=22501#p198419 3/3
5. To compile it, here's a makefile:
CODE: [SELECT ALL] [EXPAND/COLLAPSE] [DOWNLOAD] (UNTITLED.BAS)
all: bbb-io.c Makefile
gcc -Wall -o bbb-io bbb-
io.c /usr/local/lib/freebasic/fbrt0.o-lpruio -
L"/usr/local/lib/freebasic/" -lfb -lpthread -lprussdrv -ltermcap -
lsupc++ -Wno-unused-variable

GeSHi
rvega

Posts: 7
Joined: Jun 21, 2014
21:35
Has thanked: 2 times
Been thanked: 0 time

You might also like