3 * Arduino compatable (ish) Wiring library for the Raspberry Pi
4 * Copyright (c) 2012 Gordon Henderson
5 ***********************************************************************
6 * This file is part of wiringPi:
7 * https://projects.drogon.net/raspberry-pi/wiringpi/
9 * wiringPi is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * wiringPi is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
21 ***********************************************************************
29 #define WPI_MODE_PINS 0
30 #define WPI_MODE_GPIO 1
31 #define WPI_MODE_GPIO_SYS 2
32 #define WPI_MODE_PIFACE 3
33 #define WPI_MODE_UNINITIALISED -1
49 #define PWM_MODE_BAL 1
53 #define INT_EDGE_SETUP 0
54 #define INT_EDGE_FALLING 1
55 #define INT_EDGE_RISING 2
56 #define INT_EDGE_BOTH 3
60 #define PI_THREAD(X) void *X (void *dummy)
63 // Function prototypes
64 // c++ wrappers thanks to a comment by Nick Lott
65 // (and others on the Raspberry Pi forums)
71 // Basic wiringPi functions
73 extern int wiringPiSetup (void) ;
74 extern int wiringPiSetupSys (void) ;
75 extern int wiringPiSetupGpio (void) ;
76 extern int wiringPiSetupPiFace (void) ;
78 extern int piBoardRev (void) ;
79 extern int wpiPinToGpio (int wpiPin) ;
81 extern int wiringPiSetupPiFaceForGpioProg (void) ; // Don't use this - for gpio program only
83 extern void (*pinMode) (int pin, int mode) ;
84 extern int (*getAlt) (int pin) ;
85 extern void (*pullUpDnControl) (int pin, int pud) ;
86 extern void (*digitalWrite) (int pin, int value) ;
87 extern void (*digitalWriteByte) (int value) ;
88 extern void (*pwmWrite) (int pin, int value) ;
89 extern void (*setPadDrive) (int group, int value) ;
90 extern int (*digitalRead) (int pin) ;
91 extern void (*pwmSetMode) (int mode) ;
92 extern void (*pwmSetRange) (unsigned int range) ;
93 extern void (*pwmSetClock) (int divisor) ;
97 extern int (*waitForInterrupt) (int pin, int mS) ;
98 extern int wiringPiISR (int pin, int mode, void (*function)(void)) ;
102 extern int piThreadCreate (void *(*fn)(void *)) ;
103 extern void piLock (int key) ;
104 extern void piUnlock (int key) ;
106 // Schedulling priority
108 extern int piHiPri (int pri) ;
111 // Extras from arduino land
113 extern void delay (unsigned int howLong) ;
114 extern void delayMicroseconds (unsigned int howLong) ;
115 extern unsigned int millis (void) ;
116 extern unsigned int micros (void) ;