mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-08 03:21:36 +08:00
drivers/magnetometer: enable probe retry by default
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2019-2020 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2019-2022 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -87,21 +87,23 @@ void AK09916::print_status()
|
||||
|
||||
int AK09916::probe()
|
||||
{
|
||||
const uint8_t WIA1 = RegisterRead(Register::WIA1);
|
||||
for (int retry = 0; retry < 3; retry++) {
|
||||
const uint8_t WIA1 = RegisterRead(Register::WIA1);
|
||||
const uint8_t WIA2 = RegisterRead(Register::WIA2);
|
||||
|
||||
if (WIA1 != Company_ID) {
|
||||
DEVICE_DEBUG("unexpected WIA1 0x%02x", WIA1);
|
||||
return PX4_ERROR;
|
||||
if ((WIA1 == Company_ID) && (WIA2 == Device_ID)) {
|
||||
_retries = 1;
|
||||
return PX4_OK;
|
||||
|
||||
} else if (WIA1 != Company_ID) {
|
||||
DEVICE_DEBUG("unexpected WIA1 0x%02x", WIA1);
|
||||
|
||||
} else if (WIA2 != Device_ID) {
|
||||
DEVICE_DEBUG("unexpected WIA2 0x%02x", WIA2);
|
||||
}
|
||||
}
|
||||
|
||||
const uint8_t WIA2 = RegisterRead(Register::WIA2);
|
||||
|
||||
if (WIA2 != Device_ID) {
|
||||
DEVICE_DEBUG("unexpected WIA2 0x%02x", WIA2);
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
return PX4_OK;
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
void AK09916::RunImpl()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2020 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2020-2022 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -87,14 +87,19 @@ void AK8963::print_status()
|
||||
|
||||
int AK8963::probe()
|
||||
{
|
||||
const uint8_t WIA = RegisterRead(Register::WIA);
|
||||
for (int retry = 0; retry < 3; retry++) {
|
||||
const uint8_t WIA = RegisterRead(Register::WIA);
|
||||
|
||||
if (WIA != Device_ID) {
|
||||
DEVICE_DEBUG("unexpected WIA 0x%02x", WIA);
|
||||
return PX4_ERROR;
|
||||
if (WIA == Device_ID) {
|
||||
_retries = 1;
|
||||
return PX4_OK;
|
||||
|
||||
} else {
|
||||
DEVICE_DEBUG("unexpected WIA 0x%02x", WIA);
|
||||
}
|
||||
}
|
||||
|
||||
return PX4_OK;
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
void AK8963::RunImpl()
|
||||
|
||||
@@ -86,17 +86,19 @@ void BMM150::print_status()
|
||||
int BMM150::probe()
|
||||
{
|
||||
// 3 retries
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int retry = 0; retry < 3; retry++) {
|
||||
const uint8_t POWER_CONTROL = RegisterRead(Register::POWER_CONTROL);
|
||||
const uint8_t CHIP_ID = RegisterRead(Register::CHIP_ID);
|
||||
|
||||
PX4_DEBUG("POWER_CONTROL: 0x%02hhX, CHIP_ID: 0x%02hhX", POWER_CONTROL, CHIP_ID);
|
||||
|
||||
if (CHIP_ID == chip_identification_number) {
|
||||
_retries = 1;
|
||||
return PX4_OK;
|
||||
|
||||
} else if ((CHIP_ID == 0) && !(POWER_CONTROL & POWER_CONTROL_BIT::PowerControl)) {
|
||||
// in suspend Chip ID read (register 0x40) returns “0x00” (I²C) or high-Z (SPI).
|
||||
_retries = 1;
|
||||
return PX4_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,10 +86,10 @@ void IST8310::print_status()
|
||||
int IST8310::probe()
|
||||
{
|
||||
for (int retry = 0; retry < 3; retry++) {
|
||||
|
||||
const uint8_t WAI = RegisterRead(Register::WAI);
|
||||
|
||||
if (WAI == Device_ID) {
|
||||
_retries = 1;
|
||||
return PX4_OK;
|
||||
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2020 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2020-2022 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -87,7 +87,7 @@ int QMC5883L::probe()
|
||||
{
|
||||
_retries = 1;
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int retry = 0; retry < 3; retry++) {
|
||||
// first read 0x0 once
|
||||
const uint8_t cmd = 0;
|
||||
uint8_t buffer{};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2021 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2021-2022 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -87,7 +87,7 @@ int VCM1193L::probe()
|
||||
{
|
||||
_retries = 1;
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int retry = 0; retry < 3; retry++) {
|
||||
// first read 0x0 once
|
||||
const uint8_t cmd = 0;
|
||||
uint8_t buffer{};
|
||||
|
||||
Reference in New Issue
Block a user