LCD bug fixes

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3166 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2010-12-07 03:06:19 +00:00
parent 29fafdc323
commit 52173a3324
8 changed files with 168 additions and 47 deletions
+2
View File
@@ -1399,3 +1399,5 @@
* drivers/lcd/nokia6100.c -- A driver for the Nokia 6100 LCD.
* configs/olimex-lpc1766stk/nx -- A NX graphics configuration for the Olimex
LPC1766-STK board using the Nokia 6100 LCD driver.
* include/nuttx/spi.h -- the SPI_SETBITS macro was calling the setmode method.
This is a very important bug-fix in some usages.
+6 -3
View File
@@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
<p>Last Updated: December 4, 2010</p>
<p>Last Updated: December 6, 2010</p>
</td>
</tr>
</table>
@@ -1276,10 +1276,11 @@
The NSH configuration support the Nucleus2G's microSD slot and additional configurations
are available to exercise the the USB serial and USB mass storage devices.
However, due to some technical reasons, neither the SPI nor the USB device drivers are fully verified.
(Although it has been reported to me that the SPI microSD is functional on other platforms).
(Although they have since been verfiied on other platforms; this needs to be revisited on the Nucleus2G).
</p>
<p>
Support for the mbed board was contributed by Dave Marples and released in NuttX-5.11.
This port includes a NuttX OS test configuration(see <code>examples/ostest</code>).
</p>
<p>
Support for that Olimex-LPC1766-STK board was added to NuttX 5.13.
@@ -1287,7 +1288,7 @@
Verified configurations are now available for the NuttX OS test,
for the NuttShell (NSH, see the <a href="ttp://www.nuttx.org/NuttShell.html">NSH User Guide</a>),
for the NuttX network test, and for the <a href="http://acme.com/software/thttpd">THTTPD</a> webserver.
Additional drivers for USB device and MicroSD has also be added and verified are available in CVS;
Additional drivers for USB device and MicroSD have also be added and have been verified and are available in CVS;
A driver for the Nokia 6100 LCD has been added and is under test now.
All are expected to be released in NuttX-5.15.
</p>
@@ -2021,6 +2022,8 @@ nuttx-5.15 2010-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
* drivers/lcd/nokia6100.c -- A driver for the Nokia 6100 LCD.
* configs/olimex-lpc1766stk/nx -- A NX graphics configuration for the Olimex
LPC1766-STK board using the Nokia 6100 LCD driver.
* include/nuttx/spi.h -- the SPI_SETBITS macro was calling the setmode method.
This is a very important bug-fix in some usages.
pascal-2.1 2010-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
+21
View File
@@ -2838,6 +2838,27 @@ build
<li>
<code>CONFIG_NOKIA6100_BLINIT</code>: Initial backlight setting
</li>
<p>
The following may need to be tuned for your hardware:
</p>
<li>
<code>CONFIG_NOKIA6100_INVERT</code>: Display inversion, 0 or 1, Default: 1
</li>
<li>
<code>CONFIG_NOKIA6100_MY</code>: Display row direction, 0 or 1, Default: 0
</li>
<li>
<code>CONFIG_NOKIA6100_MX</code>: Display column direction, 0 or 1, Default: 1
</li>
<li>
<code>CONFIG_NOKIA6100_V</code>: Display address direction, 0 or 1, Default: 0
</li>
<li>
<code>CONFIG_NOKIA6100_ML</code>: Display scan direction, 0 or 1, Default: 0
</li>
<li>
<code>CONFIG_NOKIA6100_RGBORD</code>: Display RGB order, 0 or 1, Default: 0
</li>
<p>
Required LCD driver settings:
</p>
+2 -1
View File
@@ -434,13 +434,14 @@ static void ssp_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode)
break;
default:
sspdbg("Bad mode: %d\n", mode);
DEBUGASSERT(FALSE);
return;
}
ssp_putreg(priv, LPC17_SSP_CR0_OFFSET, regval);
/* Save the mode so that subsequent re-configuratins will be faster */
/* Save the mode so that subsequent re-configurations will be faster */
#ifndef CONFIG_SPI_OWNBUS
priv->mode = mode;
+8
View File
@@ -557,6 +557,14 @@ defconfig -- This is a configuration file similar to the Linux
CONFIG_NOKIA6100_PCF8833 - Selects the Phillips PCF8833 display controller
CONFIG_NOKIA6100_BLINIT - Initial backlight setting
The following may need to be tuned for your hardware:
CONFIG_NOKIA6100_INVERT - Display inversion, 0 or 1, Default: 1
CONFIG_NOKIA6100_MY - Display row direction, 0 or 1, Default: 0
CONFIG_NOKIA6100_MX - Display column direction, 0 or 1, Default: 1
CONFIG_NOKIA6100_V - Display address direction, 0 or 1, Default: 0
CONFIG_NOKIA6100_ML - Display scan direction, 0 or 1, Default: 0
CONFIG_NOKIA6100_RGBORD - Display RGB order, 0 or 1, Default: 0
Required LCD driver settings:
CONFIG_LCD_NOKIA6100 - Enable Nokia 6100 support
CONFIG_LCD_MAXCONTRAST - must be 63 with the Epson controller and 127 with
+114 -36
View File
@@ -83,6 +83,14 @@
* CONFIG_NOKIA6100_PCF8833 - Selects the Phillips PCF8833 display controller
* CONFIG_NOKIA6100_BLINIT - Initial backlight setting
*
* The following may need to be tuned for your hardware:
* CONFIG_NOKIA6100_INVERT - Display inversion, 0 or 1, Default: 1
* CONFIG_NOKIA6100_MY - Display row direction, 0 or 1, Default: 0
* CONFIG_NOKIA6100_MX - Display column direction, 0 or 1, Default: 1
* CONFIG_NOKIA6100_V - Display address direction, 0 or 1, Default: 0
* CONFIG_NOKIA6100_ML - Display scan direction, 0 or 1, Default: 0
* CONFIG_NOKIA6100_RGBORD - Display RGB order, 0 or 1, Default: 0
*
* Required LCD driver settings:
* CONFIG_LCD_NOKIA6100 - Enable Nokia 6100 support
* CONFIG_LCD_MAXCONTRAST - must be 63 with the Epson controller and 127 with
@@ -157,6 +165,32 @@
# error "One of CONFIG_NOKIA6100_S1D15G10 or CONFIG_NOKIA6100_PCF8833 must be defined"
#endif
/* Delay geometry defaults */
#ifndef CONFIG_NOKIA6100_INVERT
# define CONFIG_NOKIA6100_INVERT 1
#endif
#ifndef CONFIG_NOKIA6100_MY
# define CONFIG_NOKIA6100_MY 0
#endif
#ifndef CONFIG_NOKIA6100_MX
# define CONFIG_NOKIA6100_MX 1
#endif
#ifndef CONFIG_NOKIA6100_V
# define CONFIG_NOKIA6100_V 0
#endif
#ifndef CONFIG_NOKIA6100_ML
# define CONFIG_NOKIA6100_ML 0
#endif
#ifndef CONFIG_NOKIA6100_RGBORD
# define CONFIG_NOKIA6100_RGBORD 0
#endif
/* Check contrast selection */
#ifdef CONFIG_NOKIA6100_S1D15G10
@@ -200,11 +234,9 @@
#define NOKIA_LCD_DATA (1 << 9)
/* Define the following to enable register-level debug output */
#undef CONFIG_LCD_REGDEBUG
/* Verbose debug must also be enabled */
/* Define CONFIG_LCD_REGDEBUG to enable register-level debug output.
* (Verbose debug must also be enabled)
*/
#ifndef CONFIG_DEBUG
# undef CONFIG_DEBUG_VERBOSE
@@ -258,10 +290,17 @@
/* Handle any potential strange behavior at edges */
#if 0 /* REVISIT */
#define NOKIA_PGBIAS 2 /* May not be necessary */
#define NOKIA_COLBIAS 0
#define NOKIA_XBIAS 2 /* May not be necessary */
#define NOKIA_XBIAS 2 /* May not be necessary, if so need to subtract from XRES */
#define NOKIA_YBIAS 0
#else
#define NOKIA_PGBIAS 0
#define NOKIA_COLBIAS 0
#define NOKIA_XBIAS 0
#define NOKIA_YBIAS 0
#endif
#define NOKIA_ENDPAGE 131
#define NOKIA_ENDCOL 131
@@ -269,7 +308,7 @@
/* Debug ******************************************************************************/
#ifdef CONFIG_LCD_REGDEBUG
# define lcddbg(format, arg...) vdbg(format, ##arg)
# define lcddbg(format, arg...) llvdbg(format, ##arg)
#else
# define lcddbg(x...)
#endif
@@ -484,24 +523,33 @@ static const uint8_t g_pwrctr[] =
* P3: Grayscale setup
*/
#if CONFIG_NOKIA6100_BPP == 12
static const uint8_t g_datctl[] =
{
S1D15G10_DATCTL, /* Data control */
DATCTL_PGADDR_INV, /* Page addr inverted, col addr normal, addr scan in col direction */
//DATCTL_PGADDR_INV|DATCTL_COLADDR_REV /* Page addr inverted, col addr normal, addr scan in col direction */
0, /* RGB->RGB */
DATCTL_16GRAY_A /* Selects 16-bit color, Type A */
};
#else /* CONFIG_NOKIA6100_BPP == 8 */
static const uint8_t g_datctl[] =
{
S1D15G10_DATCTL, /* Data control */
0, /* Page addr normal, col addr normal, addr scan in col direction */
0, /* RGB->RGB */
DATCTL_8GRAY /* Selects 8-bit color */
};
0
#if CONFIG_NOKIA6100_MY != 0 /* Display row direction */
|DATCTL_PGADDR_INV /* Page address inverted */
#endif
#if CONFIG_NOKIA6100_MX != 0 /* Display column direction */
|DATCTL_COLADDR_REV /* Column address reversed */
#endif
#if CONFIG_NOKIA6100_V != 0 /* Display address direction */
|DATCTL_ADDR_PGDIR /* Address scan in page direction */
#endif
,
#if CONFIG_NOKIA6100_RGBORD != 0
DATCTL_BGR, /* RGB->BGR */
#else
0, /* RGB->RGB */
#endif
#if CONFIG_NOKIA6100_BPP == 8
DATCTL_16GRAY_A /* Selects 16-bit color, Type A */
#elif CONFIG_NOKIA6100_BPP == 12
DATCTL_8GRAY /* Selects 8-bit color */
#else
# error "16-bit mode not yet implemented"
#endif
};
/* Voltage control (contrast setting):
* P1: Volume value
@@ -570,7 +618,22 @@ static const uint8_t g_colmod[] =
static const uint8_t g_madctl[] =
{
PCF8833_MADCTL, /* Memory data access control*/
MADCTL_MX|MADCTL_MY|MADCTL_RGB /* Mirror x and y, reverse rgb */
0
#ifdef CONFIG_NOKIA6100_RGBORD != 0
|MADCTL_RGB /* RGB->BGR */
#endif
#ifdef CONFIG_NOKIA6100_MY != 0 /* Display row direction */
|MADCTL_MY /* Mirror Y */
#endif
#ifdef CONFIG_NOKIA6100_MX != 0 /* Display column direction */
|MADCTL_MX /* Mirror X */
#endif
#ifdef CONFIG_NOKIA6100_V != 0 /* Display address direction */
|MADCTL_V /* ertical RAM write; in Y direction */
#endif
#ifdef CONFIG_NOKIA6100_ML != 0 /* Display scan direction */
|MADCTL_LAO /* Line address order bottom to top */
#endif
};
/* Set contrast (SETCON) */
@@ -605,12 +668,8 @@ static const uint8_t g_setcon[] =
static inline void nokia_configspi(FAR struct spi_dev_s *spi)
{
#ifdef CONFIG_NOKIA6100_FREQUENCY
lcddbg("Mode: %d Bits: %d Frequency: %d\n",
CONFIG_NOKIA6100_SPIMODE, CONFIG_NOKIA6100_WORDWIDTH, CONFIG_NOKIA6100_FREQUENCY);
#else
lcddbg("Mode: %d Bits: 9\n", CONFIG_NOKIA6100_SPIMODE);
#endif
/* Configure SPI for the Nokia 6100. But only if we own the SPI bus. Otherwise, don't
* bother because it might change.
@@ -619,10 +678,8 @@ static inline void nokia_configspi(FAR struct spi_dev_s *spi)
#ifdef CONFIG_SPI_OWNBUS
SPI_SETMODE(spi, CONFIG_NOKIA6100_SPIMODE);
SPI_SETBITS(spi, CONFIG_NOKIA6100_WORDWIDTH);
#ifdef CONFIG_NOKIA6100_FREQUENCY
SPI_SETFREQUENCY(spi, CONFIG_NOKIA6100_FREQUENCY)
#endif
#endif
}
/**************************************************************************************
@@ -646,6 +703,7 @@ static inline void nokia_select(FAR struct spi_dev_s *spi)
{
/* We own the SPI bus, so just select the chip */
lcddbg("SELECTED\n");
SPI_SELECT(spi, SPIDEV_DISPLAY, true);
}
#else
@@ -655,6 +713,7 @@ static void nokia_select(FAR struct spi_dev_s *spi)
* devices competing for the SPI bus
*/
lcddbg("SELECTED\n");
SPI_LOCK(spi, true);
SPI_SELECT(spi, SPIDEV_DISPLAY, true);
@@ -664,9 +723,7 @@ static void nokia_select(FAR struct spi_dev_s *spi)
SPI_SETMODE(spi, CONFIG_NOKIA6100_SPIMODE);
SPI_SETBITS(spi, CONFIG_NOKIA6100_WORDWIDTH);
#ifdef CONFIG_NOKIA6100_FREQUENCY
SPI_SETFREQUENCY(spi, CONFIG_NOKIA6100_FREQUENCY);
#endif
}
#endif
@@ -691,6 +748,7 @@ static inline void nokia_deselect(FAR struct spi_dev_s *spi)
{
/* We own the SPI bus, so just de-select the chip */
lcddbg("DE-SELECTED\n");
SPI_SELECT(spi, SPIDEV_DISPLAY, false);
}
#else
@@ -698,6 +756,7 @@ static void nokia_deselect(FAR struct spi_dev_s *spi)
{
/* De-select Nokia 6100 chip and relinquish the SPI bus. */
lcddbg("DE-SELECTED\n");
SPI_SELECT(spi, SPIDEV_DISPLAY, false);
SPI_LOCK(spi, false);
}
@@ -715,6 +774,7 @@ static void nokia_sndcmd(FAR struct spi_dev_s *spi, const uint8_t cmd)
{
/* Select the LCD */
lcddbg("cmd: %02x\n", cmd);
nokia_select(spi);
/* Send the command. Bit 8 == 0 denotes a command */
@@ -737,14 +797,15 @@ static void nokia_sndcmd(FAR struct spi_dev_s *spi, const uint8_t cmd)
static void nokia_cmddata(FAR struct spi_dev_s *spi, uint8_t cmd, int datlen,
const uint8_t *data)
{
uint16_t *linebuf = g_rowbuf;
uint16_t *rowbuf = g_rowbuf;
int i;
lcddbg("cmd: %02x datlen: %d\n", cmd, datlen);
DEBUGASSERT(datlen <= NOKIA_STRIDE);
/* Copy the command into the line buffer. Bit 8 == 0 denotes a command. */
*linebuf++ = cmd;
*rowbuf++ = cmd;
/* Copy any data after the command into the line buffer */
@@ -752,7 +813,7 @@ static void nokia_cmddata(FAR struct spi_dev_s *spi, uint8_t cmd, int datlen,
{
/* Bit 8 == 1 denotes data */
*linebuf++ = (uint16_t)*data++ | NOKIA_LCD_DATA;
*rowbuf++ = (uint16_t)*data++ | NOKIA_LCD_DATA;
}
/* Select the LCD */
@@ -791,6 +852,14 @@ static void nokia_ramwr(FAR struct spi_dev_s *spi, int datlen, const uint8_t *da
static void nokia_cmdarray(FAR struct spi_dev_s *spi, int len, const uint8_t *cmddata)
{
#ifdef CONFIG_LCD_REGDEBUG
int i;
for (i = 0; i < len; i++)
{
lcddbg("cmddata[%d]: %02x\n", i, cmddata[i]);
}
#endif
nokia_cmddata(spi, cmddata[0], len-1, &cmddata[1]);
}
@@ -804,7 +873,7 @@ static void nokia_cmdarray(FAR struct spi_dev_s *spi, int len, const uint8_t *cm
static void nokia_clrram(FAR struct spi_dev_s *spi)
{
uint16_t *linebuf = g_rowbuf;
uint16_t *rowbuf = g_rowbuf;
int i;
/* Set all zero data in the line buffer */
@@ -813,7 +882,7 @@ static void nokia_clrram(FAR struct spi_dev_s *spi)
{
/* Bit 8 == 1 denotes data */
*linebuf++ = NOKIA_LCD_DATA;
*rowbuf++ = NOKIA_LCD_DATA;
}
/* Select the LCD and send the RAMWR command */
@@ -862,7 +931,7 @@ static int nokia_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffe
#if NOKIA_XBIAS > 0
row += NOKIA_YBIAS;
#endif
DEBUGASSERT(buffer && col < NOKIA_XRES && row >= 0 && );
DEBUGASSERT(buffer && col >=0 && (col + npixels) <= NOKIA_XRES && row >= 0 && row < NOKIA_YRES);
/* Set up to write the run. */
@@ -1070,7 +1139,11 @@ static int nokia_initialize(struct nokia_dev_s *priv)
nokia_cmdarray(spi, sizeof(g_volctr), g_volctr); /* Volume control (contrast) */
nokia_cmdarray(spi, sizeof(g_pwrctr), g_pwrctr); /* Turn on voltage regulators */
up_mdelay(100);
#ifdef CONFIG_NOKIA6100_INVERT
nokia_sndcmd(spi, S1D15G10_DISINV); /* Invert display */
#else
nokia_sndcmd(spi, S1D15G10_DISNOR); /* Normal display */
#endif
nokia_cmdarray(spi, sizeof(g_datctl), g_datctl); /* Data control */
#if CONFIG_NOKIA6100_BPP == 8
nokia_cmdarray(spi, sizeof(g_rgbset8), g_rgbset8); /* Set up color lookup table */
@@ -1091,7 +1164,11 @@ static int nokia_initialize(struct nokia_dev_s *priv)
nokia_sndcmd(spi, PCF8833_SLEEPOUT); /* Exit sleep mode */
nokia_sndcmd(spi, PCF8833_BSTRON); /* Turn on voltage booster */
#ifdef CONFIG_NOKIA6100_INVERT
nokia_sndcmd(spi, PCF8833_INVON); /* Invert display */
#else
nokia_sndcmd(spi, PCF8833_INVOFF); /* Don't invert display */
#endif
nokia_cmdarray(spi, sizeof(g_madctl), g_madctl); /* Memory data access control */
nokia_cmdarray(spi, sizeof(g_colmod), g_colmod); /* Color interface pixel format */
nokia_cmdarray(spi, sizeof(g_setcon), g_setcon); /* Set contrast */
@@ -1141,6 +1218,7 @@ FAR struct lcd_dev_s *nokia_lcdinitialize(FAR struct spi_dev_s *spi, unsigned in
/* Configure and enable the LCD controller */
nokia_configspi(spi);
if (nokia_initialize(priv) == OK)
{
/* Turn on the backlight */
+8
View File
@@ -58,6 +58,14 @@
* CONFIG_NOKIA6100_PCF8833 - Selects the Phillips PCF8833 display controller
* CONFIG_NOKIA6100_BLINIT - Initial backlight setting
*
* The following may need to be tuned for your hardware:
* CONFIG_NOKIA6100_INVERT - Display inversion, 0 or 1, Default: 1
* CONFIG_NOKIA6100_MY - Display row direction, 0 or 1, Default: 0
* CONFIG_NOKIA6100_MX - Display column direction, 0 or 1, Default: 1
* CONFIG_NOKIA6100_V - Display address direction, 0 or 1, Default: 0
* CONFIG_NOKIA6100_ML - Display scan direction, 0 or 1, Default: 0
* CONFIG_NOKIA6100_RGBORD - Display RGB order, 0 or 1, Default: 0
*
* Required LCD driver settings:
* CONFIG_LCD_NOKIA6100 - Enable Nokia 6100 support
* CONFIG_LCD_MAXCONTRAST - must be 63 with the Epson controller and 127 with
+1 -1
View File
@@ -160,7 +160,7 @@
****************************************************************************/
#define SPI_SETBITS(d,b) \
do { if ((d)->ops->setbits) (d)->ops->setmode(d,b); } while (0)
do { if ((d)->ops->setbits) (d)->ops->setbits(d,b); } while (0)
/****************************************************************************
* Name: SPI_STATUS