Liking cljdoc? Tell your friends :D

dvlopt.linux.i2c

The Linux kernel provides a standard interface for performing I2C operations.

This library exposes this interface in a clojure idiomatic way.

Each IO operation might throw if something fails.

Essentially, IO can be performed by directly reading and writing arbitrary bytes, doing transactions (uninterrupted sequence of messages) and using standard SMBus operations.

Not everything is supported by your driver, refer to capabilities. Furthermore, slave devices are often buggy and imperfect.

The Linux kernel provides a standard interface for performing I2C operations.

This library exposes this interface in a clojure idiomatic way.

Each IO operation might throw if something fails.

Essentially, IO can be performed by directly reading and writing arbitrary bytes, doing
transactions (uninterrupted sequence of messages) and using standard SMBus operations.

Not everything is supported by your driver, refer to `capabilities`. Furthermore, slave devices
are often buggy and imperfect.
raw docstring

busclj

(bus bus-path)

Opens an I2C bus by providing the number of the bus or a direct path.

Ex. (bus "/dev/i2c-1")

Opens an I2C bus by providing the number of the bus or a direct path.


Ex. (bus "/dev/i2c-1")
sourceraw docstring

capabilitiesclj

(capabilities bus)

Retrieves the capabilities of the given bus.

Not every driver is capable of doing everything this library offers, specially when it comes to SMBus operations.

Even then, support can be unperfect. For instance, sometimes transactions are supported but fail when they contain more than 1 message, which makes them quite useless.

Furthermore, a lot also depends on the slave device.

Functions from this library document what need to be checked.

Retrieves the capabilities of the given bus.

Not every driver is capable of doing everything this library offers, specially when it comes to SMBus operations.

Even then, support can be unperfect. For instance, sometimes transactions are supported but fail when they contain
more than 1 message, which makes them quite useless.

Furthermore, a lot also depends on the slave device.

Functions from this library document what need to be checked.
sourceraw docstring

closeclj

(close bus)

Closes an I2C bus.

Closes an I2C bus.
sourceraw docstring

defaultsclj

Defaults values for options used throughout this library.

Defaults values for options used throughout this library.
sourceraw docstring

readclj

(read bus length)

Reads an arbitrary amount of bytes.

Reads an arbitrary amount of bytes.
sourceraw docstring

select-slaveclj

(select-slave bus slave-address)
(select-slave bus slave-address slave-options)

Selects an I2C slave device.

Affects every IO operations besides transactions where the slave address is given for each message.

Cf. capabilities for :10-bit-addressing.

Ex. (select-slave some-bus 0x42 {::10-bit? false ::force? false})

Selects an I2C slave device.

Affects every IO operations besides transactions where the slave address is given for each message.

Cf. `capabilities` for :10-bit-addressing.


Ex. (select-slave some-bus
                  0x42
                  {::10-bit? false
                   ::force?  false})
sourceraw docstring

set-retriesclj

(set-retries bus retries)

Sets the number of retries when communication fails.

Does not always produce an effect depending on the underlying driver.

Sets the number of retries when communication fails.

Does not always produce an effect depending on the underlying driver.
sourceraw docstring

set-timeoutclj

(set-timeout bus timeout-ms)

Sets the timeout in milliseconds for slave responses.

Does not always produce an effect depending on the underlying driver.

Sets the timeout in milliseconds for slave responses.

Does not always produce an effect depending on the underlying driver.
sourceraw docstring

transactionclj

(transaction bus messages)

A transaction represents a sequence of messages, reads and writes, meant to be carried out without interruption.

Not every device supports this feature, or sometimes only supports 1 message per transaction with defeats their purpose.

Each message specifies if it is a read or a write and consists of options :

::10-bit? Should the 10-bit addressing mode be used ? ::ignore-nak? Should "not-acknowledge" be ignored ? ::no-read-ack? Should read-acks be ignored ? ::no-start? Should not issue any more START/address after the initial one. ::revise-wr-bit? Should send a read flag for writes and vice-versa (for broken slave) ? ::slave-address Which slave. ::tag Any value associated with the message, important for reads (the number of the message by default).

After the transaction is carried out, a map of tag -> bytes is returned for reads.

Cf. capabilities for :10-bit-addressing as well as other booleans flags under the :protocol-mangling capability.

Ex. (transaction some-bus [{::slave-address 0x42 ::write [24 1 2 3]} {::slave-address 0x42 ::read 3 ::tag :my-read}])

=> {:my-read [...]}
A transaction represents a sequence of messages, reads and writes, meant to be carried out without interruption.

Not every device supports this feature, or sometimes only supports 1 message per transaction with defeats their purpose.

Each message specifies if it is a read or a write and consists of options :

  ::10-bit?         Should the 10-bit addressing mode be used ?
  ::ignore-nak?     Should "not-acknowledge" be ignored ?
  ::no-read-ack?    Should read-acks be ignored ?
  ::no-start?       Should not issue any more START/address after the initial one.
  ::revise-wr-bit?  Should send a read flag for writes and vice-versa (for broken slave) ?
  ::slave-address   Which slave.
  ::tag             Any value associated with the message, important for reads (the number of the message
                    by default).

After the transaction is carried out, a map of tag -> bytes is returned for reads.

Cf. `capabilities` for :10-bit-addressing as well as other booleans flags under the :protocol-mangling capability.


Ex. (transaction some-bus
                 [{::slave-address 0x42
                   ::write         [24 1 2 3]}
                  {::slave-address 0x42
                   ::read          3
                   ::tag           :my-read}])

    => {:my-read [...]}
sourceraw docstring

writeclj

(write bus bs)

Writes a sequence of bytes.

Writes a sequence of bytes.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close