aboutsummaryrefslogtreecommitdiff
path: root/hsm-gpio/Hsm
diff options
context:
space:
mode:
Diffstat (limited to 'hsm-gpio/Hsm')
-rw-r--r--hsm-gpio/Hsm/GPIO.hs9
-rw-r--r--hsm-gpio/Hsm/GPIO/FFI.hs (renamed from hsm-gpio/Hsm/GPIO/FFI.hsc)14
2 files changed, 11 insertions, 12 deletions
diff --git a/hsm-gpio/Hsm/GPIO.hs b/hsm-gpio/Hsm/GPIO.hs
index 2bcf3ed..7cc2c36 100644
--- a/hsm-gpio/Hsm/GPIO.hs
+++ b/hsm-gpio/Hsm/GPIO.hs
@@ -73,8 +73,7 @@ setPins :: (GPIO :> es, Log "gpio" :> es) => [GPIOPin] -> LineValue -> Eff es ()
setPins pins lineValue = do
GPIO lineRequest <- getStaticRep
logMsg Trace $ "Setting pin(s) " <> show pins <> " to " <> show lineValue
- forM_ pins $ \pin ->
- unsafeEff_ $ lineRequestSetValue lineRequest (pinLine pin) lineValue
+ forM_ pins $ \pin -> unsafeEff_ $ lineRequestSetValue lineRequest (pinLine pin) lineValue
setAllPins :: (GPIO :> es, Log "gpio" :> es) => LineValue -> Eff es ()
setAllPins lineValue = do
@@ -122,8 +121,7 @@ runGPIO consumer action = do
lineSettingsDealloc lineSettings = do
logMsg Info "Freeing line settings"
liftIO $ lineSettingsFree lineSettings
- lineConfigBracket lineSettings =
- allocateEff lineConfigAlloc lineConfigDealloc
+ lineConfigBracket lineSettings = allocateEff lineConfigAlloc lineConfigDealloc
where
lineConfigAlloc = do
logMsg Info "Allocating line config"
@@ -150,8 +148,7 @@ runGPIO consumer action = do
requestConfigDealloc requestConfig = do
logMsg Info "Freeing request config"
liftIO $ requestConfigFree requestConfig
- lineRequestBracket chip requestConfig lineConfig =
- allocateEff lineRequestAlloc lineRequestDealloc
+ lineRequestBracket chip requestConfig lineConfig = allocateEff lineRequestAlloc lineRequestDealloc
where
lineRequestAlloc = do
logMsg Info "Allocating line request"
diff --git a/hsm-gpio/Hsm/GPIO/FFI.hsc b/hsm-gpio/Hsm/GPIO/FFI.hs
index f0f5737..c1bb9e8 100644
--- a/hsm-gpio/Hsm/GPIO/FFI.hsc
+++ b/hsm-gpio/Hsm/GPIO/FFI.hs
@@ -51,20 +51,20 @@ newtype LineDirection
= LineDirection CInt
deriving Show
-foreign import capi "gpiod.h value GPIOD_LINE_DIRECTION_INPUT"
+foreign import capi safe "gpiod.h value GPIOD_LINE_DIRECTION_INPUT"
input :: LineDirection
-foreign import capi "gpiod.h value GPIOD_LINE_DIRECTION_OUTPUT"
+foreign import capi safe "gpiod.h value GPIOD_LINE_DIRECTION_OUTPUT"
output :: LineDirection
newtype LineValue
= LineValue CInt
deriving (Show, Storable)
-foreign import capi "gpiod.h value GPIOD_LINE_VALUE_ACTIVE"
+foreign import capi safe "gpiod.h value GPIOD_LINE_VALUE_ACTIVE"
active :: LineValue
-foreign import capi "gpiod.h value GPIOD_LINE_VALUE_INACTIVE"
+foreign import capi safe "gpiod.h value GPIOD_LINE_VALUE_INACTIVE"
inactive :: LineValue
foreign import capi unsafe "gpiod.h gpiod_line_settings_new"
@@ -88,7 +88,8 @@ foreign import capi unsafe "gpiod.h gpiod_line_config_free"
lineConfigFree :: Ptr LineConfig -> IO ()
foreign import capi unsafe "gpiod.h gpiod_line_config_add_line_settings"
- lineConfigAddLineSettings :: Ptr LineConfig -> Ptr CUInt -> CSize -> Ptr LineSettings -> IO CInt
+ lineConfigAddLineSettings
+ :: Ptr LineConfig -> Ptr CUInt -> CSize -> Ptr LineSettings -> IO CInt
data RequestConfig
@@ -104,7 +105,8 @@ foreign import capi unsafe "gpiod.h gpiod_request_config_set_consumer"
data LineRequest
foreign import capi unsafe "gpiod.h gpiod_chip_request_lines"
- chipRequestLines :: Ptr Chip -> Ptr RequestConfig -> Ptr LineConfig -> IO (Ptr LineRequest)
+ chipRequestLines
+ :: Ptr Chip -> Ptr RequestConfig -> Ptr LineConfig -> IO (Ptr LineRequest)
foreign import capi unsafe "gpiod.h gpiod_line_request_release"
lineRequestRelease :: Ptr LineRequest -> IO ()