RPM Limiter (#12054)
[betaflight.git] / src / main / pg / motor.h
blob8c55a87b848a15d337357ec6795308249cc4f4e9
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 struct motorDevConfig_s {
41 uint16_t motorPwmRate; // The update rate of motor outputs (50-498Hz)
42 uint8_t motorPwmProtocol; // Pwm Protocol
43 uint8_t motorPwmInversion; // Active-High vs Active-Low. Useful for brushed FCs converted for brushless operation
44 uint8_t useUnsyncedPwm;
45 uint8_t useBurstDshot;
46 uint8_t useDshotTelemetry;
47 uint8_t useDshotEdt;
48 ioTag_t ioTags[MAX_SUPPORTED_MOTORS];
49 uint8_t motorTransportProtocol;
50 uint8_t useDshotBitbang;
51 uint8_t useDshotBitbangedTimer;
52 uint8_t motorOutputReordering[MAX_SUPPORTED_MOTORS]; // Reindexing motors for "remap motors" feature in Configurator
53 } motorDevConfig_t;
55 typedef struct motorConfig_s {
56 motorDevConfig_t dev;
57 uint16_t digitalIdleOffsetValue; // Idle value for DShot protocol, full motor output = 10000
58 uint16_t minthrottle; // Set the minimum throttle command sent to the ESC (Electronic Speed Controller). This is the minimum value that allow motors to run at a idle speed.
59 uint16_t maxthrottle; // This is the maximum value for the ESCs at full power. This value can be increased up to 2000
60 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
61 uint16_t kv; // Motor velocity constant (Kv) to estimate RPM under no load (unloadedRpm = Kv * batteryVoltage)
62 uint8_t motorPoleCount; // Number of magnetic poles in the motor bell for calculating actual RPM from eRPM provided by ESC telemetry
63 } motorConfig_t;
65 PG_DECLARE(motorConfig_t, motorConfig);