wiringPi-sim
Functions | Variables
wiringPi.cpp File Reference
#include <wiringPi/wiringPi.h>
#include <time.h>
#include <unistd.h>
Include dependency graph for wiringPi.cpp:

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...
 
void wiringpi_helper_timespec_diff (struct timespec *start, struct timespec *stop, struct timespec *result)
 
unsigned int millis (void)
 Get time in milliseconds. More...
 
unsigned int micros (void)
 Get time in microseconds. More...
 
void delay (unsigned int howLongMillis)
 Wait for an amount of milliseconds. More...
 
void delayMicroseconds (unsigned int howLongMicros)
 Wait for an amount of microseconds. More...
 
void wiringPiVersion (int *major, int *minor)
 Get the current major and minor version number. More...
 

Variables

struct timespec wiring_pi_setup_time
 

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:

◆ wiringpi_helper_timespec_diff()

void wiringpi_helper_timespec_diff ( struct timespec *  start,
struct timespec *  stop,
struct timespec *  result 
)
Here is the caller 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

Variable Documentation

◆ wiring_pi_setup_time

struct timespec wiring_pi_setup_time