Backlight driver fixed on Taranis+
This commit is contained in:
@@ -137,6 +137,29 @@ static void LCD_BL_Config()
|
||||
{
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBL, ENABLE);
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
#if defined(REVPLUS)
|
||||
// RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BL|GPIO_Pin_BLW;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIOBL, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL, Pin_BL_AF);
|
||||
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BLW, Pin_BL_AF);
|
||||
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM4EN ; // Enable clock
|
||||
TIM4->ARR = 100 ;
|
||||
TIM4->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 10000 - 1;
|
||||
TIM4->CCMR1 = TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2M_2 ; // PWM
|
||||
TIM4->CCMR2 = TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2 ; // PWM
|
||||
TIM4->CCER = TIM_CCER_CC4E | TIM_CCER_CC2E ;
|
||||
TIM4->CCR2 = 0 ;
|
||||
TIM4->CCR4 = 0 ;
|
||||
TIM4->EGR = 0 ;
|
||||
TIM4->CR1 = TIM_CR1_CEN ; // Counter enable
|
||||
#else
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BL;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
@@ -145,28 +168,6 @@ static void LCD_BL_Config()
|
||||
GPIO_Init(GPIOBL, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL, Pin_BL_AF);
|
||||
|
||||
#if defined(REVPLUS)
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BLW;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIOBL, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BLW, Pin_BLW_AF);
|
||||
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM4EN ; // Enable clock
|
||||
TIM4->ARR = 100 ;
|
||||
TIM4->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 10000 - 1;
|
||||
TIM4->CCMR1 = TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2M_2 ; // PWM
|
||||
TIM4->CCMR2 = TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2 ; // PWM
|
||||
TIM4->CCER = TIM_CCER_CC4E | TIM_CCER_CC2E ;
|
||||
|
||||
int BacklightBrightness = 0 ;
|
||||
TIM4->CCR2 = BacklightBrightness ;
|
||||
TIM4->CCR4 = BacklightBrightness ;
|
||||
TIM4->EGR = 0 ;
|
||||
TIM4->CR1 = TIM_CR1_CEN ; // Counter enable
|
||||
#else
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM10EN ; // Enable clock
|
||||
TIM10->ARR = 100 ;
|
||||
TIM10->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 10000 - 1;
|
||||
|
||||
Reference in New Issue
Block a user