class BBB::Pins::IO::I2C
Attributes
backend[R]
Public Class Methods
new(path)
click to toggle source
Initializes two I2C
pins. The initializer takes the cape argument, where most other IO
classes in the library take a position. This is because it seems more natural to indicate BB-I2C1 as opposed to figuring out that I2C1 is mapped to P9_18, and P9_17 (sda, scl) and then give those positions.
@param cape [String] The cape name of the I2C
chip.
# File lib/BBB/pins/io/i2c.rb, line 21 def initialize(path) @path = path self.export end
Public Instance Methods
export()
click to toggle source
# File lib/BBB/pins/io/i2c.rb, line 30 def export if pin_map.respond_to?(:devicetee) system("echo #{pinmap.devicetree} > #{cape_dir}") end sleep(0.2) # Give the kernel time to load the cape @backend = ::I2C.create(pin_map.path) end
pin_map_key()
click to toggle source
# File lib/BBB/pins/io/i2c.rb, line 46 def pin_map_key :path end
position()
click to toggle source
# File lib/BBB/pins/io/i2c.rb, line 26 def position @path end
read(address, size, *params)
click to toggle source
# File lib/BBB/pins/io/i2c.rb, line 42 def read(address, size, *params) @backend.read(address, size, *params) end
write(address, *params)
click to toggle source
# File lib/BBB/pins/io/i2c.rb, line 38 def write(address, *params) @backend.write(address, *params) end