summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-04-01 19:06:40 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-04-01 19:06:40 +0000
commit67a850ba575659cb195e67aa8357a70dece9c418 (patch)
tree37166ed8f8869924b96ba69851734c7a3bf3c883 /nuttx
parent61b6197aac69199c63055acc067a5533c3a2787c (diff)
downloadpx4-nuttx-67a850ba575659cb195e67aa8357a70dece9c418.tar.gz
px4-nuttx-67a850ba575659cb195e67aa8357a70dece9c418.tar.bz2
px4-nuttx-67a850ba575659cb195e67aa8357a70dece9c418.zip
Update STM3210E-EVAL backlight controls
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4549 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/configs/stm3210e-eval/src/up_lcd.c68
1 files changed, 55 insertions, 13 deletions
diff --git a/nuttx/configs/stm3210e-eval/src/up_lcd.c b/nuttx/configs/stm3210e-eval/src/up_lcd.c
index be2de96a1..11da916d1 100644
--- a/nuttx/configs/stm3210e-eval/src/up_lcd.c
+++ b/nuttx/configs/stm3210e-eval/src/up_lcd.c
@@ -968,6 +968,43 @@ static int stm3210e_getpower(struct lcd_dev_s *dev)
}
/**************************************************************************************
+ * Name: stm3210e_poweroff
+ *
+ * Description:
+ * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On
+ * backlit LCDs, this setting may correspond to the backlight setting.
+ *
+ **************************************************************************************/
+
+static int stm3210e_poweroff(void)
+{
+ /* Turn the display off */
+
+ stm3210e_writereg(LCD_REG_7, 0);
+
+ /* Disable timer 1 clocking */
+
+#if defined(CONFIG_LCD_BACKLIGHT)
+# if defined(CONFIG_LCD_PWM)
+ modifyreg32(STM32_RCC_APB2ENR, RCC_APB2ENR_TIM1EN, 0);
+#endif
+
+ /* Configure the PA8 pin as an output */
+
+ stm32_configgpio(GPIO_LCD_BACKLIGHT);
+
+ /* Turn the backlight off */
+
+ stm32_gpiowrite(GPIO_LCD_BACKLIGHT, false);
+#endif
+
+ /* Remember the power off state */
+
+ g_lcddev.power = 0;
+ return OK;
+}
+
+/**************************************************************************************
* Name: stm3210e_setpower
*
* Description:
@@ -990,6 +1027,20 @@ static int stm3210e_setpower(struct lcd_dev_s *dev, int power)
uint32_t frac;
uint32_t duty;
+ /* If we are coming up from the power off state, then re-configure the timer */
+
+ if (g_lcddev.power == 0)
+ {
+ stm3210e_backlight();
+ }
+
+ /* Make sure that the power value is within range */
+
+ if (power > CONFIG_LCD_MAXPOWER)
+ {
+ power = CONFIG_LCD_MAXPOWER;
+ }
+
/* Caclulate the new backlight duty. It is a faction of the timer1
* period based on the ration of the current power setting to the
* maximum power setting.
@@ -1025,14 +1076,7 @@ static int stm3210e_setpower(struct lcd_dev_s *dev, int power)
{
/* 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;
+ stm3210e_poweroff();
}
return OK;
@@ -1522,8 +1566,6 @@ static void stm3210e_backlight(void)
lcddbg("CCR3: %04x\n", getreg32(STM32_TIM1_CCR3));
lcddbg("CCR4: %04x\n", getreg32(STM32_TIM1_CCR4));
lcddbg("DMAR: %04x\n", getreg32(STM32_TIM1_DMAR));
-#else
- stm32_configgpio(GPIO_LCD_BACKLIGHT);
#endif
}
#endif
@@ -1559,9 +1601,9 @@ int up_lcdinitialize(void)
stm3210e_lcdclear(0);
- /* Configure the backlight */
+ /* Turn the backlight off */
- stm3210e_backlight();
+ stm3210e_poweroff();
return OK;
}
@@ -1590,7 +1632,7 @@ FAR struct lcd_dev_s *up_lcdgetdev(int lcddev)
void up_lcduninitialize(void)
{
- stm3210e_setpower(&g_lcddev.dev, 0);
+ stm3210e_poweroff();
stm32_deselectlcd();
}