Blackbox device type 'file' (SITL) considered working when file handler is available
[inav.git] / src / main / drivers / gimbal_common.h
blob879e81116a01bc4ee4cbf676c7caa73f4094c7b4
1 /*
2 * This file is part of INAV.
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 INAV. If not, see <http://www.gnu.org/licenses/>.
18 #pragma once
20 #include "platform.h"
22 #ifdef USE_SERIAL_GIMBAL
24 #include <stdint.h>
26 #include "config/feature.h"
27 #include "common/time.h"
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
33 typedef enum {
34 GIMBAL_DEV_UNSUPPORTED = 0,
35 GIMBAL_DEV_SERIAL,
36 GIMBAL_DEV_UNKNOWN=0xFF
37 } gimbalDevType_e;
40 struct gimbalVTable_s;
42 typedef struct gimbalDevice_s {
43 const struct gimbalVTable_s *vTable;
44 int16_t currentPanPWM;
45 } gimbalDevice_t;
47 // {set,get}BandAndChannel: band and channel are 1 origin
48 // {set,get}PowerByIndex: 0 = Power OFF, 1 = device dependent
49 // {set,get}PitMode: 0 = OFF, 1 = ON
51 typedef struct gimbalVTable_s {
52 void (*process)(gimbalDevice_t *gimbalDevice, timeUs_t currentTimeUs);
53 gimbalDevType_e (*getDeviceType)(const gimbalDevice_t *gimbalDevice);
54 bool (*isReady)(const gimbalDevice_t *gimbalDevice);
55 bool (*hasHeadTracker)(const gimbalDevice_t *gimbalDevice);
56 int16_t (*getGimbalPanPWM)(const gimbalDevice_t *gimbalDevice);
57 } gimbalVTable_t;
60 typedef struct gimbalConfig_s {
61 uint8_t panChannel;
62 uint8_t tiltChannel;
63 uint8_t rollChannel;
64 uint8_t sensitivity;
65 uint16_t panTrim;
66 uint16_t tiltTrim;
67 uint16_t rollTrim;
68 } gimbalConfig_t;
70 PG_DECLARE(gimbalConfig_t, gimbalConfig);
72 typedef enum {
73 GIMBAL_MODE_FOLLOW = 0,
74 GIMBAL_MODE_TILT_LOCK = (1<<0),
75 GIMBAL_MODE_ROLL_LOCK = (1<<1),
76 GIMBAL_MODE_PAN_LOCK = (1<<2),
77 } gimbal_htk_mode_e;
79 #define GIMBAL_MODE_DEFAULT GIMBAL_MODE_FOLLOW
80 #define GIMBAL_MODE_TILT_ROLL_LOCK (GIMBAL_MODE_TILT_LOCK | GIMBAL_MODE_ROLL_LOCK)
81 #define GIMBAL_MODE_PAN_TILT_ROLL_LOCK (GIMBAL_MODE_TILT_LOCK | GIMBAL_MODE_ROLL_LOCK | GIMBAL_MODE_PAN_LOCK)
83 void gimbalCommonInit(void);
84 void gimbalCommonSetDevice(gimbalDevice_t *gimbalDevice);
85 gimbalDevice_t *gimbalCommonDevice(void);
87 // VTable functions
88 void gimbalCommonProcess(gimbalDevice_t *gimbalDevice, timeUs_t currentTimeUs);
89 gimbalDevType_e gimbalCommonGetDeviceType(gimbalDevice_t *gimbalDevice);
90 bool gimbalCommonIsReady(gimbalDevice_t *gimbalDevice);
93 void taskUpdateGimbal(timeUs_t currentTimeUs);
95 bool gimbalCommonIsEnabled(void);
96 bool gimbalCommonHtrkIsEnabled(void);
98 int16_t gimbalCommonGetPanPwm(const gimbalDevice_t *gimbalDevice);
100 #ifdef __cplusplus
102 #endif
104 #endif