Backlight driver, totally untested. Backlight SF color not handled yet.
This commit is contained in:
@@ -171,4 +171,16 @@ void boardInit()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(REVPLUS)
|
||||
void turnBacklightOn(uint8_t level, uint8_t color)
|
||||
{
|
||||
TIM4->CCR4 = (100-level)*color;
|
||||
TIM4->CCR2 = (100-level)*(100-color);
|
||||
}
|
||||
|
||||
void turnBacklightOff(void)
|
||||
{
|
||||
TIM4->CCR4 = 0;
|
||||
TIM4->CCR2 = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -209,10 +209,19 @@ void pwrOff(void);
|
||||
#define EXTERNAL_RF_OFF() GPIO_ResetBits(GPIO_EXT_RF_PWR, PIN_EXT_RF_PWR)
|
||||
|
||||
// Backlight driver
|
||||
#define setBacklight(xx) TIM10->CCR1 = 100-xx
|
||||
#define __BACKLIGHT_ON TIM10->CCR1 = 100-g_eeGeneral.backlightBright
|
||||
#define __BACKLIGHT_OFF TIM10->CCR1 = 0
|
||||
#define IS_BACKLIGHT_ON() (TIM10->CCR1 != 0)
|
||||
#if defined(REVPLUS)
|
||||
void turnBacklightOn(uint8_t level, uint8_t color);
|
||||
void turnBacklightOff(void);
|
||||
#define setBacklight(xx) turnBacklightOn(xx, g_eeGeneral.backlightColor)
|
||||
#define __BACKLIGHT_ON turnBacklightOn(g_eeGeneral.backlightBright, g_eeGeneral.backlightColor)
|
||||
#define __BACKLIGHT_OFF turnBacklightOff()
|
||||
#define IS_BACKLIGHT_ON() (TIM4->CCR4 != 0) || (TIM4->CCR2 != 0)
|
||||
#else
|
||||
#define setBacklight(xx) TIM10->CCR1 = 100-xx
|
||||
#define __BACKLIGHT_ON TIM10->CCR1 = 100-g_eeGeneral.backlightBright
|
||||
#define __BACKLIGHT_OFF TIM10->CCR1 = 0
|
||||
#define IS_BACKLIGHT_ON() (TIM10->CCR1 != 0)
|
||||
#endif
|
||||
|
||||
// USB driver
|
||||
#define BOOTLOADER_REQUEST() (0)
|
||||
|
||||
@@ -241,13 +241,16 @@
|
||||
#if defined (REVPLUS)
|
||||
#define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOD
|
||||
#define GPIO_Pin_BL GPIO_Pin_15 //PD.15
|
||||
#define Pin_BL_AF GPIO_AF_TIM4
|
||||
#define GPIOBL GPIOD
|
||||
#define GPIO_PinSource_BL GPIO_PinSource15
|
||||
#define GPIO_Pin_BLW GPIO_Pin_13 //PD.13
|
||||
#define Pin_BLW_AF GPIO_AF_TIM4
|
||||
#define GPIO_PinSource_BLW GPIO_PinSource13
|
||||
#else
|
||||
#define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOB
|
||||
#define GPIO_Pin_BL GPIO_Pin_8 //PB.08
|
||||
#define Pin_BL_AF GPIO_AF_TIM10
|
||||
#define GPIOBL GPIOB
|
||||
#define GPIO_PinSource_BL GPIO_PinSource8
|
||||
#endif
|
||||
|
||||
@@ -137,24 +137,41 @@ static void LCD_BL_Config()
|
||||
{
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBL, ENABLE);
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_BL;
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BL;
|
||||
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_BL, GPIO_AF_TIM10);
|
||||
|
||||
#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 = 0x60 ; // PWM
|
||||
TIM4->CCER = 1 ;
|
||||
TIM4->CCR1 = 80;
|
||||
TIM4->EGR = 0 ;
|
||||
TIM4->CR1 = 1 ;
|
||||
#else
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM10EN ; // Enable clock
|
||||
TIM10->ARR = 100 ;
|
||||
TIM10->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 10000 - 1;
|
||||
TIM10->CCMR1 = 0x60 ; // PWM
|
||||
TIM10->CCER = 1 ;
|
||||
|
||||
TIM10->CCR1 = 80;
|
||||
TIM10->EGR = 0 ;
|
||||
TIM10->CR1 = 1 ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Init the anolog spi gpio
|
||||
|
||||
Reference in New Issue
Block a user