From 053a28dc622a0ff43e5f55a95899523f57ec23d0 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Thu, 17 Jul 2014 23:52:49 +0100 Subject: [PATCH] CC3D - Hack to enable a simple quad configuration using PPM input to be tested. PPM and motor outputs conflict since they use the same timers so this just avoids conflicts. --- src/main/drivers/pwm_mapping.c | 20 +++++++++++++++----- src/main/drivers/timer.c | 10 +++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main/drivers/pwm_mapping.c b/src/main/drivers/pwm_mapping.c index 7a5cad015..42db7edb4 100755 --- a/src/main/drivers/pwm_mapping.c +++ b/src/main/drivers/pwm_mapping.c @@ -139,6 +139,16 @@ static const uint16_t airPWM[] = { #endif #if USABLE_TIMER_CHANNEL_COUNT == 12 +#ifdef CC3D // XXX HACK while PPM and MOTOR code conflicts. +static const uint16_t multiPPM[] = { + PWM6 | (TYPE_IP << 8), // PPM input + PWM7 | (TYPE_M << 8), // Swap to servo if needed + PWM8 | (TYPE_M << 8), // Swap to servo if needed + PWM9 | (TYPE_M << 8), + PWM10 | (TYPE_M << 8), + 0xFFFF +}; +#else static const uint16_t multiPPM[] = { PWM1 | (TYPE_IP << 8), // PPM input PWM7 | (TYPE_M << 8), // Swap to servo if needed @@ -154,7 +164,7 @@ static const uint16_t multiPPM[] = { PWM6 | (TYPE_M << 8), // Swap to servo if needed 0xFFFF }; - +#endif static const uint16_t multiPWM[] = { PWM1 | (TYPE_IW << 8), // input #1 PWM2 | (TYPE_IW << 8), @@ -174,8 +184,8 @@ static const uint16_t multiPWM[] = { static const uint16_t airPPM[] = { PWM1 | (TYPE_IP << 8), // PPM input PWM7 | (TYPE_M << 8), - PWM8 | (TYPE_M << 8), - PWM9 | (TYPE_S << 8), + PWM8 | (TYPE_M << 8), + PWM9 | (TYPE_S << 8), PWM10 | (TYPE_S << 8), PWM11 | (TYPE_S << 8), PWM12 | (TYPE_S << 8), @@ -335,9 +345,9 @@ pwmOutputConfiguration_t *pwmInit(drv_pwm_config_t *init) channelIndex++; } else if (type == TYPE_M) { if (init->motorPwmRate > 500) { - pwmBrushedMotorConfig(&timerHardware[timerIndex], pwmOutputConfiguration.motorCount, init->motorPwmRate, init->idlePulse); + pwmBrushedMotorConfig(&timerHardware[timerIndex], pwmOutputConfiguration.motorCount, init->motorPwmRate, init->idlePulse); } else { - pwmBrushlessMotorConfig(&timerHardware[timerIndex], pwmOutputConfiguration.motorCount, init->motorPwmRate, init->idlePulse); + pwmBrushlessMotorConfig(&timerHardware[timerIndex], pwmOutputConfiguration.motorCount, init->motorPwmRate, init->idlePulse); } pwmOutputConfiguration.motorCount++; } else if (type == TYPE_S) { diff --git a/src/main/drivers/timer.c b/src/main/drivers/timer.c index 6f5475c5b..3cad5ad58 100644 --- a/src/main/drivers/timer.c +++ b/src/main/drivers/timer.c @@ -104,12 +104,12 @@ const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { { TIM2, GPIOA, Pin_0, TIM_Channel_1, TIM2_IRQn, 0, Mode_IPD}, // S5_IN { TIM2, GPIOA, Pin_1, TIM_Channel_2, TIM2_IRQn, 0, Mode_IPD}, // S6_IN - { TIM4, GPIOB, Pin_9, TIM_Channel_4, TIM4_IRQn, 0, GPIO_Mode_AF_PP}, // S1_OUT - { TIM4, GPIOB, Pin_8, TIM_Channel_3, TIM4_IRQn, 0, GPIO_Mode_AF_PP}, // S2_OUT - { TIM4, GPIOB, Pin_7, TIM_Channel_2, TIM4_IRQn, 0, GPIO_Mode_AF_PP}, // S3_OUT + { TIM4, GPIOB, Pin_9, TIM_Channel_4, TIM4_IRQn, 1, GPIO_Mode_AF_PP}, // S1_OUT + { TIM4, GPIOB, Pin_8, TIM_Channel_3, TIM4_IRQn, 1, GPIO_Mode_AF_PP}, // S2_OUT + { TIM4, GPIOB, Pin_7, TIM_Channel_2, TIM4_IRQn, 1, GPIO_Mode_AF_PP}, // S3_OUT { TIM1, GPIOA, Pin_8, TIM_Channel_1, TIM1_CC_IRQn, 1, GPIO_Mode_AF_PP}, // S4_OUT - { TIM3, GPIOB, Pin_4, TIM_Channel_1, TIM3_IRQn, 0, GPIO_Mode_AF_PP}, // S5_OUT - GPIO_PartialRemap_TIM3 - { TIM2, GPIOA, Pin_2, TIM_Channel_3, TIM2_IRQn, 0, GPIO_Mode_AF_PP}, // S6_OUT + { TIM3, GPIOB, Pin_4, TIM_Channel_1, TIM3_IRQn, 1, GPIO_Mode_AF_PP}, // S5_OUT - GPIO_PartialRemap_TIM3 + { TIM2, GPIOA, Pin_2, TIM_Channel_3, TIM2_IRQn, 1, GPIO_Mode_AF_PP}, // S6_OUT }; #define MAX_TIMERS 4 // TIM1..TIM4