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 is something fails.
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 is something fails.
(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")
Defaults values for options used throughout this library.
Defaults values for options used throughout this library.
(read bus length)
Reads an arbitrary amount of bytes.
Reads an arbitrary amount of bytes.
(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.
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. Ex. (select-slave some-bus 0x42 {::10-bit? false ::force? false})
(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.
(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.
(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.
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. Ex. (transaction some-bus [{::slave-address 0x42 ::write [24 1 2 3]} {::slave-address 0x42 ::read 3 ::tag :my-read}]) => {:my-read [...]}
cljdoc builds & hosts documentation for Clojure/Script libraries
Ctrl+k | Jump to recent docs |
← | Move to previous article |
→ | Move to next article |
Ctrl+/ | Jump to the search field |