From 997c427e0917cefbe23ce95e5fc95fb61d95e020 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Sat, 26 Jul 2014 14:00:53 +0100 Subject: [PATCH] CC3D - Add WS2812 Led Strip Support (on S5_OUT) --- .../drivers/light_ws2811strip_stm32f10x.c | 8 ++++++++ src/main/drivers/pwm_mapping.c | 20 ++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/drivers/light_ws2811strip_stm32f10x.c b/src/main/drivers/light_ws2811strip_stm32f10x.c index 4064bed25..78ac0a28c 100644 --- a/src/main/drivers/light_ws2811strip_stm32f10x.c +++ b/src/main/drivers/light_ws2811strip_stm32f10x.c @@ -31,12 +31,20 @@ void ws2811LedStripHardwareInit(void) uint16_t prescalerValue; +#ifdef CC3D + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(GPIOB, &GPIO_InitStructure); +#else RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); /* GPIOA Configuration: TIM3 Channel 1 as alternate function push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); +#endif RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); /* Compute the prescaler value */ diff --git a/src/main/drivers/pwm_mapping.c b/src/main/drivers/pwm_mapping.c index 62d0747ff..b456a59f1 100755 --- a/src/main/drivers/pwm_mapping.c +++ b/src/main/drivers/pwm_mapping.c @@ -267,25 +267,21 @@ pwmOutputConfiguration_t *pwmInit(drv_pwm_config_t *init) continue; #endif -#if defined(STM32F10X_MD) -#define LED_STRIP_PWM PWM4 +#if defined(STM32F10X_MD) && !defined(CC3D) +#define LED_STRIP_TIMER TIM3 #endif -#if defined(STM32F303xC) && !(defined(CHEBUZZF3) || defined(NAZE32PRO)) -#define LED_STRIP_PWM PWM2 +#if defined(CC3D) +#define LED_STRIP_TIMER TIM2 #endif -#if defined(CHEBUZZF3) -#define LED_STRIP_PWM PWM2 +#if defined(STM32F303xC) +#define LED_STRIP_TIMER TIM16 #endif -#if defined(NAZE32PRO) -#define LED_STRIP_PWM PWM13 -#endif - -#ifdef LED_STRIP_PWM +#ifdef LED_STRIP_TIMER // skip LED Strip output - if (init->useLEDStrip && timerIndex == LED_STRIP_PWM) + if (init->useLEDStrip && timerHardware[timerIndex].tim == LED_STRIP_TIMER) continue; #endif