Make three attempts to not only write to FLASH, but also validate it (#14001)
[betaflight.git] / src / main / pg / motor.h
blobc4fca53b2fe784d9bb3c1791c3143185e6a1346a
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 "pg/pg.h"
25 #include "drivers/io.h"
26 #include "drivers/dshot_bitbang.h"
28 typedef enum {
29 DSHOT_BITBANGED_TIMER_AUTO = 0,
30 DSHOT_BITBANGED_TIMER_TIM1,
31 DSHOT_BITBANGED_TIMER_TIM8,
32 } dshotBitbangedTimer_e;
34 typedef enum {
35 DSHOT_DMAR_OFF,
36 DSHOT_DMAR_ON,
37 DSHOT_DMAR_AUTO
38 } dshotDmar_e;
40 typedef enum {
41 DSHOT_TELEMETRY_OFF,
42 DSHOT_TELEMETRY_ON,
43 } dshotTelemetry_e;
45 typedef struct motorDevConfig_s {
46 uint16_t motorPwmRate; // The update rate of motor outputs (50-498Hz)
47 uint8_t motorPwmProtocol; // Pwm Protocol
48 uint8_t motorPwmInversion; // Active-High vs Active-Low. Useful for brushed FCs converted for brushless operation
49 uint8_t useUnsyncedPwm;
50 uint8_t useBurstDshot;
51 uint8_t useDshotTelemetry;
52 uint8_t useDshotEdt;
53 ioTag_t ioTags[MAX_SUPPORTED_MOTORS];
54 uint8_t motorTransportProtocol;
55 uint8_t useDshotBitbang;
56 uint8_t useDshotBitbangedTimer;
57 uint8_t motorOutputReordering[MAX_SUPPORTED_MOTORS]; // Reindexing motors for "remap motors" feature in Configurator
58 } motorDevConfig_t;
60 typedef struct motorConfig_s {
61 motorDevConfig_t dev;
62 uint16_t motorIdle; // When motors are idling, the percentage of the motor range added above the disarmed value, in percent * 100.
63 uint16_t maxthrottle; // This is the maximum value for the ESCs at full power. This value can be increased up to 2000
64 uint16_t mincommand; // This is the value for the ESCs when they are not armed. In some cases, this value must be lowered down to 900 for some specific ESCs
65 uint16_t kv; // Motor velocity constant (Kv) to estimate RPM under no load (unloadedRpm = Kv * batteryVoltage)
66 uint8_t motorPoleCount; // Number of magnetic poles in the motor bell for calculating actual RPM from eRPM provided by ESC telemetry
67 } motorConfig_t;
69 PG_DECLARE(motorConfig_t, motorConfig);