Ditching default target for `make` in favour of `make all` (#14099)
[betaflight.git] / src / main / drivers / camera_control_impl.h
blobdf3852772c33ff868c813203483b6174afc0deb9
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #pragma once
23 #include "io_types.h"
24 #include "pg/pg.h"
25 #include "drivers/pwm_output.h"
27 #define CAMERA_CONTROL_PWM_RESOLUTION 128
28 #define CAMERA_CONTROL_SOFT_PWM_RESOLUTION 448
30 typedef enum {
31 CAMERA_CONTROL_KEY_ENTER,
32 CAMERA_CONTROL_KEY_LEFT,
33 CAMERA_CONTROL_KEY_UP,
34 CAMERA_CONTROL_KEY_RIGHT,
35 CAMERA_CONTROL_KEY_DOWN,
36 CAMERA_CONTROL_KEYS_COUNT
37 } cameraControlKey_e;
39 typedef enum {
40 CAMERA_CONTROL_MODE_HARDWARE_PWM,
41 CAMERA_CONTROL_MODE_SOFTWARE_PWM,
42 CAMERA_CONTROL_MODE_DAC,
43 CAMERA_CONTROL_MODES_COUNT
44 } cameraControlMode_e;
46 typedef struct cameraControlConfig_s {
47 cameraControlMode_e mode;
48 // measured in 10 mV steps
49 uint16_t refVoltage;
50 uint16_t keyDelayMs;
51 // measured 100 Ohm steps
52 uint16_t internalResistance;
54 ioTag_t ioTag;
55 uint8_t inverted;
56 uint16_t buttonResistanceValues[CAMERA_CONTROL_KEYS_COUNT]; // resistance in 100ohm steps
57 } cameraControlConfig_t;
59 PG_DECLARE(cameraControlConfig_t, cameraControlConfig);
61 void cameraControlInit(void);
63 void cameraControlProcess(uint32_t currentTimeUs);
64 void cameraControlKeyPress(cameraControlKey_e key, uint32_t holdDurationMs);
66 void cameraControlHi(void);
67 void cameraControlLo(void);
69 void cameraControlSoftwarePwmInit(void);
70 void cameraControlSoftwarePwmEnable(uint32_t hiTime, uint32_t period);
71 void cameraControlSoftwarePwmDisable(void);
72 void cameraControlHardwarePwmInit(timerChannel_t *channel, const timerHardware_t *timerHardware, uint8_t inverted);