From b23cb44ffae23dc80105c656f817c41d28cea86c Mon Sep 17 00:00:00 2001 From: Gordon Henderson Date: Sat, 18 Aug 2012 00:05:38 +0100 Subject: [PATCH] Updated wiringPi.c to work with some pullUpDown stuff General tidying up of some of the code round delayMicroseconds --- wiringPi/.wiringPiFace.c.swp | Bin 16384 -> 0 bytes wiringPi/README | 2 -- wiringPi/wiringPi.c | 42 +++++++++++++++--------------------------- wiringPi/wiringPi.h | 2 -- 4 files changed, 15 insertions(+), 31 deletions(-) delete mode 100644 wiringPi/.wiringPiFace.c.swp diff --git a/wiringPi/.wiringPiFace.c.swp b/wiringPi/.wiringPiFace.c.swp deleted file mode 100644 index 3eff7deff308d27f398bd919c64bb8119b850554..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI2Ym6IL6~~7rO|mT^fr3*2M{8mh=+Iv1mY8@Mev~#YJ~(J5J5aDgoMKX+ zHdP{}NJTTsFKeHB?wxbaea;!T^C#3Lb|5>W;M%Py$M)^6of_Yvd~jM(y0&ZB78Shy z)z?m)vR_|CmVP2^Fz2~?Ze6&->ej@SAIh4}v-&kOm#U-@NF#7v5!k8B&P?a`jNid- zd&ly1)l8Ms2&556BalWQjX)ZKGy-V^(g>sxc=JcVceW^(;KohhQ{XKTmvEiI=cl6Y zTk!WVn1BN5q*oe&Gy-V^(g>sxNF$I&AdNs8fiwbX1kwnk5lAEO=81r2D9R3)dxR1I zc>hm1fdA}Lls|*7g45t}a4*;fwt(-xO;Mf&ZO{U@gBN!y%G00;?gzWTFW;&tPl83D zf}6naZ&j490Rub&THs-DA2WX!C4?c59|lGfxnI^%Fn@B z@MX{k8-N1?ydPYIlYarf0_VUtz;obp;7M>AIN&3o4D#STU>o?`c13v^`~rLvoClu= zPXix3432|+fPq`UYugm%RqzV90Dc0_f=>e%JOJ(m6JQtk=go@p5AYlC5;zaefiHqH z;3?n%7kms@;1MtmE^bwn=fSh!vw#B~dR2OiUOoqHZz<$6!EgtwX{ z{hr%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ywyp|K2Q?9m{e9NwsG zd>pss^>B0tv=fy5kJ@nus9Y`L%22WX(7f*8BG7&I%gwuP%8Gh&)3c`?=QC9x{ zViaEA@C&tREYWps<1Trb!7?)aJ;{))&0|E3(Mt!sW}rt>%5KmcmVi2Wwp^g$WWOKNgBt;J4CzFp|Sjijr76r-lXpbhN?36PL`I-k)Ji`51Ts1 zRLco`WJ`uUlNAb=xh5+Vr~-1*vc_l?yfm0(@mm+QNmG>4o`Yc@Cnhcn$<(y$Lz?}Y gzYDDwTT6upT8&z%RBRppaQH%0riCZi5n3$%3;&rqhX4Qo diff --git a/wiringPi/README b/wiringPi/README index 052cd41..781510a 100644 --- a/wiringPi/README +++ b/wiringPi/README @@ -2,8 +2,6 @@ WiringPi: An implementation of most of the Arduino Wiring functions for the Raspberry Pi --- And a lot lot more! - Full details at: https://projects.drogon.net/raspberry-pi/wiringpi/ diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index 35717ef..fb5e7c6 100644 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -402,7 +402,8 @@ void pinModeGpio (int pin, int mode) // When we change mode of any pin, we remove the pull up/downs - pullUpDnControl (pin, PUD_OFF) ; +// delayMicroseconds (300) ; +// pullUpDnControl (pin, PUD_OFF) ; } void pinModeWPi (int pin, int mode) @@ -479,24 +480,19 @@ void digitalWriteSys (int pin, int value) ********************************************************************************* */ -void pwmWriteWPi (int pin, int value) +void pwmWriteGpio (int pin, int value) { int port ; - pin = pinToGpio [pin & 63] ; + pin = pin & 63 ; port = gpioToPwmPort [pin] ; *(pwm + port) = value & 0x3FF ; } -void pwmWriteGpio (int pin, int value) +void pwmWriteWPi (int pin, int value) { - int port ; - - pin = pin & 63 ; - port = gpioToPwmPort [pin] ; - - *(pwm + port) = value & 0x3FF ; + pwmWriteGpio (pinToGpio [pin & 63], value) ; } void pwmWriteSys (int pin, int value) @@ -588,28 +584,21 @@ int digitalReadSys (int pin) ********************************************************************************* */ -void pullUpDnControlWPi (int pin, int pud) +void pullUpDnControlGpio (int pin, int pud) { - pin = pinToGpio [pin & 63] ; + pin &= 63 ; pud &= 3 ; - *(gpio + GPPUD) = pud ; delayMicroseconds (10) ; - *(gpio + gpioToPUDCLK [pin]) = 1 << (pin & 31) ; delayMicroseconds (10) ; + *(gpio + GPPUD) = pud ; delayMicroseconds (5) ; + *(gpio + gpioToPUDCLK [pin]) = 1 << (pin & 31) ; delayMicroseconds (5) ; - *(gpio + GPPUD) = 0 ; - *(gpio + gpioToPUDCLK [pin]) = 0 ; + *(gpio + GPPUD) = 0 ; delayMicroseconds (5) ; + *(gpio + gpioToPUDCLK [pin]) = 0 ; delayMicroseconds (5) ; } -void pullUpDnControlGpio (int pin, int pud) +void pullUpDnControlWPi (int pin, int pud) { - pin &= 63 ; - pud &= 3 ; - - *(gpio + GPPUD) = pud ; delayMicroseconds (10) ; - *(gpio + gpioToPUDCLK [pin]) = 1 << (pin & 31) ; delayMicroseconds (10) ; - - *(gpio + GPPUD) = 0 ; - *(gpio + gpioToPUDCLK [pin]) = 0 ; + pullUpDnControlGpio (pinToGpio [pin & 63], pud) ; } void pullUpDnControlSys (int pin, int pud) @@ -685,6 +674,7 @@ void delay (unsigned int howLong) nanosleep (&sleeper, &dummy) ; } + /* * delayMicroseconds: * This is somewhat intersting. It seems that on the Pi, a single call @@ -977,5 +967,3 @@ int wiringPiSetupSys (void) return 0 ; } - - diff --git a/wiringPi/wiringPi.h b/wiringPi/wiringPi.h index 5b9c8c7..03ab787 100644 --- a/wiringPi/wiringPi.h +++ b/wiringPi/wiringPi.h @@ -86,8 +86,6 @@ extern int piHiPri (int pri) ; // Extras from arduino land extern void delay (unsigned int howLong) ; -//extern void delayMicroseconds (unsigned int howLong) ; -//extern void delayMicrosecondsHard (unsigned int howLong) ; extern unsigned int millis (void) ; #ifdef __cplusplus