diff --git a/ChangeLog b/ChangeLog index 9ed505d56e4..3445cdb807e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index a8b3c810d22..b6427e0d5d2 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -8,7 +8,7 @@
Last Updated: December 4, 2010
+Last Updated: December 6, 2010
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 examples/ostest).
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 NSH User Guide), for the NuttX network test, and for the THTTPD 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.
@@ -2021,6 +2022,8 @@ nuttx-5.15 2010-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> * 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 <spudmonkey@racsa.co.cr> diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html index be85f66b936..2755078fef9 100644 --- a/Documentation/NuttxPortingGuide.html +++ b/Documentation/NuttxPortingGuide.html @@ -2838,6 +2838,27 @@ buildCONFIG_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:
diff --git a/arch/arm/src/lpc17xx/lpc17_ssp.c b/arch/arm/src/lpc17xx/lpc17_ssp.c index 4512cbd285a..448177345dd 100755 --- a/arch/arm/src/lpc17xx/lpc17_ssp.c +++ b/arch/arm/src/lpc17xx/lpc17_ssp.c @@ -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; diff --git a/configs/README.txt b/configs/README.txt index a4c9c9f8bbb..1d0eb0f8e9a 100644 --- a/configs/README.txt +++ b/configs/README.txt @@ -430,14 +430,14 @@ defconfig -- This is a configuration file similar to the Linux CONFIG_PAGING_AT45DB - Use the at45db.c FLASH driver. If this is selected, then the MTD interface to the Atmel AT45DB device will be used to support paging. - CONFIG_PAGING_BINOFFSET - If CONFIG_PAGING_M25PX or is CONFIG_PAGING_AT45DB - defined then CONFIG_PAGING_BINOFFSET will be used to specify the offset + CONFIG_PAGING_BINOFFSET - If CONFIG_PAGING_M25PX or is CONFIG_PAGING_AT45DB + defined then CONFIG_PAGING_BINOFFSET will be used to specify the offset in bytes into the FLASH device where the NuttX binary image is located. Default: 0 - CONFIG_PAGING_SPIPORT - If CONFIG_PAGING_M25PX CONFIG_PAGING_AT45DB is - defined and the device has multiple SPI busses (ports), then this - configuration should be set to indicate which SPI port the device is - connected. Default: 0 + CONFIG_PAGING_SPIPORT - If CONFIG_PAGING_M25PX CONFIG_PAGING_AT45DB is + defined and the device has multiple SPI busses (ports), then this + configuration should be set to indicate which SPI port the device is + connected. Default: 0 The following can be used to disable categories of APIs supported by the OS. If the compiler supports weak functions, then it @@ -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 diff --git a/drivers/lcd/nokia6100.c b/drivers/lcd/nokia6100.c index 79435cdd15c..36e92007c31 100755 --- a/drivers/lcd/nokia6100.c +++ b/drivers/lcd/nokia6100.c @@ -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 */ diff --git a/include/nuttx/lcd/nokia6100.h b/include/nuttx/lcd/nokia6100.h index f6020cac723..d6fe2d3edfa 100755 --- a/include/nuttx/lcd/nokia6100.h +++ b/include/nuttx/lcd/nokia6100.h @@ -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 diff --git a/include/nuttx/spi.h b/include/nuttx/spi.h index 39d360923f6..eb92ae64348 100644 --- a/include/nuttx/spi.h +++ b/include/nuttx/spi.h @@ -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