2017-04-02 11:56:03 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "AP_Baro_Backend.h"
|
2018-07-20 06:44:55 -03:00
|
|
|
|
2017-04-02 11:56:03 -03:00
|
|
|
#include <AP_UAVCAN/AP_UAVCAN.h>
|
|
|
|
|
2018-07-20 06:44:55 -03:00
|
|
|
class PressureCb;
|
|
|
|
class TemperatureCb;
|
|
|
|
|
2017-04-02 11:56:03 -03:00
|
|
|
class AP_Baro_UAVCAN : public AP_Baro_Backend {
|
|
|
|
public:
|
2018-07-20 06:44:55 -03:00
|
|
|
AP_Baro_UAVCAN(AP_Baro &baro);
|
2017-05-06 06:13:05 -03:00
|
|
|
|
2017-04-02 11:56:03 -03:00
|
|
|
void update() override;
|
|
|
|
|
2018-07-20 06:44:55 -03:00
|
|
|
static void subscribe_msgs(AP_UAVCAN* ap_uavcan);
|
|
|
|
static AP_Baro_UAVCAN* get_uavcan_backend(AP_UAVCAN* ap_uavcan, uint8_t node_id, bool create_new);
|
|
|
|
static AP_Baro_Backend* probe(AP_Baro &baro);
|
|
|
|
|
|
|
|
static void handle_pressure(AP_UAVCAN* ap_uavcan, uint8_t node_id, const PressureCb &cb);
|
|
|
|
static void handle_temperature(AP_UAVCAN* ap_uavcan, uint8_t node_id, const TemperatureCb &cb);
|
2017-05-06 06:13:05 -03:00
|
|
|
|
2017-04-02 11:56:03 -03:00
|
|
|
private:
|
2018-07-20 06:44:55 -03:00
|
|
|
|
2019-12-24 22:13:03 -04:00
|
|
|
static void _update_and_wrap_accumulator(float *accum, float val, uint8_t *count, const uint8_t max_count);
|
|
|
|
|
2017-04-02 11:56:03 -03:00
|
|
|
uint8_t _instance;
|
2018-07-20 06:44:55 -03:00
|
|
|
|
|
|
|
bool new_pressure;
|
2017-04-02 11:56:03 -03:00
|
|
|
float _pressure;
|
|
|
|
float _temperature;
|
2019-12-24 22:13:03 -04:00
|
|
|
uint8_t _pressure_count;
|
2018-08-15 23:53:17 -03:00
|
|
|
HAL_Semaphore _sem_baro;
|
2018-07-20 06:44:55 -03:00
|
|
|
|
|
|
|
AP_UAVCAN* _ap_uavcan;
|
|
|
|
uint8_t _node_id;
|
|
|
|
|
|
|
|
// Module Detection Registry
|
|
|
|
static struct DetectedModules {
|
|
|
|
AP_UAVCAN* ap_uavcan;
|
|
|
|
uint8_t node_id;
|
|
|
|
AP_Baro_UAVCAN* driver;
|
|
|
|
} _detected_modules[BARO_MAX_DRIVERS];
|
|
|
|
|
2018-10-11 20:35:03 -03:00
|
|
|
static HAL_Semaphore _sem_registry;
|
2017-04-02 11:56:03 -03:00
|
|
|
};
|