Changed the build system to drop I2C for now. Seems to cause too many issues

on non Raspbian systems (and even on some Raspbian systems it would appear ):

fixed a timing issue on softTone
fixed some issues in wiringPisetup introduced when optimising the mmap calls.
This commit is contained in:
Gordon Henderson
2013-01-19 10:31:14 +00:00
parent c82fb8735d
commit be04c1bd52
11 changed files with 101 additions and 29 deletions

View File

@@ -46,7 +46,7 @@ SRC = wiringPi.c wiringPiFace.c wiringSerial.c wiringShift.c \
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)

View File

@@ -54,6 +54,15 @@
// 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

View File

@@ -59,7 +59,9 @@ static PI_THREAD (softToneThread)
for (;;)
{
frewq = frewqs [pin] ;
if (frewq != 0)
if (frewq == 0)
delay (1) ;
else
{
halfPeriod = 500000 / frewq ;

View File

@@ -1204,7 +1204,11 @@ int wiringPiSetup (void)
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 ;
}
@@ -1214,7 +1218,11 @@ int wiringPiSetup (void)
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 ;
}
@@ -1224,27 +1232,39 @@ int wiringPiSetup (void)
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 ;
}
@@ -1256,10 +1276,14 @@ int wiringPiSetup (void)
// 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 ;
}

View File

@@ -53,6 +53,7 @@
#define INT_EDGE_SETUP 0
#define INT_EDGE_FALLING 1
#define INT_EDGE_RISING 2
#define INT_EDGE_BOTH 3
// Threads