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 motor_pwm_rate; // The update rate of motor outputs (50-498Hz)
uint16_t servo_pwm_rate; // The update rate of servo 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 motor_pwm_protocol; // Pwm Protocol
uint8_t use_unsyncedPwm;
#ifdef USE_SERVOS #ifdef USE_SERVOS
servoMixer_t customServoMixer[MAX_SERVO_RULES]; servoMixer_t customServoMixer[MAX_SERVO_RULES];

View File

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

View File

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

View File

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

View File

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