From a1661f8918fe6f3b49e696009db6399b5ca9d05a Mon Sep 17 00:00:00 2001 From: bugobliterator Date: Fri, 13 Oct 2023 15:26:56 +1100 Subject: [PATCH] AP_HAL_ChibiOS: fix mode setting for ICM45686 on CubeOrangePlus --- .../hwdef/CubeOrangePlus/hwdef.dat | 4 ++-- .../hwdef/scripts/chibios_hwdef.py | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus/hwdef.dat index 12b6caec69..6a3d2858d6 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus/hwdef.dat @@ -48,9 +48,9 @@ SPIDEV icm42688_ext SPI4 DEVID4 ACCEL_EXT_CS MODE3 2*MHZ 8*MHZ SPIDEV icm42688_ext2 SPI4 DEVID5 GYRO_EXT_CS MODE3 2*MHZ 8*MHZ #IMU 2 -SPIDEV icm45686 SPI1 DEVID4 ICM45686_CS MODE1 2*MHZ 8*MHZ +SPIDEV icm45686 SPI1 DEVID4 ICM45686_CS MODE0 2*MHZ 8*MHZ SPIDEV icm20649 SPI1 DEVID4 MPU_CS MODE3 4*MHZ 8*MHZ -SPIDEV icm45686_aux SPI1 DEVID4 ICM45686_CS MODE1 2*MHZ 8*MHZ +SPIDEV icm45686_aux SPI1 DEVID4 ICM45686_CS MODE0 2*MHZ 8*MHZ SPIDEV icm20948_aux SPI4 DEVID1 MPU_EXT_CS MODE3 4*MHZ 8*MHZ # INSTANCE: keyword is used to denote the instance number of the sensor diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index 101d03de18..33bd6c91c0 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -1403,26 +1403,28 @@ def write_SPI_table(f): f.write("\n") -def write_SPI_config(self, f): +def write_SPI_config(f): '''write SPI config defines''' - for t in list(self.bytype.keys()) + list(self.alttype.keys()): + global spi_list + for t in list(bytype.keys()) + list(alttype.keys()): if t.startswith('SPI'): - self.spi_list.append(t) - self.spi_list = sorted(self.spi_list) - if len(self.spi_list) == 0: + spi_list.append(t) + spi_list = sorted(spi_list) + if len(spi_list) == 0: f.write('#define HAL_USE_SPI FALSE\n') return devlist = [] - for dev in self.spi_list: + for dev in spi_list: n = int(dev[3:]) devlist.append('HAL_SPI%u_CONFIG' % n) - sck_pin = self.bylabel['SPI%s_SCK' % n] + sck_pin = bylabel['SPI%s_SCK' % n] sck_line = 'PAL_LINE(GPIO%s,%uU)' % (sck_pin.port, sck_pin.pin) f.write( '#define HAL_SPI%u_CONFIG { &SPID%u, %u, STM32_SPI_SPI%u_DMA_STREAMS, %s }\n' % (n, n, n, n, sck_line)) f.write('#define HAL_SPI_BUS_LIST %s\n\n' % ','.join(devlist)) - self.write_SPI_table(f) + write_SPI_table(f) + def write_QSPI_table(f): '''write SPI device table'''