wiringPi-sim
wiringPi.h
Go to the documentation of this file.
1 /*
2  * wiringPi.h
3  *
4  * Created on: Jan 7, 2018
5  * Author: shahada
6  * Modified and enhanced on: Feb 13, 2021
7  *
8  * Copyright (c) 2018 Shahada Abubakar.
9  * Copyright (c) 2021 Jan-Hendrik Ewers.
10  *
11  * This file is part of wiringPi-mock.
12  *
13  * This program is free software: you can redistribute it and/or
14  * modify it under the terms of the Lesser GNU General Public
15  * License as published by the Free Software Foundation, either
16  * version 3 of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21  *
22  * See the GNU General Public License for more details.
23  *
24  */
25 
26 
27 #ifndef WIRINGPI_H_
28 #define WIRINGPI_H_
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include <wiringPi/version.h>
35 
36 /* constants and enums ... copied from original wiringPi.h */
37 
38 #ifndef TRUE
40 # define TRUE (1==1)
42 # define FALSE (!TRUE)
43 #endif
44 
45 // Pin type
46 
48 #define INPUT 0
50 #define OUTPUT 1
52 #define PWM_OUTPUT 2
54 #define GPIO_CLOCK 3
56 #define SOFT_PWM_OUTPUT 4
58 #define SOFT_TONE_OUTPUT 5
60 #define PWM_TONE_OUTPUT 6
61 
62 // Define low and high
63 
65 #define LOW 0
67 #define HIGH 1
68 
69 // Pull up/down/none
70 
72 #define PUD_OFF 0
74 #define PUD_DOWN 1
76 #define PUD_UP 2
77 
78 // PWM
79 
81 #define PWM_MODE_MS 0
83 #define PWM_MODE_BAL 1
84 
85 // Interrupt levels
86 
91 #define INT_EDGE_SETUP 0
93 #define INT_EDGE_FALLING 1
95 #define INT_EDGE_RISING 2
97 #define INT_EDGE_BOTH 3
98 
99 /**********************************/
100 /**** core function prototypes ****/
101 /**********************************/
102 
111 int wiringPiSetup (void);
112 
121 int wiringPiSetupGpio (void);
122 
131 int wiringPiSetupPhys (void);
132 
143 int wiringPiSetupSys (void);
144 
153 int wiringPiISR (int pin, int edgeType, void (*function)(void));
154 
161 void pinMode (int pin, int mode);
162 
169 void pullUpDnControl (int pin, int pud);
170 
177 void digitalWrite (int pin, int value);
178 
185 void pwmWrite (int pin, int value);
186 
193 int digitalRead (int pin);
194 
203 int analogRead (int pin);
204 
213 void analogWrite (int pin, int value);
214 
227 int waitForInterrupt (int pin, int timeOut, int mode);
228 
229 /************************************/
230 /**** timing function prototypes ****/
231 /************************************/
232 
240 unsigned int millis (void);
241 
249 unsigned int micros (void);
250 
256 void delay (unsigned int howLong);
257 
263 void delayMicroseconds (unsigned int howLong);
264 
265 /*****************/
266 /**** version ****/
267 /*****************/
268 
275 void wiringPiVersion( int *major, int *minor);
276 
277 
278 #ifdef __cplusplus
279 }
280 #endif
281 
282 
283 #endif /* WIRINGPI_H_ */
284 
void pullUpDnControl(int pin, int pud)
Control the internal pull-up/down resistors on a GPIO pin.
Definition: wiringPi.cpp:71
void wiringPiVersion(int *major, int *minor)
Get the current major and minor version number.
Definition: wiringPi.cpp:156
int wiringPiISR(int pin, int edgeType, void(*function)(void))
Register a Interrupt Service Routine (ISR) - Pi Specific.
Definition: wiringPi.cpp:61
void delay(unsigned int howLong)
Wait for an amount of milliseconds.
Definition: wiringPi.cpp:143
int wiringPiSetup(void)
Must be called once at the start of your program execution.
Definition: wiringPi.cpp:37
int wiringPiSetupSys(void)
Must be called once at the start of your program execution.
Definition: wiringPi.cpp:56
void pwmWrite(int pin, int value)
Set an output PWM value.
Definition: wiringPi.cpp:79
unsigned int micros(void)
Get time in microseconds.
Definition: wiringPi.cpp:132
int analogRead(int pin)
Read the analogue value of a given Pin.
Definition: wiringPi.cpp:88
int waitForInterrupt(int pin, int timeOut, int mode)
When called, it will wait for an interrupt event to happen on that pin and your program will be stall...
Definition: wiringPi.cpp:97
void analogWrite(int pin, int value)
Write the analog value to the given Pin.
Definition: wiringPi.cpp:93
unsigned int millis(void)
Get time in milliseconds.
Definition: wiringPi.cpp:120
int wiringPiSetupPhys(void)
Must be called once at the start of your program execution.
Definition: wiringPi.cpp:51
void pinMode(int pin, int mode)
Sets the mode of a pin to be input, output or PWM output.
Definition: wiringPi.cpp:67
int wiringPiSetupGpio(void)
Must be called once at the start of your program execution.
Definition: wiringPi.cpp:46
void delayMicroseconds(unsigned int howLong)
Wait for an amount of microseconds.
Definition: wiringPi.cpp:149
int digitalRead(int pin)
Read the value of a given Pin.
Definition: wiringPi.cpp:83
void digitalWrite(int pin, int value)
Set an output bit.
Definition: wiringPi.cpp:75