bus-pirate-0.4: Haskell interface to the Bus Pirate binary interface

Safe HaskellNone

System.Hardware.BusPirate.I2C

Contents

Synopsis

Bus operations

i2cMode :: I2cM a -> BusPirateM aSource

Enter I2C mode and run given action

startBit :: I2cM ()Source

Send a start bit

stopBit :: I2cM ()Source

Send a stop bit

readByte :: I2cM Word8Source

Read a byte

ackBit :: I2cM ()Source

Send an ACK

nackBit :: I2cM ()Source

Send a NACK

bulkWrite :: ByteString -> I2cM ()Source

Write some bytes

writeRead :: ByteString -> Int -> I2cM ByteStringSource

Send Start bit, write some bytes, then read some bytes (ACKing each until the last), then send a stop bit

Configuration

data I2cConfig Source

Constructors

I2cConfig 

Instances

setConfig :: I2cConfig -> I2cM ()Source

Set Bus Pirate I2C configuration bits

setSpeed :: I2cSpeed -> I2cM ()Source

Set I2C bus speed

Device addresses

data I2CAddress Source

An I2C address (shifted 7-bit)

from7Bit :: Word8 -> I2CAddressSource

An I2C address from a unshifted 7-bit address

from8Bit :: Word8 -> I2CAddressSource

An I2C address from a shifted 8-bit address (masking out the read/write bit)

Register interface

writeReg :: I2CAddress -> Word8 -> Word8 -> I2cM ()Source

Perform a write to the given register

readReg :: I2CAddress -> Word8 -> I2cM Word8Source

Read the given register

readReg' :: I2CAddress -> Word8 -> Int -> I2cM ByteStringSource

Perform a read of the given length starting at the given register