github.com/sleepinginsomniac/spi
master / published Jan 30, 2024 / repository
SPI Interface for raspberry pi
Spi
Crystal interface to the SPI driver on the Raspberry PI. This uses the userland IOCTL SPI interface to send and receive data on the raspberry pi.
Installation
-
Add the dependency to your
shard.yml:dependencies: spi: github: sleepinginsomniac/spi -
Run
shards install
Usage
require "spi"
device = Spi::Device.new("/dev/spidev0.0")
device.mode = Spi::Mode::MODE_1
device.bits_per_word = 8_u8
device.baud = 800_000_u32 # 800KHz or whatever is supported
# Send 1 byte
data = Slice[0xAAu8] # etc.
device.send(data)
# Receive 10 bytes
data = Slice(UInt8).new(10)
device.receive(data)
# Duplex data:
dout = Slice[0xAAu8]
din = Slice(UInt8).new(1)
device.transfer(send: dout, recv: din)
Development
TODO: Write development instructions here
Contributing
- Fork it (https://github.com/sleepinginsomniac/spi/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Alex Clink - creator and maintainer