Class: Denko::SPI::BitBang

Inherits:
Object
  • Object
show all
Includes:
Behaviors::Lifecycle, Behaviors::MultiPin, BusCommon
Defined in:
lib/denko/spi/bit_bang.rb

Constant Summary

Constants included from Behaviors::Reader

Behaviors::Reader::READ_WAIT_TIME

Constants included from Behaviors::Lifecycle

Behaviors::Lifecycle::CALLBACK_METHODS

Instance Attribute Summary

Attributes included from Behaviors::State

#state

Attributes included from Behaviors::Component

#board, #params

Attributes included from Behaviors::MultiPin

#pin, #pins, #proxies

Instance Method Summary collapse

Methods included from BusCommon

#add_component, #convert_pin, #remove_component, #set_pin_mode, #stop

Methods included from Behaviors::Reader

#_read, #read, #read_busy?, #read_nb, #read_raw, #read_using, #update

Methods included from Behaviors::Callbacks

#add_callback, #callbacks, #pre_callback_filter, #remove_callback, #update

Methods included from Behaviors::State

#update_state

Methods included from Behaviors::Lifecycle

included

Methods included from Behaviors::BusController

#mutex

Methods included from Behaviors::Subcomponents

#add_component, #add_hw_i2c, #add_hw_spi, #add_single_pin, #components, #hw_i2c_comps, #hw_spi_comps, #remove_component, #remove_hw_i2c, #remove_hw_spi, #remove_single_pin, #single_pin_components

Methods included from Behaviors::Component

#initialize, #micro_delay

Methods included from Behaviors::MultiPin

#convert_pins, #proxy_pin, #proxy_states, #require_pin, #require_pins

Instance Method Details

#initialize_pins(options = {}) ⇒ Object



23
24
25
26
27
# File 'lib/denko/spi/bit_bang.rb', line 23

def initialize_pins(options={})
  proxy_pin :clock,   DigitalIO::CBitBang
  proxy_pin :output,  DigitalIO::CBitBang if pins[:output]
  proxy_pin :input,   DigitalIO::CBitBang if pins[:input]
end

#listen(select_pin, read: 0, frequency: nil, mode: 0, bit_order: :msbfirst) ⇒ Object



34
35
36
37
# File 'lib/denko/spi/bit_bang.rb', line 34

def listen(select_pin, read: 0, frequency: nil, mode: 0, bit_order: :msbfirst)
  board.spi_bb_listen select_pin, clock: pins[:clock], input: pins[:input],
                                  read: read, mode: mode, bit_order: bit_order
end

#transfer(select_pin, write: [], read: 0, frequency: nil, mode: 0, bit_order: :msbfirst) ⇒ Object



29
30
31
32
# File 'lib/denko/spi/bit_bang.rb', line 29

def transfer(select_pin, write: [], read: 0, frequency: nil, mode: 0, bit_order: :msbfirst)
  board.spi_bb_transfer select_pin, clock: pins[:clock], output: pins[:output], input: pins[:input],
                                    write: write, read: read, mode: mode, bit_order: bit_order
end