diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index ffef024682..eb5dd6776e 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -797,12 +797,20 @@ def parse_i2c_device(dev): busnum = int(a[1]) return ('', 'GET_I2C_DEVICE(%u,0x%02x)' % (busnum, busaddr)) +def seen_str(dev): + '''return string representation of device for checking for duplicates''' + return str(dev[:2]) + def write_IMU_config(f): '''write IMU config defines''' global imu_list devlist = [] wrapper = '' + seen = set() for dev in imu_list: + if seen_str(dev) in seen: + error("Duplicate IMU: %s" % seen_str(dev)) + seen.add(seen_str(dev)) driver = dev[0] for i in range(1,len(dev)): if dev[i].startswith("SPI:"): @@ -818,10 +826,14 @@ def write_IMU_config(f): f.write('#define HAL_INS_PROBE_LIST %s\n\n' % ';'.join(devlist)) def write_MAG_config(f): - '''write IMU config defines''' + '''write MAG config defines''' global compass_list devlist = [] + seen = set() for dev in compass_list: + if seen_str(dev) in seen: + error("Duplicate MAG: %s" % seen_str(dev)) + seen.add(seen_str(dev)) driver = dev[0] probe = 'probe' wrapper = '' @@ -846,7 +858,11 @@ def write_BARO_config(f): '''write barometer config defines''' global baro_list devlist = [] + seen = set() for dev in baro_list: + if seen_str(dev) in seen: + error("Duplicate BARO: %s" % seen_str(dev)) + seen.add(seen_str(dev)) driver = dev[0] probe = 'probe' wrapper = ''