Blackbox device type 'file' (SITL) considered working when file handler is available
[inav.git] / src / main / drivers / rangefinder / rangefinder.h
blob797a29a6c033e8642bc978564ab4364e59bd34e3
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #pragma once
20 #include "common/time.h"
21 #include "drivers/io.h"
22 #include "drivers/bus.h"
24 #define RANGEFINDER_OUT_OF_RANGE (-1)
25 #define RANGEFINDER_HARDWARE_FAILURE (-2)
26 #define RANGEFINDER_NO_NEW_DATA (-3)
28 struct rangefinderDev_s;
30 typedef void (*rangefinderOpInitFuncPtr)(struct rangefinderDev_s * dev);
31 typedef void (*rangefinderOpStartFuncPtr)(struct rangefinderDev_s * dev);
32 typedef int32_t (*rangefinderOpReadFuncPtr)(struct rangefinderDev_s * dev);
34 typedef struct rangefinderDev_s {
35 busDevice_t * busDev; // Device on a bus (if applicable)
37 timeMs_t delayMs;
38 int16_t maxRangeCm;
40 // these are full detection cone angles, maximum tilt is half of this
41 int16_t detectionConeDeciDegrees; // detection cone angle as in device spec
42 int16_t detectionConeExtendedDeciDegrees; // device spec is conservative, in practice have slightly larger detection cone
44 // function pointers
45 rangefinderOpInitFuncPtr init;
46 rangefinderOpStartFuncPtr update;
47 rangefinderOpReadFuncPtr read;
48 } rangefinderDev_t;