mirror of
https://github.com/clockworkpi/WiringPi.git
synced 2026-03-28 14:52:38 +01:00
Fixed delayMicroseconds for more than 1 second.
Added new code for max31855
This commit is contained in:
@@ -35,7 +35,8 @@ DYNAMIC=libwiringPi.so.$(VERSION)
|
||||
DEBUG = -O2
|
||||
CC = gcc
|
||||
INCLUDE = -I.
|
||||
CFLAGS = $(DEBUG) -Wformat=2 -Wall $(INCLUDE) -Winline -pipe -fPIC
|
||||
DEFS = -D_GNU_SOURCE
|
||||
CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC
|
||||
|
||||
LIBS =
|
||||
|
||||
@@ -52,6 +53,7 @@ SRC = wiringPi.c \
|
||||
sr595.c \
|
||||
pcf8574.c pcf8591.c \
|
||||
mcp3002.c mcp3004.c mcp4802.c mcp3422.c \
|
||||
max31855.c \
|
||||
drc.c
|
||||
|
||||
OBJ = $(SRC:.c=.o)
|
||||
@@ -101,6 +103,7 @@ install-headers:
|
||||
@install -m 0644 mcp23017.h $(DESTDIR)$(PREFIX)/include
|
||||
@install -m 0644 mcp23s08.h $(DESTDIR)$(PREFIX)/include
|
||||
@install -m 0644 mcp23s17.h $(DESTDIR)$(PREFIX)/include
|
||||
@install -m 0644 max31855.h $(DESTDIR)$(PREFIX)/include
|
||||
@install -m 0644 mcp3002.h $(DESTDIR)$(PREFIX)/include
|
||||
@install -m 0644 mcp3004.h $(DESTDIR)$(PREFIX)/include
|
||||
@install -m 0644 mcp4802.h $(DESTDIR)$(PREFIX)/include
|
||||
@@ -138,6 +141,7 @@ uninstall:
|
||||
@rm -f $(DESTDIR)$(PREFIX)/include/mcp23017.h
|
||||
@rm -f $(DESTDIR)$(PREFIX)/include/mcp23s08.h
|
||||
@rm -f $(DESTDIR)$(PREFIX)/include/mcp23s17.h
|
||||
@rm -f $(DESTDIR)$(PREFIX)/include/max31855.h
|
||||
@rm -f $(DESTDIR)$(PREFIX)/include/mcp3002.h
|
||||
@rm -f $(DESTDIR)$(PREFIX)/include/mcp3004.h
|
||||
@rm -f $(DESTDIR)$(PREFIX)/include/mcp4802.h
|
||||
@@ -173,6 +177,8 @@ sr595.o: wiringPi.h sr595.h
|
||||
pcf8574.o: wiringPi.h wiringPiI2C.h pcf8574.h
|
||||
pcf8591.o: wiringPi.h wiringPiI2C.h pcf8591.h
|
||||
mcp3002.o: wiringPi.h wiringPiSPI.h mcp3002.h
|
||||
mcp3004.o: wiringPi.h wiringPiSPI.h mcp3004.h
|
||||
mcp4802.o: wiringPi.h wiringPiSPI.h mcp4802.h
|
||||
mcp3422.o: wiringPi.h wiringPiI2C.h mcp3422.h
|
||||
max31855.o: wiringPi.h wiringPiSPI.h max31855.h
|
||||
drc.o: wiringPi.h wiringSerial.h drc.h
|
||||
|
||||
@@ -1448,6 +1448,8 @@ void delayMicrosecondsHard (unsigned int howLong)
|
||||
void delayMicroseconds (unsigned int howLong)
|
||||
{
|
||||
struct timespec sleeper ;
|
||||
unsigned int uSecs = howLong % 1000000 ;
|
||||
unsigned int wSecs = howLong / 1000000 ;
|
||||
|
||||
/**/ if (howLong == 0)
|
||||
return ;
|
||||
@@ -1455,8 +1457,8 @@ void delayMicroseconds (unsigned int howLong)
|
||||
delayMicrosecondsHard (howLong) ;
|
||||
else
|
||||
{
|
||||
sleeper.tv_sec = 0 ;
|
||||
sleeper.tv_nsec = (long)(howLong * 1000) ;
|
||||
sleeper.tv_sec = wSecs ;
|
||||
sleeper.tv_nsec = (long)(uSecs * 1000L) ;
|
||||
nanosleep (&sleeper, NULL) ;
|
||||
}
|
||||
}
|
||||
@@ -1539,7 +1541,7 @@ int wiringPiSetup (void)
|
||||
|
||||
// Open the master /dev/memory device
|
||||
|
||||
if ((fd = open ("/dev/mem", O_RDWR | O_SYNC) ) < 0)
|
||||
if ((fd = open ("/dev/mem", O_RDWR | O_SYNC | O_CLOEXEC) ) < 0)
|
||||
return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: Unable to open /dev/mem: %s\n", strerror (errno)) ;
|
||||
|
||||
// GPIO:
|
||||
|
||||
Reference in New Issue
Block a user