Add SSD1783 LCD driver for C155 phone
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4981 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
dd16b86185
commit
c19605c582
@ -3074,5 +3074,7 @@
|
||||
for the PGA117 on the Mirtoo module.
|
||||
* drivers/analog/pga11x.c and include/nuttx/analog/pga11x.h: These belong in
|
||||
the analog subdirectories, not input.
|
||||
|
||||
|
||||
* configs/compal_e99/src/ssd1783.c and /ssd1783.h: Drivers for the SSD1783
|
||||
LCD found in the Motorola C155 telephone. The driver is specific to the C155
|
||||
because it uses the uwire transport. Contributed by Denis Carilki and
|
||||
Alan Carvalho de Assis.
|
||||
|
@ -40,5 +40,10 @@ CONFIGURED_APPS += nshlib
|
||||
|
||||
|
||||
# Path to example in apps/examples
|
||||
CONFIGURED_APPS += examples/hello
|
||||
#CONFIGURED_APPS += examples/hello #fails not finding hello_main despite of good config
|
||||
CONFIGURED_APPS += vsn/poweroff
|
||||
CONFIGURED_APPS += examples/ostest
|
||||
CONFIGURED_APPS += examples/nxtext
|
||||
CONFIGURED_APPS += examples/nxhello
|
||||
CONFIGURED_APPS += examples/nxlines
|
||||
CONFIGURED_APPS += examples/nximage
|
||||
|
@ -207,6 +207,7 @@ CONFIG_HAVE_LIBM=n
|
||||
#
|
||||
#CONFIG_APPS_DIR=
|
||||
CONFIG_DEBUG=n
|
||||
CONFIG_DEBUG_GRAPHICS=n
|
||||
CONFIG_DEBUG_VERBOSE=n
|
||||
CONFIG_DEBUG_SYMBOLS=n
|
||||
CONFIG_ARCH_LOWPUTC=y
|
||||
@ -434,6 +435,49 @@ CONFIG_NSH_BUILTIN_APPS=y
|
||||
#
|
||||
# Settings for examples/hello
|
||||
CONFIG_EXAMPLES_HELLO_BUILTIN=y
|
||||
CONFIG_EXAMPLES_NXHELLO_BUILTIN=y
|
||||
CONFIG_EXAMPLES_NXTEXT_BUILTIN=y
|
||||
CONFIG_EXAMPLES_NXIMAGE_BUILTIN=y
|
||||
CONFIG_EXAMPLES_NXLINES_BUILTIN=y
|
||||
|
||||
CONFIG_EXAMPLES_NXLINES_BORDERWIDTH=2
|
||||
CONFIG_EXAMPLES_NXLINES_LINEWIDTH=4
|
||||
|
||||
CONFIG_EXAMPLES_NXTEXT_NOGETRUN=y
|
||||
CONFIG_EXAMPLES_NXTEXT_BPP=16
|
||||
CONFIG_EXAMPLES_NXTEXT_BGFONTID=14
|
||||
CONFIG_EXAMPLES_NXHELLO_BPP=16
|
||||
CONFIG_EXAMPLES_NXIMAGE_XSCALEp5=y
|
||||
CONFIG_EXAMPLES_NXIMAGE_YSCALEp5=y
|
||||
#CONFIG_EXAMPLES_NXLINES_EXTERNINIT=y
|
||||
#CONFIG_EXAMPLES_NXHELLO_EXTERNINIT=y
|
||||
#CONFIG_EXAMPLES_NXTEXT_EXTERNINIT=y
|
||||
#CONFIG_EXAMPLES_NXIMAGE_EXTERNINIT=y
|
||||
|
||||
# LCD Drivers settings
|
||||
CONFIG_NX_LCDDRIVER=y
|
||||
CONFIG_LCD_SSD1783=y
|
||||
|
||||
#
|
||||
# Graphics
|
||||
CONFIG_NX=y
|
||||
CONFIG_NXCONSOLE=n
|
||||
CONFIG_NX_KBD=y
|
||||
CONFIG_LCD_MAXPOWER=1
|
||||
CONFIG_NX_BLOCKING=y
|
||||
CONFIG_NX_DISABLE_1BPP=y
|
||||
CONFIG_NX_DISABLE_2BPP=y
|
||||
CONFIG_NX_DISABLE_4BPP=y
|
||||
CONFIG_NX_DISABLE_8BPP=y
|
||||
CONFIG_NX_DISABLE_16BPP=n
|
||||
CONFIG_NX_DISABLE_24BPP=y
|
||||
CONFIG_NX_DISABLE_32BPP=y
|
||||
CONFIG_NXCONSOLE_BPP=16
|
||||
CONFIG_NXCONSOLE_NOGETRUN=y
|
||||
CONFIG_NXFONT_SANS17X22=y
|
||||
CONFIG_NX_MULTIUSER=n
|
||||
CONFIG_EXAMPLES_NXTEXT_BPP=16
|
||||
CONFIG_EXAMPLES_NXTEXT_DEVNO=0
|
||||
|
||||
#
|
||||
# Settings for examples/wget
|
||||
|
@ -14,9 +14,9 @@ MEMORY
|
||||
/* 0x800000-0xa00000 */
|
||||
/* compal-loaded binary: our text, initialized data */
|
||||
LRAM (rw) : ORIGIN = 0x00800000, LENGTH = 0x00020000
|
||||
TRAM (rw) : ORIGIN = 0x00820000, LENGTH = 0x00019000
|
||||
TRAM (rw) : ORIGIN = 0x00820000, LENGTH = 0x0001d000
|
||||
/* compal-loaded binary: our unitialized data, stacks, heap */
|
||||
IRAM (rw) : ORIGIN = 0x00839000, LENGTH = 0x00006000
|
||||
IRAM (rw) : ORIGIN = 0x0083d000, LENGTH = 0x00002000
|
||||
}
|
||||
SECTIONS
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ CFLAGS += -I$(TOPDIR)/sched
|
||||
|
||||
ASRCS =
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
CSRCS = dummy.c
|
||||
CSRCS = dummy.c ssd1783.c
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
|
523
configs/compal_e99/src/ssd1783.c
Normal file
523
configs/compal_e99/src/ssd1783.c
Normal file
@ -0,0 +1,523 @@
|
||||
/************************************************************************************
|
||||
* nuttx/configs/compal_e99/src/ssd1783.c
|
||||
*
|
||||
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Laurent Latil <laurent@latil.nom.fr>
|
||||
* Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
|
||||
* Alan Carvalho de Assis <acassis@gmail.com>
|
||||
*
|
||||
* This driver for SSD1783 used part of SSD1783 driver developed by
|
||||
* Christian Vogel <vogelchr@vogel.cx> for Osmocom-BB and relicensed
|
||||
* to BSD with permission from author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/fb.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <arch/calypso/uwire.h>
|
||||
#include <arch/calypso/clock.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "ssd1783.h"
|
||||
|
||||
/* Color depth and format */
|
||||
#define LCD_BPP 16
|
||||
#define LCD_COLORFMT FB_FMT_RGB16_555
|
||||
|
||||
/* Display Resolution */
|
||||
# define LCD_XRES 98
|
||||
# define LCD_YRES 67
|
||||
|
||||
/* Debug ******************************************************************************/
|
||||
#ifdef CONFIG_DEBUG_LCD
|
||||
# define lcddbg(format, arg...) vdbg(format, ##arg)
|
||||
#else
|
||||
# define lcddbg(x...)
|
||||
#endif
|
||||
|
||||
/** This should be put elsewhere */
|
||||
#ifdef __CC_ARM /* ARM Compiler */
|
||||
#define lcd_inline static __inline
|
||||
#elif defined (__ICCARM__) /* for IAR Compiler */
|
||||
#define lcd_inline inline
|
||||
#elif defined (__GNUC__) /* GNU GCC Compiler */
|
||||
#define lcd_inline static __inline
|
||||
#else
|
||||
#define lcd_inline static
|
||||
#endif
|
||||
|
||||
static void lcd_clear(void);
|
||||
static void fb_ssd1783_send_cmdlist(const struct ssd1783_cmdlist *p);
|
||||
|
||||
/* LCD Data Transfer Methods */
|
||||
int lcd_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer,
|
||||
size_t npixels);
|
||||
int lcd_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
|
||||
size_t npixels);
|
||||
|
||||
/* LCD Configuration */
|
||||
static int lcd_getvideoinfo(FAR struct lcd_dev_s *dev,
|
||||
FAR struct fb_videoinfo_s *vinfo);
|
||||
static int lcd_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno,
|
||||
FAR struct lcd_planeinfo_s *pinfo);
|
||||
|
||||
/* LCD RGB Mapping */
|
||||
#ifdef CONFIG_FB_CMAP
|
||||
# error "RGB color mapping not supported by this driver"
|
||||
#endif
|
||||
|
||||
/* Cursor Controls */
|
||||
#ifdef CONFIG_FB_HWCURSOR
|
||||
# error "Cursor control not supported by this driver"
|
||||
#endif
|
||||
|
||||
/* LCD Specific Controls */
|
||||
static int lcd_getpower(struct lcd_dev_s *dev);
|
||||
static int lcd_setpower(struct lcd_dev_s *dev, int power);
|
||||
static int lcd_getcontrast(struct lcd_dev_s *dev);
|
||||
static int lcd_setcontrast(struct lcd_dev_s *dev, unsigned int contrast);
|
||||
|
||||
/* Initialization (LCD ctrl / backlight) */
|
||||
static inline void lcd_initialize(void);
|
||||
|
||||
/**************************************************************************************
|
||||
* Private Data
|
||||
**************************************************************************************/
|
||||
|
||||
/* This is working memory allocated by the LCD driver for each LCD device
|
||||
* and for each color plane. This memory will hold one raster line of data.
|
||||
* The size of the allocated run buffer must therefore be at least
|
||||
* (bpp * xres / 8). Actual alignment of the buffer must conform to the
|
||||
* bitwidth of the underlying pixel type.
|
||||
*
|
||||
* If there are multiple planes, they may share the same working buffer
|
||||
* because different planes will not be operate on concurrently. However,
|
||||
* if there are multiple LCD devices, they must each have unique run buffers.
|
||||
*/
|
||||
|
||||
static uint16_t g_runbuffer[LCD_XRES];
|
||||
|
||||
/* This structure describes the overall LCD video controller */
|
||||
|
||||
static const struct fb_videoinfo_s g_videoinfo =
|
||||
{ .fmt = LCD_COLORFMT, /* Color format: RGB16-565: RRRR RGGG GGGB BBBB */
|
||||
.xres = LCD_XRES, /* Horizontal resolution in pixel columns */
|
||||
.yres = LCD_YRES, /* Vertical resolutiSend a command list to the LCD panelon in pixel rows */
|
||||
.nplanes = 1, /* Number of color planes supported */
|
||||
};
|
||||
|
||||
/* This is the standard, NuttX Plane information object */
|
||||
|
||||
static const struct lcd_planeinfo_s g_planeinfo =
|
||||
{ .putrun = lcd_putrun, /* Put a run into LCD memory */
|
||||
// .getrun = lcd_getrun, /* Get a run from LCD memory */
|
||||
.buffer = (uint8_t*) g_runbuffer, /* Run scratch buffer */
|
||||
.bpp = LCD_BPP, /* Bits-per-pixel */
|
||||
};
|
||||
|
||||
/* This is the standard, NuttX LCD driver object */
|
||||
|
||||
static struct ssd1783_dev_s g_lcddev =
|
||||
{ .dev =
|
||||
{
|
||||
/* LCD Configuration */
|
||||
|
||||
.getvideoinfo = lcd_getvideoinfo,
|
||||
.getplaneinfo = lcd_getplaneinfo,
|
||||
|
||||
/* LCD RGB Mapping -- Not supported */
|
||||
/* Cursor Controls -- Not supported */
|
||||
|
||||
/* LCD Specific Controls */
|
||||
.getpower = lcd_getpower,
|
||||
.setpower = lcd_setpower,
|
||||
// .getcontrast = lcd_getcontrast,
|
||||
// .setcontrast = lcd_setcontrast,
|
||||
},
|
||||
.power=0
|
||||
};
|
||||
|
||||
/* we trust gcc to move this expensive bitshifting out of
|
||||
the loops in the drawing funtcions */
|
||||
static uint8_t rgb_to_pixel(uint16_t color)
|
||||
{
|
||||
uint8_t ret;
|
||||
|
||||
ret = (FB_COLOR_TO_R(color) & 0xe0); /* 765 = RRR */
|
||||
ret |= (FB_COLOR_TO_G(color) & 0xe0) >> 3; /* 432 = GGG */
|
||||
ret |= (FB_COLOR_TO_B(color) & 0xc0) >> 6; /* 10 = BB */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* somehow the palette is messed up, RRR seems to have the
|
||||
bits reversed! R0 R1 R2 G G G B B ---> R2 R1 R0 G G G B B */
|
||||
uint8_t fix_rrr(uint8_t v){
|
||||
return (v & 0x5f) | (v & 0x80) >> 2 | (v & 0x20) << 2;
|
||||
}
|
||||
|
||||
|
||||
lcd_inline void write_data(uint16_t datain)
|
||||
{
|
||||
uint16_t dataout = 0x0100 | fix_rrr(rgb_to_pixel(datain));
|
||||
uwire_xfer(SSD1783_DEV_ID,SSD1783_UWIRE_BITLEN,&dataout, NULL);
|
||||
}
|
||||
|
||||
static void fb_ssd1783_send_cmdlist(const struct ssd1783_cmdlist *p)
|
||||
{
|
||||
int i=0;
|
||||
|
||||
while(p->is_cmd != END)
|
||||
{
|
||||
uint16_t sendcmd = p->data;
|
||||
if(p->is_cmd == DATA)
|
||||
sendcmd |= 0x0100; /* 9th bit is cmd/data flag */
|
||||
uwire_xfer(SSD1783_DEV_ID, SSD1783_UWIRE_BITLEN, &sendcmd, NULL);
|
||||
p++;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
static void lcd_write_prepare(unsigned int x1, unsigned int x2, unsigned int y1, unsigned int y2)
|
||||
{;
|
||||
DEBUGASSERT( (x1 < x2 )&& (y1 < y2));
|
||||
struct ssd1783_cmdlist prepare_disp_write_cmds[] = {
|
||||
{ CMD, 0x15 }, /* set column address */
|
||||
{ DATA, x1 },
|
||||
{ DATA, x2 },
|
||||
{ CMD, 0x75 }, /* set page address (Y) */
|
||||
{ DATA, y1 },
|
||||
{ DATA, y2 },
|
||||
{ CMD, 0x5c }, /* enter write display ram mode */
|
||||
{ END, 0x00 }
|
||||
};
|
||||
dbg("x1:%d, x2:%d, y1:%d, y2:%d\n",x1, x2,y1, y2);
|
||||
fb_ssd1783_send_cmdlist(prepare_disp_write_cmds);
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
* Name: lcd_putrun
|
||||
*
|
||||
* Description:
|
||||
* This method can be used to write a partial raster line to the LCD:
|
||||
*
|
||||
* row - Starting row to write to (range: 0 <= row < yres)
|
||||
* col - Starting column to write to (range: 0 <= col <= xres-npixels)
|
||||
* buffer - The buffer containing the run to be written to the LCD
|
||||
* npixels - The number of pixels to write to the LCD
|
||||
* (range: 0 < npixels <= xres-col)
|
||||
*
|
||||
**************************************************************************************/
|
||||
|
||||
int lcd_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer,
|
||||
size_t npixels)
|
||||
{
|
||||
int i;
|
||||
FAR const uint16_t *src = (FAR const uint16_t*) buffer;
|
||||
|
||||
/* Buffer must be provided and aligned to a 16-bit address boundary */
|
||||
DEBUGASSERT(buffer && ((uintptr_t)buffer & 1) == 0);
|
||||
|
||||
|
||||
/* Write the run to GRAM. */
|
||||
lcd_write_prepare(col,col+npixels, row,row+1);
|
||||
|
||||
for (i = 0; i < npixels; i++)
|
||||
{
|
||||
write_data(*src++);
|
||||
}
|
||||
fb_ssd1783_send_cmdlist(nop);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
* Name: lcd_getrun
|
||||
*
|
||||
* Description:
|
||||
* This method can be used to read a partial raster line from the LCD:
|
||||
*
|
||||
* row - Starting row to read from (range: 0 <= row < yres)
|
||||
* col - Starting column to read read (range: 0 <= col <= xres-npixels)
|
||||
* buffer - The buffer in which to return the run read from the LCD
|
||||
* npixels - The number of pixels to read from the LCD
|
||||
* (range: 0 < npixels <= xres-col)
|
||||
*
|
||||
**************************************************************************************/
|
||||
|
||||
int lcd_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
|
||||
size_t npixels)
|
||||
{
|
||||
gvdbg("Not implemented\n");
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
* Name: lcd_getvideoinfo
|
||||
*
|
||||
* Description:
|
||||
* Get information about the LCD video controller configuration.
|
||||
*
|
||||
**************************************************************************************/
|
||||
|
||||
static int lcd_getvideoinfo(FAR struct lcd_dev_s *dev,
|
||||
FAR struct fb_videoinfo_s *vinfo)
|
||||
{
|
||||
DEBUGASSERT(dev && vinfo);gvdbg("fmt: %d xres: %d yres: %d nplanes: %d\n",
|
||||
g_videoinfo.fmt, g_videoinfo.xres, g_videoinfo.yres, g_videoinfo.nplanes);
|
||||
memcpy(vinfo, &g_videoinfo, sizeof(struct fb_videoinfo_s));
|
||||
return OK;
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
* Name: lcd_getplaneinfo
|
||||
*
|
||||
* Description:
|
||||
* Get information about the configuration of each LCD color plane.
|
||||
*
|
||||
**************************************************************************************/
|
||||
|
||||
static int lcd_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno,
|
||||
FAR struct lcd_planeinfo_s *pinfo)
|
||||
{
|
||||
DEBUGASSERT(dev && pinfo && planeno == 0);gvdbg("planeno: %d bpp: %d\n", planeno, g_planeinfo.bpp);
|
||||
memcpy(pinfo, &g_planeinfo, sizeof(struct lcd_planeinfo_s));
|
||||
return OK;
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
* Name: lcd_getpower
|
||||
*
|
||||
* Description:
|
||||
* Get the LCD panel power status (0: full off - CONFIG_LCD_MAXPOWER: full on). On
|
||||
* backlit LCDs, this setting may correspond to the backlight setting.
|
||||
*
|
||||
**************************************************************************************/
|
||||
|
||||
static int lcd_getpower(struct lcd_dev_s *dev)
|
||||
{
|
||||
gvdbg("power: %d\n", 0);
|
||||
return g_lcddev.power;
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
* Name: lcd_setpower
|
||||
*
|
||||
* Description:
|
||||
* Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on).
|
||||
* Used here to set pwm duty on timer used for backlight.
|
||||
*
|
||||
**************************************************************************************/
|
||||
|
||||
static int lcd_setpower(struct lcd_dev_s *dev, int power)
|
||||
{
|
||||
uint16_t reg;
|
||||
|
||||
if (g_lcddev.power == power) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
gvdbg("power: %d\n", power);
|
||||
DEBUGASSERT(power <= CONFIG_LCD_MAXPOWER);
|
||||
|
||||
/* Set new power level */
|
||||
reg = getreg16(ASIC_CONF_REG);
|
||||
if (power)
|
||||
{
|
||||
reg = getreg16(ASIC_CONF_REG);
|
||||
/* LCD Set I/O(3) / SA0 to I/O(3) mode */
|
||||
reg &= ~( (1 << 12) | (1 << 10) | (1 << 7) | (1 << 1)) ;
|
||||
/* don't set function pins to I2C Mode, C155 uses UWire */
|
||||
/* TWL3025: Set SPI+RIF RX clock to rising edge */
|
||||
reg |= (1 << 13) | (1 << 14);
|
||||
putreg16(reg, ASIC_CONF_REG);
|
||||
|
||||
/* LCD Set I/O(3) to output mode and enable C155 backlight (IO1) */
|
||||
/* FIXME: Put the display backlight control to backlight.c */
|
||||
reg = getreg16(IO_CNTL_REG);
|
||||
reg &= ~( (1 << 3) | (1 << 1));
|
||||
putreg16(reg, IO_CNTL_REG);
|
||||
|
||||
/* LCD Set I/O(3) output low */
|
||||
reg = getreg16(ARMIO_LATCH_OUT);
|
||||
reg &= ~(1 << 3);
|
||||
reg |= (1 << 1);
|
||||
putreg16(reg, ARMIO_LATCH_OUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
gvdbg("powering LCD off...\n");
|
||||
/* Switch pin from PWL to LT */
|
||||
reg &= ~ASCONF_PWL_ENA;
|
||||
putreg8(reg, ASIC_CONF_REG);
|
||||
/* Disable pwl */
|
||||
putreg8(0x00, PWL_REG(PWL_CTRL));
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************************
|
||||
* Name: lcd_getcontrast
|
||||
*
|
||||
* Description:
|
||||
* Get the current contrast setting (0-CONFIG_LCD_MAXCONTRAST).
|
||||
*
|
||||
**************************************************************************************/
|
||||
|
||||
static int lcd_getcontrast(struct lcd_dev_s *dev)
|
||||
{
|
||||
gvdbg("Not implemented\n");
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
* Name: lcd_setcontrast
|
||||
*
|
||||
* Description:
|
||||
* Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST).
|
||||
*
|
||||
**************************************************************************************/
|
||||
|
||||
static int lcd_setcontrast(struct lcd_dev_s *dev, unsigned int contrast)
|
||||
{
|
||||
gvdbg("Not implemented\n");
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
* Name: lcd_lcdinitialize
|
||||
*
|
||||
* Description:
|
||||
* Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST).
|
||||
*
|
||||
**************************************************************************************/
|
||||
static inline void lcd_initialize(void)
|
||||
{
|
||||
gvdbg("%s: initializing LCD.\n",__FUNCTION__);
|
||||
calypso_reset_set(RESET_EXT, 0);
|
||||
usleep(5000);
|
||||
uwire_init();
|
||||
usleep(5000);
|
||||
fb_ssd1783_send_cmdlist(ssd1783_initdata);
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
* Public Functions
|
||||
**************************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************************
|
||||
* Name: up_lcdinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the LCD video hardware. The initial state of the LCD is fully
|
||||
* initialized, display memory cleared, and the LCD ready to use, but with the power
|
||||
* setting at 0 (full off).
|
||||
*
|
||||
**************************************************************************************/
|
||||
|
||||
int up_lcdinitialize(void)
|
||||
{
|
||||
gvdbg("Initializing\n");
|
||||
|
||||
lcd_initialize();
|
||||
|
||||
/* Clear the display */
|
||||
lcd_clear();
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
* Name: up_lcdgetdev
|
||||
*
|
||||
* Description:
|
||||
* Return a a reference to the LCD object for the specified LCD. This allows support
|
||||
* for multiple LCD devices.
|
||||
*
|
||||
**************************************************************************************/
|
||||
|
||||
FAR struct lcd_dev_s *up_lcdgetdev(int lcddev)
|
||||
{
|
||||
DEBUGASSERT(lcddev == 0);
|
||||
return &g_lcddev.dev;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************************
|
||||
* Name: up_lcduninitialize
|
||||
*
|
||||
* Description:
|
||||
* Un-initialize the LCD support
|
||||
*
|
||||
**************************************************************************************/
|
||||
|
||||
void up_lcduninitialize(void)
|
||||
{
|
||||
lcd_setpower(&g_lcddev.dev, 0);
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
* Name: lcd_clear
|
||||
*
|
||||
* Description:
|
||||
* Fill the LCD ctrl memory with given color
|
||||
*
|
||||
**************************************************************************************/
|
||||
|
||||
void lcd_clear()
|
||||
{
|
||||
struct ssd1783_cmdlist prepare_disp_write_cmds[] = {
|
||||
{ CMD, 0x8E },
|
||||
{ DATA, 0x00 },
|
||||
{ DATA, 0x00 },
|
||||
{ DATA, LCD_XRES },
|
||||
{ DATA, LCD_YRES },
|
||||
{ END, 0x00 }
|
||||
};
|
||||
|
||||
struct ssd1783_cmdlist nop[] = {
|
||||
{ CMD, 0x25 }, // NOP command
|
||||
{ END, 0x00 }
|
||||
};
|
||||
|
||||
fb_ssd1783_send_cmdlist(prepare_disp_write_cmds);
|
||||
fb_ssd1783_send_cmdlist(nop);
|
||||
}
|
110
configs/compal_e99/src/ssd1783.h
Normal file
110
configs/compal_e99/src/ssd1783.h
Normal file
@ -0,0 +1,110 @@
|
||||
#ifndef SSD1783_H_
|
||||
#define SSD1783_H_
|
||||
|
||||
#include <nuttx/lcd/lcd.h>
|
||||
|
||||
#define FB_COLOR_TO_R(v) (((v)>>16) & 0xff)
|
||||
#define FB_COLOR_TO_G(v) (((v)>> 8) & 0xff)
|
||||
#define FB_COLOR_TO_B(v) ( (v) & 0xff)
|
||||
|
||||
#define SSD1783_UWIRE_BITLEN 9
|
||||
#define SSD1783_DEV_ID 0
|
||||
|
||||
#define ARMIO_LATCH_OUT 0xfffe4802
|
||||
#define IO_CNTL_REG 0xfffe4804
|
||||
#define ASIC_CONF_REG 0xfffef008
|
||||
|
||||
#define ASCONF_PWL_ENA (1 << 4)
|
||||
|
||||
/* begin backlight.c */
|
||||
#define BASE_ADDR_PWL 0xfffe8000
|
||||
#define PWL_REG(m) (BASE_ADDR_PWL + (m))
|
||||
|
||||
enum pwl_reg {
|
||||
PWL_LEVEL = 0,
|
||||
PWL_CTRL = 1,
|
||||
};
|
||||
|
||||
enum ssd1783_cmdflag { CMD, DATA, END };
|
||||
|
||||
struct ssd1783_cmdlist {
|
||||
enum ssd1783_cmdflag is_cmd:8; /* 1: is a command, 0: is data, 2: end marker! */
|
||||
uint8_t data; /* 8 bit to send to LC display */
|
||||
} __attribute__((packed));
|
||||
|
||||
static const struct ssd1783_cmdlist nop[] = {
|
||||
{ CMD, 0x25 }, // NOP command
|
||||
{ END, 0x00 }
|
||||
};
|
||||
|
||||
static const struct ssd1783_cmdlist
|
||||
ssd1783_initdata[] = {
|
||||
{ CMD, 0xD1 }, /* CMD set internal oscillator on */
|
||||
{ CMD, 0x94 }, /* CMD leave sleep mode */
|
||||
{ CMD, 0xbb }, /* CMD Set COM Output Scan Direction: */
|
||||
{ DATA, 0x01 }, /* DATA: 01: COM0-79, then COM159-80 */
|
||||
/* -------- DIFFERENT FROM ORIGINAL CODE: -------------- */
|
||||
/* we use 8bit per pixel packed RGB 332 */
|
||||
{ CMD, 0xbc }, /* CMD Set Data Output Scan Direction */
|
||||
{ DATA, 0x00 }, /* DATA: column scan, normal rotation, normal display */
|
||||
{ DATA, 0x00 }, /* DATA: RGB color arrangement R G B R G B ... */
|
||||
/*-->*/ { DATA, 0x01 }, /* DATA: 8 bit per pixel mode MSB <RRRGGGBB> LSB */
|
||||
/* --------- /DIFFERENT ---------- */
|
||||
{ CMD, 0xce }, /* CMD Set 256 Color Look Up Table LUT */
|
||||
{ DATA, 0x00 }, /* DATA red 000 */
|
||||
{ DATA, 0x03 }, /* DATA red 001 */
|
||||
{ DATA, 0x05 }, /* DATA red 010 */
|
||||
{ DATA, 0x07 }, /* DATA red 011 */
|
||||
{ DATA, 0x09 }, /* DATA red 100 */
|
||||
{ DATA, 0x0b }, /* DATA red 101 */
|
||||
{ DATA, 0x0d }, /* DATA red 110 */
|
||||
{ DATA, 0x0f }, /* DATA red 111 */
|
||||
{ DATA, 0x00 }, /* DATA green 000 */
|
||||
{ DATA, 0x03 }, /* DATA green 001 */
|
||||
{ DATA, 0x05 }, /* DATA green 010 */
|
||||
{ DATA, 0x07 }, /* DATA green 011 */
|
||||
{ DATA, 0x09 }, /* DATA green 100 */
|
||||
{ DATA, 0x0b }, /* DATA green 101 */
|
||||
{ DATA, 0x0d }, /* DATA green 110 */
|
||||
{ DATA, 0x0f }, /* DATA green 111 */
|
||||
{ DATA, 0x00 }, /* DATA blue 00 */
|
||||
{ DATA, 0x05 }, /* DATA blue 01 */
|
||||
{ DATA, 0x0a }, /* DATA blue 10 */
|
||||
{ DATA, 0x0f }, /* DATA blue 11 */
|
||||
{ CMD, 0xca }, /* CMD Set Display Control - Driver Duty Selection */
|
||||
{ DATA, 0xff }, // can't find description of the values in the original
|
||||
{ DATA, 0x10 }, // display/ssd1783.c in my datasheet :-(
|
||||
{ DATA, 0x01 }, //
|
||||
{ CMD, 0xab }, /* CMD Set Scroll Start */
|
||||
{ DATA, 0x00 }, /* DATA: Starting address at block 0 */
|
||||
{ CMD, 0x20 }, /* CMD Set power control register */
|
||||
{ DATA, 0x0b }, /* DATA: booster 6x, reference gen. & int regulator */
|
||||
{ CMD, 0x81 }, /* CMD Contrast Lvl & Int. Regul. Resistor Ratio */
|
||||
{ DATA, 0x29 }, /* DATA: contrast = 0x29 */
|
||||
{ DATA, 0x05 }, /* DATA: 0x05 = 0b101 -> 1+R2/R1 = 11.37 */
|
||||
{ CMD, 0xa7 }, /* CMD Invert Display */
|
||||
{ CMD, 0x82 }, /* CMD Set Temperature Compensation Coefficient */
|
||||
{ DATA, 0x00 }, /* DATA: Gradient is -0.10 % / degC */
|
||||
{ CMD, 0xfb }, /* CMD Set Biasing Ratio */
|
||||
{ DATA, 0x03 }, /* DATA: 1/10 bias */
|
||||
{ CMD, 0xf2 }, /* CMD Set Frame Frequency and N-line inversion */
|
||||
{ DATA, 0x08 }, /* DATA: 75 Hz (POR) */
|
||||
{ DATA, 0x06 }, /* DATA: n-line inversion: 6 lines */
|
||||
{ CMD, 0xf7 }, /* CMD Select PWM/FRC Select Full Col./8col mode */
|
||||
{ DATA, 0x28 }, /* DATA: always 0x28 */
|
||||
{ DATA, 0x8c }, /* DATA: 4bit PWM + 2 bit FRC */
|
||||
{ DATA, 0x05 }, /* DATA: full color mode */
|
||||
{ CMD, 0xaf }, /* CMD Display On */
|
||||
{ END, 0x00 }, /* MARKER: end of list */
|
||||
};
|
||||
|
||||
struct ssd1783_dev_s
|
||||
{
|
||||
/* Publicly visible device structure */
|
||||
struct lcd_dev_s dev;
|
||||
|
||||
/* Private LCD-specific information follows */
|
||||
uint8_t power; /* Current power setting */
|
||||
};
|
||||
|
||||
#endif /* SSD1783_H_ */
|
@ -60,8 +60,11 @@ export TOOLCHAIN_BIN="/cygdrive/c/MicroChip/mplabc32/v1.12/bin"
|
||||
|
||||
# This the Cygwin path to the location where I installed the Pinguino
|
||||
# toolchain under Windows. You will have to edit this if you install the
|
||||
# tool chain in a different location or use a different version
|
||||
#export TOOLCHAIN_BIN="/cygdrive/c/PinguinoX.3/win32/p32/bin"
|
||||
# tool chain in a different location or use a different version. /bin
|
||||
# needs to precede the tool path or otherwise you will get
|
||||
# /cygdrive/c/PinguinoX.3/win32/p32/bin/make which does not like POSIX
|
||||
# style paths.
|
||||
#export TOOLCHAIN_BIN="/bin:/cygdrive/c/PinguinoX.3/win32/p32/bin"
|
||||
|
||||
# This the Linux path to the location where I installed the microchipOpen
|
||||
# toolchain under Linux. You will have to edit this if you use the
|
||||
|
@ -60,8 +60,11 @@ export TOOLCHAIN_BIN="/cygdrive/c/MicroChip/mplabc32/v1.12/bin"
|
||||
|
||||
# This the Cygwin path to the location where I installed the Pinguino
|
||||
# toolchain under Windows. You will have to edit this if you install the
|
||||
# tool chain in a different location or use a different version
|
||||
#export TOOLCHAIN_BIN="/cygdrive/c/PinguinoX.3/win32/p32/bin"
|
||||
# tool chain in a different location or use a different version. /bin
|
||||
# needs to precede the tool path or otherwise you will get
|
||||
# /cygdrive/c/PinguinoX.3/win32/p32/bin/make which does not like POSIX
|
||||
# style paths.
|
||||
#export TOOLCHAIN_BIN="/bin:/cygdrive/c/PinguinoX.3/win32/p32/bin"
|
||||
|
||||
# This the Linux path to the location where I installed the microchipOpen
|
||||
# toolchain under Linux. You will have to edit this if you use the
|
||||
|
@ -60,8 +60,11 @@ export TOOLCHAIN_BIN="/cygdrive/c/MicroChip/mplabc32/v1.12/bin"
|
||||
|
||||
# This the Cygwin path to the location where I installed the Pinguino
|
||||
# toolchain under Windows. You will have to edit this if you install the
|
||||
# tool chain in a different location or use a different version
|
||||
#export TOOLCHAIN_BIN="/cygdrive/c/PinguinoX.3/win32/p32/bin"
|
||||
# tool chain in a different location or use a different version. /bin
|
||||
# needs to precede the tool path or otherwise you will get
|
||||
# /cygdrive/c/PinguinoX.3/win32/p32/bin/make which does not like POSIX
|
||||
# style paths.
|
||||
#export TOOLCHAIN_BIN="/bin:/cygdrive/c/PinguinoX.3/win32/p32/bin"
|
||||
|
||||
# This the Linux path to the location where I installed the microchipOpen
|
||||
# toolchain under Linux. You will have to edit this if you use the
|
||||
|
@ -1,8 +1,11 @@
|
||||
Contents
|
||||
========
|
||||
nuttx/drivers/lcd README
|
||||
========================
|
||||
|
||||
This is the README.txt file for the drivers/lcd/ directory.
|
||||
|
||||
Contents
|
||||
========
|
||||
|
||||
- LCD Header files
|
||||
include/nuttx/lcd/lcd.h
|
||||
struct lcd_dev_s
|
||||
@ -80,13 +83,17 @@ Binding LCD Drivers
|
||||
1. Get an instance of struct lcd_dev_s from the hardware-specific LCD
|
||||
device driver, and
|
||||
2. Provide that instance to the initialization method of the higher
|
||||
level device driver.
|
||||
level device driver.
|
||||
|
||||
Examples: /drivers/lcd/
|
||||
=======================
|
||||
|
||||
Re-usable LCD drivers reside in the drivers/lcd directory:
|
||||
|
||||
mio283qt2.c. This is a driver for the MI0283QT-2 LCD from Multi-Inno
|
||||
Technology Co., Ltd. This LCD is based on the Himax HX8347-D LCD
|
||||
controller.
|
||||
|
||||
nokia6100.c. Supports the Nokia 6100 display with either the Philips
|
||||
PCF883 or the Epson S1D15G10 display controller. This LCD is used
|
||||
with the Olimex LPC1766-STK (but has not been fully integrated).
|
||||
@ -94,7 +101,12 @@ Re-usable LCD drivers reside in the drivers/lcd directory:
|
||||
p14201.c. Driver for RiT P14201 series display with SD1329 IC
|
||||
controller. This OLED is used with older versions of the
|
||||
TI/Luminary LM3S8962 Evaluation Kit.
|
||||
|
||||
|
||||
ssd12989.c. Generic LCD driver for LCDs based on the Solomon Systech
|
||||
SSD1289 LCD controller. Think of this as a template for an LCD driver
|
||||
that you will proably ahve to customize for any particular LCD
|
||||
hardware. (see also configs/hymini-stm32v/src/ssd1289.c below).
|
||||
|
||||
ug-9664hswag01.c. OLED Display Module, UG-9664HSWAG01", Univision
|
||||
Technology Inc. Used with the LPC Xpresso and Embedded Artists
|
||||
base board.
|
||||
@ -107,18 +119,31 @@ that support additional LCDs. LCD drivers in the configuration directory
|
||||
if they support some differ LCD interface (such as a parallel interface)
|
||||
that makes then less re-usable:
|
||||
|
||||
configs/sam3u-ek/src/up_lcd.c.
|
||||
configs/compal_e99/src/ssd1783.c
|
||||
|
||||
configs/hymini-stm32v/src/ssd1289.c.
|
||||
SSD1783
|
||||
|
||||
configs/hymini-stm32v/src/ssd1289.c. See also drivers/lcd/ssd1298.c
|
||||
above.
|
||||
|
||||
SSD1289
|
||||
|
||||
|
||||
configs/kwikstik-k40/src/up_lcd.c. Don't waste your time. This is
|
||||
just a stub.
|
||||
|
||||
configs/olimex-lpc1766stk/src/up_lcd.c. This examples is the
|
||||
bottom half for the SSD1289 driver at drivers/lcd/nokia6100.c.
|
||||
This was never completedly debugged ... there are probably issues
|
||||
with that nasty 9-bit SPI interfaces.
|
||||
|
||||
configs/sam3u-ek/src/up_lcd.c
|
||||
|
||||
The SAM3U-EK developement board features a TFT/Transmissive color
|
||||
LCD module with touch-screen, FTM280C12D, with integrated driver IC
|
||||
HX8346.
|
||||
|
||||
configs/skp16c26/src/up_lcd.c. Untested alphanumeric LCD driver.
|
||||
|
||||
configs/stm3210e-eval/src/up_lcd.c
|
||||
|
||||
This driver supports the following LCDs:
|
||||
@ -126,8 +151,13 @@ configs/sam3u-ek/src/up_lcd.c.
|
||||
1. Ampire AM-240320LTNQW00H
|
||||
2. Orise Tech SPFD5408B
|
||||
3. RenesasSP R61580
|
||||
|
||||
configs/skp16c26/src/up_lcd.c. Untest alphanumeric LCD driver.
|
||||
|
||||
configs/stm3220g-eval/src/up_lcd.c and configs/stm3240g-eval/src/up_lcd.c.
|
||||
AM-240320L8TNQW00H (LCD_ILI9320 or LCD_ILI9321) and
|
||||
AM-240320D5TOQW01H (LCD_ILI9325)
|
||||
|
||||
configs/stm32f4discovery/src/up_ssd1289.c. This examples is the
|
||||
bottom half for the SSD1289 driver at drivers/lcd/ssd1289.c
|
||||
|
||||
graphics/
|
||||
=========
|
||||
|
Loading…
Reference in New Issue
Block a user