Skip to content

Commit

Permalink
AP_HAL_ChibiOS: don't reset GPIO modes on disabled lines
Browse files Browse the repository at this point in the history
  • Loading branch information
andyp1per committed Oct 9, 2023
1 parent a844d21 commit 1ed49b1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions libraries/AP_HAL_ChibiOS/RCOutput_bdshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ void RCOutput::bdshot_reset_pwm(pwm_group& group, uint8_t telem_channel)
TIMx->CCR[1] = 0; /* Comparator 2 disabled. */
TIMx->CCR[2] = 0; /* Comparator 3 disabled. */
TIMx->CCR[3] = 0; /* Comparator 4 disabled. */
// pwmStart sets these
// at the point this is called we will have done input capture on two CC channels
// we need to switch those channels back to output and the default settings
// all other channels will not have been modified
Expand Down Expand Up @@ -269,7 +268,7 @@ void RCOutput::bdshot_reset_pwm(pwm_group& group, uint8_t telem_channel)
default:
break;
}

// pwmStart sets these
uint32_t psc = (group.pwm_drv->clock / group.pwm_drv->config->frequency) - 1;
TIMx->PSC = psc;
TIMx->ARR = group.pwm_drv->period - 1;
Expand All @@ -285,6 +284,9 @@ void RCOutput::bdshot_reset_pwm(pwm_group& group, uint8_t telem_channel)
// we need to switch every output on the same input channel to avoid
// spurious line changes
for (uint8_t i = 0; i<4; i++) {
if (group.chan[i] == CHAN_DISABLED) {
continue;
}
if (group.bdshot.telem_tim_ch[telem_channel] == group.bdshot.telem_tim_ch[i]) {
palSetLineMode(group.pal_lines[i], PAL_MODE_STM32_ALTERNATE_PUSHPULL);
}
Expand Down Expand Up @@ -341,6 +343,9 @@ void RCOutput::bdshot_receive_pulses_DMAR(pwm_group* group)
// we need to switch every input on the same input channel to allow
// the ESCs to drive the lines
for (uint8_t i = 0; i<4; i++) {
if (group->chan[i] == CHAN_DISABLED) {
continue;
}
if (group->bdshot.telem_tim_ch[curr_ch] == group->bdshot.telem_tim_ch[i]) {
palSetLineMode(group->pal_lines[i], PAL_MODE_INPUT_PULLUP);
}
Expand Down

0 comments on commit 1ed49b1

Please sign in to comment.