chiark / gitweb /
6a7278ee2d568d651a9a0c1bdd1313104a65dc82
[wiringPi.git] / wiringPi / wiringPi.h
1 /*
2  * wiringPi:
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/
8  *
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.
13  *
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.
18  *
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  ***********************************************************************
22  */
23
24 // Handy defines
25
26 #define NUM_PINS        17
27
28 #define WPI_MODE_PINS            0
29 #define WPI_MODE_GPIO            1
30 #define WPI_MODE_GPIO_SYS        2
31 #define WPI_MODE_PIFACE          3
32
33 #define INPUT            0
34 #define OUTPUT           1
35 #define PWM_OUTPUT       2
36
37 #define LOW              0
38 #define HIGH             1
39
40 #define PUD_OFF          0
41 #define PUD_DOWN         1
42 #define PUD_UP           2
43
44 // PWM
45
46 #define PWM_MODE_MS     0
47 #define PWM_MODE_BAL    1
48
49
50 // Function prototypes
51 //      c++ wrappers thanks to a commend by Nick Lott
52 //      (and others on the Raspberry Pi forums)
53
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57
58 // Basic wiringPi functions
59
60 extern int  wiringPiSetup       (void) ;
61 extern int  wiringPiSetupSys    (void) ;
62 extern int  wiringPiSetupGpio   (void) ;
63 extern int  wiringPiSetupPiFace (void) ;
64
65 extern int  piBoardRev          (void) ;
66 extern int  wpiPinToGpio        (int wpiPin) ;
67
68 extern int  wiringPiSetupPiFaceForGpioProg (void) ;     // Don't use this - for gpio program only
69
70 extern void (*pinMode)           (int pin, int mode) ;
71 extern void (*pullUpDnControl)   (int pin, int pud) ;
72 extern void (*digitalWrite)      (int pin, int value) ;
73 extern void (*digitalWriteByte)  (int value) ;
74 extern void (*pwmWrite)          (int pin, int value) ;
75 extern void (*setPadDrive)       (int group, int value) ;
76 extern int  (*digitalRead)       (int pin) ;
77 extern void (*delayMicroseconds) (unsigned int howLong) ;
78 extern void (*pwmSetMode)        (int mode) ;
79 extern void (*pwmSetRange)       (unsigned int range) ;
80 extern void (*pwmSetClock)       (int divisor) ;
81
82 // Interrupts
83
84 extern int  (*waitForInterrupt) (int pin, int mS) ;
85
86 // Threads
87
88 #define PI_THREAD(X)    void *X (void *dummy)
89
90 extern int  piThreadCreate (void *(*fn)(void *)) ;
91 extern void piLock         (int key) ;
92 extern void piUnlock       (int key) ;
93
94 // Schedulling priority
95
96 extern int piHiPri (int pri) ;
97
98
99 // Extras from arduino land
100
101 extern void         delay             (unsigned int howLong) ;
102 extern unsigned int millis            (void) ;
103
104 #ifdef __cplusplus
105 }
106 #endif