Spi
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
Repository
Spi
Owner
Statistic
- 0
- 0
- 0
- 1
- 0
- 9 months ago
- January 25, 2024
License
MIT License
Links
Synced at
Thu, 21 Nov 2024 23:28:03 GMT
Languages