Arno Wagner
Suggestions for the mmap calls in wiringPiSetup()
+
+CHARLES Thibaut:
+ A small issue in softTone
--- /dev/null
+
+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
i2c-install()
{
- echo "* wiringPi needs the I2C Development Libraires installing."
- echo ""
- echo "If using Debian/Raspbian, then type this command:"
- echo " sudo apt-get install libi2c-dev"
- echo "then run ./build again."
- echo ""
- echo "If using another Linux distribution, then you will have to"
- echo "work out how to install the I2C Developmen Libraries for your"
- echo "system. (Sorry - I don't know - do let me know though!)"
- echo ""
- exit 1
+ echo "* wiringPi needs the I2C Development Libraires installing."
+ echo ""
+ echo "If using Debian/Raspbian, then type this command:"
+ echo " sudo apt-get install libi2c-dev"
+ echo "then run ./build again."
+ echo ""
+ echo "If using another Linux distribution, then you will have to"
+ echo "work out how to install the I2C Developmen Libraries for your"
+ echo "system. (Sorry - I don't know - do let me know though!)"
+ echo ""
+ exit 1
}
check-make-ok()
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe
LDFLAGS = -L/usr/local/lib
-LDLIBS = -lwiringPi
+LDLIBS = -lwiringPi -lpthread -lm
# Should not alter anything below this line
###############################################################################
BINS = $(SRC:.c=)
+# Note:
+# Please don't waste your time by emailling me or doing a
+# pull request with changes to make all these targets. It
+# is intentional that I do it this way as it now takes too
+# long to compile them all and most people will not run
+# them anyway... -GH-
+
all:
@cat README.TXT
@echo " $(BINS)" | fmt
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]
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe
LDFLAGS = -L/usr/local/lib
-LIBS = -lwiringPi -lpthread
+LIBS = -lwiringPi -lpthread -lm
# May not need to alter anything below this line
###############################################################################
# define FALSE (1==2)
#endif
-#define VERSION "1.7"
+#define VERSION "1.8"
static int wpMode ;
gertboard.c \
piNes.c \
lcd.c piHiPri.c piThread.c \
- wiringPiSPI.c wiringPiI2C.c \
+ wiringPiSPI.c \
softPwm.c softServo.c softTone.c
OBJ = $(SRC:.c=.o)
// the multipexing, but it does need to be at least 10mS, and preferably 16
// from what I've been able to determine.
+// WARNING:
+// This code is really experimental. It was written in response to some people
+// asking for a servo driver, however while it works, there is too much
+// jitter to successfully drive a small servo - I have tried it with a micro
+// servo and it worked, but the servo ran hot due to the jitter in the signal
+// being sent to it.
+//
+// If you want servo control for the Pi, then use the servoblaster kernel
+// module.
#define MAX_SERVOS 8
for (;;)
{
frewq = frewqs [pin] ;
- if (frewq != 0)
+ if (frewq == 0)
+ delay (1) ;
+ else
{
halfPeriod = 500000 / frewq ;
if ((fd = open ("/dev/mem", O_RDWR | O_SYNC) ) < 0)
{
if (wiringPiDebug)
- fprintf (stderr, "wiringPiSetup: Unable to open /dev/mem: %s\n", strerror (errno)) ;
+ {
+ int serr = errno ;
+ fprintf (stderr, "wiringPiSetup: Unable to open /dev/mem: %s\n", strerror (errno)) ;
+ errno = serr ;
+ }
return -1 ;
}
if ((int32_t)gpio == -1)
{
if (wiringPiDebug)
- fprintf (stderr, "wiringPiSetup: mmap failed: %s\n", strerror (errno)) ;
+ {
+ int serr = errno ;
+ fprintf (stderr, "wiringPiSetup: mmap failed: %s\n", strerror (errno)) ;
+ errno = serr ;
+ }
return -1 ;
}
if ((int32_t)pwm == -1)
{
if (wiringPiDebug)
- fprintf (stderr, "wiringPiSetup: mmap failed (pwm): %s\n", strerror (errno)) ;
+ {
+ int serr = errno ;
+ fprintf (stderr, "wiringPiSetup: mmap failed (pwm): %s\n", strerror (errno)) ;
+ errno = serr ;
+ }
return -1 ;
}
// Clock control (needed for PWM)
clk = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, CLOCK_BASE) ;
- if ((int32_t)clk < 0)
+ if ((int32_t)clk == -1)
{
if (wiringPiDebug)
- fprintf (stderr, "wiringPiSetup: mmap failed (clk): %s\n", strerror (errno)) ;
+ {
+ int serr = errno ;
+ fprintf (stderr, "wiringPiSetup: mmap failed (clk): %s\n", strerror (errno)) ;
+ errno = serr ;
+ }
return -1 ;
}
// The drive pads
pads = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_PADS) ;
- if ((int32_t)pads < 0)
+ if ((int32_t)pads == -1)
{
if (wiringPiDebug)
- fprintf (stderr, "wiringPiSetup: mmap failed (pads): %s\n", strerror (errno)) ;
+ {
+ int serr = errno ;
+ fprintf (stderr, "wiringPiSetup: mmap failed (pads): %s\n", strerror (errno)) ;
+ errno = serr ;
+ }
return -1 ;
}
// The system timer
timer = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_TIMER) ;
- if ((int32_t)timer < 0)
+ if ((int32_t)timer == -1)
{
if (wiringPiDebug)
- fprintf (stderr, "wiringPiSetup: mmap failed (timer): %s\n", strerror (errno)) ;
+ {
+ int serr = errno ;
+ fprintf (stderr, "wiringPiSetup: mmap failed (timer): %s\n", strerror (errno)) ;
+ errno = serr ;
+ }
return -1 ;
}
#define INT_EDGE_SETUP 0
#define INT_EDGE_FALLING 1
#define INT_EDGE_RISING 2
+#define INT_EDGE_BOTH 3
// Threads