Copyright | (c) Marc Fontaine 2017 |
---|---|
License | BSD3 |
Maintainer | Marc.Fontaine@gmx.de |
Stability | experimental |
Portability | GHC-only |
Safe Haskell | Safe |
Language | Haskell98 |
This module provides an I2C interface based Linux /devi2c-xxx
- type Addr = Word8
- type Command = Word8
- type Device = Fd
- withDevice :: FilePath -> (Device -> IO a) -> IO a
- openDevice :: FilePath -> IO Device
- closeDevice :: Device -> IO ()
- setSlaveAddr :: HasCallStack => Device -> Addr -> IO ()
- setSlaveAddrForce :: HasCallStack => Device -> Addr -> IO ()
- writeByte :: HasCallStack => Device -> Command -> IO ()
- writeByteData :: HasCallStack => Device -> Command -> Word8 -> IO ()
- readByte :: HasCallStack => Device -> IO ()
- readByteData :: HasCallStack => Device -> Command -> IO Word8
- readI2CBlockData :: HasCallStack => Device -> Command -> Int -> IO ByteString
- writeI2CBlockData :: HasCallStack => Device -> Command -> ByteString -> IO ()
Documentation
withDevice :: FilePath -> (Device -> IO a) -> IO a Source #
Open an I2C device run, an IO action and close the device again. A device file on Linux could be for example /dev/i2c-7.
closeDevice :: Device -> IO () Source #
Close an I2C Device.
setSlaveAddr :: HasCallStack => Device -> Addr -> IO () Source #
Set the address of the I2C Slave
setSlaveAddrForce :: HasCallStack => Device -> Addr -> IO () Source #
writeByteData :: HasCallStack => Device -> Command -> Word8 -> IO () Source #
readByteData :: HasCallStack => Device -> Command -> IO Word8 Source #
readI2CBlockData :: HasCallStack => Device -> Command -> Int -> IO ByteString Source #
writeI2CBlockData :: HasCallStack => Device -> Command -> ByteString -> IO () Source #