hpio-0.8.0.0: Monads for GPIO in Haskell

Copyright(c) 2016, Drew Hess
LicenseBSD3
MaintainerDrew Hess <src@drewhess.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellTrustworthy
LanguageHaskell2010

System.GPIO.Types

Contents

Description

Basic GPIO types.

Synopsis

GPIO pins

newtype Pin Source

A GPIO pin, identified by pin number.

Note that GPIO pin numbering is platform- and runtime-dependent. See the documentation for your particular platform for an explanation of how pin numbers are assigned to physical pins.

Constructors

Pin Int 

data PinInputMode Source

GPIO pins may support a number of different physical configurations when used as a digital input.

Pins that are capable of input will at least support the InputDefault mode. InputDefault mode is special in that, unlike the other input modes, it does not represent a unique physical configuration, but is simply a pseudonym for another (actual) input mode. Exactly which mode is used by the hardware when InputDefault mode is specified is platform-dependent. By using InputDefaut mode, you are saying that you don't care about the pin's actual configuration, other than the fact that it's being used for input.

Constructors

InputDefault

The pin's default input mode, i.e., the mode used when a more specific mode is not specified

InputFloating

A floating / high-impedance / tri-state mode which uses little power, but when disconnected, may cause the pin's value to be indeterminate

InputPullUp

The pin is connected to an internal pull-up resistor such that, when the pin is disconnected or connected to a floating / high-impedance node, its physical value will be High

InputPullDown

The pin is connected to an internal pull-down resistor such that, when the pin is disconnected or connected to a floating / high-impedance node, its physical value will be Low

data PinOutputMode Source

GPIO pins may support a number of different physical configurations when used as a digital output.

Pins that are capable of output will at least support the OutputDefault mode. OutputDefault mode is special in that, unlike the other output modes, it does not represent a unique physical configuration, but is simply a pseudonym for another (actual) output mode. Exactly which mode is used by the hardware when OutputDefault mode is specified is platform-dependent. By using OutputDefaut mode, you are saying that you don't care about the pin's actual configuration, other than the fact that it's being used for output.

Constructors

OutputDefault

The pin's default output mode, i.e., the mode used when a more specific mode is not specified

OutputPushPull

The output actively drives both the High and Low states

OutputOpenDrain

The output actively drives the Low state, but High is left floating (also known as open collector)

OutputOpenDrainPullUp

The output actively drives the Low state, and is connected to an internal pull-up resistor in the High state.

OutputOpenSource

The output actively drives the High state, but Low is left floating (also known as open emitter)

OutputOpenSourcePullDown

The output actively drives the High state, and is connected to an internal pull-down resistor in the Low state.

data PinCapabilities Source

Catalog a pin's capabilities.

Constructors

PinCapabilities 

Fields

_inputModes :: Set PinInputMode

The set of input modes that the pin supports

_outputModes :: Set PinOutputMode

The set of output modes that the pin supports

_interrupts :: Bool

Does the pin support interrupts in input mode?

data PinInterruptMode Source

A pin's interrupt mode.

Note that the pin's interrupt mode is defined in terms of the pin's logical signal value; i.e., when the pin is configured for active-low logic, RisingEdge refers to the physical signal's trailing edge, and FallingEdge refers to the physical signal's rising edge.

Constructors

Disabled

Interrupts are disabled

RisingEdge

Interrupt on the pin's (logical) rising edge

FallingEdge

Interrupt on the pin's (logical) falling edge

Level

Interrupt on any change to the pin's signal level

Convenience functions

pinNumber :: Pin -> Int Source

Get the pin number as an Int.

>>> pinNumber (Pin 5)
5

invertDirection :: PinDirection -> PinDirection Source

Invert a PinDirection value.

>>> invertDirection In
Out
>>> invertDirection Out
In

invertValue :: PinValue -> PinValue Source

Invert a PinValue.

>>> invertValue High
Low
>>> invertValue Low
High

PinValue conversion to/from Bool

valueToBool :: PinValue -> Bool Source

Convert a PinValue to its logical boolean equivalent.

>>> valueToBool High
True
>>> valueToBool Low
False

boolToValue :: Bool -> PinValue Source

Convert a Bool to its logical PinValue equivalent.

>>> boolToValue True
High
>>> boolToValue False
Low

GPIO exceptions

data SomeGpioException Source

The top level of the GPIO exception hierarchy.

Constructors

forall e . Exception e => SomeGpioException e