i2ccmds: Pass the i2c address as a 7-bit number (0-127)

The sam3 i2c code and the linux code use a 7-bit i2c address, while
the avr, lpc176x, and samd21 i2c code uses an 8-bit address with the
least significant bit always zero.  A similar issue occurred in the
host code (sx1509.py and replicape.py use 7-bit addresses while
uc1701.py and mcp4451.py use 8-bit addresses).

Consistently use 7-bit addresses in all the code.  This breaks
compatibility between host and mcu software, so make a change to the
config_i2c command to force users to synchronize software updates.
This also breaks common Smoothieboard configs, so update the mcp4451
code to validate the i2c_address.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-12-27 19:11:46 -05:00 committed by KevinOConnor
parent f2f54290e8
commit e26d1a3567
10 changed files with 28 additions and 17 deletions

View file

@ -10,6 +10,9 @@ WiperRegisters = [0x00, 0x01, 0x06, 0x07]
class mcp4451:
def __init__(self, config):
self.i2c = bus.MCU_I2C_from_config(config)
i2c_addr = self.i2c.get_i2c_address()
if i2c_addr < 44 or i2c_addr > 47:
raise config.error("mcp4451 address must be between 44 and 47")
scale = config.getfloat('scale', 1., above=0.)
# Configure registers
self.set_register(0x04, 0xff)