aboutsummaryrefslogtreecommitdiff
path: root/hsm-gpio/Hsm/GPIO/FFI.hs
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2025-09-07 19:23:37 +0000
committerPaul Oliver <contact@pauloliver.dev>2025-09-07 19:49:03 +0000
commit89aab732dc3d484b99c0761728285bca6f6b1ba0 (patch)
treee2b4ca6656758dc9f398b9b1de2e6d92670b77df /hsm-gpio/Hsm/GPIO/FFI.hs
parentef0713cbd90d6b84da7ea67e6dfc1fe5ab5bff86 (diff)
Adds another formatting/cleaning roundHEADmaster
Diffstat (limited to 'hsm-gpio/Hsm/GPIO/FFI.hs')
-rw-r--r--hsm-gpio/Hsm/GPIO/FFI.hs95
1 files changed, 0 insertions, 95 deletions
diff --git a/hsm-gpio/Hsm/GPIO/FFI.hs b/hsm-gpio/Hsm/GPIO/FFI.hs
deleted file mode 100644
index 2589e5e..0000000
--- a/hsm-gpio/Hsm/GPIO/FFI.hs
+++ /dev/null
@@ -1,95 +0,0 @@
-{-# LANGUAGE CApiFFI #-}
-
--- FFI bindings to `libgpiod` for direct GPIO hardware access.
---
--- Exposes only the minimal required subset of `libgpiod` functionality used by
--- this project. The bindings are suitable for low-level hardware control.
---
--- Future work could expand this into a comprehensive `gpiod` binding package.
-module Hsm.GPIO.FFI
- ( chipOpen
- , chipClose
- , input
- , output
- , LineValue
- , active
- , inactive
- , lineSettingsNew
- , lineSettingsFree
- , lineSettingsSetDirection
- , lineSettingsSetOutputValue
- , lineConfigNew
- , lineConfigFree
- , lineConfigAddLineSettings
- , requestConfigNew
- , requestConfigFree
- , requestConfigSetConsumer
- , LineRequest
- , chipRequestLines
- , lineRequestRelease
- , lineRequestSetValue
- , lineRequestSetValues
- ) where
-
-import Foreign.C.String (CString)
-import Foreign.C.Types (CInt(CInt), CSize(CSize), CUInt(CUInt))
-import Foreign.Ptr (Ptr)
-import Foreign.Storable (Storable)
-
-data Chip
-
-foreign import capi safe "gpiod.h gpiod_chip_open" chipOpen :: CString -> IO (Ptr Chip)
-
-foreign import capi safe "gpiod.h gpiod_chip_close" chipClose :: Ptr Chip -> IO ()
-
-data LineSettings
-
-newtype LineDirection =
- LineDirection CInt
- deriving (Show)
-
-foreign import capi safe "gpiod.h value GPIOD_LINE_DIRECTION_INPUT" input :: LineDirection
-
-foreign import capi safe "gpiod.h value GPIOD_LINE_DIRECTION_OUTPUT" output :: LineDirection
-
-newtype LineValue =
- LineValue CInt
- deriving (Show, Storable)
-
-foreign import capi safe "gpiod.h value GPIOD_LINE_VALUE_ACTIVE" active :: LineValue
-
-foreign import capi safe "gpiod.h value GPIOD_LINE_VALUE_INACTIVE" inactive :: LineValue
-
-foreign import capi safe "gpiod.h gpiod_line_settings_new" lineSettingsNew :: IO (Ptr LineSettings)
-
-foreign import capi safe "gpiod.h gpiod_line_settings_free" lineSettingsFree :: Ptr LineSettings -> IO ()
-
-foreign import capi safe "gpiod.h gpiod_line_settings_set_direction" lineSettingsSetDirection :: Ptr LineSettings -> LineDirection -> IO CInt
-
-foreign import capi safe "gpiod.h gpiod_line_settings_set_output_value" lineSettingsSetOutputValue :: Ptr LineSettings -> LineValue -> IO CInt
-
-data LineConfig
-
-foreign import capi safe "gpiod.h gpiod_line_config_new" lineConfigNew :: IO (Ptr LineConfig)
-
-foreign import capi safe "gpiod.h gpiod_line_config_free" lineConfigFree :: Ptr LineConfig -> IO ()
-
-foreign import capi safe "gpiod.h gpiod_line_config_add_line_settings" lineConfigAddLineSettings :: Ptr LineConfig -> Ptr CUInt -> CSize -> Ptr LineSettings -> IO CInt
-
-data RequestConfig
-
-foreign import capi safe "gpiod.h gpiod_request_config_new" requestConfigNew :: IO (Ptr RequestConfig)
-
-foreign import capi safe "gpiod.h gpiod_request_config_free" requestConfigFree :: Ptr RequestConfig -> IO ()
-
-foreign import capi safe "gpiod.h gpiod_request_config_set_consumer" requestConfigSetConsumer :: Ptr RequestConfig -> CString -> IO ()
-
-data LineRequest
-
-foreign import capi safe "gpiod.h gpiod_chip_request_lines" chipRequestLines :: Ptr Chip -> Ptr RequestConfig -> Ptr LineConfig -> IO (Ptr LineRequest)
-
-foreign import capi safe "gpiod.h gpiod_line_request_release" lineRequestRelease :: Ptr LineRequest -> IO ()
-
-foreign import capi safe "gpiod.h gpiod_line_request_set_value" lineRequestSetValue :: Ptr LineRequest -> CUInt -> LineValue -> IO CInt
-
-foreign import capi safe "gpiod.h gpiod_line_request_set_values" lineRequestSetValues :: Ptr LineRequest -> Ptr LineValue -> IO CInt