Re-added use_unsyncPwm

This commit is contained in:
blckmn 2016-06-22 06:55:27 +10:00
parent 3e72bb5e3b
commit af2ddeeffd
5 changed files with 63 additions and 63 deletions

View File

@ -35,6 +35,7 @@ typedef struct master_t {
uint16_t motor_pwm_rate; // The update rate of motor outputs (50-498Hz)
uint16_t servo_pwm_rate; // The update rate of servo outputs (50-498Hz)
uint8_t motor_pwm_protocol; // Pwm Protocol
uint8_t use_unsyncedPwm;
#ifdef USE_SERVOS
servoMixer_t customServoMixer[MAX_SERVO_RULES];

View File

@ -66,6 +66,7 @@ static flight3DConfig_t *flight3DConfig;
static escAndServoConfig_t *escAndServoConfig;
static airplaneConfig_t *airplaneConfig;
static rxConfig_t *rxConfig;
static bool syncPwm = false;
static mixerMode_e currentMixerMode;
static motorMixer_t currentMixer[MAX_SUPPORTED_MOTORS];
@ -420,13 +421,15 @@ void mixerInit(mixerMode_e mixerMode, motorMixer_t *initialCustomMotorMixers, se
}
}
void mixerUsePWMOutputConfiguration(pwmOutputConfiguration_t *pwmOutputConfiguration)
void mixerUsePWMOutputConfiguration(pwmOutputConfiguration_t *pwmOutputConfiguration, bool use_unsyncedPwm)
{
int i;
motorCount = 0;
servoCount = pwmOutputConfiguration->servoCount;
syncPwm = use_unsyncedPwm;
if (currentMixerMode == MIXER_CUSTOM || currentMixerMode == MIXER_CUSTOM_TRI || currentMixerMode == MIXER_CUSTOM_AIRPLANE) {
// load custom mixer into currentMixer
for (i = 0; i < MAX_SUPPORTED_MOTORS; i++) {
@ -635,13 +638,6 @@ void writeServos(void)
}
#endif
static bool syncPwm = false;
void syncMotors(bool enabled)
{
syncPwm = enabled;
}
void writeMotors(void)
{
uint8_t i;

View File

@ -301,8 +301,8 @@ const clicmd_t cmdTable[] = {
"[<index>]\r\n", cliPlaySound),
CLI_COMMAND_DEF("profile", "change profile",
"[<index>]", cliProfile),
CLI_COMMAND_DEF("rateprofile", "change rate profile", "[<index>]", cliRateProfile),
CLI_COMMAND_DEF("resource", "view currently used resources", NULL, cliResource),
CLI_COMMAND_DEF("rateprofile", "change rate profile", "[<index>]", cliRateProfile),
CLI_COMMAND_DEF("resource", "view currently used resources", NULL, cliResource),
CLI_COMMAND_DEF("rxrange", "configure rx channel ranges", NULL, cliRxRange),
CLI_COMMAND_DEF("rxfail", "show/set rx failsafe settings", NULL, cliRxFail),
CLI_COMMAND_DEF("save", "save and reboot", NULL, cliSave),
@ -413,20 +413,20 @@ static const char * const lookupTableGyroLpf[] = {
};
static const char * const lookupTableAccHardware[] = {
"AUTO",
"NONE",
"ADXL345",
"MPU6050",
"MMA8452",
"BMA280",
"LSM303DLHC",
"MPU6000",
"MPU6500",
"FAKE"
"AUTO",
"NONE",
"ADXL345",
"MPU6050",
"MMA8452",
"BMA280",
"LSM303DLHC",
"MPU6000",
"MPU6500",
"FAKE"
};
static const char * const lookupTableBaroHardware[] = {
"AUTO",
"AUTO",
"NONE",
"BMP085",
"MS5611",
@ -491,7 +491,7 @@ typedef enum {
TABLE_ACC_HARDWARE,
TABLE_BARO_HARDWARE,
TABLE_MAG_HARDWARE,
TABLE_DEBUG,
TABLE_DEBUG,
TABLE_SUPEREXPO_YAW,
TABLE_MOTOR_PWM_PROTOCOL,
#ifdef OSD
@ -542,7 +542,7 @@ typedef enum {
// value section
MASTER_VALUE = (0 << VALUE_SECTION_OFFSET),
PROFILE_VALUE = (1 << VALUE_SECTION_OFFSET),
PROFILE_RATE_VALUE = (2 << VALUE_SECTION_OFFSET),
PROFILE_RATE_VALUE = (2 << VALUE_SECTION_OFFSET),
// value mode
MODE_DIRECT = (0 << VALUE_MODE_OFFSET),
MODE_LOOKUP = (1 << VALUE_MODE_OFFSET)
@ -602,8 +602,9 @@ const clivalue_t valueTable[] = {
#ifdef CC3D
{ "enable_buzzer_p6", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.use_buzzer_p6, .config.lookup = { TABLE_OFF_ON } },
#endif
{ "use_unsynced_pwm", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.use_unsyncedPwm, .config.lookup = { TABLE_OFF_ON } },
{ "motor_pwm_protocol", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.motor_pwm_protocol, .config.lookup = { TABLE_MOTOR_PWM_PROTOCOL } },
{ "motor_pwm_rate", VAR_UINT16 | MASTER_VALUE, &masterConfig.motor_pwm_rate, .config.minmax = { 0, 32000 } },
{ "motor_pwm_rate", VAR_UINT16 | MASTER_VALUE, &masterConfig.motor_pwm_rate, .config.minmax = { 200, 32000 } },
{ "servo_pwm_rate", VAR_UINT16 | MASTER_VALUE, &masterConfig.servo_pwm_rate, .config.minmax = { 50, 498 } },
{ "disarm_kill_switch", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.disarm_kill_switch, .config.lookup = { TABLE_OFF_ON } },
@ -2121,10 +2122,9 @@ static void cliDump(char *cmdline)
cliDumpProfile(masterConfig.current_profile_index);
}
if (dumpMask & DUMP_RATES) {
if (dumpMask & DUMP_RATES) {
cliDumpRateProfile(currentProfile->activeRateProfile);
}
}
void cliDumpProfile(uint8_t profileIndex) {
@ -2147,9 +2147,9 @@ void cliDumpRateProfile(uint8_t rateProfileIndex) {
return;
changeControlRateProfile(rateProfileIndex);
cliPrint("\r\n# rateprofile\r\n");
cliRateProfile("");
printSectionBreak();
cliPrint("\r\n# rateprofile\r\n");
cliRateProfile("");
printSectionBreak();
dumpValues(PROFILE_RATE_VALUE);
}
@ -2266,11 +2266,11 @@ static void cliBeeper(char *cmdline)
if (len == 0) {
cliPrintf("Disabled:");
for (int i = 0; ; i++) {
if (i == beeperCount-2){
if (i == beeperCount-2){
if (mask == 0)
cliPrint(" none");
break;
}
cliPrint(" none");
break;
}
if (mask & (1 << i))
cliPrintf(" %s", beeperNameForTableIndex(i));
}
@ -2299,7 +2299,7 @@ static void cliBeeper(char *cmdline)
if (i == BEEPER_ALL-1)
beeperOffSetAll(beeperCount-2);
else
if (i == BEEPER_PREFERENCE-1)
if (i == BEEPER_PREFERENCE-1)
setBeeperOffMask(getPreferredBeeperOffMask());
else {
mask = 1 << i;
@ -2311,7 +2311,7 @@ static void cliBeeper(char *cmdline)
if (i == BEEPER_ALL-1)
beeperOffClearAll();
else
if (i == BEEPER_PREFERENCE-1)
if (i == BEEPER_PREFERENCE-1)
setPreferredBeeperOffMask(getBeeperOffMask());
else {
mask = 1 << i;
@ -2520,19 +2520,19 @@ static void cliProfile(char *cmdline)
}
}
static void cliRateProfile(char *cmdline) {
int i;
if (isEmpty(cmdline)) {
cliPrintf("rateprofile %d\r\n", getCurrentControlRateProfile());
return;
} else {
i = atoi(cmdline);
if (i >= 0 && i < MAX_RATEPROFILES) {
changeControlRateProfile(i);
cliRateProfile("");
}
}
static void cliRateProfile(char *cmdline) {
int i;
if (isEmpty(cmdline)) {
cliPrintf("rateprofile %d\r\n", getCurrentControlRateProfile());
return;
} else {
i = atoi(cmdline);
if (i >= 0 && i < MAX_RATEPROFILES) {
changeControlRateProfile(i);
cliRateProfile("");
}
}
}
static void cliReboot(void) {
@ -2597,9 +2597,9 @@ static void cliPrintVar(const clivalue_t *var, uint32_t full)
ptr = ((uint8_t *)ptr) + (sizeof(profile_t) * masterConfig.current_profile_index);
}
if ((var->type & VALUE_SECTION_MASK) == PROFILE_RATE_VALUE) {
ptr = ((uint8_t *)ptr) + (sizeof(profile_t) * masterConfig.current_profile_index) + (sizeof(controlRateConfig_t) * getCurrentControlRateProfile());
}
if ((var->type & VALUE_SECTION_MASK) == PROFILE_RATE_VALUE) {
ptr = ((uint8_t *)ptr) + (sizeof(profile_t) * masterConfig.current_profile_index) + (sizeof(controlRateConfig_t) * getCurrentControlRateProfile());
}
switch (var->type & VALUE_TYPE_MASK) {
case VAR_UINT8:
@ -2670,9 +2670,9 @@ static void cliSetVar(const clivalue_t *var, const int_float_value_t value)
if ((var->type & VALUE_SECTION_MASK) == PROFILE_VALUE) {
ptr = ((uint8_t *)ptr) + (sizeof(profile_t) * masterConfig.current_profile_index);
}
if ((var->type & VALUE_SECTION_MASK) == PROFILE_RATE_VALUE) {
ptr = ((uint8_t *)ptr) + (sizeof(profile_t) * masterConfig.current_profile_index) + (sizeof(controlRateConfig_t) * getCurrentControlRateProfile());
}
if ((var->type & VALUE_SECTION_MASK) == PROFILE_RATE_VALUE) {
ptr = ((uint8_t *)ptr) + (sizeof(profile_t) * masterConfig.current_profile_index) + (sizeof(controlRateConfig_t) * getCurrentControlRateProfile());
}
switch (var->type & VALUE_TYPE_MASK) {
case VAR_UINT8:
@ -2733,7 +2733,7 @@ static void cliSet(char *cmdline)
if (strncasecmp(cmdline, valueTable[i].name, strlen(valueTable[i].name)) == 0 && variableNameLength == strlen(valueTable[i].name)) {
bool changeValue = false;
int_float_value_t tmp = { 0 };
int_float_value_t tmp = { 0 };
switch (valueTable[i].type & VALUE_MODE_MASK) {
case MODE_DIRECT: {
int32_t value = 0;
@ -2809,7 +2809,7 @@ static void cliGet(char *cmdline)
if (matchedCommands) {
return;
return;
}
cliPrint("Invalid name\r\n");

View File

@ -1261,7 +1261,7 @@ static bool processOutCommand(uint8_t cmdMSP)
headSerialReply(6);
serialize8(masterConfig.gyro_sync_denom);
serialize8(masterConfig.pid_process_denom);
serialize8(0);
serialize8(masterConfig.use_unsyncedPwm);
serialize8(masterConfig.motor_pwm_protocol);
serialize16(masterConfig.motor_pwm_rate);
break;
@ -1837,7 +1837,7 @@ static bool processInCommand(void)
case MSP_SET_PID_ADVANCED_CONFIG :
masterConfig.gyro_sync_denom = read8();
masterConfig.pid_process_denom = read8();
read8();
masterConfig.use_unsyncedPwm = read8();
masterConfig.motor_pwm_protocol = read8();
masterConfig.motor_pwm_rate = read16();
break;

View File

@ -129,7 +129,7 @@ void mixerInit(mixerMode_e mixerMode, motorMixer_t *customMotorMixers, servoMixe
#else
void mixerInit(mixerMode_e mixerMode, motorMixer_t *customMotorMixers);
#endif
void mixerUsePWMOutputConfiguration(pwmOutputConfiguration_t *pwmOutputConfiguration);
void mixerUsePWMOutputConfiguration(pwmOutputConfiguration_t *pwmOutputConfiguration, bool use_unsyncedPwm);
void rxInit(rxConfig_t *rxConfig, modeActivationCondition_t *modeActivationConditions);
void gpsInit(serialConfig_t *serialConfig, gpsConfig_t *initialGpsConfig);
void navigationInit(gpsProfile_t *initialGpsProfile, pidProfile_t *pidProfile);
@ -319,6 +319,8 @@ void init(void)
featureClear(FEATURE_ONESHOT125);
}
bool use_unsyncedPwm = masterConfig.use_unsyncedPwm;
// Configurator feature abused for enabling Fast PWM
pwm_params.useFastPwm = (masterConfig.motor_pwm_protocol != PWM_TYPE_CONVENTIONAL && masterConfig.motor_pwm_protocol != PWM_TYPE_BRUSHED);
pwm_params.pwmProtocolType = masterConfig.motor_pwm_protocol;
@ -326,8 +328,10 @@ void init(void)
pwm_params.idlePulse = masterConfig.escAndServoConfig.mincommand;
if (feature(FEATURE_3D))
pwm_params.idlePulse = masterConfig.flight3DConfig.neutral3d;
if (masterConfig.motor_pwm_protocol == PWM_TYPE_BRUSHED)
if (masterConfig.motor_pwm_protocol == PWM_TYPE_BRUSHED) {
pwm_params.idlePulse = 0; // brushed motors
use_unsyncedPwm = false;
}
#ifdef CC3D
pwm_params.useBuzzerP6 = masterConfig.use_buzzer_p6 ? true : false;
#endif
@ -335,8 +339,7 @@ void init(void)
pwmOutputConfiguration_t *pwmOutputConfiguration = pwmInit(&pwm_params);
syncMotors(pwm_params.motorPwmRate == 0 && pwm_params.motorPwmRate != PWM_TYPE_BRUSHED);
mixerUsePWMOutputConfiguration(pwmOutputConfiguration);
mixerUsePWMOutputConfiguration(pwmOutputConfiguration, use_unsyncedPwm);
if (!feature(FEATURE_ONESHOT125))
motorControlEnable = true;