Module: Denko::SPI::Peripheral
- Included in:
- AnalogIO::ADS1118, LED::APA102, BaseRegister
- Defined in:
- lib/denko/spi/peripheral.rb
Instance Attribute Summary collapse
-
#spi_bit_order ⇒ Object
readonly
Returns the value of attribute spi_bit_order.
-
#spi_frequency ⇒ Object
readonly
Returns the value of attribute spi_frequency.
-
#spi_mode ⇒ Object
readonly
Returns the value of attribute spi_mode.
Attributes included from Behaviors::BusPeripheral
Attributes included from Behaviors::Component
Attributes included from Behaviors::Callbacks
Attributes included from Behaviors::SinglePin
Instance Method Summary collapse
- #before_initialize(options = {}) ⇒ Object
- #spi_listen(num_bytes) ⇒ Object
- #spi_read(num_bytes) ⇒ Object
- #spi_stop ⇒ Object
-
#spi_transfer(write: [], read: 0) ⇒ Object
Delegate methods to the bus.
- #spi_write(byte_array) ⇒ Object
Methods included from Behaviors::BusPeripheral
Methods included from Behaviors::Component
Methods included from Behaviors::State
Methods included from Behaviors::Callbacks
#add_callback, #callbacks, #initialize, #pre_callback_filter, #remove_callback, #update
Instance Attribute Details
#spi_bit_order ⇒ Object (readonly)
Returns the value of attribute spi_bit_order.
8 9 10 |
# File 'lib/denko/spi/peripheral.rb', line 8 def spi_bit_order @spi_bit_order end |
#spi_frequency ⇒ Object (readonly)
Returns the value of attribute spi_frequency.
8 9 10 |
# File 'lib/denko/spi/peripheral.rb', line 8 def spi_frequency @spi_frequency end |
#spi_mode ⇒ Object (readonly)
Returns the value of attribute spi_mode.
8 9 10 |
# File 'lib/denko/spi/peripheral.rb', line 8 def spi_mode @spi_mode end |
Instance Method Details
#before_initialize(options = {}) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/denko/spi/peripheral.rb', line 10 def before_initialize(={}) super() # Save SPI settings. @spi_frequency = [:spi_frequency] @spi_mode = [:spi_mode] @spi_bit_order = [:spi_bit_order] end |
#spi_listen(num_bytes) ⇒ Object
34 35 36 |
# File 'lib/denko/spi/peripheral.rb', line 34 def spi_listen(num_bytes) bus.listen(pin, read: num_bytes, frequency: spi_frequency, mode: spi_mode, bit_order: spi_bit_order) end |
#spi_read(num_bytes) ⇒ Object
30 31 32 |
# File 'lib/denko/spi/peripheral.rb', line 30 def spi_read(num_bytes) bus.transfer(pin, read: num_bytes, frequency: spi_frequency, mode: spi_mode, bit_order: spi_bit_order) end |
#spi_stop ⇒ Object
38 39 40 |
# File 'lib/denko/spi/peripheral.rb', line 38 def spi_stop bus.stop(pin) end |
#spi_transfer(write: [], read: 0) ⇒ Object
Delegate methods to the bus.
22 23 24 |
# File 'lib/denko/spi/peripheral.rb', line 22 def spi_transfer(write: [], read: 0) bus.transfer(pin, write: write, read: read, frequency: spi_frequency, mode: spi_mode, bit_order: spi_bit_order) end |
#spi_write(byte_array) ⇒ Object
26 27 28 |
# File 'lib/denko/spi/peripheral.rb', line 26 def spi_write(byte_array) bus.transfer(pin, write: byte_array, frequency: spi_frequency, mode: spi_mode, bit_order: spi_bit_order) end |