wiringPi-0.1.0.0: Access GPIO pins on Raspberry Pi via wiringPi library

Copyright© Patrick Pelletier, 2017
LicenseBSD3
Maintainercode@funwithsoftware.org
Stabilityexperimental
PortabilityRaspberry Pi
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.Hardware.WiringPi

Contents

Description

This is a Haskell binding to the wiringPi library. The functions here correspond directly to the functions in the C library. To use this library, you must either run as root, or set the WIRINGPI_GPIOMEM environment variable. However, if you set WIRINGPI_GPIOMEM, then PWM does not work, so to use PWM you must be root.

Synopsis

Types

type Pin = CInt Source

Represents a pin number. The meaning of the pin number depends on which setup function was called.

data Value Source

Digital logic level.

Constructors

LOW 
HIGH 

data Mode Source

Pin mode, used with pinMode.

Constructors

INPUT

digital input

OUTPUT

digital output

PWM_OUTPUT

pulse-width modulation; only supported on wiringPi pin 1

GPIO_CLOCK

clock output; only supported on wiringPi pin 7

data Pud Source

Use with pullUpDnControl to enable internal pull-up or pull-down resistor.

Constructors

PUD_OFF

disable pull-up/pull-down

PUD_DOWN

enable pull-down resistor

PUD_UP

enable pull-up resistor

data PwmMode Source

Argument to pwmSetMode to set "balanced" mode or "mark-space" mode.

Constructors

PWM_MODE_BAL

balanced mode

PWM_MODE_MS

mark-space mode

type PwmValue = Word16 Source

Value used with pwmWrite. Typically ranges from 0-1024, but the range can be increased up to 4096 by calling pwmSetRange.

Setup functions

See WiringPi Setup functions. You must call one of these functions, only once, before calling any other wiringPi functions. The pin numbering scheme depends on which setup function you call. On error, the program will be terminated, unless the environment variable WIRINGPI_CODES is set, in which case an exception will be thrown.

wiringPiSetupGpio :: IO () Source

Use Broadcom chip's GPIO numbers. These are the numbers on the Adafruit cobbler.

wiringPiSetupPhys :: IO () Source

Use physical pin numbers on the P1 connector.

wiringPiSetupSys :: IO () Source

Use Broadcom chip's GPIO numbers. Accesses the GPIO via /sys/class/GPIO. A bunch of functionality is not available in this mode.

Core functions

pinMode :: Pin -> Mode -> IO () Source

pwmWrite :: Pin -> PwmValue -> IO () Source

Default range is 0-1024, but it can be changed with pwmSetRange.

Additional functions

digitalWriteByte :: Word8 -> IO () Source

Write 8 bits to the 8 pins that have wiringPi pin numbers 0-7.

pwmSetRange :: PwmValue -> IO () Source

Change the range used by pwmWrite. Default is 1024. Maxium is 4096.

pwmSetClock :: PwmValue -> IO () Source

Change the PWM divisor. Range is 2-4095.