Class: Bucaneer::Protocol::SPI
- Inherits:
-
Object
- Object
- Bucaneer::Protocol::SPI
- Defined in:
- lib/bucaneer/protocol/spi.rb
Overview
SPI bitbang on the BusPirate:
http://dangerousprototypes.com/docs/SPI_(binary)
SPI protocol:
http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
Constant Summary collapse
- SPI_MODE =
0x01
- SET_CS =
0x02
- SET_SPEED =
0x61
- BULK_WRITE =
0x10
- ENABLE =
0x01
- CHUNK_SIZE =
16
Instance Method Summary collapse
-
#initialize(controller, options = {}) ⇒ SPI
constructor
A new instance of SPI.
- #tx(bytes) ⇒ Object
Constructor Details
Instance Method Details
#tx(bytes) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bucaneer/protocol/spi.rb', line 25 def tx(bytes) set_cs(false) sleep 0.0005 bytes.to_enum.each_slice(CHUNK_SIZE) do |chunk| start_bulk_write(chunk.length) chunk.each do |byte| @controller.serial_port.putc byte end @controller.serial_port.read(chunk.length) end sleep 0.0005 set_cs(true) end |