AP_Compass_UAVCAN.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include "AP_Compass.h"
  3. #include "AP_Compass_Backend.h"
  4. #include <AP_UAVCAN/AP_UAVCAN.h>
  5. class MagCb;
  6. class Mag2Cb;
  7. class AP_Compass_UAVCAN : public AP_Compass_Backend {
  8. public:
  9. AP_Compass_UAVCAN(AP_UAVCAN* ap_uavcan, uint8_t node_id, uint8_t sensor_id);
  10. void read(void) override;
  11. static void subscribe_msgs(AP_UAVCAN* ap_uavcan);
  12. static AP_Compass_Backend* probe();
  13. static void handle_magnetic_field(AP_UAVCAN* ap_uavcan, uint8_t node_id, const MagCb &cb);
  14. static void handle_magnetic_field_2(AP_UAVCAN* ap_uavcan, uint8_t node_id, const Mag2Cb &cb);
  15. private:
  16. void init();
  17. // callback for UAVCAN messages
  18. void handle_mag_msg(const Vector3f &mag);
  19. static AP_Compass_UAVCAN* get_uavcan_backend(AP_UAVCAN* ap_uavcan, uint8_t node_id, uint8_t sensor_id);
  20. uint8_t _instance;
  21. AP_UAVCAN* _ap_uavcan;
  22. uint8_t _node_id;
  23. uint8_t _sensor_id;
  24. // Module Detection Registry
  25. static struct DetectedModules {
  26. AP_UAVCAN* ap_uavcan;
  27. uint8_t node_id;
  28. uint8_t sensor_id;
  29. AP_Compass_UAVCAN *driver;
  30. } _detected_modules[COMPASS_MAX_BACKEND];
  31. static HAL_Semaphore _sem_registry;
  32. };