wiringPi-sim
Macros | Functions
wiringPi.h File Reference
#include <wiringPi/version.h>
Include dependency graph for wiringPi.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TRUE   (1==1)
 Logical TRUE. More...
 
#define FALSE   (!TRUE)
 Logical FALSE. More...
 
#define INPUT   0
 Pin type: input. More...
 
#define OUTPUT   1
 Pin type: output. More...
 
#define PWM_OUTPUT   2
 Pin type: PWM output. More...
 
#define GPIO_CLOCK   3
 Pin type: GPIO clock. More...
 
#define SOFT_PWM_OUTPUT   4
 Pin type: soft PWM output. More...
 
#define SOFT_TONE_OUTPUT   5
 Pin type: soft tone ouput. More...
 
#define PWM_TONE_OUTPUT   6
 Pin type: PWM tone output. More...
 
#define LOW   0
 Digital LOW. More...
 
#define HIGH   1
 Digital HIGH. More...
 
#define PUD_OFF   0
 Pull Up/Down resistor: off. More...
 
#define PUD_DOWN   1
 Pull Up/Down resistor: down. More...
 
#define PUD_UP   2
 Pull Up/Down resistor: up. More...
 
#define PWM_MODE_MS   0
 PWM milliseconds mode. More...
 
#define PWM_MODE_BAL   1
 PWM balanced mode. More...
 
#define INT_EDGE_SETUP   0
 
#define INT_EDGE_FALLING   1
 Interrupt triggered on the falling edge. More...
 
#define INT_EDGE_RISING   2
 Interrupt triggered on the rising edge. More...
 
#define INT_EDGE_BOTH   3
 Interrupt triggered on BOTH edges. More...
 

Functions

int wiringPiSetup (void)
 Must be called once at the start of your program execution. More...
 
int wiringPiSetupGpio (void)
 Must be called once at the start of your program execution. More...
 
int wiringPiSetupPhys (void)
 Must be called once at the start of your program execution. More...
 
int wiringPiSetupSys (void)
 Must be called once at the start of your program execution. More...
 
int wiringPiISR (int pin, int edgeType, void(*function)(void))
 Register a Interrupt Service Routine (ISR) - Pi Specific. More...
 
void pinMode (int pin, int mode)
 Sets the mode of a pin to be input, output or PWM output. More...
 
void pullUpDnControl (int pin, int pud)
 Control the internal pull-up/down resistors on a GPIO pin. More...
 
void digitalWrite (int pin, int value)
 Set an output bit. More...
 
void pwmWrite (int pin, int value)
 Set an output PWM value. More...
 
int digitalRead (int pin)
 Read the value of a given Pin. More...
 
int analogRead (int pin)
 Read the analogue value of a given Pin. More...
 
void analogWrite (int pin, int value)
 Write the analog value to the given Pin. More...
 
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 stalled.. More...
 
unsigned int millis (void)
 Get time in milliseconds. More...
 
unsigned int micros (void)
 Get time in microseconds. More...
 
void delay (unsigned int howLong)
 Wait for an amount of milliseconds. More...
 
void delayMicroseconds (unsigned int howLong)
 Wait for an amount of microseconds. More...
 
void wiringPiVersion (int *major, int *minor)
 Get the current major and minor version number. More...
 

Macro Definition Documentation

◆ FALSE

#define FALSE   (!TRUE)

Logical FALSE.

◆ GPIO_CLOCK

#define GPIO_CLOCK   3

Pin type: GPIO clock.

◆ HIGH

#define HIGH   1

Digital HIGH.

◆ INPUT

#define INPUT   0

Pin type: input.

◆ INT_EDGE_BOTH

#define INT_EDGE_BOTH   3

Interrupt triggered on BOTH edges.

◆ INT_EDGE_FALLING

#define INT_EDGE_FALLING   1

Interrupt triggered on the falling edge.

◆ INT_EDGE_RISING

#define INT_EDGE_RISING   2

Interrupt triggered on the rising edge.

◆ INT_EDGE_SETUP

#define INT_EDGE_SETUP   0

If INT_EDGE_SETUP is used for wiringPiISR, it is assumed that the pin is assumed that you have already setup the pin elsewhere (e.g. with the gpio program)

◆ LOW

#define LOW   0

Digital LOW.

◆ OUTPUT

#define OUTPUT   1

Pin type: output.

◆ PUD_DOWN

#define PUD_DOWN   1

Pull Up/Down resistor: down.

◆ PUD_OFF

#define PUD_OFF   0

Pull Up/Down resistor: off.

◆ PUD_UP

#define PUD_UP   2

Pull Up/Down resistor: up.

◆ PWM_MODE_BAL

#define PWM_MODE_BAL   1

PWM balanced mode.

◆ PWM_MODE_MS

#define PWM_MODE_MS   0

PWM milliseconds mode.

◆ PWM_OUTPUT

#define PWM_OUTPUT   2

Pin type: PWM output.

◆ PWM_TONE_OUTPUT

#define PWM_TONE_OUTPUT   6

Pin type: PWM tone output.

◆ SOFT_PWM_OUTPUT

#define SOFT_PWM_OUTPUT   4

Pin type: soft PWM output.

◆ SOFT_TONE_OUTPUT

#define SOFT_TONE_OUTPUT   5

Pin type: soft tone ouput.

◆ TRUE

#define TRUE   (1==1)

Logical TRUE.

Function Documentation

◆ analogRead()

int analogRead ( int  pin)

Read the analogue value of a given Pin.

There is no on-board Pi analog hardware, so this needs to go to a new node.

Parameters
pinPin number
Returns
LOW or HIGH

◆ analogWrite()

void analogWrite ( int  pin,
int  value 
)

Write the analog value to the given Pin.

There is no on-board Pi analog hardware, so this needs to go to a new node.

Parameters
pinPin number
valueValue

◆ delay()

void delay ( unsigned int  howLong)

Wait for an amount of milliseconds.

Parameters
howLongMilliseconds to wait
Here is the caller graph for this function:

◆ delayMicroseconds()

void delayMicroseconds ( unsigned int  howLong)

Wait for an amount of microseconds.

Parameters
howLongMicroseconds to wait

◆ digitalRead()

int digitalRead ( int  pin)

Read the value of a given Pin.

Parameters
pinPin number
Returns
LOW or HIGH

◆ digitalWrite()

void digitalWrite ( int  pin,
int  value 
)

Set an output bit.

Parameters
pinPin number
valuePWM value

◆ micros()

unsigned int micros ( void  )

Get time in microseconds.

Wraps after 71 minutes.

Returns
Microseconds
Here is the call graph for this function:

◆ millis()

unsigned int millis ( void  )

Get time in milliseconds.

Wraps after 49 days.

Returns
Milliseconds
Here is the call graph for this function:

◆ pinMode()

void pinMode ( int  pin,
int  mode 
)

Sets the mode of a pin to be input, output or PWM output.

Parameters
pinPin number
modePin type (INPUT, OUTPUT, PWM_OUTPUT, etc.)

◆ pullUpDnControl()

void pullUpDnControl ( int  pin,
int  pud 
)

Control the internal pull-up/down resistors on a GPIO pin.

Parameters
pinPin number
modePUD_OFF, PUD_DOWN, or PUD_UP

◆ pwmWrite()

void pwmWrite ( int  pin,
int  value 
)

Set an output PWM value.

Parameters
pinPin number
valueLOW or HIGH

◆ waitForInterrupt()

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 stalled..

The timeOut parameter is given in milliseconds, or can be -1 which means to wait forever.

Parameters
pinPin number
timeoutTimeout (milliseconds)
modeINT_EDGE_SETUP, INT_EDGE_FALLING, INT_EDGE_RISING, INT_EDGE_BOTH
Returns
The return value is -1 if an error occurred (and errno will be set appropriately), 0 if it timed out, or 1 on a successful interrupt event.
Here is the call graph for this function:

◆ wiringPiISR()

int wiringPiISR ( int  pin,
int  edgeType,
void(*)(void)  function 
)

Register a Interrupt Service Routine (ISR) - Pi Specific.

Parameters
pinPin number
edgeTypeINT_EDGE_SETUP, INT_EDGE_FALLING, INT_EDGE_RISING, INT_EDGE_BOTH
functionThe ISR callback function
Returns
int Exit code.

◆ wiringPiSetup()

int wiringPiSetup ( void  )

Must be called once at the start of your program execution.

Default setup: Initialises the system into wiringPi Pin mode and uses the memory mapped hardware directly.

Todo:
Actually enforce this.
Returns
int Exit code.

◆ wiringPiSetupGpio()

int wiringPiSetupGpio ( void  )

Must be called once at the start of your program execution.

GPIO setup: Initialises the system into GPIO Pin mode and uses the memory mapped hardware directly.

Todo:
Actually enforce this.
Returns
int Exit code.

◆ wiringPiSetupPhys()

int wiringPiSetupPhys ( void  )

Must be called once at the start of your program execution.

Phys setup: Initialises the system into Physical Pin mode and uses the memory mapped hardware directly.

Todo:
Actually enforce this.
Returns
int Exit code.

◆ wiringPiSetupSys()

int wiringPiSetupSys ( void  )

Must be called once at the start of your program execution.

Initialisation (again), however this time we are using the /sys/class/gpio interface to the GPIO systems - slightly slower, but always usable as a non-root user, assuming the devices are already exported and setup correctly.

Todo:
Actually enforce this.
Returns
int Exit code.

◆ wiringPiVersion()

void wiringPiVersion ( int *  major,
int *  minor 
)

Get the current major and minor version number.

Parameters
[out]majorMajor version number
[out]minorMinor version number