Shenzhou board has an SSD1289 LCD, not ILI93xx

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5194 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-09-26 19:41:54 +00:00
parent d6e70c82fe
commit 5839a2642c
6 changed files with 220 additions and 76 deletions

View File

@ -197,6 +197,7 @@ CONFIG_STM32_PHYSR_100FD=0x8000
CONFIG_STM32_RMII=y
CONFIG_STM32_RMII_MCO=y
# CONFIG_STM32_RMII_EXTCLK is not set
# CONFIG_STM32_ETHMAC_REGDEBUG is not set
#
# USB Host Configuration
@ -350,6 +351,7 @@ CONFIG_SPI_EXCHANGE=y
# CONFIG_SPI_CMDDATA is not set
CONFIG_RTC=y
# CONFIG_RTC_DATETIME is not set
# CONFIG_RTC_HIRES is not set
# CONFIG_RTC_ALARM is not set
# CONFIG_WATCHDOG is not set
# CONFIG_ANALOG is not set
@ -364,6 +366,10 @@ CONFIG_LCD_MAXPOWER=1
# CONFIG_LCD_P14201 is not set
# CONFIG_LCD_NOKIA6100 is not set
# CONFIG_LCD_UG9664HSWAG01 is not set
CONFIG_LCD_SSD1289=y
CONFIG_SSD1289_PROFILE1=y
# CONFIG_SSD1289_PROFILE2 is not set
# CONFIG_SSD1289_PROFILE3 is not set
CONFIG_LCD_LANDSCAPE=y
# CONFIG_LCD_PORTRAIT is not set
# CONFIG_LCD_RPORTRAIT is not set

View File

@ -89,7 +89,7 @@ endif
ifeq ($(CONFIG_LCD_SSD1289),y)
CSRCS += up_ssd1289.c
else
CSRCS += up_lcd.c
CSRCS += up_ili93xx.c
endif
ifeq ($(CONFIG_INPUT_ADS7843E),y)

View File

@ -295,22 +295,29 @@
(STM32_PERIPHBB_BASE + ((offs + STM32_GPIO_BRR_OFFSET) << 5) + ((pin) << 2))
#define LCD_BIT_SET(offs,pin) \
(STM32_PERIPHBB_BASE + ((offs + STM32_GPIO_BSRR_OFFSET) << 5) + ((pin) << 2))
#define LCD_BIT_READ(offs,pin) \
(STM32_PERIPHBB_BASE + ((offs + STM32_GPIO_ODR_OFFSET) << 5) + ((pin) << 2))
#define LCD_RS_CLEAR LCD_BIT_CLEAR(STM32_GPIOD_OFFSET, 13) /* GPIO_PORTD|GPIO_PIN13 */
#define LCD_RS_SET LCD_BIT_SET(STM32_GPIOD_OFFSET, 13)
#define LCD_RS_READ LCD_BIT_READ(STM32_GPIOD_OFFSET, 13)
#define LCD_CS_CLEAR LCD_BIT_CLEAR(STM32_GPIOC_OFFSET, 8) /* GPIO_PORTC|GPIO_PIN8 */
#define LCD_CS_SET LCD_BIT_SET(STM32_GPIOC_OFFSET, 8)
#define LCD_CS_READ LCD_BIT_READ(STM32_GPIOC_OFFSET, 8)
#define LCD_RD_CLEAR LCD_BIT_CLEAR(STM32_GPIOD_OFFSET, 15) /* GPIO_PORTD|GPIO_PIN15 */
#define LCD_RD_SET LCD_BIT_SET(STM32_GPIOD_OFFSET, 15)
#define LCD_RD_READ LCD_BIT_READ(STM32_GPIOD_OFFSET, 15)
#define LCD_WR_CLEAR LCD_BIT_CLEAR(STM32_GPIOD_OFFSET, 14) /* GPIO_PORTD|GPIO_PIN14 */
#define LCD_WR_SET LCD_BIT_SET(STM32_GPIOD_OFFSET, 14)
#define LCD_WR_READ LCD_BIT_READ(STM32_GPIOD_OFFSET, 14)
#define LCD_LE_CLEAR LCD_BIT_CLEAR(STM32_GPIOB_OFFSET, 2) /* GPIO_PORTB|GPIO_PIN2 */
#define LCD_LE_SET LCD_BIT_SET(STM32_GPIOB_OFFSET, 2)
#define LCD_LE_READ LCD_BIT_READ(STM32_GPIOB_OFFSET, 2)
#define LCD_CRL STM32_GPIOE_CRL
#define LCD_CRH STM32_GPIOE_CRH
#define LCD_INPUT 0x44444444
#define LCD_OUTPUT 0x33333333
#define LCD_INPUT 0x44444444 /* Floating input */
#define LCD_OUTPUT 0x33333333 /* Push/pull output */
#define LCD_ODR STM32_GPIOE_ODR
#define LCD_IDR STM32_GPIOE_IDR

View File

@ -1,6 +1,6 @@
/************************************************************************************
* configs/shenzhou/src/up_lcd.c
* arch/arm/src/board/up_lcd.c
* configs/shenzhou/src/up_ili93xx.c
* arch/arm/src/board/up_ili93xx.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
@ -211,6 +211,7 @@
# undef CONFIG_DEBUG_VERBOSE
# undef CONFIG_DEBUG_GRAPHICS
# undef CONFIG_DEBUG_LCD
# undef CONFIG_LCD_REGDEBUG
#endif
#ifndef CONFIG_DEBUG_VERBOSE
@ -425,6 +426,12 @@ struct stm32_dev_s
************************************************************************************/
/* Low Level LCD access */
#ifdef CONFIG_LCD_REGDEBUG
static void stm32_lcdshow(FAR struct stm32_lower_s *priv, FAR const char *msg);
#else
# define stm32_lcdshow(p,m)
#endif
static void stm32_writereg(FAR struct stm32_dev_s *priv, uint8_t regaddr,
uint16_t regval);
static uint16_t stm32_readreg(FAR struct stm32_dev_s *priv, uint8_t regaddr);
@ -485,7 +492,7 @@ static inline void stm32_lcd9919init(FAR struct stm32_dev_s *priv);
#ifndef CONFIG_STM32_ILI1505_DISABLE
static inline void stm32_lcd1505init(FAR struct stm32_dev_s *priv);
#endif
static inline void stm32_lcdinitialize(FAR struct stm32_dev_s *priv);
static inline int stm32_lcdinitialize(FAR struct stm32_dev_s *priv);
/************************************************************************************
* Private Data
@ -577,6 +584,33 @@ static struct stm32_dev_s g_lcddev =
* Private Functions
************************************************************************************/
/************************************************************************************
* Name: stm32_lcdshow
*
* Description:
* Show the state of the interface
*
************************************************************************************/
#ifdef CONFIG_LCD_REGDEBUG
static void stm32_lcdshow(FAR struct stm32_lower_s *priv, FAR const char *msg)
{
dbg("%s:\n", msg);
dbg(" CRTL RS: %d CS: %d RD: %d WR: %d LE: %d\n",
getreg32(LCD_RS_READ), getreg32(LCD_CS_READ), getreg32(LCD_RD_READ),
getreg32(LCD_WR_READ), getreg32(LCD_LE_READ));
dbg(" DATA CR: %08x %08x\n", getreg32(LCD_CRL), getreg32(LCD_CRH));
if (priv->output)
{
dbg(" OUTPUT: %08x\n", getreg32(LCD_ODR));
}
else
{
dbg(" INPUT: %08x\n", getreg32(LCD_IDR));
}
}
#endif
/************************************************************************************
* Name: stm32_writereg
*
@ -601,7 +635,7 @@ static void stm32_writereg(FAR struct stm32_dev_s *priv, uint8_t regaddr, uint16
/* Then write the 16-bit register value */
putreg32(1, LCD_RS_CLEAR);
putreg32(1, LCD_RS_SET);
putreg32(1, LCD_WR_CLEAR);
putreg32((uint32_t)regval, LCD_ODR);
putreg32(1, LCD_WR_SET);
@ -638,7 +672,7 @@ static uint16_t stm32_readreg(FAR struct stm32_dev_s *priv, uint8_t regaddr)
/* Read the 16-bit register value */
putreg32(1, LCD_RS_CLEAR);
putreg32(1, LCD_RS_SET);
putreg32(1, LCD_RD_CLEAR);
putreg32(1, LCD_RD_SET);
regval = (uint16_t)getreg32(LCD_IDR);
@ -688,7 +722,7 @@ static inline void stm32_writegram(FAR struct stm32_dev_s *priv, uint16_t rgbval
/* Write the value (GRAM register already selected) */
putreg32(1, LCD_CS_CLEAR);
putreg32(1, LCD_RS_CLEAR);
putreg32(1, LCD_RS_SET);
putreg32(1, LCD_WR_CLEAR);
putreg32((uint32_t)rgbval, LCD_ODR);
putreg32(1, LCD_WR_SET);
@ -713,7 +747,8 @@ static inline uint16_t stm32_readgram(FAR struct stm32_dev_s *priv)
/* Read the 16-bit value */
putreg32(1, LCD_RS_CLEAR);
putreg32(1, LCD_CS_CLEAR);
putreg32(1, LCD_RS_SET);
putreg32(1, LCD_RD_CLEAR);
putreg32(1, LCD_RD_SET);
regval = (uint16_t)getreg32(LCD_IDR);
@ -770,8 +805,16 @@ static uint16_t stm32_readnoshift(FAR struct stm32_dev_s *priv, FAR uint16_t *ac
static void stm32_setcursor(FAR struct stm32_dev_s *priv, uint16_t col, uint16_t row)
{
stm32_writereg(priv, LCD_REG_32, row); /* GRAM horizontal address */
stm32_writereg(priv, LCD_REG_33, col); /* GRAM vertical address */
if (priv->type = LCD_TYPE_ILI9919)
{
stm32_writereg(priv, LCD_REG_78, col); /* GRAM horizontal address */
stm32_writereg(priv, LCD_REG_79, row); /* GRAM vertical address */
}
else
{
stm32_writereg(priv, LCD_REG_32, row); /* GRAM vertical address */
stm32_writereg(priv, LCD_REG_33, col); /* GRAM horizontal address */
}
}
/************************************************************************************
@ -1726,9 +1769,10 @@ static inline void stm32_lcd1505init(FAR struct stm32_dev_s *priv)
*
************************************************************************************/
static inline void stm32_lcdinitialize(FAR struct stm32_dev_s *priv)
static inline int stm32_lcdinitialize(FAR struct stm32_dev_s *priv)
{
uint16_t id;
int ret = OK;
/* Check LCD ID */
@ -1809,11 +1853,12 @@ static inline void stm32_lcdinitialize(FAR struct stm32_dev_s *priv)
#endif
{
lcddbg("Unsupported LCD type\n");
ret = -ENODEV;
}
lcddbg("LCD type: %d\n", priv->type);
return ret;
}
/************************************************************************************
* Public Functions
************************************************************************************/
@ -1831,6 +1876,7 @@ static inline void stm32_lcdinitialize(FAR struct stm32_dev_s *priv)
int up_lcdinitialize(void)
{
FAR struct stm32_dev_s *priv = &g_lcddev;
int ret;
int i;
lcdvdbg("Initializing\n");
@ -1851,8 +1897,9 @@ int up_lcdinitialize(void)
/* Configure and enable LCD */
up_mdelay(50);
stm32_lcdinitialize(priv);
ret = stm32_lcdinitialize(priv);
if (ret == OK)
{
/* Clear the display (setting it to the color 0=black) */
stm32_lcdclear(0);
@ -1860,7 +1907,9 @@ int up_lcdinitialize(void)
/* Turn the display off */
stm32_poweroff(priv);
return OK;
}
return ret;
}
/************************************************************************************
@ -1925,7 +1974,7 @@ void stm32_lcdclear(uint16_t color)
/* Write the selected color into the entire GRAM memory */
putreg32(1, LCD_CS_CLEAR);
putreg32(1, LCD_RS_CLEAR);
putreg32(1, LCD_RS_SET);
for (i = 0; i < STM32_XRES * STM32_YRES; i++)
{
putreg32(1, LCD_WR_CLEAR);

View File

@ -76,6 +76,7 @@
# undef CONFIG_DEBUG_VERBOSE
# undef CONFIG_DEBUG_GRAPHICS
# undef CONFIG_DEBUG_LCD
# undef CONFIG_LCD_REGDEBUG
#endif
#ifndef CONFIG_DEBUG_VERBOSE
@ -100,14 +101,29 @@
* Private Type Definition
************************************************************************************/
/* This structure describes the state of this driver */
struct stm32_lower_s
{
struct ssd1289_lcd_s dev; /* This is externally visible the driver state */
FAR struct lcd_dev_s *drvr; /* The saved instance of the LCD driver */
bool output; /* True: Configured for output */
};
/**************************************************************************************
* Private Function Protototypes
**************************************************************************************/
/* Helpers */
static void stm32_wrdata(uint16_t data);
#ifdef CONFIG_LCD_REGDEBUG
static void stm32_lcdshow(FAR struct stm32_lower_s *priv, FAR const char *msg);
#else
# define stm32_lcdshow(p,m)
#endif
static void stm32_wrdata(FAR struct stm32_lower_s *priv, uint16_t data);
#ifndef CONFIG_SSD1289_WRONLY
static uint16_t stm32_rddata(void);
static inline uint16_t stm32_rddata(FAR struct stm32_lower_s *priv);
#endif
/* Low Level LCD access */
@ -121,6 +137,11 @@ static uint16_t stm32_read(FAR struct ssd1289_lcd_s *dev);
static void stm32_write(FAR struct ssd1289_lcd_s *dev, uint16_t data);
static void stm32_backlight(FAR struct ssd1289_lcd_s *dev, int power);
/* Initialization */
static void stm32_lcdinput(FAR struct stm32_lower_s *priv);
static void stm32_lcdoutput(FAR struct stm32_lower_s *priv);
/************************************************************************************
* Private Data
************************************************************************************/
@ -224,10 +245,11 @@ static const uint32_t g_lcdconfig[] =
};
#define NLCD_CONFIG (sizeof(g_lcdconfig)/sizeof(uint32_t))
/* This is the driver state structure (there is no retained state information) */
/* Driver state structure (only supports one LCD) */
static struct ssd1289_lcd_s g_ssd1289 =
static struct stm32_lower_s g_lcdlower =
{
{
.select = stm32_select,
.deselect = stm32_deselect,
.index = stm32_index,
@ -236,16 +258,42 @@ static struct ssd1289_lcd_s g_ssd1289 =
#endif
.write = stm32_write,
.backlight = stm32_backlight
},
.drvr = NULL,
.output = false
};
/* The saved instance of the LCD driver */
static FAR struct lcd_dev_s *g_ssd1289drvr;
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Name: stm32_lcdshow
*
* Description:
* Show the state of the interface
*
************************************************************************************/
#ifdef CONFIG_LCD_REGDEBUG
static void stm32_lcdshow(FAR struct stm32_lower_s *priv, FAR const char *msg)
{
dbg("%s:\n", msg);
dbg(" CRTL RS: %d CS: %d RD: %d WR: %d LE: %d\n",
getreg32(LCD_RS_READ), getreg32(LCD_CS_READ), getreg32(LCD_RD_READ),
getreg32(LCD_WR_READ), getreg32(LCD_LE_READ));
dbg(" DATA CR: %08x %08x\n", getreg32(LCD_CRL), getreg32(LCD_CRH));
if (priv->output)
{
dbg(" OUTPUT: %08x\n", getreg32(LCD_ODR));
}
else
{
dbg(" INPUT: %08x\n", getreg32(LCD_IDR));
}
}
#endif
/************************************************************************************
* Name: stm32_wrdata
*
@ -254,11 +302,11 @@ static FAR struct lcd_dev_s *g_ssd1289drvr;
*
************************************************************************************/
static void stm32_wrdata(uint16_t data)
static void stm32_wrdata(FAR struct stm32_lower_s *priv, uint16_t data)
{
/* Make sure D0-D15 are configured as outputs */
stm32_lcdoutput();
stm32_lcdoutput(priv);
/* Latch the 16-bit LCD data and toggle the WR line */
@ -276,18 +324,17 @@ static void stm32_wrdata(uint16_t data)
************************************************************************************/
#ifndef CONFIG_SSD1289_WRONLY
static uint16_t stm32_rddata(void);
static inline uint16_t stm32_rddata(FAR struct stm32_lower_s *priv)
{
/* Make sure D0-D15 are configured as inputs */
stm32_lcdinput();
stm32_lcdinput(priv);
/* Toggle the RD line to latch the 16-bit LCD data */
#warning "Requires pins configured as inputs"
putreg32(1, LCD_RD_CLEAR);
putreg32(1, LCD_RD_SET);
return (uin16_t)getreg32(LCD_IDR);
return (uint16_t)getreg32(LCD_IDR);
}
#endif
@ -322,7 +369,7 @@ static void stm32_deselect(FAR struct ssd1289_lcd_s *dev)
}
/************************************************************************************
* Name: stm32_deselect
* Name: stm32_index
*
* Description:
* Set the index register
@ -331,13 +378,15 @@ static void stm32_deselect(FAR struct ssd1289_lcd_s *dev)
static void stm32_index(FAR struct ssd1289_lcd_s *dev, uint8_t index)
{
/* Clear the RS signal */
FAR struct stm32_lower_s *priv = (FAR struct stm32_lower_s *)dev;
putreg32(1, LCD_RS_CLR);
/* Clear the RS signal to select the index address */
putreg32(1, LCD_RS_CLEAR);
/* And write the index */
stm32_wrdata((uint16_t)index);
stm32_wrdata(priv, (uint16_t)index);
}
/************************************************************************************
@ -351,13 +400,15 @@ static void stm32_index(FAR struct ssd1289_lcd_s *dev, uint8_t index)
#ifndef CONFIG_SSD1289_WRONLY
static uint16_t stm32_read(FAR struct ssd1289_lcd_s *dev)
{
/* Set the RS signal */
FAR struct stm32_lower_s *priv = (FAR struct stm32_lower_s *)dev;
putreg32(1, LCD_RS_CLR);
/* Set the RS signal to select the data address */
/* And return the data */
putreg32(1, LCD_RS_SET);
return stm32_rddata();
/* Read and return the data */
return stm32_rddata(priv);
}
#endif
@ -371,13 +422,15 @@ static uint16_t stm32_read(FAR struct ssd1289_lcd_s *dev)
static void stm32_write(FAR struct ssd1289_lcd_s *dev, uint16_t data)
{
/* Set the RS signal */
FAR struct stm32_lower_s *priv = (FAR struct stm32_lower_s *)dev;
putreg32(1, LCD_RS_CLR);
/* Set the RS signal to select the data address */
putreg32(1, LCD_RS_SET);
/* And write the data */
stm32_wrdata(data);
stm32_wrdata(priv, data);
}
/************************************************************************************
@ -401,21 +454,31 @@ static void stm32_backlight(FAR struct ssd1289_lcd_s *dev, int power)
*
************************************************************************************/
static void stm32_lcdinput(void)
static void stm32_lcdinput(FAR struct stm32_lower_s *priv)
{
#ifndef CONFIG_LCD_FASTCONFIG
int i;
#endif
/* Check if we are already configured for input */
if (priv->output)
{
/* Configure GPIO data lines as inputs */
#ifdef CONFIG_LCD_FASTCONFIG
putreg32(LCD_INPUT, LCD_CRL);
putreg32(LCD_INPUT, LCD_CRH);
#else
int i;
/* Configure GPIO data lines as inputs */
for (i = 0; i < 16; i++)
{
stm32_configgpio(g_lcdin[i]);
}
#endif
/* No longer configured for output */
priv->output = false;
}
}
/************************************************************************************
@ -426,16 +489,31 @@ static void stm32_lcdinput(void)
*
************************************************************************************/
static void stm32_lcdoutput(void)
static void stm32_lcdoutput(FAR struct stm32_lower_s *priv)
{
#ifndef CONFIG_LCD_FASTCONFIG
int i;
#endif
/* Check if we are already configured for output */
if (!priv->output)
{
/* Configure GPIO data lines as outputs */
#ifdef CONFIG_LCD_FASTCONFIG
putreg32(LCD_OUTPUT, LCD_CRL);
putreg32(LCD_OUTPUT, LCD_CRH);
#else
for (i = 0; i < 16; i++)
{
stm32_configgpio(g_lcdout[i]);
}
#endif
/* Now we are configured for output */
priv->output = true;
}
}
/************************************************************************************
@ -454,17 +532,18 @@ static void stm32_lcdoutput(void)
int up_lcdinitialize(void)
{
FAR struct stm32_lower_s *priv = &g_lcdlower;
int i;
/* Only initialize the driver once */
if (!g_ssd1289drvr)
if (!priv->drvr)
{
lcdvdbg("Initializing\n");
/* Configure GPIO pins */
stm32_lcdoutput();
stm32_lcdoutput(priv);
for (i = 0; i < NLCD_CONFIG; i++)
{
stm32_configgpio(g_lcdconfig[i]);
@ -472,8 +551,8 @@ int up_lcdinitialize(void)
/* Configure and enable the LCD */
g_ssd1289drvr = ssd1289_lcdinitialize(&g_ssd1289);
if (!g_ssd1289drvr)
priv->drvr = ssd1289_lcdinitialize(&priv->dev);
if (!priv->drvr)
{
lcddbg("ERROR: ssd1289_lcdinitialize failed\n");
return -ENODEV;
@ -482,7 +561,7 @@ int up_lcdinitialize(void)
/* Turn the display off */
g_ssd1289drvr->setpower(g_ssd1289drvr, 0);
priv->drvr->setpower(priv->drvr, 0);
return OK;
}
@ -497,8 +576,9 @@ int up_lcdinitialize(void)
FAR struct lcd_dev_s *up_lcdgetdev(int lcddev)
{
FAR struct stm32_lower_s *priv = &g_lcdlower;
DEBUGASSERT(lcddev == 0);
return g_ssd1289drvr;
return priv->drvr;
}
/************************************************************************************
@ -511,9 +591,11 @@ FAR struct lcd_dev_s *up_lcdgetdev(int lcddev)
void up_lcduninitialize(void)
{
FAR struct stm32_lower_s *priv = &g_lcdlower;
/* Turn the display off */
g_ssd1289drvr->setpower(g_ssd1289drvr, 0);
priv->drvr->setpower(priv->drvr, 0);
}
#endif /* CONFIG_LCD_SSD1289 */

View File

@ -177,7 +177,7 @@ static void tsc_enable(FAR struct ads7843e_config_s *state, bool enable)
/* Attach and enable, or detach and disable */
ivdbg("IRQ:%d enable:%d\n", STM32_TCS_IRQ, enable);
ivdbg("enable:%d\n", enable);
if (enable)
{
(void)stm32_gpiosetevent(GPIO_TP_INT, false, true, true,