AP_Compass: move to using CANManager library

This commit is contained in:
Siddharth Purohit 2020-05-31 17:34:56 +05:30 committed by Andrew Tridgell
parent ad2a63e173
commit bf1a7799f8
2 changed files with 9 additions and 11 deletions

View File

@ -20,7 +20,7 @@
#include "AP_Compass_LIS3MDL.h" #include "AP_Compass_LIS3MDL.h"
#include "AP_Compass_AK09916.h" #include "AP_Compass_AK09916.h"
#include "AP_Compass_QMC5883L.h" #include "AP_Compass_QMC5883L.h"
#if HAL_WITH_UAVCAN #if HAL_ENABLE_LIBUAVCAN_DRIVERS
#include "AP_Compass_UAVCAN.h" #include "AP_Compass_UAVCAN.h"
#endif #endif
#include "AP_Compass_MMC3416.h" #include "AP_Compass_MMC3416.h"
@ -1272,7 +1272,7 @@ void Compass::_detect_backends(void)
#endif #endif
#if HAL_WITH_UAVCAN #if HAL_ENABLE_LIBUAVCAN_DRIVERS
if (_driver_enabled(DRIVER_UAVCAN)) { if (_driver_enabled(DRIVER_UAVCAN)) {
for (uint8_t i=0; i<COMPASS_MAX_BACKEND; i++) { for (uint8_t i=0; i<COMPASS_MAX_BACKEND; i++) {
AP_Compass_Backend* _uavcan_backend = AP_Compass_UAVCAN::probe(i); AP_Compass_Backend* _uavcan_backend = AP_Compass_UAVCAN::probe(i);
@ -1427,7 +1427,7 @@ void Compass::_reset_compass_id()
void void
Compass::_detect_runtime(void) Compass::_detect_runtime(void)
{ {
#if HAL_WITH_UAVCAN #if HAL_ENABLE_LIBUAVCAN_DRIVERS
//Don't try to add device while armed //Don't try to add device while armed
if (hal.util->get_soft_armed()) { if (hal.util->get_soft_armed()) {
return; return;

View File

@ -15,11 +15,11 @@
#include <AP_HAL/AP_HAL.h> #include <AP_HAL/AP_HAL.h>
#if HAL_WITH_UAVCAN #if HAL_ENABLE_LIBUAVCAN_DRIVERS
#include "AP_Compass_UAVCAN.h" #include "AP_Compass_UAVCAN.h"
#include <AP_BoardConfig/AP_BoardConfig_CAN.h> #include <AP_CANManager/AP_CANManager.h>
#include <AP_UAVCAN/AP_UAVCAN.h> #include <AP_UAVCAN/AP_UAVCAN.h>
#include <uavcan/equipment/ahrs/MagneticFieldStrength.hpp> #include <uavcan/equipment/ahrs/MagneticFieldStrength.hpp>
@ -27,9 +27,7 @@
extern const AP_HAL::HAL& hal; extern const AP_HAL::HAL& hal;
#define debug_mag_uavcan(level_debug, can_driver, fmt, args...) do { if ((level_debug) <= AP::can().get_debug_level_driver(can_driver)) { printf(fmt, ##args); }} while (0) #define LOG_TAG "COMPASS"
// Frontend Registry Binders // Frontend Registry Binders
UC_REGISTRY_BINDER(MagCb, uavcan::equipment::ahrs::MagneticFieldStrength); UC_REGISTRY_BINDER(MagCb, uavcan::equipment::ahrs::MagneticFieldStrength);
UC_REGISTRY_BINDER(Mag2Cb, uavcan::equipment::ahrs::MagneticFieldStrength2); UC_REGISTRY_BINDER(Mag2Cb, uavcan::equipment::ahrs::MagneticFieldStrength2);
@ -83,8 +81,8 @@ AP_Compass_Backend* AP_Compass_UAVCAN::probe(uint8_t index)
return nullptr; return nullptr;
} }
_detected_modules[index].driver = driver; _detected_modules[index].driver = driver;
debug_mag_uavcan(2, AP::can().log_text(AP_CANManager::LOG_INFO,
_detected_modules[index].ap_uavcan->get_driver_index(), LOG_TAG,
"Found Mag Node %d on Bus %d Sensor ID %d\n", "Found Mag Node %d on Bus %d Sensor ID %d\n",
_detected_modules[index].node_id, _detected_modules[index].node_id,
_detected_modules[index].ap_uavcan->get_driver_index(), _detected_modules[index].ap_uavcan->get_driver_index(),
@ -104,7 +102,7 @@ bool AP_Compass_UAVCAN::init()
set_dev_id(_instance, _devid); set_dev_id(_instance, _devid);
set_external(_instance, true); set_external(_instance, true);
debug_mag_uavcan(2, _ap_uavcan->get_driver_index(), "AP_Compass_UAVCAN loaded\n\r"); AP::can().log_text(AP_CANManager::LOG_INFO, LOG_TAG, "AP_Compass_UAVCAN loaded\n\r");
return true; return true;
} }