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)
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/>.
28 #include "common/time.h"
32 #include "drivers/io_types.h"
33 #include "drivers/pwm_output.h"
35 #define QUAD_MOTOR_COUNT 4
37 // Note: this is called MultiType/MULTITYPE_* in baseflight.
38 typedef enum mixerMode
47 MIXER_FLYING_WING
= 8,
53 MIXER_AIRPLANE
= 14, // airplane / singlecopter / dualcopter (not yet properly supported)
54 MIXER_HELI_120_CCPM
= 15,
55 MIXER_HELI_90_DEG
= 16,
58 MIXER_PPM_TO_SERVO
= 19, // PPM -> servo relay
59 MIXER_DUALCOPTER
= 20,
60 MIXER_SINGLECOPTER
= 21,
63 MIXER_CUSTOM_AIRPLANE
= 24,
64 MIXER_CUSTOM_TRI
= 25,
65 MIXER_QUADX_1234
= 26,
69 typedef enum mixerType
77 // Custom mixer data per motor
78 typedef struct motorMixer_s
{
85 PG_DECLARE_ARRAY(motorMixer_t
, MAX_SUPPORTED_MOTORS
, customMotorMixer
);
87 // Custom mixer configuration
88 typedef struct mixer_s
{
91 const motorMixer_t
*motor
;
94 typedef struct mixerConfig_s
{
96 bool yaw_motors_reversed
;
97 uint8_t crashflip_motor_percent
;
98 uint8_t crashflip_rate
;
102 uint16_t rpm_limit_p
;
103 uint16_t rpm_limit_i
;
104 uint16_t rpm_limit_d
;
105 uint16_t rpm_limit_value
;
109 PG_DECLARE(mixerConfig_t
, mixerConfig
);
111 #define CHANNEL_FORWARDING_DISABLED (uint8_t)0xFF
114 #define RPM_LIMIT_ACTIVE mixerConfig()->rpm_limit
116 #define RPM_LIMIT_ACTIVE false
119 extern const mixer_t mixers
[];
120 extern float motor
[MAX_SUPPORTED_MOTORS
];
121 extern float motor_disarmed
[MAX_SUPPORTED_MOTORS
];
124 bool hasServos(void);
125 uint8_t getMotorCount(void);
126 float getMotorMixRange(void);
127 bool areMotorsRunning(void);
128 bool areMotorsSaturated(void);
130 void mixerLoadMix(int index
, motorMixer_t
*customMixers
);
131 void initEscEndpoints(void);
132 void mixerInit(mixerMode_e mixerMode
);
133 void mixerInitProfile(void);
134 void mixerResetRpmLimiter(void);
135 void mixerResetDisarmedMotors(void);
136 void mixTable(timeUs_t currentTimeUs
);
137 void stopMotors(void);
138 void writeMotors(void);
140 bool mixerIsTricopter(void);
142 void mixerSetThrottleAngleCorrection(int correctionValue
);
143 float mixerGetThrottle(void);
144 float mixerGetRcThrottle(void);
145 mixerMode_e
getMixerMode(void);
146 bool mixerModeIsFixedWing(mixerMode_e mixerMode
);
147 bool isFixedWing(void);
149 float getMotorOutputLow(void);
150 float getMotorOutputHigh(void);
152 bool crashFlipSuccessful(void);
155 float getMotorOutputRms(void);