From ee8631e9fd24d3362eb16dab008b3f9ef9e4fb7b Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Thu, 31 Aug 2023 16:46:34 +0100 Subject: [PATCH] AP_HAL_ChibiOS: cope with different IMU drivers in hwdef conversion --- .../scripts/convert_betaflight_unified.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/convert_betaflight_unified.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/convert_betaflight_unified.py index 4c1a259e79..cf3194c694 100755 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/convert_betaflight_unified.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/convert_betaflight_unified.py @@ -106,8 +106,25 @@ def write_imu_config(f, n): f.write(''' # IMU setup SPIDEV imu%s SPI%s DEVID1 GYRO%s_CS MODE3 1*MHZ 8*MHZ -IMU Invensense SPI:imu%s %s -''' % (n, bus, n, n, alignment[align])) +''' % (n, bus, n)) + + c = 0 + for define in defines: + for imudefine in ['USE_GYRO_SPI_', 'USE_ACCGYRO_']: + if define.startswith(imudefine): + imu = define[len(imudefine):] + c = c + 1 + if c == int(n): + if imu == 'ICM42688P': + imudriver = 'Invensensev3' + elif imu == 'BMI270': + imudriver = 'BMI270' + else: + imudriver = 'Invensense' + f.write(''' +IMU %s SPI:imu%s %s +''' % (imudriver, n, alignment[align])) + dma = "SPI" + bus + "*" dma_noshare[dma] = dma