From 83f135da9f621bea1bb99707cbecb7bff820b22d Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 16 May 2010 16:52:04 +0000 Subject: [PATCH] Misc OLED-related bug fixes git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2681 42af7a65-404d-4744-a932-0658087f49c3 --- configs/eagle100/src/eagle100_internal.h | 2 + configs/lm3s6965-ek/src/lm3s6965ek_internal.h | 5 ++ configs/lm3s6965-ek/src/up_boot.c | 3 +- configs/lm3s6965-ek/src/up_oled.c | 57 ++++++++++++++----- drivers/lcd/p14201.c | 8 ++- examples/nx/nx_main.c | 5 +- 6 files changed, 61 insertions(+), 19 deletions(-) diff --git a/configs/eagle100/src/eagle100_internal.h b/configs/eagle100/src/eagle100_internal.h index 67eec836d5..173f5e274b 100644 --- a/configs/eagle100/src/eagle100_internal.h +++ b/configs/eagle100/src/eagle100_internal.h @@ -44,6 +44,8 @@ #include #include +#include "chip.h" + /************************************************************************************ * Definitions ************************************************************************************/ diff --git a/configs/lm3s6965-ek/src/lm3s6965ek_internal.h b/configs/lm3s6965-ek/src/lm3s6965ek_internal.h index c0ddfa6d96..fb3a8a4eae 100755 --- a/configs/lm3s6965-ek/src/lm3s6965ek_internal.h +++ b/configs/lm3s6965-ek/src/lm3s6965ek_internal.h @@ -44,6 +44,8 @@ #include #include +#include "chip.h" + /************************************************************************************ * Definitions ************************************************************************************/ @@ -103,12 +105,15 @@ /* GPIOs for OLED: * - PC7: OLED display data/control select (D/Cn) * - PA3: OLED display chip select (CSn) + * - PC6: Enable +15V needed by OLED (EN+15V) */ #define OLEDDC_GPIO (GPIO_FUNC_OUTPUT | GPIO_PADTYPE_STD | GPIO_STRENGTH_8MA | \ GPIO_VALUE_ONE | GPIO_PORTC | 7) #define OLEDCS_GPIO (GPIO_FUNC_OUTPUT | GPIO_PADTYPE_STDWPU | GPIO_STRENGTH_4MA | \ GPIO_VALUE_ONE | GPIO_PORTA | 3) +#define OLEDEN_GPIO (GPIO_FUNC_OUTPUT | GPIO_PADTYPE_STD | GPIO_STRENGTH_8MA | \ + GPIO_VALUE_ONE | GPIO_PORTC | 6) /************************************************************************************ * Public Functions diff --git a/configs/lm3s6965-ek/src/up_boot.c b/configs/lm3s6965-ek/src/up_boot.c index 2a3d593898..3fb75cf543 100755 --- a/configs/lm3s6965-ek/src/up_boot.c +++ b/configs/lm3s6965-ek/src/up_boot.c @@ -45,6 +45,7 @@ #include #include "up_arch.h" +#include "up_internal.h" #include "lm3s6965ek_internal.h" /************************************************************************************ @@ -74,7 +75,7 @@ void lm3s_boardinitialize(void) * lm3s_ssiinitialize() has been brought into the link. */ - /* The LM3S6965 Eval Kit microSD CS and OLED are on SSI0 */ + /* The LM3S6965 Eval Kit microSD CS and OLED are on SSI0 (Duh! There is no SSI1) */ #if !defined(CONFIG_SSI0_DISABLE) /* || !defined(CONFIG_SSI1_DISABLE) */ if (lm3s_ssiinitialize) diff --git a/configs/lm3s6965-ek/src/up_oled.c b/configs/lm3s6965-ek/src/up_oled.c index 5bc3e9146a..55b8a3414a 100755 --- a/configs/lm3s6965-ek/src/up_oled.c +++ b/configs/lm3s6965-ek/src/up_oled.c @@ -55,28 +55,57 @@ * Pre-Processor Definitions ****************************************************************************/ +/* Define the CONFIG_LCD_RITDEBUG to enable detailed debug output (stuff you + * would never want to see unless you are debugging this file). + * + * Verbose debug must also be enabled + */ + +#ifndef CONFIG_DEBUG +# undef CONFIG_DEBUG_VERBOSE +# undef CONFIG_DEBUG_GRAPHICS +#endif + +#ifndef CONFIG_DEBUG_VERBOSE +# undef CONFIG_LCD_RITDEBUG +#endif + +#ifdef CONFIG_LCD_RITDEBUG +# define ritdbg(format, arg...) vdbg(format, ##arg) +# define oleddc_dumpgpio(m) lm3s_dumpgpio(OLEDDC_GPIO, m) +# define oledcs_dumpgpio(m) lm3s_dumpgpio(OLEDCS_GPIO, m) +#else +# define ritdbg(x...) +# define oleddc_dumpgpio(m) +# define oledcs_dumpgpio(m) +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Name: up_nxdrvinit * * Description: * Called NX initialization logic to configure the OLED. * - ************************************************************************************/ + ****************************************************************************/ FAR struct lcd_dev_s *up_nxdrvinit(unsigned int devno) { FAR struct spi_dev_s *spi; FAR struct lcd_dev_s *dev; - /* Configure the OLED D/Cn GPIO */ + /* Configure the OLED GPIOs */ - lm3s_configgpio(OLEDDC_GPIO); + oledcs_dumpgpio("up_nxdrvinit: After OLEDCS setup"); + oleddc_dumpgpio("up_nxdrvinit: On entry"); + lm3s_configgpio(OLEDDC_GPIO); /* PC7: OLED display data/control select (D/Cn) */ + lm3s_configgpio(OLEDEN_GPIO); /* PC6: Enable +15V needed by OLED (EN+15V) */ + oleddc_dumpgpio("up_nxdrvinit: After OLEDDC/EN setup"); - /* Get the SPI port */ + /* Get the SSI port (configure as a Freescale SPI port) */ spi = up_spiinitialize(0); if (!spi) @@ -85,16 +114,16 @@ FAR struct lcd_dev_s *up_nxdrvinit(unsigned int devno) } else { - /* Bind the SPI port to the OLED */ + /* Bind the SSI port to the OLED */ dev = rit_initialize(spi, devno); if (!dev) { - glldbg("Failed to bind SPI port 0 to OLED %d: %d\n", devno); + glldbg("Failed to bind SSI port 0 to OLED %d: %d\n", devno); } else { - gllvdbg("Bound SPI port 0 to OLED %d\n", devno); + gllvdbg("Bound SSI port 0 to OLED %d\n", devno); /* And turn the OLED on (CONFIG_LCD_MAXPOWER should be 1) */ @@ -105,23 +134,23 @@ FAR struct lcd_dev_s *up_nxdrvinit(unsigned int devno) return NULL; } -/************************************************************************************** +/****************************************************************************** * Name: rit_seldata * * Description: - * Set or clear the SD1329 D/Cn bit to select data (true) or command (false). This - * function must be provided by platform-specific logic. + * Set or clear the SD1329 D/Cn bit to select data (true) or command + * (false). This function must be provided by platform-specific logic. * * Input Parameters: * - * devno - A value in the range of 0 throuh CONFIG_P14201_NINTERFACES-1. This allows - * support for multiple OLED devices. + * devno - A value in the range of 0 throuh CONFIG_P14201_NINTERFACES-1. + * This allows support for multiple OLED devices. * data - true: select data; false: select command * * Returned Value: * None * - **************************************************************************************/ + ******************************************************************************/ void rit_seldata(unsigned int devno, bool data) { diff --git a/drivers/lcd/p14201.c b/drivers/lcd/p14201.c index d591360292..6c05bacbf5 100755 --- a/drivers/lcd/p14201.c +++ b/drivers/lcd/p14201.c @@ -173,9 +173,9 @@ /* Debug ******************************************************************************/ #ifdef CONFIG_LCD_RITDEBUG -# define ritdbg(format, arg...) vdbg(format, ##arg) +# define ritdbg(format, arg...) vdbg(format, ##arg) #else -# define ritdbg(x...) +# define ritdbg(x...) #endif /************************************************************************************** @@ -1068,7 +1068,7 @@ static int rit_getpower(FAR struct lcd_dev_s *dev) DEBUGASSERT(priv); gvdbg("power: %s\n", priv->on ? "ON" : "OFF"); - return (int)priv->on; + return priv->on ? CONFIG_LCD_MAXPOWER : 0; } /************************************************************************************** @@ -1102,12 +1102,14 @@ static int rit_setpower(struct lcd_dev_s *dev, int power) /* Take the display out of sleep mode */ rit_sndcmd(priv, g_sleepoff, sizeof(g_sleepoff)); + priv->on = true; } else { /* Put the display into sleep mode */ rit_sndcmd(priv, g_sleepon, sizeof(g_sleepon)); + priv->on = false; } /* De-select the SD1329 controller */ diff --git a/examples/nx/nx_main.c b/examples/nx/nx_main.c index 06f0c53ec3..1320862f3d 100644 --- a/examples/nx/nx_main.c +++ b/examples/nx/nx_main.c @@ -417,7 +417,6 @@ static inline int nxeg_raise(NXEGWINDOW hwnd) static inline int nxeg_suinitialize(void) { FAR NX_DRIVERTYPE *dev; - int ret; #if defined(CONFIG_EXAMPLES_NX_EXTERNINIT) /* Use external graphics driver initialization */ @@ -432,6 +431,8 @@ static inline int nxeg_suinitialize(void) } #elif defined(CONFIG_NX_LCDDRIVER) + int ret; + /* Initialize the LCD device */ message("nxeg_initialize: Initializing LCD\n"); @@ -457,6 +458,8 @@ static inline int nxeg_suinitialize(void) (void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4)); #else + int ret; + /* Initialize the frame buffer device */ message("nxeg_initialize: Initializing framebuffer\n");