Skip to content

Commit

Permalink
AP_BoardConfig: detect Holybro 6X Rev6
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Oct 24, 2023
1 parent 203f51d commit 35eb362
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions libraries/AP_BoardConfig/AP_BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class AP_BoardConfig {
PX4_BOARD_FMUV6 = 39,
FMUV6_BOARD_HOLYBRO_6X = 40,
FMUV6_BOARD_CUAV_6X = 41,
FMUV6_BOARD_HOLYBRO_6X_REV6 = 42,
PX4_BOARD_OLDDRIVERS = 100,
};

Expand Down
19 changes: 10 additions & 9 deletions libraries/AP_BoardConfig/board_drivers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ void AP_BoardConfig::board_setup_drivers(void)
case PX4_BOARD_PCNC1:
case PX4_BOARD_MINDPXV2:
case FMUV6_BOARD_HOLYBRO_6X:
case FMUV6_BOARD_HOLYBRO_6X_REV6:
case FMUV6_BOARD_CUAV_6X:
break;
default:
Expand All @@ -129,17 +130,15 @@ bool AP_BoardConfig::spi_check_register(const char *devname, uint8_t regnum, uin
return false;
}
dev->set_read_flag(read_flag);
dev->get_semaphore()->take_blocking();
WITH_SEMAPHORE(dev->get_semaphore());
dev->set_speed(AP_HAL::Device::SPEED_LOW);
uint8_t v;
if (!dev->read_registers(regnum, &v, 1)) {
#if SPI_PROBE_DEBUG
hal.console->printf("%s: reg %02x read fail\n", devname, (unsigned)regnum);
#endif
dev->get_semaphore()->give();
return false;
}
dev->get_semaphore()->give();
#if SPI_PROBE_DEBUG
hal.console->printf("%s: reg %02x expected:%02x got:%02x\n", devname, (unsigned)regnum, (unsigned)value, (unsigned)v);
#endif
Expand All @@ -161,7 +160,7 @@ bool AP_BoardConfig::spi_check_register_inv2(const char *devname, uint8_t regnum
return false;
}
dev->set_read_flag(read_flag);
dev->get_semaphore()->take_blocking();
WITH_SEMAPHORE(dev->get_semaphore());
dev->set_speed(AP_HAL::Device::SPEED_LOW);
uint8_t v;
// select bank 0 for who am i
Expand All @@ -170,10 +169,8 @@ bool AP_BoardConfig::spi_check_register_inv2(const char *devname, uint8_t regnum
#if SPI_PROBE_DEBUG
hal.console->printf("%s: reg %02x read fail\n", devname, (unsigned)regnum);
#endif
dev->get_semaphore()->give();
return false;
}
dev->get_semaphore()->give();
#if SPI_PROBE_DEBUG
hal.console->printf("%s: reg %02x expected:%02x got:%02x\n", devname, (unsigned)regnum, (unsigned)value, (unsigned)v);
#endif
Expand Down Expand Up @@ -257,12 +254,13 @@ bool AP_BoardConfig::check_ms5611(const char* devname) {
#define INV2_WHOAMI_ICM20649 0xE1

#define INV3REG_WHOAMI 0x75
#define INV3REG_456_WHOAMI 0x72
#define INV3REG_456_WHOAMI 0x72

#define INV3_WHOAMI_ICM42688 0x47
#define INV3_WHOAMI_ICM42670 0x67

#define INV3_WHOAMI_ICM45686 0xE9
#define INV3_WHOAMI_IIM42652 0x6f

/*
validation of the board type
*/
Expand Down Expand Up @@ -503,7 +501,10 @@ void AP_BoardConfig::detect_fmuv6_variant()
state.board_type.set_and_notify(FMUV6_BOARD_CUAV_6X);
DEV_PRINTF("Detected CUAV 6X\n");
AP_Param::load_defaults_file("@ROMFS/param/CUAV_V6X_defaults.parm", false);
} else if (spi_check_register("iim42652", INV3REG_WHOAMI, INV3_WHOAMI_IIM42652) &&
spi_check_register("icm45686", INV3REG_456_WHOAMI, INV3_WHOAMI_ICM45686)) {
state.board_type.set_and_notify(FMUV6_BOARD_HOLYBRO_6X_REV6);
DEV_PRINTF("Detected Holybro 6X_Rev6\n");
}

}
#endif

0 comments on commit 35eb362

Please sign in to comment.