diff --git a/.gitignore b/.gitignore index ed2ec80..a675006 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,7 @@ lib*.so.* debian-template/wiringPi debian-template/wiringpi-*.deb gpio/gpio +CMakeCache.txt +CMakeFiles/ +Makefile +cmake_install.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5e9ae47 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8) +project(WiringPi_lib) + +add_subdirectory(devLib) +add_subdirectory(gpio) +#add_subdirectory(pins) +add_subdirectory(wiringPi) diff --git a/README.md b/README.md new file mode 100644 index 0000000..b23ced8 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +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 + + http://wiringpi.com/ + +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 + + + 同步 git://git.drogon.net/wiringPi 最新源代码到项目当中。 + 此修改基于 原来的master 分支 + + ` git remote add upstream git://git.drogon.net/wiringPi ` + + ` git fetch upstream master:upstream/master ` + + ` git merge upstream/master ` + + ` git push origin master:master ` diff --git a/devLib/CMakeLists.txt b/devLib/CMakeLists.txt new file mode 100644 index 0000000..062fc8a --- /dev/null +++ b/devLib/CMakeLists.txt @@ -0,0 +1,15 @@ +set(devLib_src ds1302.c maxdetect.c scrollPhat.c piNes.c gertboard.c piFace.c lcd128x64.c lcd.c piGlow.c) +set(LIB_INSTALL_PATH /usr/lib) +set(LIB_INSTALL_HEADERS_PATH /usr/local) +add_library(libwiringPiDev SHARED ${devLib_src}) +set(LIBRARY_OUTPUT_PATH {LIB_INSTALL_PATH) +add_definitions("-lpthread") +set_target_properties(libwiringPiDev PROPERTIES OUTPUT_NAME "wiringPiDev") +set(root_HEADERS + ds1302.h gertboard.h lcd.h + lcd128x64.h maxdetect.h piFace.h + piGlow.h piNes.h scrollPhat.h scrollPhatFont.h) +install(FILES ${root_HEADERS} DESTINATION ${LIB_INSTALL_HEADERS_PATH}/include) +install(TARGETS libwiringPiDev DESTINATION ${LIB_INSTALL_PATH}) + + diff --git a/devLib/Makefile b/devLib/Makefile deleted file mode 100644 index 1b1ebe0..0000000 --- a/devLib/Makefile +++ /dev/null @@ -1,140 +0,0 @@ -# -# Makefile: -# wiringPi device - Wiring Compatable library for the Raspberry Pi -# -# Copyright (c) 2012-2015 Gordon Henderson -################################################################################# -# 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 . -################################################################################# - -VERSION=$(shell cat ../VERSION) -DESTDIR?=/usr -PREFIX?=/local - -LDCONFIG?=ldconfig - -ifneq ($V,1) -Q ?= @ -endif - -STATIC=libwiringPiDev.a -DYNAMIC=libwiringPiDev.so.$(VERSION) - -#DEBUG = -g -O0 -DEBUG = -O2 -CC = gcc -INCLUDE = -I. -DEFS = -D_GNU_SOURCE -CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC - -LIBS = - -############################################################################### - -SRC = ds1302.c maxdetect.c piNes.c \ - gertboard.c piFace.c \ - lcd128x64.c lcd.c \ - scrollPhat.c \ - piGlow.c - -OBJ = $(SRC:.c=.o) - -HEADERS = ds1302.h gertboard.h lcd128x64.h lcd.h maxdetect.h piFace.h piGlow.h piNes.h\ - scrollPhat.h - -all: $(DYNAMIC) - -static: $(STATIC) - -$(STATIC): $(OBJ) - $Q echo "[Link (Static)]" - $Q ar rcs $(STATIC) $(OBJ) - $Q ranlib $(STATIC) -# @size $(STATIC) - -$(DYNAMIC): $(OBJ) - $Q echo "[Link (Dynamic)]" - $Q $(CC) -shared -Wl,-soname,libwiringPiDev.so$(WIRINGPI_SONAME_SUFFIX) -o libwiringPiDev.so.$(VERSION) -lpthread $(OBJ) - -.c.o: - $Q echo [Compile] $< - $Q $(CC) -c $(CFLAGS) $< -o $@ - -.PHONY: clean -clean: - $Q echo "[Clean]" - $Q rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPiDev.* - -.PHONY: tags -tags: $(SRC) - $Q echo [ctags] - $Q ctags $(SRC) - - -.PHONY: install -install: $(DYNAMIC) - $Q echo "[Install Headers]" - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include - $Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include - $Q echo "[Install Dynamic Lib]" - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib - $Q install -m 0755 libwiringPiDev.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) - $Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) $(DESTDIR)/lib/libwiringPiDev.so - $Q $(LDCONFIG) - -.PHONY: install-static -install-static: $(STATIC) - $Q echo "[Install Headers]" - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include - $Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include - $Q echo "[Install Static Lib]" - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib - $Q install -m 0755 libwiringPiDev.a $(DESTDIR)$(PREFIX)/lib - -.PHONY: install-deb -install-deb: $(DYNAMIC) - $Q echo "[Install Headers: deb]" - $Q install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/include - $Q install -m 0644 $(HEADERS) ~/wiringPi/debian-template/wiringPi/usr/include - $Q echo "[Install Dynamic Lib: deb]" - install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/lib - install -m 0755 libwiringPiDev.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so.$(VERSION) - ln -sf ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so - -.PHONY: uninstall -uninstall: - $Q echo "[UnInstall]" - $Q cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS) - $Q cd $(DESTDIR)$(PREFIX)/lib/ && rm -f libwiringPiDev.* - $Q $(LDCONFIG) - - -.PHONY: depend -depend: - makedepend -Y $(SRC) - -# DO NOT DELETE - -ds1302.o: ds1302.h -maxdetect.o: maxdetect.h -piNes.o: piNes.h -gertboard.o: gertboard.h -piFace.o: piFace.h -lcd128x64.o: font.h lcd128x64.h -lcd.o: lcd.h -scrollPhat.o: scrollPhatFont.h scrollPhat.h -piGlow.o: piGlow.h diff --git a/gpio/CMakeLists.txt b/gpio/CMakeLists.txt new file mode 100644 index 0000000..fe73066 --- /dev/null +++ b/gpio/CMakeLists.txt @@ -0,0 +1,11 @@ +include_directories(${PROJECT_SOURCE_DIR}/devLib) +include_directories(${PROJECT_SOURCE_DIR}/wiringPi) +#project(gpio) +set(GPIO_SRC gpio.c readall.c pins.c) +set(GPIO_BINARY_PATH /usr/bin) +add_executable(gpio ${GPIO_SRC}) +target_link_libraries(gpio libwiringPi libwiringPiDev -lpthread -lm) +set(EXECUTABLE_OUTPUT_PATH ${GPIO_BINARY_PATH}) +install(TARGETS gpio + RUNTIME DESTINATION bin) + diff --git a/gpio/Makefile b/gpio/Makefile deleted file mode 100644 index 7dcd090..0000000 --- a/gpio/Makefile +++ /dev/null @@ -1,101 +0,0 @@ -# -# Makefile: -# The gpio command: -# A swiss-army knige of GPIO shenanigans. -# https://projects.drogon.net/wiring-pi -# -# Copyright (c) 2012-2015 Gordon Henderson -################################################################################# -# This file is part of wiringPi: -# Wiring Compatable library for the Raspberry Pi -# -# 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 . -################################################################################# - -DESTDIR?=/usr -PREFIX?=/local - -ifneq ($V,1) -Q ?= @ -endif - -#DEBUG = -g -O0 -DEBUG = -O2 -CC = gcc -INCLUDE = -I$(DESTDIR)$(PREFIX)/include -CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe - -LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib -LIBS = -lwiringPi -lwiringPiDev -lpthread - -# May not need to alter anything below this line -############################################################################### - -SRC = gpio.c readall.c pins.c - -OBJ = $(SRC:.c=.o) - -all: gpio - -version.h: ../VERSION - $Q echo Need to run newVersion above. - -gpio: $(OBJ) - $Q echo [Link] - $Q $(CC) -o $@ $(OBJ) $(LDFLAGS) $(LIBS) - -.c.o: - $Q echo [Compile] $< - $Q $(CC) -c $(CFLAGS) $< -o $@ - -.PHONY: clean -clean: - $Q echo "[Clean]" - $Q rm -f $(OBJ) gpio *~ core tags *.bak - -.PHONY: tags -tags: $(SRC) - $Q echo [ctags] - $Q ctags $(SRC) - -.PHONY: install -install: gpio - $Q echo "[Install]" - $Q cp gpio $(DESTDIR)$(PREFIX)/bin -ifneq ($(WIRINGPI_SUID),0) - $Q chown root.root $(DESTDIR)$(PREFIX)/bin/gpio - $Q chmod 4755 $(DESTDIR)$(PREFIX)/bin/gpio -endif - $Q mkdir -p $(DESTDIR)$(PREFIX)/man/man1 - $Q cp gpio.1 $(DESTDIR)$(PREFIX)/man/man1 - -.PHONY: install-deb -install-deb: gpio - $Q echo "[Install: deb]" - $Q install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/bin - $Q install -m 0755 gpio ~/wiringPi/debian-template/wiringPi/usr/bin - -.PHONY: uninstall -uninstall: - $Q echo "[UnInstall]" - $Q rm -f $(DESTDIR)$(PREFIX)/bin/gpio - $Q rm -f $(DESTDIR)$(PREFIX)/man/man1/gpio.1 - -.PHONY: depend -depend: - makedepend -Y $(SRC) - -# DO NOT DELETE - -gpio.o: version.h diff --git a/wiringPi/CMakeLists.txt b/wiringPi/CMakeLists.txt new file mode 100644 index 0000000..cb7816e --- /dev/null +++ b/wiringPi/CMakeLists.txt @@ -0,0 +1,34 @@ +set(wiringPi_src wiringPi.c + wiringSerial.c wiringShift.c + piHiPri.c piThread.c + wiringPiSPI.c wiringPiI2C.c + softPwm.c softTone.c ads1115.c + mcp23008.c mcp23016.c mcp23017.c + mcp23s08.c mcp23s17.c sr595.c + pcf8574.c pcf8591.c sn3218.c + mcp3002.c mcp3004.c mcp4802.c mcp3422.c + max31855.c max5322.c drcSerial.c + wpiExtensions.c) +set(LIB_INSTALL_PATH /usr/lib) +set(LIB_INSTALL_HEADERS_PATH /usr/local) +add_library(libwiringPi SHARED ${wiringPi_src}) +set(LIBRARY_OUTPUT_PATH {LIB_INSTALL_PATH) +add_definitions("-lpthread") +set_target_properties(libwiringPi PROPERTIES OUTPUT_NAME "wiringPi") + +set(root_HEADERS + wiringPi.h + wiringSerial.h wiringShift.h + wiringPiSPI.h wiringPiI2C.h + softPwm.h softTone.h + mcp23008.h mcp23016.h mcp23017.h + mcp23s08.h mcp23s17.h + sr595.h ads1115.h + pcf8574.h pcf8591.h + mcp3002.h mcp3004.h mcp4802.h mcp3422.h + max31855.h max5322.h + sn3218.h drcSerial.h + wpiExtensions.h) + +install(FILES ${root_HEADERS} DESTINATION ${LIB_INSTALL_HEADERS_PATH}/include) +install(TARGETS libwiringPi DESTINATION ${LIB_INSTALL_PATH}) diff --git a/wiringPi/Makefile b/wiringPi/Makefile deleted file mode 100644 index acb6e58..0000000 --- a/wiringPi/Makefile +++ /dev/null @@ -1,182 +0,0 @@ -# -# Makefile: -# wiringPi - Wiring Compatable library for the Raspberry Pi -# -# Copyright (c) 2012-2015 Gordon Henderson -################################################################################# -# 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 . -################################################################################# - -VERSION=$(shell cat ../VERSION) -DESTDIR?=/usr -PREFIX?=/local - -LDCONFIG?=ldconfig - -ifneq ($V,1) -Q ?= @ -endif - -STATIC=libwiringPi.a -DYNAMIC=libwiringPi.so.$(VERSION) - -#DEBUG = -g -O0 -DEBUG = -O2 -CC = gcc -INCLUDE = -I. -DEFS = -D_GNU_SOURCE -CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC - -LIBS = - -############################################################################### - -SRC = wiringPi.c \ - wiringSerial.c wiringShift.c \ - piHiPri.c piThread.c \ - wiringPiSPI.c wiringPiI2C.c \ - softPwm.c softTone.c \ - mcp23008.c mcp23016.c mcp23017.c \ - mcp23s08.c mcp23s17.c \ - sr595.c \ - pcf8574.c pcf8591.c \ - mcp3002.c mcp3004.c mcp4802.c mcp3422.c \ - max31855.c max5322.c ads1115.c \ - sn3218.c \ - drcSerial.c \ - wpiExtensions.c - -HEADERS = wiringPi.h \ - wiringSerial.h wiringShift.h \ - wiringPiSPI.h wiringPiI2C.h \ - softPwm.h softTone.h \ - mcp23008.h mcp23016.h mcp23017.h \ - mcp23s08.h mcp23s17.h \ - sr595.h \ - pcf8574.h pcf8591.h \ - mcp3002.h mcp3004.h mcp4802.h mcp3422.h \ - max31855.h max5322.h ads1115.h \ - sn3218.h \ - drcSerial.h \ - wpiExtensions.h - - -OBJ = $(SRC:.c=.o) - -all: $(DYNAMIC) - -static: $(STATIC) - -$(STATIC): $(OBJ) - $Q echo "[Link (Static)]" - $Q ar rcs $(STATIC) $(OBJ) - $Q ranlib $(STATIC) -# @size $(STATIC) - -$(DYNAMIC): $(OBJ) - $Q echo "[Link (Dynamic)]" - $Q $(CC) -shared -Wl,-soname,libwiringPi.so$(WIRINGPI_SONAME_SUFFIX) -o libwiringPi.so.$(VERSION) -lpthread $(OBJ) - -.c.o: - $Q echo [Compile] $< - $Q $(CC) -c $(CFLAGS) $< -o $@ - - -.PHONY: clean -clean: - $Q echo "[Clean]" - $Q rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPi.* - -.PHONY: tags -tags: $(SRC) - $Q echo [ctags] - $Q ctags $(SRC) - - -.PHONY: install -install: $(DYNAMIC) - $Q echo "[Install Headers]" - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include - $Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include - $Q echo "[Install Dynamic Lib]" - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib - $Q install -m 0755 libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) - $Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)/lib/libwiringPi.so - $Q $(LDCONFIG) - -.PHONY: install-static -install-static: $(STATIC) - $Q echo "[Install Headers]" - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include - $Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include - $Q echo "[Install Static Lib]" - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib - $Q install -m 0755 libwiringPi.a $(DESTDIR)$(PREFIX)/lib - -.PHONY: install-deb -install-deb: $(DYNAMIC) - $Q echo "[Install Headers: deb]" - $Q install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/include - $Q install -m 0644 $(HEADERS) ~/wiringPi/debian-template/wiringPi/usr/include - $Q echo "[Install Dynamic Lib: deb]" - install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/lib - install -m 0755 libwiringPi.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so.$(VERSION) - ln -sf ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so - -.PHONY: uninstall -uninstall: - $Q echo "[UnInstall]" - $Q cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS) - $Q cd $(DESTDIR)$(PREFIX)/lib/ && rm -f libwiringPi.* - $Q $(LDCONFIG) - - -.PHONY: depend -depend: - makedepend -Y $(SRC) $(SRC_I2C) - -# DO NOT DELETE - -wiringPi.o: softPwm.h softTone.h wiringPi.h -wiringSerial.o: wiringSerial.h -wiringShift.o: wiringPi.h wiringShift.h -piHiPri.o: wiringPi.h -piThread.o: wiringPi.h -wiringPiSPI.o: wiringPi.h wiringPiSPI.h -wiringPiI2C.o: wiringPi.h wiringPiI2C.h -softPwm.o: wiringPi.h softPwm.h -softTone.o: wiringPi.h softTone.h -mcp23008.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23008.h -mcp23016.o: wiringPi.h wiringPiI2C.h mcp23016.h mcp23016reg.h -mcp23017.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23017.h -mcp23s08.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s08.h -mcp23s17.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s17.h -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 -max5322.o: wiringPi.h wiringPiSPI.h max5322.h -sn3218.o: wiringPi.h wiringPiI2C.h sn3218.h -drcSerial.o: wiringPi.h wiringSerial.h drcSerial.h -wpiExtensions.o: wiringPi.h mcp23008.h mcp23016.h mcp23017.h mcp23s08.h -wpiExtensions.o: mcp23s17.h sr595.h pcf8574.h pcf8591.h mcp3002.h mcp3004.h -wpiExtensions.o: mcp4802.h mcp3422.h max31855.h max5322.h sn3218.h -wpiExtensions.o: drcSerial.h wpiExtensions.h