sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
wiringPi.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#include <ctype.h>
#include <poll.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <fcntl.h>
#include <pthread.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <asm/ioctl.h>
#include "softPwm.h"
#include "softTone.h"
#include "wiringPi.h"
#include "../version.h"

Macros

#define ENV_DEBUG   "WIRINGPI_DEBUG"
 
#define ENV_CODES   "WIRINGPI_CODES"
 
#define ENV_GPIOMEM   "WIRINGPI_GPIOMEM"
 
#define BCM_PASSWORD   0x5A000000
 
#define FSEL_INPT   0b000
 
#define FSEL_OUTP   0b001
 
#define FSEL_ALT0   0b100
 
#define FSEL_ALT1   0b101
 
#define FSEL_ALT2   0b110
 
#define FSEL_ALT3   0b111
 
#define FSEL_ALT4   0b011
 
#define FSEL_ALT5   0b010
 
#define PAGE_SIZE   (4*1024)
 
#define BLOCK_SIZE   (4*1024)
 
#define PWM_CONTROL   0
 
#define PWM_STATUS   1
 
#define PWM0_RANGE   4
 
#define PWM0_DATA   5
 
#define PWM1_RANGE   8
 
#define PWM1_DATA   9
 
#define PWMCLK_CNTL   40
 
#define PWMCLK_DIV   41
 
#define PWM0_MS_MODE   0x0080
 
#define PWM0_USEFIFO   0x0020
 
#define PWM0_REVPOLAR   0x0010
 
#define PWM0_OFFSTATE   0x0008
 
#define PWM0_REPEATFF   0x0004
 
#define PWM0_SERIAL   0x0002
 
#define PWM0_ENABLE   0x0001
 
#define PWM1_MS_MODE   0x8000
 
#define PWM1_USEFIFO   0x2000
 
#define PWM1_REVPOLAR   0x1000
 
#define PWM1_OFFSTATE   0x0800
 
#define PWM1_REPEATFF   0x0400
 
#define PWM1_SERIAL   0x0200
 
#define PWM1_ENABLE   0x0100
 
#define TIMER_LOAD   (0x400 >> 2)
 
#define TIMER_VALUE   (0x404 >> 2)
 
#define TIMER_CONTROL   (0x408 >> 2)
 
#define TIMER_IRQ_CLR   (0x40C >> 2)
 
#define TIMER_IRQ_RAW   (0x410 >> 2)
 
#define TIMER_IRQ_MASK   (0x414 >> 2)
 
#define TIMER_RELOAD   (0x418 >> 2)
 
#define TIMER_PRE_DIV   (0x41C >> 2)
 
#define TIMER_COUNTER   (0x420 >> 2)
 
#define GPIO_PERI_BASE_OLD   0x20000000
 
#define GPIO_PERI_BASE_NEW   0x3F000000
 
#define GPPUD   37
 
#define GPIO_CLOCK_SOURCE   1
 

Functions

int wiringPiFailure (int fatal, const char *message,...)
 
int piGpioLayout (void)
 
int piBoardRev (void)
 
void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty)
 
int wpiPinToGpio (int wpiPin)
 
int physPinToGpio (int physPin)
 
void setPadDrive (int group, int value)
 
int getAlt (int pin)
 
void pwmSetMode (int mode)
 
void pwmSetRange (unsigned int range)
 
void pwmSetClock (int divisor)
 
void gpioClockSet (int pin, int freq)
 
struct wiringPiNodeStructwiringPiFindNode (int pin)
 
struct wiringPiNodeStructwiringPiNewNode (int pinBase, int numPins)
 
void pinModeAlt (int pin, int mode)
 
void pinMode (int pin, int mode)
 
void pullUpDnControl (int pin, int pud)
 
int digitalRead (int pin)
 
void digitalWrite (int pin, int value)
 
void pwmWrite (int pin, int value)
 
int analogRead (int pin)
 
void analogWrite (int pin, int value)
 
void pwmToneWrite (int pin, int freq)
 
void digitalWriteByte (const int value)
 
unsigned int digitalReadByte (void)
 
void digitalWriteByte2 (const int value)
 
unsigned int digitalReadByte2 (void)
 
int waitForInterrupt (int pin, int mS)
 
int wiringPiISR (int pin, int mode, void(*function)(void))
 
void delay (unsigned int howLong)
 
void delayMicrosecondsHard (unsigned int howLong)
 
void delayMicroseconds (unsigned int howLong)
 
unsigned int millis (void)
 
unsigned int micros (void)
 
void wiringPiVersion (int *major, int *minor)
 
int wiringPiSetup (void)
 
int wiringPiSetupGpio (void)
 
int wiringPiSetupPhys (void)
 
int wiringPiSetupSys (void)
 

Variables

struct wiringPiNodeStructwiringPiNodes = NULL
 
volatile unsigned int * _wiringPiGpio
 
volatile unsigned int * _wiringPiPwm
 
volatile unsigned int * _wiringPiClk
 
volatile unsigned int * _wiringPiPads
 
volatile unsigned int * _wiringPiTimer
 
volatile unsigned int * _wiringPiTimerIrqRaw
 
const char * piModelNames [20]
 
const char * piRevisionNames [16]
 
const char * piMakerNames [16]
 
const int piMemorySize [8]
 
int wiringPiDebug = FALSE
 
int wiringPiReturnCodes = FALSE
 
int wiringPiTryGpioMem = FALSE
 

Macro Definition Documentation

#define BCM_PASSWORD   0x5A000000
#define BLOCK_SIZE   (4*1024)
#define ENV_CODES   "WIRINGPI_CODES"
#define ENV_DEBUG   "WIRINGPI_DEBUG"
#define ENV_GPIOMEM   "WIRINGPI_GPIOMEM"
#define FSEL_ALT0   0b100
#define FSEL_ALT1   0b101
#define FSEL_ALT2   0b110
#define FSEL_ALT3   0b111
#define FSEL_ALT4   0b011
#define FSEL_ALT5   0b010
#define FSEL_INPT   0b000
#define FSEL_OUTP   0b001
#define GPIO_CLOCK_SOURCE   1
#define GPIO_PERI_BASE_NEW   0x3F000000
#define GPIO_PERI_BASE_OLD   0x20000000
#define GPPUD   37
#define PAGE_SIZE   (4*1024)
#define PWM0_DATA   5
#define PWM0_ENABLE   0x0001
#define PWM0_MS_MODE   0x0080
#define PWM0_OFFSTATE   0x0008
#define PWM0_RANGE   4
#define PWM0_REPEATFF   0x0004
#define PWM0_REVPOLAR   0x0010
#define PWM0_SERIAL   0x0002
#define PWM0_USEFIFO   0x0020
#define PWM1_DATA   9
#define PWM1_ENABLE   0x0100
#define PWM1_MS_MODE   0x8000
#define PWM1_OFFSTATE   0x0800
#define PWM1_RANGE   8
#define PWM1_REPEATFF   0x0400
#define PWM1_REVPOLAR   0x1000
#define PWM1_SERIAL   0x0200
#define PWM1_USEFIFO   0x2000
#define PWM_CONTROL   0
#define PWM_STATUS   1
#define PWMCLK_CNTL   40
#define PWMCLK_DIV   41
#define TIMER_CONTROL   (0x408 >> 2)
#define TIMER_COUNTER   (0x420 >> 2)
#define TIMER_IRQ_CLR   (0x40C >> 2)
#define TIMER_IRQ_MASK   (0x414 >> 2)
#define TIMER_IRQ_RAW   (0x410 >> 2)
#define TIMER_LOAD   (0x400 >> 2)
#define TIMER_PRE_DIV   (0x41C >> 2)
#define TIMER_RELOAD   (0x418 >> 2)
#define TIMER_VALUE   (0x404 >> 2)

Function Documentation

int analogRead ( int  pin)
void analogWrite ( int  pin,
int  value 
)
void delay ( unsigned int  howLong)
void delayMicroseconds ( unsigned int  howLong)
void delayMicrosecondsHard ( unsigned int  howLong)
int digitalRead ( int  pin)
unsigned int digitalReadByte ( void  )
unsigned int digitalReadByte2 ( void  )
void digitalWrite ( int  pin,
int  value 
)
void digitalWriteByte ( const int  value)
void digitalWriteByte2 ( const int  value)
int getAlt ( int  pin)
void gpioClockSet ( int  pin,
int  freq 
)
unsigned int micros ( void  )
unsigned int millis ( void  )
int physPinToGpio ( int  physPin)
void piBoardId ( int *  model,
int *  rev,
int *  mem,
int *  maker,
int *  warranty 
)
int piBoardRev ( void  )
int piGpioLayout ( void  )
void pinMode ( int  pin,
int  mode 
)
void pinModeAlt ( int  pin,
int  mode 
)
void pullUpDnControl ( int  pin,
int  pud 
)
void pwmSetClock ( int  divisor)
void pwmSetMode ( int  mode)
void pwmSetRange ( unsigned int  range)
void pwmToneWrite ( int  pin,
int  freq 
)
void pwmWrite ( int  pin,
int  value 
)
void setPadDrive ( int  group,
int  value 
)
int waitForInterrupt ( int  pin,
int  mS 
)
int wiringPiFailure ( int  fatal,
const char *  message,
  ... 
)
struct wiringPiNodeStruct* wiringPiFindNode ( int  pin)
int wiringPiISR ( int  pin,
int  mode,
void(*)(void)  function 
)
struct wiringPiNodeStruct* wiringPiNewNode ( int  pinBase,
int  numPins 
)
int wiringPiSetup ( void  )
int wiringPiSetupGpio ( void  )
int wiringPiSetupPhys ( void  )
int wiringPiSetupSys ( void  )
void wiringPiVersion ( int *  major,
int *  minor 
)
int wpiPinToGpio ( int  wpiPin)

Variable Documentation

volatile unsigned int* _wiringPiClk
volatile unsigned int* _wiringPiGpio
volatile unsigned int* _wiringPiPads
volatile unsigned int* _wiringPiPwm
volatile unsigned int* _wiringPiTimer
volatile unsigned int* _wiringPiTimerIrqRaw
const char* piMakerNames[16]
Initial value:
=
{
"Sony",
"Egoman",
"Embest",
"Unknown",
"Embest",
"Unknown05",
"Unknown06",
"Unknown07",
"Unknown08",
"Unknown09",
"Unknown10",
"Unknown11",
"Unknown12",
"Unknown13",
"Unknown14",
"Unknown15",
}
const int piMemorySize[8]
Initial value:
=
{
256,
512,
1024,
0,
0,
0,
0,
0,
}
const char* piModelNames[20]
Initial value:
=
{
"Model A",
"Model B",
"Model A+",
"Model B+",
"Pi 2",
"Alpha",
"CM",
"Unknown07",
"Pi 3",
"Pi Zero",
"CM3",
"Unknown11",
"Pi Zero-W",
"Pi 3B+",
"Pi 3A+",
"Unknown15",
"CM3+",
"Unknown17",
"Unknown18",
"Unknown19",
}
const char* piRevisionNames[16]
Initial value:
=
{
"00",
"01",
"02",
"03",
"04",
"05",
"06",
"07",
"08",
"09",
"10",
"11",
"12",
"13",
"14",
"15",
}
int wiringPiDebug = FALSE
struct wiringPiNodeStruct* wiringPiNodes = NULL
int wiringPiReturnCodes = FALSE
int wiringPiTryGpioMem = FALSE