Class: UChip::MCP2221::I2CProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/uchip/mcp2221.rb

Instance Method Summary collapse

Constructor Details

#initialize(address, handler) ⇒ I2CProxy

Returns a new instance of I2CProxy.



244
245
246
247
248
# File 'lib/uchip/mcp2221.rb', line 244

def initialize address, handler
  @read_address  = (address << 1) | 1
  @write_address = address << 1
  @handler       = handler
end

Instance Method Details

#cancelObject



250
# File 'lib/uchip/mcp2221.rb', line 250

def cancel; @handler.i2c_cancel; end

#read(size) ⇒ Object



256
257
258
259
# File 'lib/uchip/mcp2221.rb', line 256

def read size
  @handler.i2c_read_start @read_address, 8
  @handler.i2c_read
end

#write(buf) ⇒ Object



252
253
254
# File 'lib/uchip/mcp2221.rb', line 252

def write buf
  @handler.i2c_write @write_address, buf
end