aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gdisp/gdispSsd1289
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gdisp/gdispSsd1289')
-rw-r--r--drivers/gdisp/gdispSsd1289/gdisp_lld.c610
-rw-r--r--drivers/gdisp/gdispSsd1289/gdisp_lld.mk5
-rw-r--r--drivers/gdisp/gdispSsd1289/gdisp_lld_config.h66
-rw-r--r--drivers/gdisp/gdispSsd1289/readme.txt16
-rw-r--r--drivers/gdisp/gdispSsd1289/ssd1289_lld.c.h322
5 files changed, 1019 insertions, 0 deletions
diff --git a/drivers/gdisp/gdispSsd1289/gdisp_lld.c b/drivers/gdisp/gdispSsd1289/gdisp_lld.c
new file mode 100644
index 00000000..7dfb83a7
--- /dev/null
+++ b/drivers/gdisp/gdispSsd1289/gdisp_lld.c
@@ -0,0 +1,610 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdispSsd1289/gdisp_lld.c
+ * @brief GDISP Graphics Driver subsystem low level driver source for the Ssd1289 display.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+#include "gdisp.h"
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+/* Include the emulation code for things we don't support */
+#include "gdisp_emulation.c"
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+#include "ssd1289_lld.c.h"
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/* ---- Required Routines ---- */
+/*
+ The following 2 routines are required.
+ All other routines are optional.
+*/
+
+/**
+ * @brief Low level GDISP driver initialization.
+ *
+ * @notapi
+ */
+bool_t GDISP_LLD(init)(void) {
+ uint16_t deviceCode;
+
+ #ifdef LCD_USE_FSMC
+ /* FSMC setup. TODO: this only works for STM32F1 */
+ rccEnableAHB(RCC_AHBENR_FSMCEN, 0);
+ int FSMC_Bank = 0;
+ /* timing structure */
+ /* from datasheet:
+ address setup: 0ns
+ address hold: 0ns
+ Data setup: 5ns
+ Data hold: 5ns
+ Data access: 250ns
+ output hold: 100ns
+ */
+ FSMC_Bank1->BTCR[FSMC_Bank+1] = FSMC_BTR1_ADDSET_1 | FSMC_BTR1_DATAST_1;
+
+ /* Bank1 NOR/SRAM control register configuration */
+ FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN;
+ #endif
+
+ deviceCode = lld_lcdReadReg(0x0000);
+
+ lld_lcdWriteReg(0x0000,0x0001); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0003,0xA8A4); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x000C,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x000D,0x080C); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x000E,0x2B00); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x001E,0x00B0); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0001,0x2B3F); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0002,0x0600); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0010,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0011,0x6070); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0005,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0006,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0016,0xEF1C); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0017,0x0003); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0007,0x0133); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x000B,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x000F,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0041,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0042,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0048,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0049,0x013F); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x004A,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x004B,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0044,0xEF00); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0045,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0046,0x013F); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0030,0x0707); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0031,0x0204); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0032,0x0204); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0033,0x0502); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0034,0x0507); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0035,0x0204); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0036,0x0204); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0037,0x0502); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x003A,0x0302); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x003B,0x0302); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0023,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0024,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0025,0x8000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x004f,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x004e,0x0000); lld_lcdDelay(5);
+
+ /* Initialise the GDISP structure */
+ GDISP.Width = SCREEN_WIDTH;
+ GDISP.Height = SCREEN_HEIGHT;
+ GDISP.Orientation = portrait;
+ GDISP.Powermode = powerOn;
+ GDISP.Backlight = 100;
+ GDISP.Contrast = 50;
+ return TRUE;
+}
+
+/**
+ * @brief Draws a pixel on the display.
+ *
+ * @param[in] x X location of the pixel
+ * @param[in] y Y location of the pixel
+ * @param[in] color The color of the pixel
+ *
+ * @notapi
+ */
+void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ if (x >= GDISP.Width || y >= GDISP.Height) return;
+ #endif
+ lld_lcdSetCursor(x, y);
+ lld_lcdWriteReg(0x0022, color);
+}
+
+/* ---- Optional Routines ---- */
+/*
+ All the below routines are optional.
+ Defining them will increase speed but everything
+ will work if they are not defined.
+ If you are not using a routine - turn it off using
+ the appropriate GDISP_HARDWARE_XXXX macro.
+ Don't bother coding for obvious similar routines if
+ there is no performance penalty as the emulation software
+ makes a good job of using similar routines.
+ eg. If gfillarea() is defined there is little
+ point in defining clear() unless the
+ performance bonus is significant.
+ For good performance it is suggested to implement
+ fillarea() and blitarea().
+*/
+
+#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__)
+ /**
+ * @brief Clear the display.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] color The color of the pixel
+ *
+ * @notapi
+ */
+ void GDISP_LLD(clear)(color_t color) {
+ unsigned i;
+
+ lld_lcdSetCursor(0, 0);
+ lld_lcdWriteStreamStart();
+
+ for(i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; i++)
+ lld_lcdWriteData(color);
+
+ lld_lcdWriteStreamStop();
+ }
+#endif
+
+#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a line.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x0, y0 The start of the line
+ * @param[in] x1, y1 The end of the line
+ * @param[in] color The color of the line
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__)
+ /**
+ * @brief Fill an area with a color.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The start filled area
+ * @param[in] cx, cy The width and height to be filled
+ * @param[in] color The color of the fill
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
+ if (x+cx > GDISP.Width) cx = GDISP.Width - x;
+ if (y+cy > GDISP.Height) cy = GDISP.Height - y;
+ #endif
+
+ unsigned i, area;
+
+ area = cx*cy;
+ lld_lcdSetViewPort(x, y, cx, cy);
+ lld_lcdWriteStreamStart();
+ for(i = 0; i < area; i++)
+ lld_lcdWriteData(color);
+ lld_lcdWriteStreamStop();
+ lld_lcdResetViewPort();
+ }
+#endif
+
+#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__)
+ /**
+ * @brief Fill an area with a bitmap.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The start filled area
+ * @param[in] cx, cy The width and height to be filled
+ * @param[in] buffer The pixels to use to fill the area.
+ *
+ * @notapi
+ */
+ void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) {
+ unsigned i, area;
+
+ #if GDISP_NEED_VALIDATION
+ if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
+ if (x+cx > GDISP.Width) return;
+ if (y+cy > GDISP.Height) cy = GDISP.Height - y;
+ #endif
+
+ area = cx*cy;
+ lld_lcdSetViewPort(x, y, cx, cy);
+ lld_lcdWriteStreamStart();
+ for(i = 0; i < area; i++)
+ lld_lcdWriteData(*buffer++);
+ lld_lcdWriteStreamStop();
+ lld_lcdResetViewPort();
+ }
+#endif
+
+/* Circular Drawing Functions */
+#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a circle.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the circle is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the circle
+ * @param[in] radius The radius of the circle
+ * @param[in] color The color of the circle
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Create a filled circle.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the circle is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the circle
+ * @param[in] radius The radius of the circle
+ * @param[in] color The color of the circle
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw an ellipse.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the ellipse is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the ellipse
+ * @param[in] a, b The dimensions of the ellipse
+ * @param[in] color The color of the ellipse
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Create a filled ellipse.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the ellipse is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the ellipse
+ * @param[in] a, b The dimensions of the ellipse
+ * @param[in] color The color of the ellipse
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__)
+ #include "gdisp_fonts.h"
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a character using a transparent background.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The top-left corner of the text
+ * @param[in] c The character to print
+ * @param[in] color The color of the character
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a character using a filled background.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The top-left corner of the text
+ * @param[in] c The character to print
+ * @param[in] color The color of the character
+ * @param[in] bgcolor The background color
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__)
+ /**
+ * @brief Get the color of a particular pixel.
+ * @note Optional.
+ * @note If x,y is off the screen, the result is undefined.
+ *
+ * @param[in] x, y The start of the text
+ *
+ * @notapi
+ */
+ color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) {
+ color_t color;
+
+ #if GDISP_NEED_VALIDATION
+ if (x >= GDISP.Width || y >= GDISP.Height) return 0;
+ #endif
+
+ lld_lcdSetCursor(x, y);
+ lld_lcdWriteStreamStart();
+
+ color = lld_lcdReadData();
+ color = lld_lcdReadData();
+
+ lld_lcdWriteStreamStop();
+
+ return color;
+ }
+#endif
+
+#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__)
+ /**
+ * @brief Scroll vertically a section of the screen.
+ * @note Optional.
+ * @note If x,y + cx,cy is off the screen, the result is undefined.
+ * @note If lines is >= cy, it is equivelent to a area fill with bgcolor.
+ *
+ * @param[in] x, y The start of the area to be scrolled
+ * @param[in] cx, cy The size of the area to be scrolled
+ * @param[in] lines The number of lines to scroll (Can be positive or negative)
+ * @param[in] bgcolor The color to fill the newly exposed area.
+ *
+ * @notapi
+ */
+ void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
+ static color_t buf[((SCREEN_HEIGHT > SCREEN_WIDTH ) ? SCREEN_HEIGHT : SCREEN_WIDTH)];
+ coord_t row0, row1;
+ unsigned i, gap, abslines;
+
+ abslines = lines < 0 ? -lines : lines;
+
+ #if GDISP_NEED_VALIDATION
+ if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
+ if (x+cx > GDISP.Width) cx = GDISP.Width - x;
+ if (y+cy > GDISP.Height) cy = GDISP.Height - y;
+ #endif
+
+ if (!abslines) return;
+ if (abslines >= cy) {
+ abslines = cy;
+ gap = 0;
+ } else {
+ gap = cy - abslines;
+ for(i = 0; i < gap; i++) {
+ if(lines > 0) {
+ row0 = y + i + lines;
+ row1 = y + i;
+ } else {
+ row0 = (y - i - 1) + lines;
+ row1 = (y - i - 1);
+ }
+
+ /* read row0 into the buffer and then write at row1*/
+ lld_lcdSetViewPort(x, row0, cx, 1);
+ lld_lcdReadStreamStart();
+ lld_lcdReadStream(buf, cx);
+ lld_lcdReadStreamStop();
+
+ lld_lcdSetViewPort(x, row1, cx, 1);
+ lld_lcdWriteStreamStart();
+ lld_lcdWriteStream(buf, cx);
+ lld_lcdWriteStreamStop();
+ }
+ }
+
+ /* fill the remaining gap */
+ lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines);
+ lld_lcdWriteStreamStart();
+ gap = cx*abslines;
+ for(i = 0; i < gap; i++) lld_lcdWriteData(color);
+ lld_lcdWriteStreamStop();
+ lld_lcdResetViewPort();
+ }
+#endif
+
+#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__)
+ /**
+ * @brief Driver Control
+ * @detail Unsupported control codes are ignored.
+ * @note The value parameter should always be typecast to (void *).
+ * @note There are some predefined and some specific to the low level driver.
+ * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t
+ * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t
+ * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver
+ * that only supports off/on anything other
+ * than zero is on.
+ * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100.
+ * GDISP_CONTROL_LLD - Low level driver control constants start at
+ * this value.
+ *
+ * @param[in] what What to do.
+ * @param[in] value The value to use (always cast to a void *).
+ *
+ * @notapi
+ */
+ void GDISP_LLD(control)(unsigned what, void *value) {
+ switch(what) {
+ case GDISP_CONTROL_POWER:
+ if (GDISP.Powermode == (gdisp_powermode_t)value)
+ return;
+ switch((gdisp_powermode_t)value) {
+ case powerOff:
+ lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode
+ lld_lcdWriteReg(0x0007, 0x0000); // halt operation
+ lld_lcdWriteReg(0x0000, 0x0000); // turn off oszillator
+ lld_lcdWriteReg(0x0010, 0x0001); // enter sleepmode
+ break;
+ case powerOn:
+ lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode
+ if (GDISP.Powermode != powerSleep)
+ GDISP_LLD(init)();
+ break;
+ case powerSleep:
+ lld_lcdWriteReg(0x0010, 0x0001); // enter sleep mode
+ break;
+ default:
+ return;
+ }
+ GDISP.Powermode = (gdisp_powermode_t)value;
+ return;
+ case GDISP_CONTROL_ORIENTATION:
+ if (GDISP.Orientation == (gdisp_orientation_t)value)
+ return;
+ switch((gdisp_orientation_t)value) {
+ case portrait:
+ lld_lcdWriteReg(0x0001, 0x2B3F);
+ /* ID = 11 AM = 0 */
+ lld_lcdWriteReg(0x0011, 0x6070);
+ GDISP.Height = SCREEN_HEIGHT;
+ GDISP.Width = SCREEN_WIDTH;
+ break;
+ case landscape:
+ lld_lcdWriteReg(0x0001, 0x293F);
+ /* ID = 11 AM = 1 */
+ lld_lcdWriteReg(0x0011, 0x6078);
+ GDISP.Height = SCREEN_WIDTH;
+ GDISP.Width = SCREEN_HEIGHT;
+ break;
+ case portraitInv:
+ lld_lcdWriteReg(0x0001, 0x2B3F);
+ /* ID = 01 AM = 0 */
+ lld_lcdWriteReg(0x0011, 0x6040);
+ GDISP.Height = SCREEN_HEIGHT;
+ GDISP.Width = SCREEN_WIDTH;
+ break;
+ case landscapeInv:
+ lld_lcdWriteReg(0x0001, 0x293F);
+ /* ID = 01 AM = 1 */
+ lld_lcdWriteReg(0x0011, 0x6048);
+ GDISP.Height = SCREEN_WIDTH;
+ GDISP.Width = SCREEN_HEIGHT;
+ break;
+ default:
+ return;
+ }
+ GDISP.Orientation = (gdisp_orientation_t)value;
+ return;
+/*
+ case GDISP_CONTROL_BACKLIGHT:
+ case GDISP_CONTROL_CONTRAST:
+*/
+ }
+ }
+#endif
+
+#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__)
+/**
+ * @brief Query a driver value.
+ * @detail Typecase the result to the type you want.
+ * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen
+ * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen
+ * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode
+ * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation
+ * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100)
+ * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100).
+ * GDISP_QUERY_LLD - Low level driver control constants start at
+ * this value.
+ *
+ * @param[in] what What to Query
+ *
+ * @notapi
+ */
+void *GDISP_LLD(query)(unsigned what) {
+ switch(what) {
+ case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width;
+ case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height;
+ case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode;
+ case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation;
+ case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight;
+ case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast;
+ case GDISP_QUERY_LLD+0:
+ /* Code here */
+ default: return (void *)-1;
+ }
+}
+#endif
+
+#endif /* HAL_USE_GDISP */
+/** @} */
diff --git a/drivers/gdisp/gdispSsd1289/gdisp_lld.mk b/drivers/gdisp/gdispSsd1289/gdisp_lld.mk
new file mode 100644
index 00000000..8167cbfb
--- /dev/null
+++ b/drivers/gdisp/gdispSsd1289/gdisp_lld.mk
@@ -0,0 +1,5 @@
+# List the required driver.
+LCDSRC += $(LCDLIB)/drivers/gdisp/gdispSsd1289/gdisp_lld.c
+
+# Required include directories
+LCDINC += $(LCDLIB)/drivers/gdisp/gdispSsd1289
diff --git a/drivers/gdisp/gdispSsd1289/gdisp_lld_config.h b/drivers/gdisp/gdispSsd1289/gdisp_lld_config.h
new file mode 100644
index 00000000..123ce875
--- /dev/null
+++ b/drivers/gdisp/gdispSsd1289/gdisp_lld_config.h
@@ -0,0 +1,66 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdispSsd1289/gdisp_lld_config.h
+ * @brief GDISP Graphic Driver subsystem low level driver header for the Ssd1289 display.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#ifndef _GDISP_LLD_CONFIG_H
+#define _GDISP_LLD_CONFIG_H
+
+#if HAL_USE_GDISP
+
+/*===========================================================================*/
+/* Driver hardware support. */
+/*===========================================================================*/
+
+#define GDISP_DRIVER_NAME "SSD1289"
+#define GDISP_LLD(x) gdisp_lld_##x##_SSD1289
+
+#define GDISP_HARDWARE_LINES FALSE
+#define GDISP_HARDWARE_CLEARS TRUE
+#define GDISP_HARDWARE_FILLS TRUE
+#define GDISP_HARDWARE_BITFILLS TRUE
+#define GDISP_HARDWARE_CIRCLES FALSE
+#define GDISP_HARDWARE_CIRCLEFILLS FALSE
+#define GDISP_HARDWARE_ELLIPSES FALSE
+#define GDISP_HARDWARE_ELLIPSEFILLS FALSE
+#define GDISP_HARDWARE_TEXT FALSE
+#define GDISP_HARDWARE_TEXTFILLS FALSE
+#define GDISP_HARDWARE_SCROLL TRUE
+#define GDISP_HARDWARE_PIXELREAD TRUE
+#define GDISP_HARDWARE_CONTROL TRUE
+#define GDISP_HARDWARE_QUERY FALSE
+
+#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE
+#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE
+
+#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
+#define GDISP_PACKED_PIXELS FALSE
+#define GDISP_PACKED_LINES FALSE
+
+#endif /* HAL_USE_GDISP */
+
+#endif /* _GDISP_LLD_CONFIG_H */
+/** @} */
diff --git a/drivers/gdisp/gdispSsd1289/readme.txt b/drivers/gdisp/gdispSsd1289/readme.txt
new file mode 100644
index 00000000..17d22223
--- /dev/null
+++ b/drivers/gdisp/gdispSsd1289/readme.txt
@@ -0,0 +1,16 @@
+To use this driver:
+
+1. Add in your halconf.h:
+ a) #define HAL_USE_GDISP TRUE
+ b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD
+ c) One (only) of:
+ #define LCD_USE_GPIO
+ #define LCD_USE_SPI
+ #define LCD_USE_FSMC
+ d) All of the following (with appropriate values):
+ #define SCREEN_WIDTH 320
+ #define SCREEN_HEIGHT 240
+
+2. To your makefile add the following lines:
+ include $(CHIBIOS)/os/halext/halext.mk
+ include $(CHIBIOS)/os/halext/drivers/gdispSsd1289/gdisp_lld.mk
diff --git a/drivers/gdisp/gdispSsd1289/ssd1289_lld.c.h b/drivers/gdisp/gdispSsd1289/ssd1289_lld.c.h
new file mode 100644
index 00000000..7c0fade2
--- /dev/null
+++ b/drivers/gdisp/gdispSsd1289/ssd1289_lld.c.h
@@ -0,0 +1,322 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef SSD1289_H
+#define SSD1289_H
+
+#if defined(LCD_USE_GPIO)
+ #define Set_CS palSetPad(LCD_CMD_PORT, LCD_CS);
+ #define Clr_CS palClearPad(LCD_CMD_PORT, LCD_CS);
+ #define Set_RS palSetPad(LCD_CMD_PORT, LCD_RS);
+ #define Clr_RS palClearPad(LCD_CMD_PORT, LCD_RS);
+ #define Set_WR palSetPad(LCD_CMD_PORT, LCD_WR);
+ #define Clr_WR palClearPad(LCD_CMD_PORT, LCD_WR);
+ #define Set_RD palSetPad(LCD_CMD_PORT, LCD_RD);
+ #define Clr_RD palClearPad(LCD_CMD_PORT, LCD_RD);
+
+ static __inline void lld_lcdWriteIndex(uint16_t index) {
+ Clr_RS; Set_RD;
+ lld_lcdWriteGPIO(index);
+ Clr_WR; Set_WR;
+ }
+ static __inline void lld_lcdWriteData(uint16_t data) {
+ Set_RS;
+ lld_lcdWriteGPIO(data);
+ Clr_WR; Set_WR;
+ }
+ static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) {
+ Clr_CS;
+ lld_lcdWriteIndex(lcdReg);
+ lld_lcdWriteData(lcdRegValue);
+ Set_CS;
+ }
+ static __inline uint16_t lld_lcdReadData(void) {
+ uint16_t value;
+
+ Set_RS; Set_WR; Clr_RD;
+ value = lld_lcdReadGPIO();
+ Set_RD;
+ return value;
+ }
+ static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) {
+ uint16_t value;
+
+ Clr_CS;
+ lld_lcdWriteIndex(lcdReg);
+ value = lld_lcdReadData();
+ Set_CS;
+ return value;
+ }
+
+ static __inline void lld_lcdWriteStreamStart(void) {
+ Clr_CS;
+ lld_lcdWriteIndex(0x0022);
+ }
+
+ static __inline void lld_lcdWriteStreamStop(void) {
+ Set_CS;
+ }
+
+ static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
+ uint16_t i;
+
+ Set_RS;
+ for(i = 0; i < size; i++) { lld_lcdWriteGPIO(buffer[i]); Clr_WR; Set_WR; }
+ }
+
+ static __inline void lld_lcdReadStreamStart(void) {
+ Clr_CS
+ lld_lcdWriteIndex(0x0022);
+ }
+
+ static __inline void lld_lcdReadStreamStop(void) {
+ Set_CS;
+ }
+
+ static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) {
+ uint16_t i;
+ volatile uint16_t dummy;
+
+ dummy = lld_lcdReadData();
+ for(i = 0; i < size; i++) buffer[i] = lld_lcdReadData();
+ }
+
+#elif defined(LCD_USE_FSMC)
+ /* LCD Registers */
+ #define R0 0x00
+ #define R1 0x01
+ #define R2 0x02
+ #define R3 0x03
+ #define R4 0x04
+ #define R5 0x05
+ #define R6 0x06
+ #define R7 0x07
+ #define R8 0x08
+ #define R9 0x09
+ #define R10 0x0A
+ #define R12 0x0C
+ #define R13 0x0D
+ #define R14 0x0E
+ #define R15 0x0F
+ #define R16 0x10
+ #define R17 0x11
+ #define R18 0x12
+ #define R19 0x13
+ #define R20 0x14
+ #define R21 0x15
+ #define R22 0x16
+ #define R23 0x17
+ #define R24 0x18
+ #define R25 0x19
+ #define R26 0x1A
+ #define R27 0x1B
+ #define R28 0x1C
+ #define R29 0x1D
+ #define R30 0x1E
+ #define R31 0x1F
+ #define R32 0x20
+ #define R33 0x21
+ #define R34 0x22
+ #define R36 0x24
+ #define R37 0x25
+ #define R40 0x28
+ #define R41 0x29
+ #define R43 0x2B
+ #define R45 0x2D
+ #define R48 0x30
+ #define R49 0x31
+ #define R50 0x32
+ #define R51 0x33
+ #define R52 0x34
+ #define R53 0x35
+ #define R54 0x36
+ #define R55 0x37
+ #define R56 0x38
+ #define R57 0x39
+ #define R59 0x3B
+ #define R60 0x3C
+ #define R61 0x3D
+ #define R62 0x3E
+ #define R63 0x3F
+ #define R64 0x40
+ #define R65 0x41
+ #define R66 0x42
+ #define R67 0x43
+ #define R68 0x44
+ #define R69 0x45
+ #define R70 0x46
+ #define R71 0x47
+ #define R72 0x48
+ #define R73 0x49
+ #define R74 0x4A
+ #define R75 0x4B
+ #define R76 0x4C
+ #define R77 0x4D
+ #define R78 0x4E
+ #define R79 0x4F
+ #define R80 0x50
+ #define R81 0x51
+ #define R82 0x52
+ #define R83 0x53
+ #define R96 0x60
+ #define R97 0x61
+ #define R106 0x6A
+ #define R118 0x76
+ #define R128 0x80
+ #define R129 0x81
+ #define R130 0x82
+ #define R131 0x83
+ #define R132 0x84
+ #define R133 0x85
+ #define R134 0x86
+ #define R135 0x87
+ #define R136 0x88
+ #define R137 0x89
+ #define R139 0x8B
+ #define R140 0x8C
+ #define R141 0x8D
+ #define R143 0x8F
+ #define R144 0x90
+ #define R145 0x91
+ #define R146 0x92
+ #define R147 0x93
+ #define R148 0x94
+ #define R149 0x95
+ #define R150 0x96
+ #define R151 0x97
+ #define R152 0x98
+ #define R153 0x99
+ #define R154 0x9A
+ #define R157 0x9D
+ #define R192 0xC0
+ #define R193 0xC1
+ #define R229 0xE5
+
+ #define LCD_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */
+ #define LCD_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */
+
+ static __inline void lld_lcdWriteIndex(uint16_t index) { LCD_REG = index; }
+ static __inline void lld_lcdWriteData(uint16_t data) { LCD_RAM = data; }
+ static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) {
+ LCD_REG = lcdReg;
+ LCD_RAM = lcdRegValue;
+ }
+ static __inline uint16_t lld_lcdReadData(void) { return (LCD_RAM); }
+ static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) {
+ volatile uint16_t dummy;
+
+ LCD_REG = lcdReg;
+ dummy = LCD_RAM;
+ return (LCD_RAM);
+ }
+ static __inline void lld_lcdWriteStreamStart(void) { LCD_REG = 0x0022; }
+ static __inline void lld_lcdWriteStreamStop(void) {}
+ static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
+ uint16_t i;
+
+ for(i = 0; i < size; i++) LCD_RAM = buffer[i];
+ }
+ static __inline void lld_lcdReadStreamStart(void) { LCD_REG = 0x0022; }
+ static __inline void lld_lcdReadStreamStop(void) {}
+ static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) {
+ uint16_t i;
+ volatile uint16_t dummy;
+
+ dummy = LCD_RAM; /* throw away first value read */
+ for(i = 0; i < size; i++) buffer[i] = LCD_RAM;
+ }
+
+#elif defined(LCD_USE_SPI)
+ #error "gdispSsd1289: LCD_USE_SPI not implemented yet"
+
+#else
+ #error "gdispSsd1289: No known LCD_USE_XXX has been defined"
+#endif
+
+static __inline void lld_lcdDelay(uint16_t us) {
+ chThdSleepMicroseconds(us);
+}
+
+static void lld_lcdSetCursor(uint16_t x, uint16_t y) {
+ /* Reg 0x004E is an 8 bit value
+ * Reg 0x004F is 9 bit
+ * Use a bit mask to make sure they are not set too high
+ */
+ switch(GDISP.Orientation) {
+ case portraitInv:
+ lld_lcdWriteReg(0x004e, (SCREEN_WIDTH-1-x) & 0x00FF);
+ lld_lcdWriteReg(0x004f, (SCREEN_HEIGHT-1-y) & 0x01FF);
+ break;
+ case portrait:
+ lld_lcdWriteReg(0x004e, x & 0x00FF);
+ lld_lcdWriteReg(0x004f, y & 0x01FF);
+ break;
+ case landscape:
+ lld_lcdWriteReg(0x004e, y & 0x00FF);
+ lld_lcdWriteReg(0x004f, x & 0x01FF);
+ break;
+ case landscapeInv:
+ lld_lcdWriteReg(0x004e, (SCREEN_WIDTH - y - 1) & 0x00FF);
+ lld_lcdWriteReg(0x004f, (SCREEN_HEIGHT - x - 1) & 0x01FF);
+ break;
+ }
+}
+
+static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) {
+ lld_lcdSetCursor(x, y);
+
+ /* Reg 0x44 - Horizontal RAM address position
+ * Upper Byte - HEA
+ * Lower Byte - HSA
+ * 0 <= HSA <= HEA <= 0xEF
+ * Reg 0x45,0x46 - Vertical RAM address position
+ * Lower 9 bits gives 0-511 range in each value
+ * 0 <= Reg(0x45) <= Reg(0x46) <= 0x13F
+ */
+
+ switch(GDISP.Orientation) {
+ case portrait:
+ lld_lcdWriteReg(0x44, (((x+cx-1) << 8) & 0xFF00 ) | (x & 0x00FF));
+ lld_lcdWriteReg(0x45, y & 0x01FF);
+ lld_lcdWriteReg(0x46, (y+cy-1) & 0x01FF);
+ break;
+ case landscape:
+ lld_lcdWriteReg(0x44, (((x+cx-1) << 8) & 0xFF00) | ((y+cy) & 0x00FF));
+ lld_lcdWriteReg(0x45, x & 0x01FF);
+ lld_lcdWriteReg(0x46, (x+cx-1) & 0x01FF);
+ break;
+ case portraitInv:
+ lld_lcdWriteReg(0x44, (((SCREEN_WIDTH-x-1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (x+cx)) & 0x00FF));
+ lld_lcdWriteReg(0x45, (SCREEN_HEIGHT-(y+cy)) & 0x01FF);
+ lld_lcdWriteReg(0x46, (SCREEN_HEIGHT-y-1) & 0x01FF);
+ break;
+ case landscapeInv:
+ lld_lcdWriteReg(0x44, (((SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (y+cy)) & 0x00FF));
+ lld_lcdWriteReg(0x45, (SCREEN_HEIGHT - (x+cx)) & 0x01FF);
+ lld_lcdWriteReg(0x46, (SCREEN_HEIGHT - x - 1) & 0x01FF);
+ break;
+ }
+
+ lld_lcdSetCursor(x, y);
+}
+
+static __inline void lld_lcdResetViewPort(void) {}
+
+#endif /* SSD1289_H */