AP_Baro_UAVCAN.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #pragma once
  2. #include "AP_Baro_Backend.h"
  3. #include <AP_UAVCAN/AP_UAVCAN.h>
  4. class PressureCb;
  5. class TemperatureCb;
  6. class AP_Baro_UAVCAN : public AP_Baro_Backend {
  7. public:
  8. AP_Baro_UAVCAN(AP_Baro &baro);
  9. void update() override;
  10. inline void register_sensor() {
  11. _instance = _frontend.register_sensor();
  12. }
  13. static void subscribe_msgs(AP_UAVCAN* ap_uavcan);
  14. static AP_Baro_UAVCAN* get_uavcan_backend(AP_UAVCAN* ap_uavcan, uint8_t node_id, bool create_new);
  15. static AP_Baro_Backend* probe(AP_Baro &baro);
  16. static void handle_pressure(AP_UAVCAN* ap_uavcan, uint8_t node_id, const PressureCb &cb);
  17. static void handle_temperature(AP_UAVCAN* ap_uavcan, uint8_t node_id, const TemperatureCb &cb);
  18. private:
  19. uint8_t _instance;
  20. bool new_pressure;
  21. float _pressure;
  22. float _temperature;
  23. HAL_Semaphore _sem_baro;
  24. AP_UAVCAN* _ap_uavcan;
  25. uint8_t _node_id;
  26. // Module Detection Registry
  27. static struct DetectedModules {
  28. AP_UAVCAN* ap_uavcan;
  29. uint8_t node_id;
  30. AP_Baro_UAVCAN* driver;
  31. } _detected_modules[BARO_MAX_DRIVERS];
  32. static HAL_Semaphore _sem_registry;
  33. };