mirror of
https://github.com/clockworkpi/WiringPi.git
synced 2026-03-30 16:52:46 +02:00
More changes to help reflect usage on Rev 2 / 512MB Raspberry Pi's.
Also Makefile tweaks to help improve things somewhat - decided to read the Makefile manual after some 15 years to updated my make grey cells somewhat. New command in the gpio command - readall
This commit is contained in:
@@ -43,40 +43,37 @@ SRC = wiringPi.c wiringPiFace.c wiringSerial.c wiringShift.c \
|
||||
piNes.c \
|
||||
lcd.c piHiPri.c piThread.c softPwm.c wiringPiSPI.c
|
||||
|
||||
OBJ = wiringPi.o wiringPiFace.o wiringSerial.o wiringShift.o \
|
||||
gertboard.o \
|
||||
piNes.o \
|
||||
lcd.o piHiPri.o piThread.o softPwm.o wiringPiSPI.o
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
all: $(STATIC) $(DYNAMIC)
|
||||
#all: $(STATIC) $(DYNAMIC)
|
||||
all: $(DYNAMIC)
|
||||
|
||||
$(STATIC): $(OBJ)
|
||||
@echo [STATIC]
|
||||
@echo [Link (Static)]
|
||||
@ar rcs $(STATIC) $(OBJ)
|
||||
@ranlib $(STATIC)
|
||||
|
||||
# @size $(STATIC)
|
||||
@size $(STATIC)
|
||||
|
||||
$(DYNAMIC): $(OBJ)
|
||||
@echo [DYNAMIC]
|
||||
@gcc -shared -Wl,-soname,libwiringPi.so.1 -o libwiringPi.so.1.0 -lpthread $(OBJ)
|
||||
@echo [Link]
|
||||
@$(CC) -shared -Wl,-soname,libwiringPi.so.1 -o libwiringPi.so.1.0 -lpthread $(OBJ)
|
||||
|
||||
.c.o:
|
||||
@echo [CC] $<
|
||||
@echo [Compile] $<
|
||||
@$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
.PHONEY: clean
|
||||
clean:
|
||||
rm -f $(OBJ) *~ core tags Makefile.bak libwiringPi.*
|
||||
|
||||
.PHONEY: tags
|
||||
tags: $(SRC)
|
||||
@echo [ctags]
|
||||
@ctags $(SRC)
|
||||
|
||||
depend:
|
||||
makedepend -Y $(SRC)
|
||||
|
||||
.PHONEY: install
|
||||
install: $(TARGET)
|
||||
@echo [install]
|
||||
@echo "[Install]"
|
||||
@install -m 0755 -d /usr/local/lib
|
||||
@install -m 0755 -d /usr/local/include
|
||||
@install -m 0644 wiringPi.h /usr/local/include
|
||||
@@ -87,14 +84,15 @@ install: $(TARGET)
|
||||
@install -m 0644 softPwm.h /usr/local/include
|
||||
@install -m 0644 lcd.h /usr/local/include
|
||||
@install -m 0644 wiringPiSPI.h /usr/local/include
|
||||
@install -m 0644 libwiringPi.a /usr/local/lib
|
||||
# @install -m 0644 libwiringPi.a /usr/local/lib
|
||||
@install -m 0755 libwiringPi.so.1.0 /usr/local/lib
|
||||
@ln -sf /usr/local/lib/libwiringPi.so.1.0 /usr/local/lib/libwiringPi.so
|
||||
@ln -sf /usr/local/lib/libwiringPi.so.1.0 /usr/local/lib/libwiringPi.so.1
|
||||
@ldconfig
|
||||
|
||||
.PHONEY: uninstall
|
||||
uninstall:
|
||||
@echo [uninstall]
|
||||
@echo "[UnInstall]"
|
||||
@rm -f /usr/local/include/wiringPi.h
|
||||
@rm -f /usr/local/include/wiringSerial.h
|
||||
@rm -f /usr/local/include/wiringShift.h
|
||||
@@ -107,6 +105,10 @@ uninstall:
|
||||
@ldconfig
|
||||
|
||||
|
||||
.PHONEY: depend
|
||||
depend:
|
||||
makedepend -Y $(SRC)
|
||||
|
||||
# DO NOT DELETE
|
||||
|
||||
wiringPi.o: wiringPi.h
|
||||
|
||||
@@ -397,15 +397,31 @@ int wpiPinToGpio (int wpiPin)
|
||||
* piBoardRev:
|
||||
* Return a number representing the hardware revision of the board.
|
||||
* Revision is currently 1 or 2. -1 is returned on error.
|
||||
*
|
||||
* Much confusion here )-:
|
||||
* Seems there ar esome boards with 0000 in them (mistake in manufacture)
|
||||
* and some board with 0005 in them (another mistake in manufacture).
|
||||
* So the distinction between boards that I can see is:
|
||||
* 0000 - Error
|
||||
* 0001 - Not used
|
||||
* 0002 - Rev 1
|
||||
* 0003 - Rev 1
|
||||
* 0004 - Rev 2
|
||||
* 0005 - Rev 2
|
||||
* 0006 - Rev 2
|
||||
* 000f - Rev 2 + 512MB
|
||||
*
|
||||
* A small thorn is the olde style overvolting - that will add in
|
||||
* 1000000
|
||||
*
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
int piBoardRev (void)
|
||||
{
|
||||
FILE *cpuFd ;
|
||||
char line [80] ;
|
||||
char *c ;
|
||||
int r = -1 ;
|
||||
char line [120] ;
|
||||
char *c, lastChar ;
|
||||
static int boardRev = -1 ;
|
||||
|
||||
// No point checking twice...
|
||||
@@ -416,21 +432,28 @@ int piBoardRev (void)
|
||||
if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL)
|
||||
return -1 ;
|
||||
|
||||
while (fgets (line, 80, cpuFd) != NULL)
|
||||
while (fgets (line, 120, cpuFd) != NULL)
|
||||
if (strncmp (line, "Revision", 8) == 0)
|
||||
for (c = line ; *c ; ++c)
|
||||
{
|
||||
if (!isdigit (*c))
|
||||
continue ;
|
||||
r = atoi (c) ;
|
||||
break ;
|
||||
}
|
||||
break ;
|
||||
|
||||
fclose (cpuFd) ;
|
||||
|
||||
if (r == -1)
|
||||
if (line == NULL)
|
||||
{
|
||||
fprintf (stderr, "piBoardRev: Unable to determine board revision from /proc/cpuinfo\n") ;
|
||||
fprintf (stderr, " (No \"Revision\" line)\n") ;
|
||||
errno = 0 ;
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
for (c = line ; *c ; ++c)
|
||||
if (isdigit (*c))
|
||||
break ;
|
||||
|
||||
if (!isdigit (*c))
|
||||
{
|
||||
fprintf (stderr, "piBoardRev: Unable to determine board revision from /proc/cpuinfo\n") ;
|
||||
fprintf (stderr, " (No numeric revision string in: \"%s\"\n", line) ;
|
||||
errno = 0 ;
|
||||
return -1 ;
|
||||
}
|
||||
@@ -439,15 +462,17 @@ int piBoardRev (void)
|
||||
// has 100000 added to it!
|
||||
|
||||
if (wiringPiDebug)
|
||||
if (r > 1000)
|
||||
if (strlen (c) != 4)
|
||||
printf ("piboardRev: This Pi has/is overvolted!\n") ;
|
||||
|
||||
r %= 100 ;
|
||||
lastChar = c [strlen (c) - 2] ;
|
||||
|
||||
/**/ if ((r == 2) || (r == 3))
|
||||
/**/ if ((lastChar == '2') || (lastChar == '3'))
|
||||
boardRev = 1 ;
|
||||
else if ((r == 4) || (r == 5) || (r == 6))
|
||||
else
|
||||
boardRev = 2 ;
|
||||
|
||||
#ifdef DO_WE_CARE_ABOUT_THIS_NOW
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "WARNING: wiringPi: Unable to determine board revision from \"%d\"\n", r) ;
|
||||
@@ -456,9 +481,10 @@ int piBoardRev (void)
|
||||
fprintf (stderr, " -> Assuming a Rev 1 board\n") ;
|
||||
boardRev = 1 ;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (wiringPiDebug)
|
||||
printf ("piboardRev: Revision: %d, board revision: %d\n", r, boardRev) ;
|
||||
printf ("piboardRev: Revision string: %s, board revision: %d\n", c, boardRev) ;
|
||||
|
||||
return boardRev ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user