CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_Airspeed/AP_Airspeed_Backend.cpp
Views: 1798
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
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
11
12
You should have received a copy of the GNU General Public License
13
along with this program. If not, see <http://www.gnu.org/licenses/>.
14
*/
15
16
/*
17
backend driver class for airspeed
18
*/
19
20
#include "AP_Airspeed_config.h"
21
22
#if AP_AIRSPEED_ENABLED
23
24
#include <AP_Common/AP_Common.h>
25
#include <AP_HAL/AP_HAL.h>
26
#include "AP_Airspeed.h"
27
#include "AP_Airspeed_Backend.h"
28
29
extern const AP_HAL::HAL &hal;
30
31
AP_Airspeed_Backend::AP_Airspeed_Backend(AP_Airspeed &_frontend, uint8_t _instance) :
32
frontend(_frontend),
33
instance(_instance)
34
{
35
}
36
37
AP_Airspeed_Backend::~AP_Airspeed_Backend(void)
38
{
39
}
40
41
42
int8_t AP_Airspeed_Backend::get_pin(void) const
43
{
44
#ifndef HAL_BUILD_AP_PERIPH
45
return frontend.param[instance].pin;
46
#else
47
return 0;
48
#endif
49
}
50
51
float AP_Airspeed_Backend::get_psi_range(void) const
52
{
53
return frontend.param[instance].psi_range;
54
}
55
56
uint8_t AP_Airspeed_Backend::get_bus(void) const
57
{
58
return frontend.param[instance].bus;
59
}
60
61
bool AP_Airspeed_Backend::bus_is_configured(void) const
62
{
63
return frontend.param[instance].bus.configured();
64
}
65
66
void AP_Airspeed_Backend::set_bus_id(uint32_t id)
67
{
68
frontend.param[instance].bus_id.set_and_save(int32_t(id));
69
}
70
71
#endif // AP_AIRSPEED_ENABLED
72
73