diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-11-10 20:31:21 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-11-10 20:31:21 +0000 |
commit | 97532cbaafe1225ad8e96ff52212681cd87ed907 (patch) | |
tree | 1761bf2f4036caa71facae8e22a9cca5a89ef13b /nuttx/configs/stm3210e-eval/src | |
parent | c1074fd3aae86440ac6ac95b79f8695d9f5f8136 (diff) | |
download | px4-nuttx-97532cbaafe1225ad8e96ff52212681cd87ed907.tar.gz px4-nuttx-97532cbaafe1225ad8e96ff52212681cd87ed907.tar.bz2 px4-nuttx-97532cbaafe1225ad8e96ff52212681cd87ed907.zip |
Add support for STM32 LCD backlight
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4087 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/configs/stm3210e-eval/src')
-rw-r--r-- | nuttx/configs/stm3210e-eval/src/stm3210e-internal.h | 10 | ||||
-rw-r--r-- | nuttx/configs/stm3210e-eval/src/up_lcd.c | 58 |
2 files changed, 52 insertions, 16 deletions
diff --git a/nuttx/configs/stm3210e-eval/src/stm3210e-internal.h b/nuttx/configs/stm3210e-eval/src/stm3210e-internal.h index e86b9a66a..0a953b5e6 100644 --- a/nuttx/configs/stm3210e-eval/src/stm3210e-internal.h +++ b/nuttx/configs/stm3210e-eval/src/stm3210e-internal.h @@ -101,6 +101,16 @@ #define GPIO_FLASH_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\ GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN2) +/* Backlight control: PA.8 + * + * If CONFIG_LCD_TIM1 (and CONFIG_STM32_TIM1) is defined, PA.8 will be + * configured as CH1OUT for variable backlight control. Otherwise, the + * following definition will be used to support a discrete backlight control. + */ + +#define GPIO_LCD_BACKLIGHT (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\ + GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN8) + /* USB Soft Connect Pullup: PB.14 */ #define GPIO_USB_PULLUP (GPIO_OUTPUT|GPIO_CNF_OUTOD|GPIO_MODE_50MHz|\ diff --git a/nuttx/configs/stm3210e-eval/src/up_lcd.c b/nuttx/configs/stm3210e-eval/src/up_lcd.c index 587d4092c..481da54dd 100644 --- a/nuttx/configs/stm3210e-eval/src/up_lcd.c +++ b/nuttx/configs/stm3210e-eval/src/up_lcd.c @@ -84,11 +84,34 @@ # define CONFIG_LCD_MAXCONTRAST 1 #endif +/* Backlight */ + +#ifndef CONFIG_LCD_BACKLIGHT +# undef CONFIG_LCD_PWM +#endif + +#if defined(CONFIG_LCD_BACKLIGHT) && defined(CONFIG_LCD_PWM) +# if !defined(CONFIG_STM32_TIM1) +# warning "CONFIG_LCD_PWM requires CONFIG_STM32_TIM1" +# undef CONFIG_LCD_PWM +# endif +# if defined(CONFIG_STM32_TIM1_FULL_REMAP) +# warning "PA8 cannot be configured as TIM1 CH1 with full remap" +# undef CONFIG_LCD_PWM +# endif +#endif + +#if defined(CONFIG_LCD_BACKLIGHT) && defined(CONFIG_LCD_PWM) +# if CONFIG_LCD_MAXPOWER < 2 +# warning "A larger value of CONFIG_LCD_MAXPOWER is recommended" +# endif +#endif + /* Check power setting */ #if !defined(CONFIG_LCD_MAXPOWER) || CONFIG_LCD_MAXPOWER < 1 # undef CONFIG_LCD_MAXPOWER -# ifdef CONFIG_LCD_BACKLIGHT +# if defined(CONFIG_LCD_BACKLIGHT) && defined(CONFIG_LCD_PWM) # define CONFIG_LCD_MAXPOWER 100 # else # define CONFIG_LCD_MAXPOWER 1 @@ -113,21 +136,6 @@ # define CONFIG_LCD_LANDSCAPE 1 #endif -/* Backlight */ - -#ifdef CONFIG_LCD_BACKLIGHT -# ifndef CONFIG_STM32_TIM1 -# error "CONFIG_STM32_TIM1 to use the LCD backlight controls" -# endif -# if CONFIG_LCD_MAXPOWER < 2 -# warning "A larger value of CONFIG_LCD_MAXPOWER is recommended" -# endif -#endif - -#if defined(CONFIG_STM32_TIM1_FULL_REMAP) -# error "PA8 cannot be configured as TIM1 CH1 with full remap" -#endif - /* When reading 16-bit gram data, there may some shifts in the returned data * and/or there may be some colors in the incorrect posisions: * @@ -969,6 +977,7 @@ static int stm3210e_setpower(struct lcd_dev_s *dev, int power) if (power > 0) { #ifdef CONFIG_LCD_BACKLIGHT +#ifdef CONFIG_LCD_PWM uint32_t duty; /* Caclulate the new backlight duty. It is a faction of the timer1 @@ -982,6 +991,11 @@ static int stm3210e_setpower(struct lcd_dev_s *dev, int power) duty = LCD_BL_TIMER_PERIOD - 1; } putreg16((uint16_t)duty, STM32_TIM1_CCR1); +#else + /* Turn the backlight on */ + + stm32_gpiowrite(GPIO_LCD_BACKLIGHT, true); +#endif #endif /* Then turn the display on */ @@ -998,7 +1012,15 @@ static int stm3210e_setpower(struct lcd_dev_s *dev, int power) } else { + /* Turn the display off */ + stm3210e_writereg(LCD_REG_7, 0); + + /* Turn the backlight off */ + +#if defined(CONFIG_LCD_BACKLIGHT) && !defined(CONFIG_LCD_PWM) + stm32_gpiowrite(GPIO_LCD_BACKLIGHT, true); +#endif g_lcddev.power = 0; } @@ -1279,6 +1301,7 @@ static inline void stm3210e_lcdinitialize(void) #ifdef CONFIG_LCD_BACKLIGHT static void stm3210e_backlight(void) { +#ifdef CONFIG_LCD_PWM uint16_t ccmr; uint16_t ccer; uint16_t cr2; @@ -1387,6 +1410,9 @@ static void stm3210e_backlight(void) lcddbg("CCR4: %04x\n", getreg32(STM32_TIM1_CCR4)); lcddbg("CCR4: %04x\n", getreg32(STM32_TIM1_CCR4)); lcddbg("DMAR: %04x\n", getreg32(STM32_TIM1_DMAR)); +#else + stm32_configgpio(GPIO_LCD_BACKLIGHT); +#endif } #endif |