| Copyright | (c) 2017 Quixoftic LLC |
|---|---|
| License | BSD3 |
| Maintainer | Drew Hess <dhess-src@quixoftic.com> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
System.GPIO.Types
Description
Basic GPIO types.
- newtype Pin = Pin Int
- data PinInputMode
- data PinOutputMode
- data PinCapabilities = PinCapabilities {}
- data PinDirection
- data PinActiveLevel
- data PinValue
- data PinInterruptMode
- pinNumber :: Pin -> Int
- invertDirection :: PinDirection -> PinDirection
- invertValue :: PinValue -> PinValue
- valueToBool :: PinValue -> Bool
- boolToValue :: Bool -> PinValue
- data SomeGpioException = Exception e => SomeGpioException e
- gpioExceptionToException :: Exception e => e -> SomeException
- gpioExceptionFromException :: Exception e => SomeException -> Maybe e
GPIO pins
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.
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 |
| 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 |
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 | |
| OutputOpenDrain | The output actively drives the |
| OutputOpenDrainPullUp | The output actively drives the |
| OutputOpenSource | The output actively drives the |
| OutputOpenSourcePullDown | The output actively drives the |
data PinCapabilities Source #
Catalog a pin's capabilities.
Constructors
| PinCapabilities | |
Fields
| |
Instances
data PinDirection Source #
A pin's direction (input/output).
Instances
data PinActiveLevel Source #
A pin's active level (active-high/active-low).
Constructors
| ActiveLow | |
| ActiveHigh |
Instances
A pin's signal level as a binary value.
Instances
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 |
Instances
Convenience functions
invertDirection :: PinDirection -> PinDirection Source #
Invert a PinDirection value.
>>>invertDirection InOut>>>invertDirection OutIn
invertValue :: PinValue -> PinValue Source #
Invert a PinValue.
>>>invertValue HighLow>>>invertValue LowHigh
PinValue conversion to/from Bool
valueToBool :: PinValue -> Bool Source #
Convert a PinValue to its logical boolean equivalent.
>>>valueToBool HighTrue>>>valueToBool LowFalse
boolToValue :: Bool -> PinValue Source #
GPIO exceptions
data SomeGpioException Source #
The top level of the GPIO exception hierarchy.
Constructors
| Exception e => SomeGpioException e |
Instances
gpioExceptionToException :: Exception e => e -> SomeException Source #
Convert SomeGpioException to SomeException.
gpioExceptionFromException :: Exception e => SomeException -> Maybe e Source #
Ask whether an exception is SomeGpioException.