AP_GPS_UAVCAN.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. This program is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation, either version 3 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>.
  12. */
  13. //
  14. // UAVCAN GPS driver
  15. //
  16. #pragma once
  17. #include <AP_Common/AP_Common.h>
  18. #include <AP_HAL/AP_HAL.h>
  19. #include "AP_GPS.h"
  20. #include "GPS_Backend.h"
  21. #include <AP_UAVCAN/AP_UAVCAN.h>
  22. class FixCb;
  23. class AuxCb;
  24. class AP_GPS_UAVCAN : public AP_GPS_Backend {
  25. public:
  26. AP_GPS_UAVCAN(AP_GPS &_gps, AP_GPS::GPS_State &_state);
  27. ~AP_GPS_UAVCAN();
  28. bool read() override;
  29. const char *name() const override { return "UAVCAN"; }
  30. static void subscribe_msgs(AP_UAVCAN* ap_uavcan);
  31. static AP_GPS_Backend* probe(AP_GPS &_gps, AP_GPS::GPS_State &_state);
  32. static void handle_fix_msg_trampoline(AP_UAVCAN* ap_uavcan, uint8_t node_id, const FixCb &cb);
  33. static void handle_aux_msg_trampoline(AP_UAVCAN* ap_uavcan, uint8_t node_id, const AuxCb &cb);
  34. private:
  35. void handle_fix_msg(const FixCb &cb);
  36. void handle_aux_msg(const AuxCb &cb);
  37. static bool take_registry();
  38. static void give_registry();
  39. static AP_GPS_UAVCAN* get_uavcan_backend(AP_UAVCAN* ap_uavcan, uint8_t node_id);
  40. bool _new_data;
  41. AP_GPS::GPS_State interim_state;
  42. HAL_Semaphore sem;
  43. uint8_t _detected_module;
  44. // Module Detection Registry
  45. static struct DetectedModules {
  46. AP_UAVCAN* ap_uavcan;
  47. uint8_t node_id;
  48. AP_GPS_UAVCAN* driver;
  49. } _detected_modules[GPS_MAX_RECEIVERS];
  50. static HAL_Semaphore _sem_registry;
  51. };