From 3d1e4afdef442a7a2cdf67876d136f3a43c944f3 Mon Sep 17 00:00:00 2001 From: zhaolei Date: Fri, 23 Oct 2015 15:35:34 +0800 Subject: [PATCH 01/24] h3 chip gpio ok --- examples/echo.c | 83 +++++++++++++++++++++++++ examples/te.c | 59 ++++++++++++++++++ examples/tser.c | 75 ++++++++++++++++++++++ examples/xserv.c | 74 ++++++++++++++++++++++ gpio/readall.c | 90 ++++++++++++++++++++++++++- wiringPi/Makefile | 5 +- wiringPi/wiringPi.c | 138 +++++++++++++++++++++++++++++++++++++++-- wiringPi/wiringPiI2C.c | 2 +- 8 files changed, 515 insertions(+), 11 deletions(-) create mode 100644 examples/echo.c create mode 100644 examples/te.c create mode 100644 examples/tser.c create mode 100644 examples/xserv.c diff --git a/examples/echo.c b/examples/echo.c new file mode 100644 index 0000000..2983e27 --- /dev/null +++ b/examples/echo.c @@ -0,0 +1,83 @@ +/* + * blink.c: + * Standard "blink" program in wiringPi. Blinks an LED connected + * to the first GPIO pin. + * + * Copyright (c) 2012-2013 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 . + *********************************************************************** + */ + +#include +#include +#include + +#define TRIG 15 +#define ECHO 16 + +float disT(void) +{ + struct timeval tv1; + struct timeval tv2; + + long start, stop; + float dis; + + digitalWrite(TRIG, LOW); + delayMicroseconds(2); + + digitalWrite(TRIG, HIGH); + delayMicroseconds(10); + digitalWrite(TRIG, LOW); + + while(!(digitalRead(ECHO) == 1)) { + gettimeofday(&tv1, NULL); + } + + while(!(digitalRead(ECHO) == 0)) { + if(tv2.tv_sec - tv1.tv_sec > 10) break; + gettimeofday(&tv2, NULL); + } + + + start = tv1.tv_sec * 1000000 + tv1.tv_usec; + stop = tv2.tv_sec * 1000000 + tv2.tv_usec; + + dis = (float) (stop - start) / 1000000 * 34000 / 2; + + return dis; +} + +int main (void) +{ + float dis; + + wiringPiSetup () ; + + pinMode(TRIG, OUTPUT); + pinMode(ECHO, INPUT); + + while(1) + { + dis = disT(); + printf("dis: %f \n", dis); + delay(1200); + } + + return 0 ; +} diff --git a/examples/te.c b/examples/te.c new file mode 100644 index 0000000..2e11bb5 --- /dev/null +++ b/examples/te.c @@ -0,0 +1,59 @@ +/* + * blink.c: + * Standard "blink" program in wiringPi. Blinks an LED connected + * to the first GPIO pin. + * + * Copyright (c) 2012-2013 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 . + *********************************************************************** + */ + +#include +#include + +// LED Pin - wiringPi pin 0 is BCM_GPIO 17. + +#define LED 0 + +int leds[] = {16, 15,13, 9}; + +//16 15 13 9 +int main (void) +{ + + int i; + printf ("Raspberry Pi blink\n") ; + + wiringPiSetup () ; + pinMode (16, OUTPUT) ; + pinMode (15, OUTPUT) ; + pinMode (13, OUTPUT) ; + pinMode (9, OUTPUT) ; + + for (;;) + { + for(i=0; i<4; i++) { + digitalWrite (leds[i], HIGH) ; // On + delay (20) ; // mS + digitalWrite (leds[i], LOW) ; // Off + delay (20) ; + } + delay(800); + } + return 0 ; +} diff --git a/examples/tser.c b/examples/tser.c new file mode 100644 index 0000000..0d6da5f --- /dev/null +++ b/examples/tser.c @@ -0,0 +1,75 @@ +/* + * serialTest.c: + * Very simple program to test the serial port. Expects + * the port to be looped back to itself + * + * Copyright (c) 2012-2013 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 . + *********************************************************************** + */ + +#include +#include +#include + +#include +#include + +int main () +{ + int fd ; + int count ; + unsigned int nextTime ; + + if ((fd = serialOpen ("/dev/ttyAMA0", 115200)) < 0) + { + fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ; + return 1 ; + } + + if (wiringPiSetup () == -1) + { + fprintf (stdout, "Unable to start wiringPi: %s\n", strerror (errno)) ; + return 1 ; + } + + nextTime = millis () + 300 ; + + for (count = 0 ; count < 256 ; ) + { + if (millis () > nextTime) + { + printf ("\nOut: %3d: ", count) ; + fflush (stdout) ; + serialPutchar (fd, count) ; + nextTime += 300 ; + ++count ; + } + + delay (3) ; + + while (serialDataAvail (fd)) + { + printf (" -> %3d", serialGetchar (fd)) ; + fflush (stdout) ; + } + } + + printf ("\n") ; + return 0 ; +} diff --git a/examples/xserv.c b/examples/xserv.c new file mode 100644 index 0000000..791c9fe --- /dev/null +++ b/examples/xserv.c @@ -0,0 +1,74 @@ +/* + * servo.c: + * Test of the softServo code. + * Do not use this code - use the servoBlaster kernel module instead + * + * Copyright (c) 2012-2013 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 . + *********************************************************************** + */ + +#include +#include +#include + +#include +#include + +int main (int argc, char *argv[]) +{ + if (wiringPiSetup () == -1) + { + fprintf (stdout, "oops: %s\n", strerror (errno)) ; + return 1 ; + } + + int du = atoi(argv[2]) ; + int de = atoi(argv[1]) ; + + du = (du == 0) ? 1000 : du; + de = (de == 0) ? 1000 : de; + + softServoSetup (0, 1, 2, 3, 4, 5, 6, 16) ; + + softServoWrite (0, 0) ; +/* + softServoWrite (1, 1000) ; + softServoWrite (2, 1100) ; + softServoWrite (3, 1200) ; + softServoWrite (4, 1300) ; + softServoWrite (5, 1400) ; + softServoWrite (6, 1500) ; + softServoWrite (7, 2200) ; +*/ + + //softServoWrite (16, du) ; + // delay (1500) ; + for (;;) { + softServoWrite (16, de) ; + delay (du) ; + softServoWrite (16, 0) ; + delay (du) ; + printf("%d \n", de); + softServoWrite (16, 0-de) ; + delay (du) ; + softServoWrite (16, 0) ; + delay (du) ; + } + +} diff --git a/gpio/readall.c b/gpio/readall.c index 9063c89..f3b2b95 100644 --- a/gpio/readall.c +++ b/gpio/readall.c @@ -80,7 +80,7 @@ static char *alts [] = "IN", "OUT", "ALT5", "ALT4", "ALT0", "ALT1", "ALT2", "ALT3" } ; -static int physToWpi [64] = +/* guenter static int physToWpi [64] = { -1, // 0 -1, -1, // 1, 2 @@ -111,9 +111,40 @@ static int physToWpi [64] = -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 +} ; +guenter ende */ + +// guenter anfang +static int physToWpi [64] = +{ + -1, // 0 + -1, -1, //1, 2 + -1, -1, //3, 4 + -1, -1, //5, 6 + -1, -1, //7, 8 + -1, -1, //9, 10 + -1, 1, //11, 12 + -1, -1, //13, 14 + -1, 4, //15, 16 + -1, 5, //17, 18 + -1, -1, //19, 20 + -1, -1, //21, 22 + -1, -1, //23, 24 + -1, -1, //25, 26 + -1, -1, //27, 28 + 7, -1, //29, 30 + 8, 9, //31, 32 + 10, -1, //33, 34 + 12, 13, //35, 36 + 14, 15, //37, 38 + -1, 16, //39, 40 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //41-> 55 + -1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63 } ; +//guenter ende -static char *physNames [64] = + +/* guenter static char *physNames [64] = { NULL, @@ -145,7 +176,43 @@ static char *physNames [64] = "GPIO.17", "GPIO.18", "GPIO.19", "GPIO.20", NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, +} ; guenter ende */ + +//guenter orange pi +static char *physNames [64] = +{ + NULL, + + " 3.3v", "5v ", + " SDA.0", "5V ", + " SCL.0", "0v ", + " ?? ", "TxD3 ", + " 0v", "RxD3 ", + " RxD2", "IO1 PD14", + " TxD2", "0v ", + " CTS2", "IO4 PC04", + " 3.3v", "IO5 PC07", + " MOSI", "0v ", + " MISO", "RTS2 ", + " SCLK", "SPI-CE0 ", + " 0v", "CE1 ", + " SDA.1", "SCL.1 ", + " IO7 PA7", "0v ", + " IO8 PA8", "IO9 PG08", + "IO10 PA9", "0v ", + "IO12PA10", "IO13PG09", + "IO14PA20", "IO15PG06", + " 0v", "IO16PG07", + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + "GPIO.17", "GPIO.18", + "GPIO.19", "GPIO.20", + NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, } ; +// guenter ende /* @@ -313,6 +380,22 @@ void BPReadAll(void) } //end 2014.09.26 +//guenter +void OrangePiReadAll(void) +{ + int pin ; + + printf (" +-----+-----+----------+------+---+--OrangePiPC--+---+------+---------+-----+--+\n") ; + printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n") ; + printf (" +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+\n") ; + for (pin = 1 ; pin <= 40 ; pin += 2) + readallPhys (pin) ; + printf (" +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+\n") ; + printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n") ; + printf (" +-----+-----+----------+------+---+--OrangePIPC--+------+----------+-----+-----+\n") ; +} +//guenter ende + void doReadall (void) { int model, rev, mem, maker, overVolted ; @@ -332,7 +415,8 @@ void doReadall (void) else if (model == PI_MODEL_CM) cmReadall () ; else if (model == PI_MODEL_BPR) //add for BananaPro by lemaker team - BPReadAll(); + OrangePiReadAll(); //guenter + // guenter BPReadAll(); else printf ("Oops - unable to determine board type... model: %d\n", model) ; } diff --git a/wiringPi/Makefile b/wiringPi/Makefile index 78d3612..9e92202 100644 --- a/wiringPi/Makefile +++ b/wiringPi/Makefile @@ -47,7 +47,7 @@ SRC = wiringPi.c \ wiringSerial.c wiringShift.c \ piHiPri.c piThread.c \ wiringPiSPI.c wiringPiI2C.c \ - softPwm.c softTone.c \ + softPwm.c softTone.c softServo.c \ mcp23008.c mcp23016.c mcp23017.c \ mcp23s08.c mcp23s17.c \ sr595.c \ @@ -97,6 +97,7 @@ install-headers: @install -m 0644 wiringShift.h $(DESTDIR)$(PREFIX)/include @install -m 0644 softPwm.h $(DESTDIR)$(PREFIX)/include @install -m 0644 softTone.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 softServo.h $(DESTDIR)$(PREFIX)/include @install -m 0644 wiringPiSPI.h $(DESTDIR)$(PREFIX)/include @install -m 0644 wiringPiI2C.h $(DESTDIR)$(PREFIX)/include @install -m 0644 drcSerial.h $(DESTDIR)$(PREFIX)/include @@ -138,6 +139,7 @@ uninstall: @rm -f $(DESTDIR)$(PREFIX)/include/wiringShift.h @rm -f $(DESTDIR)$(PREFIX)/include/softPwm.h @rm -f $(DESTDIR)$(PREFIX)/include/softTone.h + @rm -f $(DESTDIR)$(PREFIX)/include/softServo.h @rm -f $(DESTDIR)$(PREFIX)/include/wiringPiSPI.h @rm -f $(DESTDIR)$(PREFIX)/include/wiringPiI2C.h @rm -f $(DESTDIR)$(PREFIX)/include/drcSerial.h @@ -175,6 +177,7 @@ wiringPiSPI.o: wiringPi.h wiringPiSPI.h wiringPiI2C.o: wiringPi.h wiringPiI2C.h softPwm.o: wiringPi.h softPwm.h softTone.o: wiringPi.h softTone.h +softServo.o: wiringPi.h softServo.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 diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index 9feec9f..6dc0337 100755 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -291,7 +291,7 @@ static pthread_mutex_t pinMutex ; // Debugging & Return codes -int wiringPiDebug = FALSE ; +int wiringPiDebug = FALSE; // guenter FALSE ; int wiringPiReturnCodes = FALSE ; // sysFds: @@ -621,7 +621,7 @@ static int *physToPin ; static int upDnConvert[3] = {7, 7, 5}; -static int pinToGpio_BP [64] = +/* guenter static int pinToGpio_BP [64] = { 275,259, 274,273, @@ -640,10 +640,41 @@ static int pinToGpio_BP [64] = 44,40, 257,256, // ...31 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,// ... 63 +} ; guenter ende */ + +// WiringPiNr. gegeben .. -> Array GPIOx orange pi guenter neu +// A ab 0x00, B ab 0x20, C ab 0x40, D ab 0x50 ...... +// 00 - 31 = PA00-PA31 +// 32 - 63 = PB00-PB31 +// 64 - 95 = PC00-PC31 +static int pinToGpio_BP [64] = +{ + -1,110, + -1,-1, + 68,71, + -1,7, + 8,200, + 9,-1, + 10,201, + 20,198, + 199, -1, + -1, -1, + -1, -1, + -1, -1, + -1, -1, + -1, -1, + -1,-1, + -1,-1, // ...31 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,// ... 63 } ; +// guenter neu ende + +// guenter ... dieses braucht nicht umgewandelt werden, da kein /sys/class/gpio auf orange pi static int pinTobcm_BP [64] = { 257,256, //map to BCM GPIO0,1 @@ -665,6 +696,7 @@ static int pinTobcm_BP [64] = -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //45... 60 -1, -1, -1, -1 // ...63 } ; +/* guenter static int physToGpio_BP [64] = { -1, // 0 @@ -691,6 +723,37 @@ static int physToGpio_BP [64] = -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //41-> 55 -1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63 } ; +guenter ende */ + +//guenter anfang +static int physToGpio_BP [64] = +{ + -1, // 0 + -1, -1, //1, 2 + -1, -1, //3, 4 + -1, -1, //5, 6 + -1, -1, //7, 8 + -1, -1, //9, 10 + -1, 110, //11, 12 + -1, -1, //13, 14 + -1, 68, //15, 16 + -1, 71, //17, 18 + -1, -1, //19, 20 + -1, -1, //21, 22 + -1, -1, //23, 24 + -1, -1, //25, 26 + -1, -1, //27, 28 + 7, -1, //29, 30 + 8, 200, //31, 32 + 9, -1, //33, 34 + 10, 201, //35, 36 + 20, 198, //37, 38 + -1, 199, //39, 40 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //41-> 55 + -1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63 +} ; +// guenter ende + static int syspin [64] = @@ -791,6 +854,7 @@ static int physToPinR3 [64] = //return wiringPI pin -1, -1, -1, -1, -1, -1, -1, // ... 63 } ; +/* guenter raus static int BP_PIN_MASK[9][32] = //[BANK] [INDEX] { {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PA @@ -803,6 +867,24 @@ static int BP_PIN_MASK[9][32] = //[BANK] [INDEX] {-1,-1, 2,-1, 4, 5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,20,21,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PH {0,1,-1,3,-1,-1,-1,-1,-1,-1,10,11,12,13,14,-1,16,17,18,19,20,21,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PI }; + guenter ende */ + +// guenter anfang ... welche pins werden freigegeben .. -1 = gesperrt +static int BP_PIN_MASK[9][32] = //[BANK] [INDEX] +{ + {-1,-1,-1,-1,-1,-1,-1, 7, 8, 9,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,20,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PA + {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PB + {-1,-1,-1,-1, 4,-1,-1, 7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PC + {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,14,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PD + {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PE + {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PF + {-1,-1,-1,-1,-1,-1, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PG + {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PH + {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PI +}; +// guenter ende + + static int version=0; static int pwmmode=0; @@ -950,7 +1032,7 @@ int sunxi_get_gpio_mode(int pin) regval = readl(phyaddr); if (wiringPiDebug) printf("read reg val: 0x%x offset:%d return: %d\n",regval,offset,reval); - //reval=regval &(reval+(7 << offset)); + // reval=regval &(reval+(7 << offset)); reval=(regval>>offset)&7; if (wiringPiDebug) printf("read reg val: 0x%x offset:%d return: %d\n",regval,offset,reval); @@ -1213,7 +1295,7 @@ int isA20(void) if (wiringPiDebug) printf ("piboardRev: Hardware string: %s\n", line) ; - if (strstr(line,"sun7i") != NULL) + if (strstr(line,"sun7i") != NULL) { if (wiringPiDebug) printf ("Hardware:%s\n",line) ; @@ -1228,6 +1310,50 @@ int isA20(void) } /*end 2014.09.18*/ + + +/*add for H3 guenter*/ +int isH3(void) +{ + FILE *cpuFd ; + char line [120] ; + char *d; + if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL) + piBoardRevOops ("Unable to open /proc/cpuinfo") ; + while (fgets (line, 120, cpuFd) != NULL) + { + if (strncmp (line, "Hardware", 8) == 0) + break ; + } + + fclose (cpuFd) ; + if (strncmp (line, "Hardware", 8) != 0) + piBoardRevOops ("No \"Hardware\" line") ; + + for (d = &line [strlen (line) - 1] ; (*d == '\n') || (*d == '\r') ; --d) + *d = 0 ; + if (wiringPiDebug) + printf ("piboardRev: Hardware string: %s\n", line) ; + + if (strstr(line,"sun8i") != NULL) //guenter von sun7i auf sun8i + { + if (wiringPiDebug) + printf ("Hardware:%s\n",line) ; + return 1 ; + } + else + { + if (wiringPiDebug) + printf ("Hardware:%s\n",line) ; + return 0 ; + } +} +/* guenter ende */ + + + + + int piBoardRev (void) { FILE *cpuFd ; @@ -1235,8 +1361,8 @@ int piBoardRev (void) char *c ; static int boardRev = -1 ; -/*add for BananaPro by LeMaker team*/ - if(isA20()) +/*add for orange pi guenter */ + if(isH3()) //guenter if(isA20()) { version = BPRVER; if (wiringPiDebug) diff --git a/wiringPi/wiringPiI2C.c b/wiringPi/wiringPiI2C.c index 1970e57..2ad94a3 100644 --- a/wiringPi/wiringPiI2C.c +++ b/wiringPi/wiringPiI2C.c @@ -228,7 +228,7 @@ int wiringPiI2CSetup (const int devId) else if (rev == 2) device = "/dev/i2c-1" ; else if (rev == 3) - device = "/dev/i2c-2"; + device = "/dev/i2c-0"; // guenter fuer orange pi device = "/dev/i2c-2"; else device = "/dev/i2c-3" ; From 7bf91dccbb49c2635538321e7d33edc7f098e9da Mon Sep 17 00:00:00 2001 From: zhaolei Date: Fri, 23 Oct 2015 16:58:42 +0800 Subject: [PATCH 02/24] edit readme --- README.md | 19 ++++--------------- build | 0 2 files changed, 4 insertions(+), 15 deletions(-) mode change 100644 => 100755 build diff --git a/README.md b/README.md index 037e0b6..edf926b 100755 --- a/README.md +++ b/README.md @@ -1,29 +1,18 @@ # wiringBP README -This is a modified WiringPi for Banana Pro/Pi. We call it WiringBP. -It is based on the original [WiringPi for Raspberry Pi created by Drogon](http://wiringpi.com/). -The modification is done by [LeMaker](http://lemaker.org). The WiringBP API usage are the same to the original wiringPi. -You can donwload the WiringBP from: -https://github.com/LeMaker/WiringBP.git. +This is a modified WiringPi for OrangePi. We call it WiringOP. ## Download -### For Banana Pro - git clone https://github.com/LeMaker/WiringBP.git -b bananapro -### For Banana Pi - git clone https://github.com/LeMaker/WiringBP.git -b bananapi +### For Orangepi Pi + git clone https://github.com/zhaolei/WiringOP.git -b h3 ## Installation - cd WiringBP + cd WiringOP chmod +x ./build sudo ./build -## Examples -You can go to LeMaker wiki to see the basic examples: http://wiki.lemaker.org/WiringPi - -You can also use the examples and instructions provided by http://wiringpi.com/ And the source directory examples also has many demo. Thanks! -LeMaker Team diff --git a/build b/build old mode 100644 new mode 100755 From 6ff982141d4cf362b7b0af30ef17de1bb7ae9943 Mon Sep 17 00:00:00 2001 From: zhaolei Date: Thu, 29 Oct 2015 13:50:44 +0800 Subject: [PATCH 03/24] fix io6 => PA6 --- gpio/readall.c | 4 ++-- wiringPi/wiringPi.c | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/gpio/readall.c b/gpio/readall.c index f3b2b95..d454a58 100644 --- a/gpio/readall.c +++ b/gpio/readall.c @@ -121,7 +121,7 @@ static int physToWpi [64] = -1, -1, //1, 2 -1, -1, //3, 4 -1, -1, //5, 6 - -1, -1, //7, 8 + 6, -1, //7, 8 -1, -1, //9, 10 -1, 1, //11, 12 -1, -1, //13, 14 @@ -186,7 +186,7 @@ static char *physNames [64] = " 3.3v", "5v ", " SDA.0", "5V ", " SCL.0", "0v ", - " ?? ", "TxD3 ", + "IO6 PA06", "TxD3 ", " 0v", "RxD3 ", " RxD2", "IO1 PD14", " TxD2", "0v ", diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index 6dc0337..8dab266 100755 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -654,7 +654,7 @@ static int pinToGpio_BP [64] = -1,110, -1,-1, 68,71, - -1,7, + 6,7, 8,200, 9,-1, 10,201, @@ -732,7 +732,7 @@ static int physToGpio_BP [64] = -1, -1, //1, 2 -1, -1, //3, 4 -1, -1, //5, 6 - -1, -1, //7, 8 + 6, -1, //7, 8 -1, -1, //9, 10 -1, 110, //11, 12 -1, -1, //13, 14 @@ -872,7 +872,7 @@ static int BP_PIN_MASK[9][32] = //[BANK] [INDEX] // guenter anfang ... welche pins werden freigegeben .. -1 = gesperrt static int BP_PIN_MASK[9][32] = //[BANK] [INDEX] { - {-1,-1,-1,-1,-1,-1,-1, 7, 8, 9,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,20,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PA + {-1,-1,-1,-1,-1,-1, 6, 7, 8, 9,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,20,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PA {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PB {-1,-1,-1,-1, 4,-1,-1, 7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PC {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,14,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PD @@ -1594,17 +1594,19 @@ int getAlt (int pin) /*add for BananaPro by LeMaker team*/ if(BPRVER == version) { + + //printf("[%s:L%d] the pin:%d mode: %d is invaild,please check it over!\n", __func__, __LINE__, pin, wiringPiMode); if (wiringPiMode == WPI_MODE_PINS) pin = pinToGpio_BP [pin] ; else if (wiringPiMode == WPI_MODE_PHYS) pin = physToGpio_BP[pin] ; - else if (wiringPiMode == WPI_MODE_GPIO) + else if (wiringPiMode == WPI_MODE_GPIO) pin=pinTobcm_BP[pin];//need map A20 to bcm else return 0 ; if(-1 == pin) { - printf("[%s:L%d] the pin:%d is invaild,please check it over!\n", __func__, __LINE__, pin); + printf("[%s:L%d] the pin:%d mode: %d is invaild,please check it over!\n", __func__, __LINE__, pin, wiringPiMode); return -1; } alt=sunxi_get_gpio_mode(pin); @@ -2872,7 +2874,7 @@ int wiringPiSetup (void) boardRev = piBoardRev () ; - if (BPRVER == boardRev) /*modify for BananaPro by LeMaker team*/ + if (BPRVER == boardRev) /*modify for BananaPro by LeMaker team zhaolei*/ { pinToGpio = pinToGpioR3 ; physToGpio = physToGpioR3 ; From 7538fcb4b82c65f19e09a38ca8aef38db501ce7d Mon Sep 17 00:00:00 2001 From: zhaolei Date: Fri, 30 Oct 2015 11:12:41 +0800 Subject: [PATCH 04/24] readme --- README.md | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index edf926b..e07eefa 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # wiringBP README This is a modified WiringPi for OrangePi. We call it WiringOP. +Test fo Orangepi pc ## Download ### For Orangepi Pi @@ -9,10 +10,36 @@ This is a modified WiringPi for OrangePi. We call it WiringOP. cd WiringOP chmod +x ./build sudo ./build - - -And the source directory examples also has many demo. +``` +orangepi@orangepi:~$ gpio readall + +-----+-----+----------+------+---+--OrangePiPC--+---+------+---------+-----+--+ + | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM | + +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+ + | | | 3.3v | | | 1 || 2 | | | 5v | | | + | 2 | -1 | SDA.0 | | | 3 || 4 | | | 5V | | | + | 3 | -1 | SCL.0 | | | 5 || 6 | | | 0v | | | + | 4 | 6 | IO6 PA06 | OUT | 0 | 7 || 8 | | | TxD3 | | | + | | | 0v | | | 9 || 10 | | | RxD3 | | | + | 17 | -1 | RxD2 | | | 11 || 12 | 0 | OUT | IO1 PD14 | 1 | 18 | + | 27 | -1 | TxD2 | | | 13 || 14 | | | 0v | | | + | 22 | -1 | CTS2 | | | 15 || 16 | 0 | OUT | IO4 PC04 | 4 | 23 | + | | | 3.3v | | | 17 || 18 | 0 | OUT | IO5 PC07 | 5 | 24 | + | 10 | -1 | MOSI | | | 19 || 20 | | | 0v | | | + | 9 | -1 | MISO | | | 21 || 22 | | | RTS2 | | | + | 11 | -1 | SCLK | | | 23 || 24 | | | SPI-CE0 | | | + | | | 0v | | | 25 || 26 | | | CE1 | | | + | 0 | -1 | SDA.1 | | | 27 || 28 | | | SCL.1 | | | + | 5 | 7 | IO7 PA7 | OUT | 0 | 29 || 30 | | | 0v | | | + | 6 | 8 | IO8 PA8 | OUT | 0 | 31 || 32 | 0 | OUT | IO9 PG08 | 9 | 12 | + | 13 | 10 | IO10 PA9 | OUT | 0 | 33 || 34 | | | 0v | | | + | 19 | 12 | IO12PA10 | OUT | 0 | 35 || 36 | 0 | OUT | IO13PG09 | 13 | 16 | + | 26 | 14 | IO14PA20 | OUT | 0 | 37 || 38 | 0 | OUT | IO15PG06 | 15 | 20 | + | | | 0v | | | 39 || 40 | 0 | OUT | IO16PG07 | 16 | 21 | + +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+ + | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM | + +-----+-----+----------+------+---+--OrangePIPC--+------+----------+-----+-----+ +``` Thanks! From 1e442918251c13606b8da250ceed07e4a09d9a90 Mon Sep 17 00:00:00 2001 From: WereCatf Date: Wed, 17 Feb 2016 01:15:21 +0000 Subject: [PATCH 05/24] Fix interrupts --- wiringPi/wiringPi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index 8dab266..833f2df 100755 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -1522,7 +1522,7 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *overVolted) int wpiPinToGpio (int wpiPin) { - return pinToGpio [wpiPin & 63] ; + return pinToGpio_BP [wpiPin & 63] ; } @@ -1535,7 +1535,7 @@ int wpiPinToGpio (int wpiPin) int physPinToGpio (int physPin) { - return physToGpio [physPin & 63] ; + return physToGpio_BP [physPin & 63] ; } /* @@ -1858,7 +1858,7 @@ struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins) void pinEnableED01Pi (int pin) { - pin = pinToGpio [pin & 63] ; + pin = pinToGpio_BP [pin & 63] ; } #endif @@ -2559,9 +2559,9 @@ int waitForInterrupt (int pin, int mS) struct pollfd polls ; /**/ if (wiringPiMode == WPI_MODE_PINS) - pin = pinToGpio [pin] ; + pin = pinToGpio_BP [pin] ; else if (wiringPiMode == WPI_MODE_PHYS) - pin = physToGpio [pin] ; + pin = physToGpio_BP [pin] ; if ((fd = sysFds [pin]) == -1) return -2 ; @@ -2634,9 +2634,9 @@ int wiringPiISR (int pin, int mode, void (*function)(void)) /**/ if (wiringPiMode == WPI_MODE_UNINITIALISED) return wiringPiFailure (WPI_FATAL, "wiringPiISR: wiringPi has not been initialised. Unable to continue.\n") ; else if (wiringPiMode == WPI_MODE_PINS) - bcmGpioPin = pinToGpio [pin] ; + bcmGpioPin = pinToGpio_BP [pin] ; else if (wiringPiMode == WPI_MODE_PHYS) - bcmGpioPin = physToGpio [pin] ; + bcmGpioPin = physToGpio_BP [pin] ; else bcmGpioPin = pin ; From 143630f981ad7896dc86c67c0f637804e7489b01 Mon Sep 17 00:00:00 2001 From: WereCatf Date: Wed, 17 Feb 2016 03:39:33 +0000 Subject: [PATCH 06/24] Fix edge-setup --- gpio/gpio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gpio/gpio.c b/gpio/gpio.c index 9a4a604..3809430 100644 --- a/gpio/gpio.c +++ b/gpio/gpio.c @@ -596,6 +596,7 @@ void doEdge (int argc, char *argv []) exit (1) ; } + fprintf (fd, "none\n") ; fprintf (fd, "in\n") ; fclose (fd) ; From edf9ba1b52963d9b49649983b142365cc152f73d Mon Sep 17 00:00:00 2001 From: WereCatf Date: Wed, 17 Feb 2016 11:03:40 +0000 Subject: [PATCH 07/24] Fix pull-up/pull-down --- wiringPi/wiringPi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index 833f2df..441f415 100755 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -619,7 +619,7 @@ static uint8_t gpioToClkDiv [] = static int *physToPin ; -static int upDnConvert[3] = {7, 7, 5}; +static int upDnConvert[3] = {0, 2, 1}; /* guenter static int pinToGpio_BP [64] = { @@ -2052,8 +2052,6 @@ void pullUpDnControl (int pin, int pud) /*add for BananaPro by LeMaker team*/ if(BPRVER == version) { - pud = upDnConvert[pud]; - if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin { if (wiringPiMode == WPI_MODE_PINS) @@ -2072,7 +2070,7 @@ if(BPRVER == version) return; } - pud &= 3 ; + pud = upDnConvert[pud]; // convert wiringpi pud to sunxi pud value sunxi_pullUpDnControl(pin, pud); return; } From cb0dbc969e1b6943fe0a9a34379474619b9a9770 Mon Sep 17 00:00:00 2001 From: WereCatf Date: Thu, 18 Feb 2016 13:12:23 +0000 Subject: [PATCH 08/24] digitalRead() didn't work in ALT2 - mode, implement clunky workaround --- gpio/readall.c | 4 +- wiringPi/wiringPi.c | 102 ++++++++++++++++++++++++++++---------------- 2 files changed, 68 insertions(+), 38 deletions(-) diff --git a/gpio/readall.c b/gpio/readall.c index d454a58..8a5367b 100644 --- a/gpio/readall.c +++ b/gpio/readall.c @@ -385,14 +385,14 @@ void OrangePiReadAll(void) { int pin ; - printf (" +-----+-----+----------+------+---+--OrangePiPC--+---+------+---------+-----+--+\n") ; + printf (" +-----+-----+----------+------+---+-Orange Pi+---+---+------+---------+-----+--+\n") ; printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n") ; printf (" +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+\n") ; for (pin = 1 ; pin <= 40 ; pin += 2) readallPhys (pin) ; printf (" +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+\n") ; printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n") ; - printf (" +-----+-----+----------+------+---+--OrangePIPC--+------+----------+-----+-----+\n") ; + printf (" +-----+-----+----------+------+---+-Orange Pi+---+------+----------+-----+-----+\n") ; } //guenter ende diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index 441f415..b7509d4 100755 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -297,7 +297,7 @@ int wiringPiReturnCodes = FALSE ; // sysFds: // Map a file descriptor from the /sys/class/gpio/gpioX/value -static int sysFds [64] = +static int sysFds [300] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -1044,6 +1044,7 @@ int sunxi_get_gpio_mode(int pin) return reval; } } + void sunxi_set_gpio_mode(int pin,int mode) { uint32_t regval = 0; @@ -1109,6 +1110,7 @@ void sunxi_set_gpio_mode(int pin,int mode) return ; } + void sunxi_digitalWrite(int pin, int value) { uint32_t regval = 0; @@ -1143,32 +1145,34 @@ void sunxi_digitalWrite(int pin, int value) { printf("pin number error\n"); } - + return ; } + int sunxi_digitalRead(int pin) -{ - uint32_t regval = 0; - int bank = pin >> 5; - int index = pin - (bank << 5); - uint32_t phyaddr = SUNXI_GPIO_BASE + (bank * 36) + 0x10; // +0x10 -> data reg - if (wiringPiDebug) - printf("func:%s pin:%d,bank:%d index:%d phyaddr:0x%x\n",__func__, pin,bank,index,phyaddr); - if(BP_PIN_MASK[bank][index] != -1) - { - regval = readl(phyaddr); - regval = regval >> index; - regval &= 1; +{ + uint32_t regval = 0; + int bank = pin >> 5; + int index = pin - (bank << 5); + uint32_t phyaddr = SUNXI_GPIO_BASE + (bank * 36) + 0x10; // +0x10 -> data reg + if (wiringPiDebug) + printf("func:%s pin:%d,bank:%d index:%d phyaddr:0x%x\n",__func__, pin,bank,index,phyaddr); + if(BP_PIN_MASK[bank][index] != -1) + { + regval = readl(phyaddr); + regval = regval >> index; + regval &= 1; if (wiringPiDebug) printf("***** read reg val: 0x%x,bank:%d,index:%d,line:%d\n",regval,bank,index,__LINE__); - return regval; - } - else - { - printf("pin number error\n"); - return regval; - } + return regval; + } + else + { + printf("Sunxi_digitalRead() pin - number error\n"); + return regval; + } } + void sunxi_pullUpDnControl (int pin, int pud) { uint32_t regval = 0; @@ -2117,15 +2121,15 @@ int digitalRead (int pin) { char c ; struct wiringPiNodeStruct *node = wiringPiNodes ; - + /*add for BananaPro by LeMaker team*/ if(BPRVER == version) { if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin { + int _pinMode = getAlt(pin); if (wiringPiMode == WPI_MODE_GPIO_SYS) // Sys mode { - if(pin==0) { //printf("%d %s,%d invalid pin,please check it over.\n",pin,__func__, __LINE__); @@ -2136,17 +2140,17 @@ int digitalRead (int pin) //printf("%d %s,%d invalid pin,please check it over.\n",pin,__func__, __LINE__); return 0; } - if (sysFds [pin] == -1) + if (sysFds [pin] == -1) { if (wiringPiDebug) printf ("pin %d sysFds -1.%s,%d\n", pin ,__func__, __LINE__) ; - return LOW ; + return LOW; } - if (wiringPiDebug) - printf ("pin %d :%d.%s,%d\n", pin ,sysFds [pin],__func__, __LINE__) ; - lseek (sysFds [pin], 0L, SEEK_SET) ; - read (sysFds [pin], &c, 1) ; - return (c == '0') ? LOW : HIGH ; + if (wiringPiDebug) + printf ("pin %d :%d.%s,%d\n", pin ,sysFds [pin],__func__, __LINE__) ; + lseek (sysFds [pin], 0L, SEEK_SET) ; + read (sysFds [pin], &c, 1) ; + return (c == '0') ? LOW : HIGH ; } else if (wiringPiMode == WPI_MODE_PINS) pin = pinToGpio_BP [pin] ; @@ -2154,12 +2158,37 @@ int digitalRead (int pin) pin = physToGpio_BP[pin] ; else if (wiringPiMode == WPI_MODE_GPIO) pin=pinTobcm_BP[pin];//need map A20 to bcm - else + else return LOW ; - if(-1 == pin){ - printf("[%s:L%d] the pin:%d is invaild,please check it over!\n", __func__, __LINE__, pin); + if(-1 == pin){ + printf("[%s:L%d] the pin:%d is invalid, please check it over!\n", __func__, __LINE__, pin); return LOW; } + if(_pinMode == 6){ + // -- Allwinner H3 -- + //ALT2, ie. EINT is enabled! + //Gotta export the pin if it's not exported already, then read its value that way + char fName[64]; + struct stat s; + sprintf(fName, "/sys/class/gpio/gpio%d", pin); + if(stat(fName, &s) == -1) { + int tempFd = open("/sys/class/gpio/export", O_WRONLY); + if(tempFd < 0) return LOW; + sprintf(fName, "%d\n", pin); + write(tempFd, fName, strlen(fName)); + close(tempFd); + } + sprintf(fName, "/sys/class/gpio/gpio%d/value", pin); + if(sysFds[pin] == -1){ + if ((sysFds[pin] = open (fName, O_RDWR)) < 0){ + printf("digitalRead(): Failed to open %s, pin not exported?\n", fName); + return LOW; + } + } + lseek(sysFds[pin], 0L, SEEK_SET); + read(sysFds[pin], &c, 1); + return (c == '0') ? LOW : HIGH; + } return sunxi_digitalRead(pin); } else @@ -2170,7 +2199,7 @@ int digitalRead (int pin) } } /*end 2014.08.19*/ - + if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin { /**/ if (wiringPiMode == WPI_MODE_GPIO_SYS) // Sys mode @@ -2644,12 +2673,12 @@ int wiringPiISR (int pin, int mode, void (*function)(void)) { if(-1 == bcmGpioPin) /**/ { - printf("[%s:L%d] the pin:%d is invaild,please check it over!\n", __func__, __LINE__, pin); + printf("[%s:L%d] the pin:%d is invalid, please check it over!\n", __func__, __LINE__, pin); return -1; } if(edge[bcmGpioPin]==-1) - return wiringPiFailure (WPI_FATAL, "wiringPiISR: pin not sunpprt on bananaPi (%d,%d)\n", pin,bcmGpioPin) ; + return wiringPiFailure (WPI_FATAL, "wiringPiISR: pin not supported on Banana Pi (%d,%d)\n", pin,bcmGpioPin) ; } /*end 2014.08.19*/ @@ -2857,6 +2886,7 @@ int wiringPiSetup (void) int fd ; int boardRev ; int model, rev, mem, maker, overVolted ; + memset(&sysFds, -1, sizeof(int)*300); // Initialize the filedescriptor - table all to -1 if (getenv (ENV_DEBUG) != NULL) wiringPiDebug = TRUE ; From 4322c06195e4a4008d6e1083d059c16095f57c7f Mon Sep 17 00:00:00 2001 From: WereCatf Date: Mon, 14 Mar 2016 09:29:26 +0200 Subject: [PATCH 09/24] Dirty fix for interrupts Reset edge to "none" before setting a value on it. --- wiringPi/wiringPi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index b7509d4..5aa015f 100755 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -2706,11 +2706,13 @@ int wiringPiISR (int pin, int mode, void (*function)(void)) { /**/ if (access ("/usr/local/bin/gpio", X_OK) == 0) { + execl ("/usr/local/bin/gpio", "gpio", "edge", pinS, "none", (char *)NULL) ; execl ("/usr/local/bin/gpio", "gpio", "edge", pinS, modeS, (char *)NULL) ; return wiringPiFailure (WPI_FATAL, "wiringPiISR: execl failed: %s\n", strerror (errno)) ; } else if (access ("/usr/bin/gpio", X_OK) == 0) { + execl ("/usr/bin/gpio", "gpio", "edge", pinS, "none", (char *)NULL) ; execl ("/usr/bin/gpio", "gpio", "edge", pinS, modeS, (char *)NULL) ; return wiringPiFailure (WPI_FATAL, "wiringPiISR: execl failed: %s\n", strerror (errno)) ; } From a7ed5806ff2f591f1b7a182f6ded40b26cbc62ee Mon Sep 17 00:00:00 2001 From: WereCatf Date: Mon, 14 Mar 2016 11:46:57 +0200 Subject: [PATCH 10/24] Revert "Dirty fix for interrupts" This reverts commit 4322c06195e4a4008d6e1083d059c16095f57c7f. --- wiringPi/wiringPi.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index 5aa015f..b7509d4 100755 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -2706,13 +2706,11 @@ int wiringPiISR (int pin, int mode, void (*function)(void)) { /**/ if (access ("/usr/local/bin/gpio", X_OK) == 0) { - execl ("/usr/local/bin/gpio", "gpio", "edge", pinS, "none", (char *)NULL) ; execl ("/usr/local/bin/gpio", "gpio", "edge", pinS, modeS, (char *)NULL) ; return wiringPiFailure (WPI_FATAL, "wiringPiISR: execl failed: %s\n", strerror (errno)) ; } else if (access ("/usr/bin/gpio", X_OK) == 0) { - execl ("/usr/bin/gpio", "gpio", "edge", pinS, "none", (char *)NULL) ; execl ("/usr/bin/gpio", "gpio", "edge", pinS, modeS, (char *)NULL) ; return wiringPiFailure (WPI_FATAL, "wiringPiISR: execl failed: %s\n", strerror (errno)) ; } From 05efa71786e8eabba1e1edb7432ef198a8f3a239 Mon Sep 17 00:00:00 2001 From: nopnop2002 Date: Tue, 15 Mar 2016 08:13:21 +0900 Subject: [PATCH 11/24] wiringPiSetupGpio don't work. I changed pinTobcm_BP table. --- wiringPi/wiringPi.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index 8dab266..9053fe4 100755 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -677,6 +677,7 @@ static int pinToGpio_BP [64] = // guenter ... dieses braucht nicht umgewandelt werden, da kein /sys/class/gpio auf orange pi static int pinTobcm_BP [64] = { +#if 0 257,256, //map to BCM GPIO0,1 53,52, //map to BCM GPIO2,3 226,35, //map to BCM GPIO4,5 @@ -691,6 +692,22 @@ static int pinTobcm_BP [64] = 273,244, //map to BCM GPIO22,23 245,272, //map to BCM GPIO24,25 37, 274, //map to BCM GPIO26,27 +#endif + + -1, -1, + -1, -1, + 6, 7, //map to BCM GPIO4,5 + 8, -1, //map to BCM GPIO6,7 + -1, -1, + -1, -1, +200, 9, //map to BCM GPIO12,13 + -1, -1, //map to BCM GPIO14,15 +201, -1, //map to BCM GPIO16,17 +110, 10, //map to BCM GPIO18,19 +198,199, //map to BCM GPIO20,21 + -1, 68, //map to BCM GPIO22,23 + 71, -1, //map to BCM GPIO24,25 + 20, -1, //map to BCM GPIO26,27 -1,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 29... 44 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //45... 60 From f08252861eeb4e415df47297da8055799f16cecb Mon Sep 17 00:00:00 2001 From: WereCatf Date: Wed, 16 Mar 2016 12:03:30 +0200 Subject: [PATCH 12/24] Possible fix for a bug people have been reporting --- gpio/gpio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gpio/gpio.c b/gpio/gpio.c index 3809430..038abee 100644 --- a/gpio/gpio.c +++ b/gpio/gpio.c @@ -607,6 +607,10 @@ void doEdge (int argc, char *argv []) exit (1) ; } + // Always reset mode to "none" before setting a new mode + fprintf (fd, "none\n") ; + fclose (fd) ; + fd = fopen (fName, "w") ; /**/ if (strcasecmp (mode, "none") == 0) fprintf (fd, "none\n") ; else if (strcasecmp (mode, "rising") == 0) fprintf (fd, "rising\n") ; else if (strcasecmp (mode, "falling") == 0) fprintf (fd, "falling\n") ; From 6a7ec1f7cc0f985e45d12c82839734bc83fdb8e4 Mon Sep 17 00:00:00 2001 From: WereCatf Date: Wed, 16 Mar 2016 12:14:25 +0200 Subject: [PATCH 13/24] Another small change to gpio --- gpio/gpio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gpio/gpio.c b/gpio/gpio.c index 038abee..6429e29 100644 --- a/gpio/gpio.c +++ b/gpio/gpio.c @@ -597,6 +597,8 @@ void doEdge (int argc, char *argv []) } fprintf (fd, "none\n") ; + fclose (fd) ; + fd = fopen (fName, "w") ; fprintf (fd, "in\n") ; fclose (fd) ; From 336b91600d45202aebe780fa9e1e3e3956416a50 Mon Sep 17 00:00:00 2001 From: WereCatf Date: Wed, 16 Mar 2016 19:18:29 +0200 Subject: [PATCH 14/24] More bugfixes --- wiringPi/wiringPi.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index b7509d4..f7a9d8d 100755 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -2676,9 +2676,13 @@ int wiringPiISR (int pin, int mode, void (*function)(void)) printf("[%s:L%d] the pin:%d is invalid, please check it over!\n", __func__, __LINE__, pin); return -1; } - - if(edge[bcmGpioPin]==-1) - return wiringPiFailure (WPI_FATAL, "wiringPiISR: pin not supported on Banana Pi (%d,%d)\n", pin,bcmGpioPin) ; + if(isH3()){ + // All PA- and PG-pins support interrupts, the others don't + if(bcmGpioPin > 31 && bcmGpioPin < 192) + return wiringPiFailure (WPI_FATAL, "wiringPiISR: the specified pin does not support interrupts on this board (Allwinner H3) (%d,%d)\n", pin,bcmGpioPin) ; + } + else if(edge[bcmGpioPin]==-1) + return wiringPiFailure (WPI_FATAL, "wiringPiISR: pin not supported on Banana Pi (%d,%d)\n", pin,bcmGpioPin) ; } /*end 2014.08.19*/ From 1d7377a3d91e31cd0c1184c83c3676521adf169e Mon Sep 17 00:00:00 2001 From: nopnop2002 Date: Sat, 26 Mar 2016 11:05:17 +0900 Subject: [PATCH 15/24] Change pin assign to Full compatible to WiringPi. The pin allocation was changed to a perfect compatible with WiringPi. --- gpio/readall.c | 42 ++++++++++---------- wiringPi/wiringPi.c | 96 ++++++++++++++++++++++----------------------- 2 files changed, 69 insertions(+), 69 deletions(-) diff --git a/gpio/readall.c b/gpio/readall.c index d454a58..09b5ff1 100644 --- a/gpio/readall.c +++ b/gpio/readall.c @@ -117,27 +117,27 @@ guenter ende */ // guenter anfang static int physToWpi [64] = { - -1, // 0 - -1, -1, //1, 2 - -1, -1, //3, 4 - -1, -1, //5, 6 - 6, -1, //7, 8 - -1, -1, //9, 10 - -1, 1, //11, 12 - -1, -1, //13, 14 - -1, 4, //15, 16 - -1, 5, //17, 18 - -1, -1, //19, 20 - -1, -1, //21, 22 - -1, -1, //23, 24 - -1, -1, //25, 26 - -1, -1, //27, 28 - 7, -1, //29, 30 - 8, 9, //31, 32 - 10, -1, //33, 34 - 12, 13, //35, 36 - 14, 15, //37, 38 - -1, 16, //39, 40 + -1, // 0 + -1, -1, // 1, 2 + 8, -1, // 3, 4 + 9, -1, // 5, 6 + 7, 15, // 7, 8 + -1, 16, // 9, 10 + 0, 1, //11, 12 + 2, -1, //13, 14 + 3, 4, //15, 16 + -1, 5, //17, 18 + 12, -1, //19, 20 + 13, 6, //21, 22 + 14, 10, //23, 24 + -1, 11, //25, 26 + 30, 31, //27, 28 + 21, -1, //29, 30 + 22, 26, //31, 32 + 23, -1, //33, 34 + 24, 27, //35, 36 + 25, 28, //37, 38 + -1, 29, //39, 40 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //41-> 55 -1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63 } ; diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index 9053fe4..7fb9702 100755 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -651,22 +651,22 @@ static int upDnConvert[3] = {7, 7, 5}; // 64 - 95 = PC00-PC31 static int pinToGpio_BP [64] = { - -1,110, - -1,-1, - 68,71, - 6,7, - 8,200, - 9,-1, - 10,201, - 20,198, - 199, -1, - -1, -1, - -1, -1, - -1, -1, - -1, -1, - -1, -1, - -1,-1, - -1,-1, // ...31 + 1,110, // 0, 1 + 0, 3, // 2, 3 + 68, 71, // 4 5 + 2, 6, // 6, 7 + 12, 11, // 8, 9 + 67, 21, //10,11 + 64, 65, //12,13 + 66, 13, //14,15 + 14, -1, //16,17 + -1, -1, //18,19 + -1, 7, //20,21 + 8, 9, //22,23 + 10, 20, //24,25 + 200,201, //26,27 + 198,199, //28,29 + 19, 18, //30,31 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,// ... 63 @@ -694,20 +694,20 @@ static int pinTobcm_BP [64] = 37, 274, //map to BCM GPIO26,27 #endif - -1, -1, - -1, -1, + 19, 18, //map to BCM GPIO0,1 + 12, 11, //map to BCM GPIO2,3 6, 7, //map to BCM GPIO4,5 - 8, -1, //map to BCM GPIO6,7 - -1, -1, - -1, -1, + 8, 21, //map to BCM GPIO6,7 + 67, 65, //map to BCM GPIO8,9 + 64, 66, //map to BCM GPIO10,11 200, 9, //map to BCM GPIO12,13 - -1, -1, //map to BCM GPIO14,15 -201, -1, //map to BCM GPIO16,17 + 13, 14, //map to BCM GPIO14,15 +201, 1, //map to BCM GPIO16,17 110, 10, //map to BCM GPIO18,19 198,199, //map to BCM GPIO20,21 - -1, 68, //map to BCM GPIO22,23 - 71, -1, //map to BCM GPIO24,25 - 20, -1, //map to BCM GPIO26,27 + 3, 68, //map to BCM GPIO22,23 + 71, 2, //map to BCM GPIO24,25 + 20, 0, //map to BCM GPIO26,27 -1,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 29... 44 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //45... 60 @@ -746,26 +746,26 @@ guenter ende */ static int physToGpio_BP [64] = { -1, // 0 - -1, -1, //1, 2 - -1, -1, //3, 4 - -1, -1, //5, 6 - 6, -1, //7, 8 - -1, -1, //9, 10 - -1, 110, //11, 12 - -1, -1, //13, 14 - -1, 68, //15, 16 - -1, 71, //17, 18 - -1, -1, //19, 20 - -1, -1, //21, 22 - -1, -1, //23, 24 - -1, -1, //25, 26 - -1, -1, //27, 28 - 7, -1, //29, 30 - 8, 200, //31, 32 - 9, -1, //33, 34 - 10, 201, //35, 36 - 20, 198, //37, 38 - -1, 199, //39, 40 + -1, -1, // 1, 2 + 12, -1, // 3, 4 + 11, -1, // 5, 6 + 6, 13, // 7, 8 + -1, 14, // 9, 10 + 1, 110, //11, 12 + 0, -1, //13, 14 + 3, 68, //15, 16 + -1, 71, //17, 18 + 64, -1, //19, 20 + 65, 2, //21, 22 + 66, 67, //23, 24 + -1, 21, //25, 26 + 19, 18, //27, 28 + 7, -1, //29, 30 + 8, 200, //31, 32 + 9, -1, //33, 34 + 10, 201, //35, 36 + 20, 198, //37, 38 + -1, 199, //39, 40 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //41-> 55 -1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63 } ; @@ -889,9 +889,9 @@ static int BP_PIN_MASK[9][32] = //[BANK] [INDEX] // guenter anfang ... welche pins werden freigegeben .. -1 = gesperrt static int BP_PIN_MASK[9][32] = //[BANK] [INDEX] { - {-1,-1,-1,-1,-1,-1, 6, 7, 8, 9,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,20,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PA + { 0, 1, 2, 3,-1,-1, 6, 7, 8, 9,10,11,12,13,14,-1,-1,-1,18,19,20,21,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PA {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PB - {-1,-1,-1,-1, 4,-1,-1, 7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PC + { 0, 1, 2, 3, 4,-1,-1, 7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PC {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,14,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PD {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PE {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PF From db30d625be702e408a039a6e92e4b49272ca5640 Mon Sep 17 00:00:00 2001 From: nopnop2002 Date: Sat, 2 Apr 2016 05:54:15 +0900 Subject: [PATCH 16/24] gpio i2cd don't work. gpio i2cd don't work. --- gpio/gpio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gpio/gpio.c b/gpio/gpio.c index 9a4a604..55b7630 100644 --- a/gpio/gpio.c +++ b/gpio/gpio.c @@ -315,6 +315,7 @@ static void doI2Cdetect (int argc, char *argv []) return ; } +#if 0 if (!moduleLoaded ("i2c-sunxi")) { fprintf (stderr, "%s: The I2C kernel module(s) are not loaded.\n", argv [0]) ; @@ -322,6 +323,8 @@ static void doI2Cdetect (int argc, char *argv []) } sprintf (command, "%s -y %d", I2CDETECT, 2) ; +#endif + sprintf (command, "%s -y %d", I2CDETECT, 0) ; if (system (command) < 0) fprintf (stderr, "%s: Unable to run i2cdetect: %s\n", argv [0], strerror (errno)) ; } From 64a13186d5e761ba3582f272e9216fba0614e2e3 Mon Sep 17 00:00:00 2001 From: nopnop2002 Date: Tue, 5 Apr 2016 20:26:56 +0900 Subject: [PATCH 17/24] Pin#26 don't have SPI Function Pin#26 don't have SPI Function --- gpio/readall.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/gpio/readall.c b/gpio/readall.c index 09b5ff1..ea159d0 100644 --- a/gpio/readall.c +++ b/gpio/readall.c @@ -186,23 +186,23 @@ static char *physNames [64] = " 3.3v", "5v ", " SDA.0", "5V ", " SCL.0", "0v ", - "IO6 PA06", "TxD3 ", + " GPIO.7", "TxD3 ", " 0v", "RxD3 ", - " RxD2", "IO1 PD14", + " RxD2", "GPIO.1 ", " TxD2", "0v ", - " CTS2", "IO4 PC04", - " 3.3v", "IO5 PC07", + " CTS2", "GPIO.4 ", + " 3.3v", "GPIO.5 ", " MOSI", "0v ", " MISO", "RTS2 ", - " SCLK", "SPI-CE0 ", - " 0v", "CE1 ", + " SCLK", "CE0 ", + " 0v", "GPIO.11 ", " SDA.1", "SCL.1 ", - " IO7 PA7", "0v ", - " IO8 PA8", "IO9 PG08", - "IO10 PA9", "0v ", - "IO12PA10", "IO13PG09", - "IO14PA20", "IO15PG06", - " 0v", "IO16PG07", + " GPIO.21", "0v ", + " GPIO.22", "RTS1 ", + " GPIO.23", "0v ", + " GPIO.24", "CTS1 ", + " GPIO.25", "TxD1 ", + " 0v", "RxD1 ", NULL, NULL, NULL, NULL, NULL, NULL, From e9cd9008c93bea17eea2a565a06e0bddab122383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A5=D0=BB=D1=83?= =?UTF-8?q?=D1=82=D1=87=D0=B8=D0=BD?= Date: Sat, 24 Sep 2016 23:47:15 +0400 Subject: [PATCH 18/24] Files to make deb-package for Ubuntu vivid 15.04 --- Makefile | 6 ++ debian/changelog | 5 ++ debian/compat | 1 + debian/control | 34 ++++++++++ debian/copyright | 33 ++++++++++ debian/docs | 1 + debian/libwiringop-dev.dirs | 1 + debian/libwiringop-dev.install | 1 + debian/libwiringop2.dirs | 1 + debian/libwiringop2.install | 2 + debian/libwiringop2.symbols | 110 +++++++++++++++++++++++++++++++++ debian/rules | 34 ++++++++++ debian/source/format | 1 + wiringPi/Makefile | 14 ++--- 14 files changed, 237 insertions(+), 7 deletions(-) create mode 100644 Makefile create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/docs create mode 100644 debian/libwiringop-dev.dirs create mode 100644 debian/libwiringop-dev.install create mode 100644 debian/libwiringop2.dirs create mode 100644 debian/libwiringop2.install create mode 100644 debian/libwiringop2.symbols create mode 100755 debian/rules create mode 100644 debian/source/format diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4a9b11a --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +%: + $(MAKE) -C wiringPi $@ + +all: + $(MAKE) -C wiringPi $@ + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..9c4de4e --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +wiringop (2.0~ppa1~vivid1) vivid; urgency=high + + * Initial release + + -- Сергей Хлутчин Fri, 23 Sep 2016 18:10:04 +0400 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..6c419ee --- /dev/null +++ b/debian/control @@ -0,0 +1,34 @@ +Source: wiringop +Priority: optional +Maintainer: Сергей Хлутчин +Build-Depends: debhelper (>= 9) +Standards-Version: 3.9.5 +Section: libs +Homepage: https://github.com/zhaolei/WiringOP +Vcs-Git: https://github.com/zhaolei/WiringOP.git +Vcs-Browser: https://github.com/zhaolei/WiringOP + +Package: libwiringop-dev +Section: libdevel +Architecture: any +Depends: libwiringop2 (= ${binary:Version}), ${misc:Depends} +Description: GPIO access library for OrangePi. Development files. + This is a modified WiringPi for OrangePi. + It is based on the original WiringPi for Raspberry Pi. + WiringPi is a GPIO access library written in C originally for the BCM2835 used in the Raspberry Pi. + It’s released under the GNU LGPLv3 license and is usable from C and C++ + and many other languages with suitable wrappers. + It’s designed to be familiar to people who have used the Arduino “wiring” system. + +Package: libwiringop2 +Architecture: any +Multi-Arch: same +Pre-Depends: ${misc:Pre-Depends} +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: GPIO access library for OrangePi. Dynamic library. + This is a modified WiringPi for OrangePi. + It is based on the original WiringPi for Raspberry Pi. + WiringPi is a GPIO access library written in C originally for the BCM2835 used in the Raspberry Pi. + It’s released under the GNU LGPLv3 license and is usable from C and C++ + and many other languages with suitable wrappers. + It’s designed to be familiar to people who have used the Arduino “wiring” system. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..b293a07 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,33 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: wiringop +Source: + +Files: * +Copyright: Copyright (C) 2007 Free Software Foundation, Inc. +License: LGPL-3.0+ + +Files: debian/* +Copyright: 2016 Сергей Хлутчин +License: LGPL-3.0+ + +License: LGPL-3.0+ + This package 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. + . + This package 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 General Public License + along with this program. If not, see . + . + On Debian systems, the complete text of the GNU Lesser General + Public License can be found in "/usr/share/common-licenses/LGPL-3". + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. +# Please avoid to pick license terms that are more restrictive than the +# packaged work, as it may make Debian's contributions unacceptable upstream. diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..b43bf86 --- /dev/null +++ b/debian/docs @@ -0,0 +1 @@ +README.md diff --git a/debian/libwiringop-dev.dirs b/debian/libwiringop-dev.dirs new file mode 100644 index 0000000..e43b95c --- /dev/null +++ b/debian/libwiringop-dev.dirs @@ -0,0 +1 @@ +usr/include diff --git a/debian/libwiringop-dev.install b/debian/libwiringop-dev.install new file mode 100644 index 0000000..41a1414 --- /dev/null +++ b/debian/libwiringop-dev.install @@ -0,0 +1 @@ +usr/include/* diff --git a/debian/libwiringop2.dirs b/debian/libwiringop2.dirs new file mode 100644 index 0000000..6845771 --- /dev/null +++ b/debian/libwiringop2.dirs @@ -0,0 +1 @@ +usr/lib diff --git a/debian/libwiringop2.install b/debian/libwiringop2.install new file mode 100644 index 0000000..eacf2f9 --- /dev/null +++ b/debian/libwiringop2.install @@ -0,0 +1,2 @@ +usr/lib/*/lib*.so.* +usr/lib/*/lib*.so diff --git a/debian/libwiringop2.symbols b/debian/libwiringop2.symbols new file mode 100644 index 0000000..b416ef9 --- /dev/null +++ b/debian/libwiringop2.symbols @@ -0,0 +1,110 @@ +libwiringPi.so libwiringop2 #MINVER# + analogRead@Base 2.0~ppa1~vivid1 + analogWrite@Base 2.0~ppa1~vivid1 + delay@Base 2.0~ppa1~vivid1 + delayMicroseconds@Base 2.0~ppa1~vivid1 + delayMicrosecondsHard@Base 2.0~ppa1~vivid1 + digitalRead@Base 2.0~ppa1~vivid1 + digitalWrite@Base 2.0~ppa1~vivid1 + digitalWriteByte@Base 2.0~ppa1~vivid1 + drcSetupSerial@Base 2.0~ppa1~vivid1 + getAlt@Base 2.0~ppa1~vivid1 + gpioClockSet@Base 2.0~ppa1~vivid1 + isA20@Base 2.0~ppa1~vivid1 + isH3@Base 2.0~ppa1~vivid1 + max31855Setup@Base 2.0~ppa1~vivid1 + max5322Setup@Base 2.0~ppa1~vivid1 + mcp23008Setup@Base 2.0~ppa1~vivid1 + mcp23016Setup@Base 2.0~ppa1~vivid1 + mcp23017Setup@Base 2.0~ppa1~vivid1 + mcp23s08Setup@Base 2.0~ppa1~vivid1 + mcp23s17Setup@Base 2.0~ppa1~vivid1 + mcp3002Setup@Base 2.0~ppa1~vivid1 + mcp3004Setup@Base 2.0~ppa1~vivid1 + mcp3422Setup@Base 2.0~ppa1~vivid1 + mcp4802Setup@Base 2.0~ppa1~vivid1 + micros@Base 2.0~ppa1~vivid1 + millis@Base 2.0~ppa1~vivid1 + myAnalogRead@Base 2.0~ppa1~vivid1 + newPin@Base 2.0~ppa1~vivid1 + pcf8574Setup@Base 2.0~ppa1~vivid1 + pcf8591Setup@Base 2.0~ppa1~vivid1 + physPinToGpio@Base 2.0~ppa1~vivid1 + physPinToPin@Base 2.0~ppa1~vivid1 + piBoardId@Base 2.0~ppa1~vivid1 + piBoardRev@Base 2.0~ppa1~vivid1 + piHiPri@Base 2.0~ppa1~vivid1 + piLock@Base 2.0~ppa1~vivid1 + piMakerNames@Base 2.0~ppa1~vivid1 + piModelNames@Base 2.0~ppa1~vivid1 + piRevisionNames@Base 2.0~ppa1~vivid1 + piThreadCreate@Base 2.0~ppa1~vivid1 + piUnlock@Base 2.0~ppa1~vivid1 + pinMode@Base 2.0~ppa1~vivid1 + pinModeAlt@Base 2.0~ppa1~vivid1 + pullUpDnControl@Base 2.0~ppa1~vivid1 + pwmSetClock@Base 2.0~ppa1~vivid1 + pwmSetMode@Base 2.0~ppa1~vivid1 + pwmSetRange@Base 2.0~ppa1~vivid1 + pwmToneWrite@Base 2.0~ppa1~vivid1 + pwmWrite@Base 2.0~ppa1~vivid1 + readl@Base 2.0~ppa1~vivid1 + serialClose@Base 2.0~ppa1~vivid1 + serialDataAvail@Base 2.0~ppa1~vivid1 + serialFlush@Base 2.0~ppa1~vivid1 + serialGetchar@Base 2.0~ppa1~vivid1 + serialOpen@Base 2.0~ppa1~vivid1 + serialPrintf@Base 2.0~ppa1~vivid1 + serialPutchar@Base 2.0~ppa1~vivid1 + serialPuts@Base 2.0~ppa1~vivid1 + setPadDrive@Base 2.0~ppa1~vivid1 + shiftIn@Base 2.0~ppa1~vivid1 + shiftOut@Base 2.0~ppa1~vivid1 + sn3218Setup@Base 2.0~ppa1~vivid1 + softPwmCreate@Base 2.0~ppa1~vivid1 + softPwmStop@Base 2.0~ppa1~vivid1 + softPwmWrite@Base 2.0~ppa1~vivid1 + softServoSetup@Base 2.0~ppa1~vivid1 + softServoWrite@Base 2.0~ppa1~vivid1 + softToneCreate@Base 2.0~ppa1~vivid1 + softToneStop@Base 2.0~ppa1~vivid1 + softToneWrite@Base 2.0~ppa1~vivid1 + sr595Setup@Base 2.0~ppa1~vivid1 + sunxi_digitalRead@Base 2.0~ppa1~vivid1 + sunxi_digitalWrite@Base 2.0~ppa1~vivid1 + sunxi_get_gpio_mode@Base 2.0~ppa1~vivid1 + sunxi_pullUpDnControl@Base 2.0~ppa1~vivid1 + sunxi_pwm_get_act@Base 2.0~ppa1~vivid1 + sunxi_pwm_get_period@Base 2.0~ppa1~vivid1 + sunxi_pwm_set_act@Base 2.0~ppa1~vivid1 + sunxi_pwm_set_clk@Base 2.0~ppa1~vivid1 + sunxi_pwm_set_enable@Base 2.0~ppa1~vivid1 + sunxi_pwm_set_mode@Base 2.0~ppa1~vivid1 + sunxi_pwm_set_period@Base 2.0~ppa1~vivid1 + sunxi_set_gpio_mode@Base 2.0~ppa1~vivid1 + waitForInterrupt@Base 2.0~ppa1~vivid1 + wiringPiCodes@Base 2.0~ppa1~vivid1 + wiringPiDebug@Base 2.0~ppa1~vivid1 + wiringPiFailure@Base 2.0~ppa1~vivid1 + wiringPiFindNode@Base 2.0~ppa1~vivid1 + wiringPiI2CRead@Base 2.0~ppa1~vivid1 + wiringPiI2CReadReg16@Base 2.0~ppa1~vivid1 + wiringPiI2CReadReg8@Base 2.0~ppa1~vivid1 + wiringPiI2CSetup@Base 2.0~ppa1~vivid1 + wiringPiI2CSetupInterface@Base 2.0~ppa1~vivid1 + wiringPiI2CWrite@Base 2.0~ppa1~vivid1 + wiringPiI2CWriteReg16@Base 2.0~ppa1~vivid1 + wiringPiI2CWriteReg8@Base 2.0~ppa1~vivid1 + wiringPiISR@Base 2.0~ppa1~vivid1 + wiringPiNewNode@Base 2.0~ppa1~vivid1 + wiringPiNodes@Base 2.0~ppa1~vivid1 + wiringPiReturnCodes@Base 2.0~ppa1~vivid1 + wiringPiSPIDataRW@Base 2.0~ppa1~vivid1 + wiringPiSPIGetFd@Base 2.0~ppa1~vivid1 + wiringPiSPISetup@Base 2.0~ppa1~vivid1 + wiringPiSetup@Base 2.0~ppa1~vivid1 + wiringPiSetupGpio@Base 2.0~ppa1~vivid1 + wiringPiSetupPhys@Base 2.0~ppa1~vivid1 + wiringPiSetupSys@Base 2.0~ppa1~vivid1 + wpiPinToGpio@Base 2.0~ppa1~vivid1 + writel@Base 2.0~ppa1~vivid1 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..4d179ce --- /dev/null +++ b/debian/rules @@ -0,0 +1,34 @@ +#!/usr/bin/make -f +export CC=$(DEB_TARGET_GNU_TYPE)-gcc +export CXX=$(DEB_TARGET_GNU_TYPE)-g++ +DEB_HOST_MULTIARCH?=$(shell dpkg-architecture -qDEB_HOST_MULTIARCH) +export LIBARCH=/$(DEB_HOST_MULTIARCH) +PREFIX=/usr +export PREFIX +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +DH_VERBOSE = 1 + +# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/* +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/default.mk + +# see FEATURE AREAS in dpkg-buildflags(1) +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +# see ENVIRONMENT in dpkg-buildflags(1) +# package maintainers to append CFLAGS +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +# package maintainers to append LDFLAGS +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + + +# main packaging script based on dh7 syntax +%: + dh $@ + +# debmake generated override targets +# This is example for Cmake (See http://bugs.debian.org/641051 ) +#override_dh_auto_configure: +# dh_auto_configure -- \ +# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/wiringPi/Makefile b/wiringPi/Makefile index 9e92202..c36c47b 100644 --- a/wiringPi/Makefile +++ b/wiringPi/Makefile @@ -26,17 +26,17 @@ DYN_VERS_MIN=0 VERSION=$(DYN_VERS_MAJ).$(DYN_VERS_MIN) DESTDIR=/usr -PREFIX=/local +PREFIX?=/local STATIC=libwiringPi.a DYNAMIC=libwiringPi.so.$(VERSION) #DEBUG = -g -O0 DEBUG = -O2 -CC = gcc +CC ?= gcc INCLUDE = -I. DEFS = -D_GNU_SOURCE -CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC +CFLAGS += $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC LIBS = @@ -120,10 +120,10 @@ install-headers: .PHONEY: install install: $(DYNAMIC) install-headers @echo "[Install Dynamic Lib]" - @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib - @install -m 0755 libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) - @ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)/lib/libwiringPi.so - @ldconfig + @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib$(LIBARCH) + @install -m 0755 libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib$(LIBARCH)/libwiringPi.so.$(VERSION) + @ln -sfr $(DESTDIR)$(PREFIX)/lib$(LIBARCH)/libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib$(LIBARCH)/libwiringPi.so + -@ldconfig .PHONEY: install-static install-static: $(STATIC) install-headers From 123e158d3669ec8f87ee32a8fffdffd0e503a520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A5=D0=BB=D1=83?= =?UTF-8?q?=D1=82=D1=87=D0=B8=D0=BD?= Date: Sat, 24 Sep 2016 23:59:39 +0400 Subject: [PATCH 19/24] Fix files access modes (drop unnecessary execute bits) --- README.md | 0 examples/BProTest/testLedCon6.c | 0 wiringPi/Makefile | 3 ++- wiringPi/wiringPi.c | 0 wiringPi/wiringPi.h | 0 5 files changed, 2 insertions(+), 1 deletion(-) mode change 100755 => 100644 README.md mode change 100755 => 100644 examples/BProTest/testLedCon6.c mode change 100755 => 100644 wiringPi/wiringPi.c mode change 100755 => 100644 wiringPi/wiringPi.h diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/examples/BProTest/testLedCon6.c b/examples/BProTest/testLedCon6.c old mode 100755 new mode 100644 diff --git a/wiringPi/Makefile b/wiringPi/Makefile index c36c47b..c518938 100644 --- a/wiringPi/Makefile +++ b/wiringPi/Makefile @@ -72,6 +72,7 @@ $(STATIC): $(OBJ) $(DYNAMIC): $(OBJ) @echo "[Link (Dynamic)]" @$(CC) -shared -Wl,-soname,libwiringPi.so -o libwiringPi.so.$(VERSION) -lpthread $(OBJ) + @chmod -x $@ .c.o: @echo [Compile] $< @@ -121,7 +122,7 @@ install-headers: install: $(DYNAMIC) install-headers @echo "[Install Dynamic Lib]" @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib$(LIBARCH) - @install -m 0755 libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib$(LIBARCH)/libwiringPi.so.$(VERSION) + @install -m 0644 libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib$(LIBARCH)/libwiringPi.so.$(VERSION) @ln -sfr $(DESTDIR)$(PREFIX)/lib$(LIBARCH)/libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib$(LIBARCH)/libwiringPi.so -@ldconfig diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c old mode 100755 new mode 100644 diff --git a/wiringPi/wiringPi.h b/wiringPi/wiringPi.h old mode 100755 new mode 100644 From 157c07981377f887cae24e2f57a43d4463e2a3ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A5=D0=BB=D1=83?= =?UTF-8?q?=D1=82=D1=87=D0=B8=D0=BD?= Date: Thu, 29 Sep 2016 19:04:06 +0400 Subject: [PATCH 20/24] Fix files access modes 2 (drop unnecessary execute bits) --- devLib/Makefile | 5 +++-- wiringPi/Makefile | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/devLib/Makefile b/devLib/Makefile index a3c0d42..69ac377 100644 --- a/devLib/Makefile +++ b/devLib/Makefile @@ -60,6 +60,7 @@ $(STATIC): $(OBJ) $(DYNAMIC): $(OBJ) @echo "[Link (Dynamic)]" @$(CC) -shared -Wl,-soname,libwiringPiDev.so -o libwiringPiDev.so.$(VERSION) -lpthread $(OBJ) + @chmod -x $@ .c.o: @echo [Compile] $< @@ -93,7 +94,7 @@ install-headers: install: $(DYNAMIC) install-headers @echo "[Install Dynamic Lib]" @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib - @install -m 0755 libwiringPiDev.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) + @install -m 0644 libwiringPiDev.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) @ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) $(DESTDIR)/lib/libwiringPiDev.so @ldconfig @@ -101,7 +102,7 @@ install: $(DYNAMIC) install-headers install-static: $(STATIC) install-headers @echo "[Install Static Lib]" @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib - @install -m 0755 libwiringPiDev.a $(DESTDIR)$(PREFIX)/lib + @install -m 0644 libwiringPiDev.a $(DESTDIR)$(PREFIX)/lib .PHONEY: uninstall uninstall: diff --git a/wiringPi/Makefile b/wiringPi/Makefile index c518938..0c16d5a 100644 --- a/wiringPi/Makefile +++ b/wiringPi/Makefile @@ -130,7 +130,7 @@ install: $(DYNAMIC) install-headers install-static: $(STATIC) install-headers @echo "[Install Static Lib]" @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib - @install -m 0755 libwiringPi.a $(DESTDIR)$(PREFIX)/lib + @install -m 0644 libwiringPi.a $(DESTDIR)$(PREFIX)/lib .PHONEY: uninstall uninstall: From 248e2b7d4aa287fc364a82a31c3d50b0dce23dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A5=D0=BB=D1=83?= =?UTF-8?q?=D1=82=D1=87=D0=B8=D0=BD?= Date: Fri, 30 Sep 2016 19:39:37 +0400 Subject: [PATCH 21/24] Full build in deb. --- Makefile | 11 ++++++++--- debian/control | 23 ++++++++++++++++++++++- debian/gpio.install | 2 ++ debian/libwiringop2.install | 4 ++-- debian/libwiringopdev2.install | 2 ++ devLib/Makefile | 20 ++++++++++---------- gpio/Makefile | 14 ++++++-------- wiringPi/Makefile | 6 +++--- 8 files changed, 55 insertions(+), 27 deletions(-) create mode 100644 debian/gpio.install create mode 100644 debian/libwiringopdev2.install diff --git a/Makefile b/Makefile index 4a9b11a..0ddfcb6 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,11 @@ -%: - $(MAKE) -C wiringPi $@ - all: $(MAKE) -C wiringPi $@ + $(MAKE) -C devLib $@ + -ln -fs libwiringPiDev.so.2.0 devLib/libwiringPiDev.so + -ln -fs libwiringPi.so.2.0 wiringPi/libwiringPi.so + $(MAKE) -C gpio 'INCLUDE=-I../devLib -I../wiringPi' 'LDFLAGS=-L../devLib -L../wiringPi' $@ +%: + $(MAKE) -C wiringPi $@ + $(MAKE) -C devLib $@ + $(MAKE) -C gpio $@ diff --git a/debian/control b/debian/control index 6c419ee..fcfad95 100644 --- a/debian/control +++ b/debian/control @@ -11,7 +11,7 @@ Vcs-Browser: https://github.com/zhaolei/WiringOP Package: libwiringop-dev Section: libdevel Architecture: any -Depends: libwiringop2 (= ${binary:Version}), ${misc:Depends} +Depends: libwiringop2 (= ${binary:Version}), libwiringopdev2 (= ${binary:Version}), ${misc:Depends} Description: GPIO access library for OrangePi. Development files. This is a modified WiringPi for OrangePi. It is based on the original WiringPi for Raspberry Pi. @@ -32,3 +32,24 @@ Description: GPIO access library for OrangePi. Dynamic library. It’s released under the GNU LGPLv3 license and is usable from C and C++ and many other languages with suitable wrappers. It’s designed to be familiar to people who have used the Arduino “wiring” system. + +Package: libwiringopdev2 +Architecture: any +Multi-Arch: same +Pre-Depends: ${misc:Pre-Depends} +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: WiringPi device library for OrangePi. Dynamic library. + This is a part of a modified WiringPi for OrangePi. + It is based on the original WiringPi for Raspberry Pi. + Dev Lib is a library of device drivers for some popular hardware devices. + These device drivers are not true device drivers in the Linux kernel terms, + but are C libraries to use the existing wiringPi library to access the hardware devices via simple to use APIs. + +Package: gpio +Section: libdevel +Architecture: any +Depends: ${misc:Depends} +Description: GPIO access Utility from the WiringPi library. + This is a part of a modified WiringPi for OrangePi. + gpio is an utility to acess GPIO using the WiringPi library. + It also is necessary for use interrupts with this library. diff --git a/debian/gpio.install b/debian/gpio.install new file mode 100644 index 0000000..fab0f6a --- /dev/null +++ b/debian/gpio.install @@ -0,0 +1,2 @@ +usr/bin/* +usr/man/* diff --git a/debian/libwiringop2.install b/debian/libwiringop2.install index eacf2f9..54f5291 100644 --- a/debian/libwiringop2.install +++ b/debian/libwiringop2.install @@ -1,2 +1,2 @@ -usr/lib/*/lib*.so.* -usr/lib/*/lib*.so +usr/lib/*/libwiringPi.so.* +usr/lib/*/libwiringPi.so diff --git a/debian/libwiringopdev2.install b/debian/libwiringopdev2.install new file mode 100644 index 0000000..e04a95b --- /dev/null +++ b/debian/libwiringopdev2.install @@ -0,0 +1,2 @@ +usr/lib/*/libwiringPiDev.so.* +usr/lib/*/libwiringPiDev.so diff --git a/devLib/Makefile b/devLib/Makefile index 69ac377..7f87b1e 100644 --- a/devLib/Makefile +++ b/devLib/Makefile @@ -25,16 +25,16 @@ DYN_VERS_MIN=0 VERSION=$(DYN_VERS_MAJ).$(DYN_VERS_MIN) DESTDIR=/usr -PREFIX=/local +PREFIX?=/local STATIC=libwiringPiDev.a DYNAMIC=libwiringPiDev.so.$(VERSION) #DEBUG = -g -O0 DEBUG = -O2 -CC = gcc +CC ?= gcc INCLUDE = -I. -CFLAGS = $(DEBUG) -Wformat=2 -Wall $(INCLUDE) -Winline -pipe -fPIC +CFLAGS += $(DEBUG) -Wformat=2 -Wall $(INCLUDE) -Winline -pipe -fPIC LIBS = @@ -93,16 +93,16 @@ install-headers: .PHONEY: install install: $(DYNAMIC) install-headers @echo "[Install Dynamic Lib]" - @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib - @install -m 0644 libwiringPiDev.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) - @ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) $(DESTDIR)/lib/libwiringPiDev.so - @ldconfig + @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib$(LIBARCH) + @install -m 0644 libwiringPiDev.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib$(LIBARCH)/libwiringPiDev.so.$(VERSION) + @ln -sf $(DESTDIR)$(PREFIX)/lib$(LIBARCH)/libwiringPiDev.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib$(LIBARCH)/libwiringPiDev.so + -@ldconfig .PHONEY: install-static install-static: $(STATIC) install-headers @echo "[Install Static Lib]" - @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib - @install -m 0644 libwiringPiDev.a $(DESTDIR)$(PREFIX)/lib + @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib$(LIBARCH) + @install -m 0644 libwiringPiDev.a $(DESTDIR)$(PREFIX)/lib$(LIBARCH) .PHONEY: uninstall uninstall: @@ -115,7 +115,7 @@ uninstall: @rm -f $(DESTDIR)$(PREFIX)/include/lcd128x64.h @rm -f $(DESTDIR)$(PREFIX)/include/lcd.h @rm -f $(DESTDIR)$(PREFIX)/include/piGlow.h - @rm -f $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.* + @rm -f $(DESTDIR)$(PREFIX)/lib$(LIBARCH)/libwiringPiDev.* @ldconfig diff --git a/gpio/Makefile b/gpio/Makefile index 37b4887..bdf0925 100644 --- a/gpio/Makefile +++ b/gpio/Makefile @@ -24,13 +24,13 @@ ################################################################################# DESTDIR=/usr -PREFIX=/local +PREFIX?=/local #DEBUG = -g -O0 DEBUG = -O2 -CC = gcc +CC ?= gcc INCLUDE = -I$(DESTDIR)$(PREFIX)/include -CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe +CFLAGS += $(DEBUG) -Wall $(INCLUDE) -Winline -pipe LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib LIBS = -lwiringPi -lwiringPiDev -lpthread -lm @@ -65,11 +65,9 @@ tags: $(SRC) .PHONY: install install: @echo "[Install]" - @cp gpio $(DESTDIR)$(PREFIX)/bin - @chown root.root $(DESTDIR)$(PREFIX)/bin/gpio - @chmod 4755 $(DESTDIR)$(PREFIX)/bin/gpio - @mkdir -p $(DESTDIR)$(PREFIX)/man/man1 - @cp gpio.1 $(DESTDIR)$(PREFIX)/man/man1 + @install -m 0755 -d $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/man/man1 + @install -m 4755 -o root -g root gpio $(DESTDIR)$(PREFIX)/bin + @install -m 0644 gpio.1 $(DESTDIR)$(PREFIX)/man/man1 .PHONY: uninstall uninstall: diff --git a/wiringPi/Makefile b/wiringPi/Makefile index 0c16d5a..8700b6a 100644 --- a/wiringPi/Makefile +++ b/wiringPi/Makefile @@ -129,8 +129,8 @@ install: $(DYNAMIC) install-headers .PHONEY: install-static install-static: $(STATIC) install-headers @echo "[Install Static Lib]" - @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib - @install -m 0644 libwiringPi.a $(DESTDIR)$(PREFIX)/lib + @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib$(LIBARCH) + @install -m 0644 libwiringPi.a $(DESTDIR)$(PREFIX)/lib$(LIBARCH) .PHONEY: uninstall uninstall: @@ -159,7 +159,7 @@ uninstall: @rm -f $(DESTDIR)$(PREFIX)/include/pcf8574.h @rm -f $(DESTDIR)$(PREFIX)/include/pcf8591.h @rm -f $(DESTDIR)$(PREFIX)/include/sn3218.h - @rm -f $(DESTDIR)$(PREFIX)/lib/libwiringPi.* + @rm -f $(DESTDIR)$(PREFIX)/lib$(LIBARCH)/libwiringPi.* @ldconfig From 5242c2c414f8241a050195313fa43e61045cf4ff Mon Sep 17 00:00:00 2001 From: blecher-at Date: Fri, 24 Feb 2017 21:45:25 +0000 Subject: [PATCH 22/24] change owner of active_low as well on export --- gpio/gpio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gpio/gpio.c b/gpio/gpio.c index cb57765..a7ce4fd 100644 --- a/gpio/gpio.c +++ b/gpio/gpio.c @@ -500,6 +500,8 @@ void doExport (int argc, char *argv []) sprintf (fName, "/sys/class/gpio/gpio%d/edge", pin) ; changeOwner (argv [0], fName) ; + sprintf (fName, "/sys/class/gpio/gpio%d/active_low", pin) ; + changeOwner (argv [0], fName) ; } From ffaf39686cedb6819041a5539f1a007435e8d426 Mon Sep 17 00:00:00 2001 From: Zhao Lei Date: Tue, 11 Jul 2017 10:47:25 +0800 Subject: [PATCH 23/24] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e07eefa..a83f681 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# wiringBP README +# wiringOP README This is a modified WiringPi for OrangePi. We call it WiringOP. Test fo Orangepi pc From 83649301a966643909949f67fb20e19f1946942b Mon Sep 17 00:00:00 2001 From: Robert Savage Date: Sun, 6 Aug 2017 12:26:30 -0400 Subject: [PATCH 24/24] updated SPI API & impl to match current WiringPi version --- wiringPi/wiringPiSPI.c | 42 +++++++++++++++++++++++++++++------------- wiringPi/wiringPiSPI.h | 1 + 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/wiringPi/wiringPiSPI.c b/wiringPi/wiringPiSPI.c index 215a027..baeb127 100644 --- a/wiringPi/wiringPiSPI.c +++ b/wiringPi/wiringPiSPI.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "wiringPi.h" @@ -38,11 +39,10 @@ // The SPI bus parameters // Variables as they need to be passed as pointers later on -const static char *spiDev0 = "/dev/spidev0.0" ; -const static char *spiDev1 = "/dev/spidev0.1" ; -const static uint8_t spiMode = 0 ; -const static uint8_t spiBPW = 8 ; -const static uint16_t spiDelay = 0 ; +static const char *spiDev0 = "/dev/spidev0.0" ; +static const char *spiDev1 = "/dev/spidev0.1" ; +static const uint8_t spiBPW = 8 ; +static const uint16_t spiDelay = 0 ; static uint32_t spiSpeeds [2] ; static int spiFds [2] ; @@ -75,6 +75,11 @@ int wiringPiSPIDataRW (int channel, unsigned char *data, int len) channel &= 1 ; +// Mentioned in spidev.h but not used in the original kernel documentation +// test program )-: + + memset (&spi, 0, sizeof (spi)) ; + spi.tx_buf = (unsigned long)data ; spi.rx_buf = (unsigned long)data ; spi.len = len ; @@ -87,16 +92,17 @@ int wiringPiSPIDataRW (int channel, unsigned char *data, int len) /* - * wiringPiSPISetup: - * Open the SPI device, and set it up, etc. + * wiringPiSPISetupMode: + * Open the SPI device, and set it up, with the mode, etc. ********************************************************************************* */ -int wiringPiSPISetup (int channel, int speed) +int wiringPiSPISetupMode (int channel, int speed, int mode) { int fd ; - channel &= 1 ; + mode &= 3 ; // Mode is 0, 1, 2 or 3 + channel &= 1 ; // Channel is 0 or 1 if ((fd = open (channel == 0 ? spiDev0 : spiDev1, O_RDWR)) < 0) return wiringPiFailure (WPI_ALMOST, "Unable to open SPI device: %s\n", strerror (errno)) ; @@ -105,12 +111,10 @@ int wiringPiSPISetup (int channel, int speed) spiFds [channel] = fd ; // Set SPI parameters. -// Why are we reading it afterwriting it? I've no idea, but for now I'm blindly -// copying example code I've seen online... - if (ioctl (fd, SPI_IOC_WR_MODE, &spiMode) < 0) + if (ioctl (fd, SPI_IOC_WR_MODE, &mode) < 0) return wiringPiFailure (WPI_ALMOST, "SPI Mode Change failure: %s\n", strerror (errno)) ; - + if (ioctl (fd, SPI_IOC_WR_BITS_PER_WORD, &spiBPW) < 0) return wiringPiFailure (WPI_ALMOST, "SPI BPW Change failure: %s\n", strerror (errno)) ; @@ -119,3 +123,15 @@ int wiringPiSPISetup (int channel, int speed) return fd ; } + + +/* + * wiringPiSPISetup: + * Open the SPI device, and set it up, etc. in the default MODE 0 + ********************************************************************************* + */ + +int wiringPiSPISetup (int channel, int speed) +{ + return wiringPiSPISetupMode (channel, speed, 0) ; +} diff --git a/wiringPi/wiringPiSPI.h b/wiringPi/wiringPiSPI.h index f53697d..48cb7be 100644 --- a/wiringPi/wiringPiSPI.h +++ b/wiringPi/wiringPiSPI.h @@ -28,6 +28,7 @@ extern "C" { int wiringPiSPIGetFd (int channel) ; int wiringPiSPIDataRW (int channel, unsigned char *data, int len) ; +int wiringPiSPISetupMode (int channel, int speed, int mode) ; int wiringPiSPISetup (int channel, int speed) ; #ifdef __cplusplus