Class: Denko::SPI::BaseRegister
- Inherits:
-
Object
- Object
- Denko::SPI::BaseRegister
- Includes:
- Behaviors::BoardProxy, Peripheral
- Defined in:
- lib/denko/spi/base_register.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#bytes ⇒ Object
readonly
Returns the value of attribute bytes.
Attributes included from Peripheral
#spi_bit_order, #spi_frequency, #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
Methods included from Behaviors::BoardProxy
#convert_pin, #high, #low, #set_pin_mode, #start_read
Methods included from Behaviors::Subcomponents
#add_component, #components, #remove_component, #single_pin_components
Methods included from Peripheral
#spi_listen, #spi_read, #spi_stop, #spi_transfer, #spi_write
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
#bytes ⇒ Object (readonly)
Returns the value of attribute bytes.
12 13 14 |
# File 'lib/denko/spi/base_register.rb', line 12 def bytes @bytes end |
Instance Method Details
#after_initialize(options = {}) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/denko/spi/base_register.rb', line 29 def after_initialize(={}) super() # Drive select pin high by default. self.high end |
#before_initialize(options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/denko/spi/base_register.rb', line 14 def before_initialize(={}) super() # # To use the register as a board proxy, we need to know how many # bytes there are and map each bit to a virtual pin. # Defaults to 1 byte. Ignore if writing to the register directly. # @bytes = [:bytes] || 1 # # When used as a board proxy, store the state of each register # pin as a 0 or 1 in an array that is (@bytes * 8) long. Zero out to start. # @state = Array.new(@bytes*8) { 0 } end |