Add support for STM32 LCD backlight
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4087 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
7b86861be5
commit
81fac01b31
@ -545,13 +545,25 @@ STM3210E-EVAL-specific Configuration Options
|
|||||||
portrait" orientation support. In this orientation, the
|
portrait" orientation support. In this orientation, the
|
||||||
STM3210E-EVAL's LCD ribbon cable is at the top of the display.
|
STM3210E-EVAL's LCD ribbon cable is at the top of the display.
|
||||||
Default is 320x240 "landscape" orientation.
|
Default is 320x240 "landscape" orientation.
|
||||||
CONFIG_LCD_BACKLIGHT - Define to support an adjustable backlight
|
CONFIG_LCD_BACKLIGHT - Define to support a backlight.
|
||||||
using timer 1. The granularity of the settings is determined
|
CONFIG_LCD_PWM - If CONFIG_STM32_TIM1 is also defined, then an
|
||||||
by CONFIG_LCD_MAXPOWER. Requires CONFIG_STM32_TIM1.
|
adjustable backlight will be provided using timer 1 to generate
|
||||||
|
various pulse widthes. The granularity of the settings is
|
||||||
|
determined by CONFIG_LCD_MAXPOWER. If CONFIG_LCD_PWM (or
|
||||||
|
CONFIG_STM32_TIM1) is not defined, then a simple on/off backlight
|
||||||
|
is provided.
|
||||||
CONFIG_LCD_RDSHIFT - When reading 16-bit gram data, there appears
|
CONFIG_LCD_RDSHIFT - When reading 16-bit gram data, there appears
|
||||||
to be a shift in the returned data. This value fixes the offset.
|
to be a shift in the returned data. This value fixes the offset.
|
||||||
Default 5.
|
Default 5.
|
||||||
|
|
||||||
|
The LCD driver dynamically selects the LCD based on the reported LCD
|
||||||
|
ID value. However, code size can be reduced by suppressing support for
|
||||||
|
individual LCDs using:
|
||||||
|
|
||||||
|
CONFIG_STM32_AM240320_DISABLE
|
||||||
|
CONFIG_STM32_SPFD5408B_DISABLE
|
||||||
|
CONFIG_STM32_R61580_DISABLE
|
||||||
|
|
||||||
Configurations
|
Configurations
|
||||||
==============
|
==============
|
||||||
|
|
||||||
|
@ -906,14 +906,19 @@ CONFIG_NX_MXCLIENTMSGS=16
|
|||||||
# portrait" orientation support. In this orientation, the
|
# portrait" orientation support. In this orientation, the
|
||||||
# STM3210E-EVAL's LCD ribbon cable is at the top of the display.
|
# STM3210E-EVAL's LCD ribbon cable is at the top of the display.
|
||||||
# Default is 320x240 "landscape" orientation.
|
# Default is 320x240 "landscape" orientation.
|
||||||
# CONFIG_LCD_BACKLIGHT - Define to support an adjustable backlight
|
# CONFIG_LCD_BACKLIGHT - Define to support a backlight.
|
||||||
# using timer 1. The granularity of the settings is determined
|
# CONFIG_LCD_PWM - If CONFIG_STM32_TIM1 is also defined, then an
|
||||||
# by CONFIG_LCD_MAXPOWER. Requires CONFIG_STM32_TIM1.
|
# adjustable backlight will be provided using timer 1 to generate
|
||||||
|
# various pulse widthes. The granularity of the settings is
|
||||||
|
# determined by CONFIG_LCD_MAXPOWER. If CONFIG_LCD_PWM (or
|
||||||
|
# CONFIG_STM32_TIM1) is not defined, then a simple on/off backlight
|
||||||
|
# is provided.
|
||||||
#
|
#
|
||||||
CONFIG_LCD_LANDSCAPE=n
|
CONFIG_LCD_LANDSCAPE=n
|
||||||
CONFIG_LCD_PORTRAIT=n
|
CONFIG_LCD_PORTRAIT=n
|
||||||
CONFIG_LCD_RPORTRAIT=y
|
CONFIG_LCD_RPORTRAIT=y
|
||||||
CONFIG_LCD_BACKLIGHT=n
|
CONFIG_LCD_BACKLIGHT=n
|
||||||
|
CONFIG_LCD_PWM=n
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for examples/uip
|
# Settings for examples/uip
|
||||||
|
@ -893,14 +893,19 @@ CONFIG_NX_MXCLIENTMSGS=16
|
|||||||
# portrait" orientation support. In this orientation, the
|
# portrait" orientation support. In this orientation, the
|
||||||
# STM3210E-EVAL's LCD ribbon cable is at the top of the display.
|
# STM3210E-EVAL's LCD ribbon cable is at the top of the display.
|
||||||
# Default is 320x240 "landscape" orientation.
|
# Default is 320x240 "landscape" orientation.
|
||||||
# CONFIG_LCD_BACKLIGHT - Define to support an adjustable backlight
|
# CONFIG_LCD_BACKLIGHT - Define to support a backlight.
|
||||||
# using timer 1. The granularity of the settings is determined
|
# CONFIG_LCD_PWM - If CONFIG_STM32_TIM1 is also defined, then an
|
||||||
# by CONFIG_LCD_MAXPOWER. Requires CONFIG_STM32_TIM1.
|
# adjustable backlight will be provided using timer 1 to generate
|
||||||
|
# various pulse widthes. The granularity of the settings is
|
||||||
|
# determined by CONFIG_LCD_MAXPOWER. If CONFIG_LCD_PWM (or
|
||||||
|
# CONFIG_STM32_TIM1) is not defined, then a simple on/off backlight
|
||||||
|
# is provided.
|
||||||
#
|
#
|
||||||
CONFIG_LCD_LANDSCAPE=n
|
CONFIG_LCD_LANDSCAPE=n
|
||||||
CONFIG_LCD_PORTRAIT=n
|
CONFIG_LCD_PORTRAIT=n
|
||||||
CONFIG_LCD_RPORTRAIT=y
|
CONFIG_LCD_RPORTRAIT=y
|
||||||
CONFIG_LCD_BACKLIGHT=n
|
CONFIG_LCD_BACKLIGHT=n
|
||||||
|
CONFIG_LCD_PWM=n
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for examples/uip
|
# Settings for examples/uip
|
||||||
|
@ -892,14 +892,19 @@ CONFIG_NX_MXCLIENTMSGS=16
|
|||||||
# portrait" orientation support. In this orientation, the
|
# portrait" orientation support. In this orientation, the
|
||||||
# STM3210E-EVAL's LCD ribbon cable is at the top of the display.
|
# STM3210E-EVAL's LCD ribbon cable is at the top of the display.
|
||||||
# Default is 320x240 "landscape" orientation.
|
# Default is 320x240 "landscape" orientation.
|
||||||
# CONFIG_LCD_BACKLIGHT - Define to support an adjustable backlight
|
# CONFIG_LCD_BACKLIGHT - Define to support a backlight.
|
||||||
# using timer 1. The granularity of the settings is determined
|
# CONFIG_LCD_PWM - If CONFIG_STM32_TIM1 is also defined, then an
|
||||||
# by CONFIG_LCD_MAXPOWER. Requires CONFIG_STM32_TIM1.
|
# adjustable backlight will be provided using timer 1 to generate
|
||||||
|
# various pulse widthes. The granularity of the settings is
|
||||||
|
# determined by CONFIG_LCD_MAXPOWER. If CONFIG_LCD_PWM (or
|
||||||
|
# CONFIG_STM32_TIM1) is not defined, then a simple on/off backlight
|
||||||
|
# is provided.
|
||||||
#
|
#
|
||||||
CONFIG_LCD_LANDSCAPE=n
|
CONFIG_LCD_LANDSCAPE=n
|
||||||
CONFIG_LCD_PORTRAIT=n
|
CONFIG_LCD_PORTRAIT=n
|
||||||
CONFIG_LCD_RPORTRAIT=y
|
CONFIG_LCD_RPORTRAIT=y
|
||||||
CONFIG_LCD_BACKLIGHT=n
|
CONFIG_LCD_BACKLIGHT=n
|
||||||
|
CONFIG_LCD_PWM=n
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for examples/uip
|
# Settings for examples/uip
|
||||||
|
@ -892,14 +892,19 @@ CONFIG_NX_MXCLIENTMSGS=16
|
|||||||
# portrait" orientation support. In this orientation, the
|
# portrait" orientation support. In this orientation, the
|
||||||
# STM3210E-EVAL's LCD ribbon cable is at the top of the display.
|
# STM3210E-EVAL's LCD ribbon cable is at the top of the display.
|
||||||
# Default is 320x240 "landscape" orientation.
|
# Default is 320x240 "landscape" orientation.
|
||||||
# CONFIG_LCD_BACKLIGHT - Define to support an adjustable backlight
|
# CONFIG_LCD_BACKLIGHT - Define to support a backlight.
|
||||||
# using timer 1. The granularity of the settings is determined
|
# CONFIG_LCD_PWM - If CONFIG_STM32_TIM1 is also defined, then an
|
||||||
# by CONFIG_LCD_MAXPOWER. Requires CONFIG_STM32_TIM1.
|
# adjustable backlight will be provided using timer 1 to generate
|
||||||
|
# various pulse widthes. The granularity of the settings is
|
||||||
|
# determined by CONFIG_LCD_MAXPOWER. If CONFIG_LCD_PWM (or
|
||||||
|
# CONFIG_STM32_TIM1) is not defined, then a simple on/off backlight
|
||||||
|
# is provided.
|
||||||
#
|
#
|
||||||
CONFIG_LCD_LANDSCAPE=n
|
CONFIG_LCD_LANDSCAPE=n
|
||||||
CONFIG_LCD_PORTRAIT=n
|
CONFIG_LCD_PORTRAIT=n
|
||||||
CONFIG_LCD_RPORTRAIT=y
|
CONFIG_LCD_RPORTRAIT=y
|
||||||
CONFIG_LCD_BACKLIGHT=n
|
CONFIG_LCD_BACKLIGHT=n
|
||||||
|
CONFIG_LCD_PWM=n
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for examples/uip
|
# Settings for examples/uip
|
||||||
|
@ -101,6 +101,16 @@
|
|||||||
#define GPIO_FLASH_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
|
#define GPIO_FLASH_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
|
||||||
GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN2)
|
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 */
|
/* USB Soft Connect Pullup: PB.14 */
|
||||||
|
|
||||||
#define GPIO_USB_PULLUP (GPIO_OUTPUT|GPIO_CNF_OUTOD|GPIO_MODE_50MHz|\
|
#define GPIO_USB_PULLUP (GPIO_OUTPUT|GPIO_CNF_OUTOD|GPIO_MODE_50MHz|\
|
||||||
|
@ -84,11 +84,34 @@
|
|||||||
# define CONFIG_LCD_MAXCONTRAST 1
|
# define CONFIG_LCD_MAXCONTRAST 1
|
||||||
#endif
|
#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 */
|
/* Check power setting */
|
||||||
|
|
||||||
#if !defined(CONFIG_LCD_MAXPOWER) || CONFIG_LCD_MAXPOWER < 1
|
#if !defined(CONFIG_LCD_MAXPOWER) || CONFIG_LCD_MAXPOWER < 1
|
||||||
# undef CONFIG_LCD_MAXPOWER
|
# undef CONFIG_LCD_MAXPOWER
|
||||||
# ifdef CONFIG_LCD_BACKLIGHT
|
# if defined(CONFIG_LCD_BACKLIGHT) && defined(CONFIG_LCD_PWM)
|
||||||
# define CONFIG_LCD_MAXPOWER 100
|
# define CONFIG_LCD_MAXPOWER 100
|
||||||
# else
|
# else
|
||||||
# define CONFIG_LCD_MAXPOWER 1
|
# define CONFIG_LCD_MAXPOWER 1
|
||||||
@ -113,21 +136,6 @@
|
|||||||
# define CONFIG_LCD_LANDSCAPE 1
|
# define CONFIG_LCD_LANDSCAPE 1
|
||||||
#endif
|
#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
|
/* 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:
|
* 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)
|
if (power > 0)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_LCD_BACKLIGHT
|
#ifdef CONFIG_LCD_BACKLIGHT
|
||||||
|
#ifdef CONFIG_LCD_PWM
|
||||||
uint32_t duty;
|
uint32_t duty;
|
||||||
|
|
||||||
/* Caclulate the new backlight duty. It is a faction of the timer1
|
/* 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;
|
duty = LCD_BL_TIMER_PERIOD - 1;
|
||||||
}
|
}
|
||||||
putreg16((uint16_t)duty, STM32_TIM1_CCR1);
|
putreg16((uint16_t)duty, STM32_TIM1_CCR1);
|
||||||
|
#else
|
||||||
|
/* Turn the backlight on */
|
||||||
|
|
||||||
|
stm32_gpiowrite(GPIO_LCD_BACKLIGHT, true);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
/* Then turn the display on */
|
/* Then turn the display on */
|
||||||
|
|
||||||
@ -998,7 +1012,15 @@ static int stm3210e_setpower(struct lcd_dev_s *dev, int power)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* Turn the display off */
|
||||||
|
|
||||||
stm3210e_writereg(LCD_REG_7, 0);
|
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;
|
g_lcddev.power = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1279,6 +1301,7 @@ static inline void stm3210e_lcdinitialize(void)
|
|||||||
#ifdef CONFIG_LCD_BACKLIGHT
|
#ifdef CONFIG_LCD_BACKLIGHT
|
||||||
static void stm3210e_backlight(void)
|
static void stm3210e_backlight(void)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_LCD_PWM
|
||||||
uint16_t ccmr;
|
uint16_t ccmr;
|
||||||
uint16_t ccer;
|
uint16_t ccer;
|
||||||
uint16_t cr2;
|
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("CCR4: %04x\n", getreg32(STM32_TIM1_CCR4));
|
lcddbg("CCR4: %04x\n", getreg32(STM32_TIM1_CCR4));
|
||||||
lcddbg("DMAR: %04x\n", getreg32(STM32_TIM1_DMAR));
|
lcddbg("DMAR: %04x\n", getreg32(STM32_TIM1_DMAR));
|
||||||
|
#else
|
||||||
|
stm32_configgpio(GPIO_LCD_BACKLIGHT);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user