Skip to content

Commit

Permalink
Synced to git.drogon.net
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon Henderson authored and Gadgetoid committed Mar 24, 2013
1 parent dda3305 commit 3fbc564
Show file tree
Hide file tree
Showing 41 changed files with 1,828 additions and 424 deletions.
48 changes: 48 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

How to install wiringPi
=======================

The easiest way is to use the supplied 'build' script:

./build

that should do a complete install or upgrade of wiringPi for you.

That will install a dynamic library.

Some distributions do not have /usr/local/lib in the default LD_LIBRARY_PATH. To
fix this, you need to edit /etc/ld.so.conf and add in a single line:

/usr/local/lib

then run the ldconfig command.

sudo ldconfig

If you want to install a static library, you may need to do this manually:

cd wiringPi
make static
sudo make install-static


To un-install wiringPi:

./build uninstall


I2C:

If your system has the correct i2c-dev libraries and headers installed,
then the I2C helpers will be compiled into wiringPi. If you want to
use the I2C helpers and don't have them installed, then under Raspbian,
issue the command:

sudo apt-get install libi2c-dev

Consult the documentation for your system if you are not running Raspbian.

Gordon Henderson

projects@drogon.net
https://projects.drogon.net/
12 changes: 12 additions & 0 deletions People
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@ Chris McSweeny
inside the dealyMicrosecondsHard() function.
And spotting a couple of schoolboy errors in the (experimental)
softServo code, prompting me to completely re-write it.

Armin (Via projects website)
Some pointers about the i2c-dev.h files.

Arno Wagner
Suggestions for the mmap calls in wiringPiSetup()

CHARLES Thibaut:
A small issue in softTone

Xian Stannard
Fixing some typos in the man page!
26 changes: 26 additions & 0 deletions README.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

wiringPi README
===============

Please note that the official way to get wiringPi is via git from
git.drogon.net and not GitHub.

ie.

git clone git://git.drogon.net/wiringPi

The version of wiringPi held on GitHub by "Gadgetoid" is used to build the
wiringPython, Ruby, Perl, etc. wrappers for these other languages. This
version may lag the official Drogon release. Pull requests may not be
accepted to Github....

Please see

https://projects.drogon.net/raspberry-pi/wiringpi/

for the official documentation, etc. and the best way to submit bug reports, etc.
is by sending an email to projects@drogon.net

Thanks!

-Gordon
63 changes: 52 additions & 11 deletions build
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#!/bin/bash

check-make-ok()
{
if [ $? != 0 ]; then
echo ""
echo "Make Failed..."
echo "Please check the messages and fix any problems. If you're still stuck,"
echo "then please email all the output and as many details as you can to"
echo " projects@drogon.net"
echo ""
exit 1
fi
}

if [ x$1 = "xclean" ]; then
echo Cleaning
echo
Expand All @@ -9,8 +22,10 @@ if [ x$1 = "xclean" ]; then
make clean
cd ../examples
make clean
cd ..
elif [ x$1 = "xuninstall" ]; then
exit
fi

if [ x$1 = "xuninstall" ]; then
echo Uninstalling
echo
echo "WiringPi library"
Expand All @@ -21,24 +36,50 @@ elif [ x$1 = "xuninstall" ]; then
cd ../gpio
sudo make uninstall
cd ..
else
echo wiringPi Build script - please wait...
exit
fi


echo "wiringPi Build script"
echo "====================="
echo

# Check for I2C being installed...
# ... and if-so, then automatically make the I2C helpers

if [ -f /usr/include/linux/i2c-dev.h ]; then
grep -q i2c_smbus_read_byte /usr/include/linux/i2c-dev.h
if [ $? = 0 ]; then
target=i2c
echo "Building wiringPi with the I2C helper libraries."
else
target=all
echo "The wiringPi I2C helper libraries will not be built."
fi
fi

echo
echo "WiringPi library"
cd wiringPi
make
sudo make uninstall
make $target
check-make-ok
sudo make install
check-make-ok

echo
echo "GPIO Utility"
cd ../gpio
make
check-make-ok
sudo make install
echo
echo "Examples"
cd ../examples
make
cd ..
fi
check-make-ok

# echo
# echo "Examples"
# cd ../examples
# make
# cd ..

echo
echo All Done.
36 changes: 27 additions & 9 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ INCLUDE = -I/usr/local/include
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe

LDFLAGS = -L/usr/local/lib
LDLIBS = -lwiringPi
LDLIBS = -lwiringPi -lpthread -lm

# Should not alter anything below this line
###############################################################################

SRC = test1.c test2.c speed.c lcd.c wfi.c \
piface.c gertboard.c nes.c \
pwm.c tone.c servo.c \
delayTest.c serialRead.c okLed.c
SRC = blink.c test1.c test2.c speed.c lcd.c wfi.c isr.c isr-osc.c \
piface.c gertboard.c nes.c \
pwm.c tone.c servo.c \
delayTest.c serialRead.c serialTest.c okLed.c

OBJ = $(SRC:.c=.o)

Expand All @@ -49,6 +49,12 @@ all:
@echo " $(BINS)" | fmt
@echo ""

really-all: $(BINS)

blink: blink.o
@echo [link]
@$(CC) -o $@ blink.o $(LDFLAGS) $(LDLIBS)

test1: test1.o
@echo [link]
@$(CC) -o $@ test1.o $(LDFLAGS) $(LDLIBS)
Expand All @@ -69,21 +75,29 @@ wfi: wfi.o
@echo [link]
@$(CC) -o $@ wfi.o $(LDFLAGS) $(LDLIBS)

isr: isr.o
@echo [link]
@$(CC) -o $@ isr.o $(LDFLAGS) $(LDLIBS)

isr-osc: isr-osc.o
@echo [link]
@$(CC) -o $@ isr-osc.o $(LDFLAGS) $(LDLIBS)

piface: piface.o
@echo [link]
@$(CC) -o $@ piface.o $(LDFLAGS) $(LDLIBS) -lpthread
@$(CC) -o $@ piface.o $(LDFLAGS) $(LDLIBS)

gertboard: gertboard.o
@echo [link]
@$(CC) -o $@ gertboard.o $(LDFLAGS) $(LDLIBS) -lm
@$(CC) -o $@ gertboard.o $(LDFLAGS) $(LDLIBS)

nes: nes.o
@echo [link]
@$(CC) -o $@ nes.o $(LDFLAGS) $(LDLIBS) -lm
@$(CC) -o $@ nes.o $(LDFLAGS) $(LDLIBS)

pwm: pwm.o
@echo [link]
@$(CC) -o $@ pwm.o $(LDFLAGS) $(LDLIBS) -lm -lpthread
@$(CC) -o $@ pwm.o $(LDFLAGS) $(LDLIBS)

delayTest: delayTest.o
@echo [link]
Expand All @@ -93,6 +107,10 @@ serialRead: serialRead.o
@echo [link]
@$(CC) -o $@ serialRead.o $(LDFLAGS) $(LDLIBS)

serialTest: serialTest.o
@echo [link]
@$(CC) -o $@ serialTest.o $(LDFLAGS) $(LDLIBS)

okLed: okLed.o
@echo [link]
@$(CC) -o $@ okLed.o $(LDFLAGS) $(LDLIBS)
Expand Down
6 changes: 5 additions & 1 deletion examples/README.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ To compile an individual example, just type

make exampleName

Where exampleName is one of:
To really compile everything:

make really-all

The individual tests are:

50 changes: 50 additions & 0 deletions examples/blink.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* blink.c:
* Standard "blink" program in wiringPi. Blinks an LED connected
* to the first GPIO pin.
*
* Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
***********************************************************************
* This file is part of wiringPi:
* https://projects.drogon.net/raspberry-pi/wiringpi/
*
* wiringPi is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* wiringPi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************
*/

#include <stdio.h>
#include <wiringPi.h>

// LED Pin - wiringPi pin 0 is BCM_GPIO 17.

#define LED 0

int main (void)
{
printf ("Raspberry Pi blink\n") ;

if (wiringPiSetup () == -1)
return 1 ;

pinMode (LED, OUTPUT) ;

for (;;)
{
digitalWrite (LED, 1) ; // On
delay (500) ; // mS
digitalWrite (LED, 0) ; // Off
delay (500) ;
}
return 0 ;
}
30 changes: 30 additions & 0 deletions examples/blink.rtb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// blink.rtb:
// Blink program in Return to Basic
//
// Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
//**********************************************************************
// This file is part of wiringPi:
// https://projects.drogon.net/raspberry-pi/wiringpi/
//
// wiringPi is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// wiringPi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************
//
PinMode (0, 1) // Output
CYCLE
DigitalWrite (0, 1) // Pin 0 ON
WAIT (0.5) // 0.5 seconds
DigitalWrite (0, 0)
WAIT (0.5)
REPEAT
END
37 changes: 37 additions & 0 deletions examples/blink.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
#
# blink.sh:
# Standard "blink" program in wiringPi. Blinks an LED connected
# to the first GPIO pin.
#
# Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
#######################################################################
# This file is part of wiringPi:
# https://projects.drogon.net/raspberry-pi/wiringpi/
#
# wiringPi is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# wiringPi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
#######################################################################

# LED Pin - wiringPi pin 0 is BCM_GPIO 17.

LED=0

gpio mode $PIN out

while true; do
gpio write $PIN 1
sleep 0.5
gpio write $PIN 0
sleep 0.5
done
Loading

0 comments on commit 3fbc564

Please sign in to comment.