-- | Like 'withPin', but for 'InputPin's. Sets the pin's input mode to
-- the specified 'PinInputMode' value.
--
-- If the optional active level argument is 'Nothing', then the pin's
-- active level is unchanged from its current state. Otherwise, the
-- pin's active level is set to the specified level.
--
-- It is an error to call this action if the pin cannot be configured
-- for input, or if it does not support the specified input mode.
withInputPin :: (MaskGpioM h m) => Pin -> PinInputMode -> Maybe PinActiveLevel -> (InputPin h -> m a) -> m a
withInputPin p mode l action =
  withPin p $ \h ->
    do setPinInputMode h mode
       maybeSetPinActiveLevel h l
       action $ InputPin h

-- | Like 'readPin'.
withInputPin :: (MaskGpioM h m) => Pin -> PinInputMode -> Maybe PinActiveLevel -> (InputPin h -> m a) -> m a
withInputPin p mode l action =
  withPin p $ \h ->
    do setPinInputMode h mode
       maybeSetPinActiveLevel h l
       action $ InputPin h

-- | Like 'readPin'.
withInputPin p mode l action =
  withPin p $ \h ->
    do setPinInputMode h mode
       maybeSetPinActiveLevel h l
       action $ InputPin h

-- | Like 'readPin'.