1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-22 07:45:29 +03:00

Introduced TIM_USE_ flags to give defaults for reset configuration.

This commit is contained in:
blckmn 2016-10-25 21:02:46 +11:00
parent 1da7883b5c
commit c5bb7cfd2f
6 changed files with 46 additions and 34 deletions

View file

@ -243,6 +243,14 @@ void resetServoConfig(servoConfig_t *servoConfig)
{
servoConfig->servoCenterPulse = 1500;
servoConfig->servoPwmRate = 50;
uint8_t servoIndex = 0;
for (int i = 0; i < USABLE_TIMER_CHANNEL_COUNT && i < MAX_SUPPORTED_SERVOS; i++) {
if ((timerHardware[i].usageFlags & TIM_USE_SERVO) == TIM_USE_SERVO) {
servoConfig->ioTags[servoIndex] = timerHardware[i].tag;
servoIndex++;
}
}
}
#endif
@ -264,7 +272,7 @@ void resetMotorConfig(motorConfig_t *motorConfig)
uint8_t motorIndex = 0;
for (int i = 0; i < USABLE_TIMER_CHANNEL_COUNT && i < MAX_SUPPORTED_MOTORS; i++) {
if ((timerHardware[i].output & TIMER_OUTPUT_ENABLED) == TIMER_OUTPUT_ENABLED) {
if ((timerHardware[i].usageFlags & TIM_USE_MOTOR) == TIM_USE_MOTOR) {
motorConfig->ioTags[motorIndex] = timerHardware[i].tag;
motorIndex++;
}
@ -304,7 +312,7 @@ void resetPpmConfig(ppmConfig_t *ppmConfig)
ppmConfig->ioTag = IO_TAG(PPM_PIN);
#else
for (int i = 0; i < USABLE_TIMER_CHANNEL_COUNT; i++) {
if ((timerHardware[i].output == TIMER_INPUT_ENABLED)) {
if ((timerHardware[i].usageFlags & TIM_USE_PPM) == TIM_USE_PPM) {
ppmConfig->ioTag = timerHardware[i].tag;
return;
}
@ -318,7 +326,7 @@ void resetPwmConfig(pwmConfig_t *pwmConfig)
{
uint8_t inputIndex = 0;
for (int i = 0; i < USABLE_TIMER_CHANNEL_COUNT && inputIndex < PWM_INPUT_PORT_COUNT; i++) {
if ((timerHardware[i].output == TIMER_INPUT_ENABLED)) {
if ((timerHardware[i].usageFlags & TIM_USE_PWM) == TIM_USE_PWM) {
pwmConfig->ioTags[inputIndex] = timerHardware[i].tag;
inputIndex++;
}