aboutsummaryrefslogtreecommitdiffstats
path: root/halext/drivers
diff options
context:
space:
mode:
authorAndrew Hannam <andrewh@inmarket.com.au>2012-08-09 17:12:45 +1000
committerAndrew Hannam <andrewh@inmarket.com.au>2012-08-09 17:18:32 +1000
commit8f9c956810cc2cc66306d41b8501b366eab9c035 (patch)
treebf7590abc8a9d1a64ee961755f61ab2c8ecc0107 /halext/drivers
parentfb070f8d2cb31481c4a80f4a56e86fb9cc9bf4cc (diff)
downloaduGFX-8f9c956810cc2cc66306d41b8501b366eab9c035.tar.gz
uGFX-8f9c956810cc2cc66306d41b8501b366eab9c035.tar.bz2
uGFX-8f9c956810cc2cc66306d41b8501b366eab9c035.zip
Multi-thread, Async Multi-thread & VMT
Diffstat (limited to 'halext/drivers')
-rw-r--r--halext/drivers/gdispNokia6610/gdisp_lld.c123
-rw-r--r--halext/drivers/gdispNokia6610/gdisp_lld_board_example.h10
-rw-r--r--halext/drivers/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h10
-rw-r--r--halext/drivers/gdispNokia6610/gdisp_lld_config.h14
-rw-r--r--halext/drivers/gdispS6d1121/gdisp_lld.c91
-rw-r--r--halext/drivers/gdispS6d1121/gdisp_lld_config.h18
-rw-r--r--halext/drivers/gdispSsd1289/gdisp_lld.c89
-rw-r--r--halext/drivers/gdispSsd1289/gdisp_lld_config.h16
-rw-r--r--halext/drivers/gdispTestStub/gdisp_lld.c87
-rw-r--r--halext/drivers/gdispTestStub/gdisp_lld_config.h20
-rw-r--r--halext/drivers/gdispVMT/gdisp_lld.c249
-rw-r--r--halext/drivers/gdispVMT/gdisp_lld.mk7
-rw-r--r--halext/drivers/gdispVMT/gdisp_lld_config.h67
-rw-r--r--halext/drivers/gdispVMT/gdisp_lld_driver1.c51
-rw-r--r--halext/drivers/gdispVMT/gdisp_lld_driver2.c51
-rw-r--r--halext/drivers/gdispVMT/readme.txt23
16 files changed, 726 insertions, 200 deletions
diff --git a/halext/drivers/gdispNokia6610/gdisp_lld.c b/halext/drivers/gdispNokia6610/gdisp_lld.c
index 1608c1f0..5ebe2177 100644
--- a/halext/drivers/gdispNokia6610/gdisp_lld.c
+++ b/halext/drivers/gdispNokia6610/gdisp_lld.c
@@ -32,19 +32,13 @@
#if HAL_USE_GDISP || defined(__DOXYGEN__)
+/* Include the emulation code for things we don't support */
+#include "gdisp_emulation.c"
+
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
-#ifdef UNUSED
-#elif defined(__GNUC__)
-# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
-#elif defined(__LCLINT__)
-# define UNUSED(x) /*@unused@*/ x
-#else
-# define UNUSED(x) x
-#endif
-
/* Controller definitions */
#if defined(LCD_USE_GE8)
#include "GE8.h"
@@ -58,10 +52,6 @@
/* Driver exported variables. */
/*===========================================================================*/
-#if !defined(__DOXYGEN__)
- GDISPDriver GDISP;
-#endif
-
/*===========================================================================*/
/* Driver local variables. */
/*===========================================================================*/
@@ -79,8 +69,8 @@
#include "gdisp_lld_board.h"
#endif
-#define gdisp_lld_write_command(cmd) gdisp_lld_write_spi((cmd) & ~0x0100)
-#define gdisp_lld_write_data(data) gdisp_lld_write_spi((data) | 0x0100)
+#define gdisp_lld_write_command(cmd) GDISP_LLD(write_spi)((cmd) & ~0x0100)
+#define gdisp_lld_write_data(data) GDISP_LLD(write_spi)((data) | 0x0100)
static __inline void gdisp_lld_setviewport(coord_t x, coord_t y, coord_t cx, coord_t cy) {
gdisp_lld_write_command(CASET); // Column address set
@@ -91,12 +81,6 @@ static __inline void gdisp_lld_setviewport(coord_t x, coord_t y, coord_t cx, coo
gdisp_lld_write_data(y+cy-1);
}
-void Delay (unsigned long a) {
- chThdSleepMilliseconds(a/100);
-// volatile unsigned long d;
-// for(d=a; d; d--);
-}
-
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
@@ -116,15 +100,15 @@ void Delay (unsigned long a) {
*
* @notapi
*/
-void gdisp_lld_init(void) {
+bool_t GDISP_LLD(init)(void) {
/* Initialise your display */
- gdisp_lld_init_board();
+ GDISP_LLD(init_board)();
// Hardware reset
- gdisp_lld_setpin_reset(TRUE);
- Delay(20000);
- gdisp_lld_setpin_reset(FALSE);
- Delay(20000);
+ GDISP_LLD(setpin_reset)(TRUE);
+ chThdSleepMilliseconds(20);
+ GDISP_LLD(setpin_reset)(FALSE);
+ chThdSleepMilliseconds(20);
#if defined(LCD_USE_GE8)
#if 1
@@ -147,7 +131,7 @@ void gdisp_lld_init(void) {
gdisp_lld_write_command(VOLCTR); // Voltage control (contrast setting)
gdisp_lld_write_data(32); // P1 = 32 volume value (experiment with this value to get the best contrast)
gdisp_lld_write_data(3); // P2 = 3 resistance ratio (only value that works)
- Delay(100000); // allow power supply to stabilize
+ chThdSleepMilliseconds(100); // allow power supply to stabilize
gdisp_lld_write_command(DISON); // Turn on the display
#else
// Alternative
@@ -158,7 +142,7 @@ void gdisp_lld_init(void) {
gdisp_lld_write_command(COMSCN); // COM scan
gdisp_lld_write_data(0x00); // Scan 1-80
gdisp_lld_write_command(OSCON); // Internal oscilator ON
- Delay(10000); // wait aproximetly 100ms
+ chThdSleepMilliseconds(100); // wait aproximetly 100ms
gdisp_lld_write_command(SLPOUT); // Sleep out
gdisp_lld_write_command(VOLCTR); // Voltage control
gdisp_lld_write_data(0x1F); // middle value of V1
@@ -200,15 +184,15 @@ void gdisp_lld_init(void) {
gdisp_lld_write_data(0xC8); // 0xC0 = mirror x and y, reverse rgb
gdisp_lld_write_command(SETCON); // Write contrast
gdisp_lld_write_data(0x30); // contrast - experiental value
- Delay(2000);
+ chThdSleepMilliseconds(20);
gdisp_lld_write_command(DISPON); // Display On
#else
// Alternative
// Hardware reset commented out
gdisp_lld_write_command(SOFTRST); // Software Reset
- Delay(2000);
+ chThdSleepMilliseconds(20);
gdisp_lld_write_command(INITESC); // Initial escape
- Delay(2000);
+ chThdSleepMilliseconds(20);
gdisp_lld_write_command(REFSET); // Refresh set
gdisp_lld_write_data(0);
gdisp_lld_write_command(DISPCTRL); // Set Display control
@@ -258,7 +242,7 @@ void gdisp_lld_init(void) {
//gdisp_lld_write_data(0x03); // must be "1"
gdisp_lld_write_command(CONTRAST); // Write contrast
gdisp_lld_write_data(0x3b); // contrast
- Delay(2000);
+ chThdSleepMilliseconds(20);
gdisp_lld_write_command(TEMPGRADIENT); // Temperature gradient
for(i=0; i<14; i++) gdisp_lld_write_data(0);
gdisp_lld_write_command(BOOSTVON); // Booster voltage ON
@@ -267,13 +251,16 @@ void gdisp_lld_init(void) {
#endif
/* Turn on the back-light */
- gdisp_lld_setpin_backlight(TRUE);
+ GDISP_LLD(setpin_backlight)(TRUE);
/* Initialise the GDISP structure to match */
GDISP.Width = 132;
GDISP.Height = 132;
GDISP.Orientation = portrait;
GDISP.Powermode = powerOn;
+ GDISP.Backlight = 100;
+ GDISP.Contrast = 50;
+ return TRUE;
}
/**
@@ -285,7 +272,7 @@ void gdisp_lld_init(void) {
*
* @notapi
*/
-void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
+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
@@ -306,11 +293,11 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
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 gdisp_lld_fillarea() is defined there is little
- point in defining gdisp_lld_clear() unless the
+ eg. If fillarea() is defined there is little
+ point in defining clear() unless the
performance bonus is significant.
For good performance it is suggested to implement
- gdisp_lld_fillarea() and gdisp_lld_blitarea().
+ fillarea() and blitarea().
*/
#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__)
@@ -322,7 +309,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_clear(color_t color) {
+ void GDISP_LLD(clear(color_t color) {
/* NOT IMPLEMENTED */
/* Nothing to be gained by implementing this
* as fillarea is just as fast.
@@ -341,7 +328,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_drawline(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
+ void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
/* NOT IMPLEMENTED */
}
#endif
@@ -357,7 +344,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_fillarea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
+ void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
unsigned i, tuples;
#if GDISP_NEED_VALIDATION
@@ -390,7 +377,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_blitarea(coord_t x, coord_t y, coord_t cx, coord_t cy, pixel_t *buffer) {
+ void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) {
unsigned i, area, tuples;
#ifndef GDISP_PACKED_PIXELS
color_t c1, c2;
@@ -451,7 +438,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_drawcircle(coord_t x, coord_t y, coord_t radius, color_t color) {
+ void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
/* NOT IMPLEMENTED */
}
#endif
@@ -469,7 +456,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_fillcircle(coord_t x, coord_t y, coord_t radius, color_t color) {
+ void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
/* NOT IMPLEMENTED */
}
#endif
@@ -487,7 +474,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_drawellipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
/* NOT IMPLEMENTED */
}
#endif
@@ -505,7 +492,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_fillellipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
/* NOT IMPLEMENTED */
}
#endif
@@ -525,7 +512,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_drawchar(coord_t x, coord_t y, char c, font_t font, color_t color) {
+ void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) {
/* NOT IMPLEMENTED */
}
#endif
@@ -542,7 +529,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_fillchar(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) {
+ void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) {
/* NOT IMPLEMENTED */
}
#endif
@@ -557,7 +544,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- color_t gdisp_lld_getpixelcolor(coord_t x, coord_t y) {
+ color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) {
/* NOT IMPLEMENTED */
}
#endif
@@ -576,7 +563,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_verticalscroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
+ void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
/* NOT IMPLEMENTED */
}
#endif
@@ -601,7 +588,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_control(int what, void *value) {
+ void GDISP_LLD(control)(int what, void *value) {
/* NOT IMPLEMENTED YET */
switch(what) {
case GDISP_CONTROL_POWER:
@@ -615,7 +602,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
/* Code here */
/* You may need this ---
if (GDISP.Powermode != powerSleep)
- gdisp_lld_init();
+ GDISP_LLD(init();
*/
break;
case powerSleep:
@@ -665,5 +652,37 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
}
#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/halext/drivers/gdispNokia6610/gdisp_lld_board_example.h b/halext/drivers/gdispNokia6610/gdisp_lld_board_example.h
index 984e1aae..0e2b806e 100644
--- a/halext/drivers/gdispNokia6610/gdisp_lld_board_example.h
+++ b/halext/drivers/gdispNokia6610/gdisp_lld_board_example.h
@@ -39,7 +39,7 @@
*
* @notapi
*/
-static __inline void gdisp_lld_init_board(void) {
+static __inline void GDISP_LLD(init_board)(void) {
/* Code here */
}
@@ -50,7 +50,7 @@ static __inline void gdisp_lld_init_board(void) {
*
* @notapi
*/
-static __inline void gdisp_lld_setpin_reset(bool_t state) {
+static __inline void GDISP_LLD(setpin_reset)(bool_t state) {
/* Code here */
}
@@ -61,7 +61,7 @@ static __inline void gdisp_lld_setpin_reset(bool_t state) {
*
* @notapi
*/
-static __inline void gdisp_lld_setpin_backlight(bool_t state) {
+static __inline void GDISP_LLD(setpin_backlight)(bool_t state) {
/* Code here */
}
@@ -74,7 +74,7 @@ static __inline void gdisp_lld_setpin_backlight(bool_t state) {
*
* @notapi
*/
-static __inline void gdisp_lld_write_spi(uint16_t data) {
+static __inline void GDISP_LLD(write_spi)(uint16_t data) {
/* Code here */
}
@@ -88,7 +88,7 @@ static __inline void gdisp_lld_write_spi(uint16_t data) {
*
* @notapi
*/
-static __inline uint16_t gdisp_lld_read_spi(void) {
+static __inline uint16_t GDISP_LLD(read_spi)(void) {
/* Code here */
}
#endif
diff --git a/halext/drivers/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h b/halext/drivers/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h
index e2a8c1d7..b5b4b1d5 100644
--- a/halext/drivers/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h
+++ b/halext/drivers/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h
@@ -82,7 +82,7 @@ volatile AT91PS_PDC pPDC = AT91C_BASE_PDC_SPI0;
*
* @notapi
*/
-static __inline void gdisp_lld_init_board(void) {
+static __inline void GDISP_LLD(init_board)(void) {
// *********************************************************************************************
// InitSpi( )
//
@@ -142,7 +142,7 @@ static __inline void gdisp_lld_init_board(void) {
*
* @notapi
*/
-static __inline void gdisp_lld_setpin_reset(bool_t state) {
+static __inline void GDISP_LLD(setpin_reset)(bool_t state) {
if (state)
palClearPad(IOPORT1, PIOA_LCD_RESET);
// pPIOA->PIO_CODR = PIOA_LCD_RESET_MASK;
@@ -158,7 +158,7 @@ static __inline void gdisp_lld_setpin_reset(bool_t state) {
*
* @notapi
*/
-static __inline void gdisp_lld_setpin_backlight(bool_t state) {
+static __inline void GDISP_LLD(setpin_backlight)(bool_t state) {
if (state)
palSetPad(IOPORT2, PIOB_LCD_BL);
// pPIOB->PIO_SODR = PIOB_LCD_BL_MASK;
@@ -174,7 +174,7 @@ static __inline void gdisp_lld_setpin_backlight(bool_t state) {
*
* @notapi
*/
-static __inline void gdisp_lld_write_spi(uint16_t data) {
+static __inline void GDISP_LLD(write_spi)(uint16_t data) {
// wait for the previous transfer to complete
while((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0);
// send the data
@@ -189,7 +189,7 @@ static __inline void gdisp_lld_write_spi(uint16_t data) {
*
* @notapi
*/
-static __inline uint16_t gdisp_lld_read_spi(void) {
+static __inline uint16_t GDISP_LLD(read_spi)(void) {
#error "gdispNokia6610: GDISP_HARDWARE_READPIXEL and GDISP_HARDWARE_SCROLL are not supported on this board"
return 0;
}
diff --git a/halext/drivers/gdispNokia6610/gdisp_lld_config.h b/halext/drivers/gdispNokia6610/gdisp_lld_config.h
index fafda6c3..9e2d1258 100644
--- a/halext/drivers/gdispNokia6610/gdisp_lld_config.h
+++ b/halext/drivers/gdispNokia6610/gdisp_lld_config.h
@@ -35,6 +35,9 @@
/* Driver hardware support. */
/*===========================================================================*/
+#define GDISP_DRIVER_NAME "Nokia6610"
+#define GDISP_LLD(x) gdisp_lld_##x##_Nokia6610
+
#define GDISP_HARDWARE_LINES FALSE
#define GDISP_HARDWARE_CLEARS FALSE
#define GDISP_HARDWARE_FILLS TRUE
@@ -48,22 +51,15 @@
#define GDISP_HARDWARE_SCROLL FALSE
#define GDISP_HARDWARE_PIXELREAD FALSE
#define GDISP_HARDWARE_CONTROL FALSE
+#define GDISP_HARDWARE_QUERY FALSE
#define GDISP_SOFTWARE_TEXTFILLDRAW TRUE
#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE
-#define GDISP_PIXELFORMAT_RGB444
+#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB444
#define GDISP_PACKED_PIXELS FALSE
#define GDISP_PACKED_LINES FALSE
-/*===========================================================================*/
-/* Extra fields for the GDISPDriver structure */
-/*===========================================================================*/
-
-/*
-#define GDISP_DRIVER_EXT_FIELDS int abc; int def;
-*/
-
#endif /* HAL_USE_GDISP */
#endif /* _GDISP_LLD_CONFIG_H */
diff --git a/halext/drivers/gdispS6d1121/gdisp_lld.c b/halext/drivers/gdispS6d1121/gdisp_lld.c
index 4e83fc82..32e0fa32 100644
--- a/halext/drivers/gdispS6d1121/gdisp_lld.c
+++ b/halext/drivers/gdispS6d1121/gdisp_lld.c
@@ -32,27 +32,17 @@
#if HAL_USE_GDISP || defined(__DOXYGEN__)
+/* Include the emulation code for things we don't support */
+#include "gdisp_emulation.c"
+
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
-#ifdef UNUSED
-#elif defined(__GNUC__)
-# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
-#elif defined(__LCLINT__)
-# define UNUSED(x) /*@unused@*/ x
-#else
-# define UNUSED(x) x
-#endif
-
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
-#if !defined(__DOXYGEN__)
- GDISPDriver GDISP;
-#endif
-
/*===========================================================================*/
/* Driver local variables. */
/*===========================================================================*/
@@ -82,7 +72,7 @@
*
* @notapi
*/
-void gdisp_lld_init(void) {
+bool_t GDISP_LLD(init)(void) {
palSetPadMode(LCD_RST_GPIO, LCD_RST_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
// A Good idea to reset the module before using
LCD_RST_LOW;
@@ -208,6 +198,9 @@ void gdisp_lld_init(void) {
GDISP.Height = SCREEN_HEIGHT;
GDISP.Orientation = portrait;
GDISP.Powermode = powerOn;
+ GDISP.Backlight = 100;
+ GDISP.Contrast = 50;
+ return TRUE;
}
/**
@@ -219,7 +212,7 @@ void gdisp_lld_init(void) {
*
* @notapi
*/
-void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
+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
@@ -237,11 +230,11 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
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 gdisp_lld_fillarea() is defined there is little
- point in defining gdisp_lld_clear() unless the
+ eg. If fillarea() is defined there is little
+ point in defining clear() unless the
performance bonus is significant.
For good performance it is suggested to implement
- gdisp_lld_fillarea() and gdisp_lld_blitarea().
+ fillarea() and blitarea().
*/
#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__)
@@ -253,7 +246,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_clear(color_t color) {
+ void GDISP_LLD(clear)(color_t color) {
unsigned i;
lld_lcdSetCursor(0, 0);
@@ -277,7 +270,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_drawline(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
+ void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
#if GDISP_NEED_VALIDATION
/* Need to clip to screen */
#endif
@@ -296,7 +289,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_fillarea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
+ 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;
@@ -326,7 +319,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_blitarea(coord_t x, coord_t y, coord_t cx, coord_t cy, pixel_t *buffer) {
+ 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
@@ -359,7 +352,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_drawcircle(coord_t x, coord_t y, coord_t radius, color_t color) {
+ void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
#if GDISP_NEED_VALIDATION
/* Code here */
#endif
@@ -380,7 +373,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_fillcircle(coord_t x, coord_t y, coord_t radius, color_t color) {
+ void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
#if GDISP_NEED_VALIDATION
/* Code here */
#endif
@@ -401,7 +394,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_drawellipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
#if GDISP_NEED_VALIDATION
/* Code here */
#endif
@@ -422,7 +415,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_fillellipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
#if GDISP_NEED_VALIDATION
/* Code here */
#endif
@@ -445,7 +438,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_drawchar(coord_t x, coord_t y, char c, font_t font, color_t color) {
+ void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) {
#if GDISP_NEED_VALIDATION
/* Code here */
#endif
@@ -465,7 +458,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_fillchar(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) {
+ void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) {
#if GDISP_NEED_VALIDATION
/* Code here */
#endif
@@ -483,7 +476,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- color_t gdisp_lld_getpixelcolor(coord_t x, coord_t y) {
+ color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) {
/* This routine is marked "DO NOT USE" in the original
* GLCD driver. We just keep our GDISP_HARDWARE_READPIXEL
* turned off for now.
@@ -520,7 +513,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_verticalscroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
+ void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
/* This is marked as "TODO: Test this" in the original GLCD driver.
* For now we just leave the GDISP_HARDWARE_SCROLL off.
*/
@@ -568,7 +561,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines);
lld_lcdWriteStreamStart();
gap = cx*abslines;
- for(i = 0; i < gap; i++) lld_lcdWriteData(bgcolor);
+ for(i = 0; i < gap; i++) lld_lcdWriteData(color);
lld_lcdWriteStreamStop();
lld_lcdResetViewPort();
}
@@ -594,7 +587,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_control(int what, void *value) {
+ void GDISP_LLD(control)(unsigned what, void *value) {
switch(what) {
case GDISP_CONTROL_POWER:
if (GDISP.Powermode == (gdisp_powermode_t)value)
@@ -607,7 +600,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
/* Code here */
/* You may need this ---
if (GDISP.Powermode != powerSleep)
- gdisp_lld_init();
+ GDISP_LLD(init();
*/
/* break; */
case powerSleep:
@@ -659,5 +652,37 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
}
#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/halext/drivers/gdispS6d1121/gdisp_lld_config.h b/halext/drivers/gdispS6d1121/gdisp_lld_config.h
index 9e01b901..57aaf692 100644
--- a/halext/drivers/gdispS6d1121/gdisp_lld_config.h
+++ b/halext/drivers/gdispS6d1121/gdisp_lld_config.h
@@ -29,12 +29,15 @@
#ifndef _GDISP_LLD_CONFIG_H
#define _GDISP_LLD_CONFIG_H
-#if HAL_USE_GDISP || defined(__DOXYGEN__)
+#if HAL_USE_GDISP
/*===========================================================================*/
/* Driver hardware support. */
/*===========================================================================*/
+#define GDISP_DRIVER_NAME "S6d1121"
+#define GDISP_LLD(x) gdisp_lld_##x##_S6d1121
+
#define GDISP_HARDWARE_LINES FALSE
#define GDISP_HARDWARE_CLEARS TRUE
#define GDISP_HARDWARE_FILLS TRUE
@@ -45,25 +48,18 @@
#define GDISP_HARDWARE_ELLIPSEFILLS FALSE
#define GDISP_HARDWARE_TEXT FALSE
#define GDISP_HARDWARE_TEXTFILLS FALSE
-#define GDISP_HARDWARE_SCROLL TRUE
+#define GDISP_HARDWARE_SCROLL FALSE
#define GDISP_HARDWARE_PIXELREAD FALSE
#define GDISP_HARDWARE_CONTROL TRUE
+#define GDISP_HARDWARE_QUERY FALSE
#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE
#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE
-#define GDISP_PIXELFORMAT_RGB565
+#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
#define GDISP_PACKED_PIXELS FALSE
#define GDISP_PACKED_LINES FALSE
-/*===========================================================================*/
-/* Extra fields for the GDISPDriver structure */
-/*===========================================================================*/
-
-/*
-#define GDISP_DRIVER_EXT_FIELDS int abc; int def;
-*/
-
#endif /* HAL_USE_GDISP */
#endif /* _GDISP_LLD_CONFIG_H */
diff --git a/halext/drivers/gdispSsd1289/gdisp_lld.c b/halext/drivers/gdispSsd1289/gdisp_lld.c
index f5c94bf1..7dfb83a7 100644
--- a/halext/drivers/gdispSsd1289/gdisp_lld.c
+++ b/halext/drivers/gdispSsd1289/gdisp_lld.c
@@ -32,27 +32,17 @@
#if HAL_USE_GDISP || defined(__DOXYGEN__)
+/* Include the emulation code for things we don't support */
+#include "gdisp_emulation.c"
+
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
-#ifdef UNUSED
-#elif defined(__GNUC__)
-# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
-#elif defined(__LCLINT__)
-# define UNUSED(x) /*@unused@*/ x
-#else
-# define UNUSED(x) x
-#endif
-
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
-#if !defined(__DOXYGEN__)
- GDISPDriver GDISP;
-#endif
-
/*===========================================================================*/
/* Driver local variables. */
/*===========================================================================*/
@@ -82,7 +72,7 @@
*
* @notapi
*/
-void gdisp_lld_init(void) {
+bool_t GDISP_LLD(init)(void) {
uint16_t deviceCode;
#ifdef LCD_USE_FSMC
@@ -153,6 +143,9 @@ void gdisp_lld_init(void) {
GDISP.Height = SCREEN_HEIGHT;
GDISP.Orientation = portrait;
GDISP.Powermode = powerOn;
+ GDISP.Backlight = 100;
+ GDISP.Contrast = 50;
+ return TRUE;
}
/**
@@ -164,7 +157,7 @@ void gdisp_lld_init(void) {
*
* @notapi
*/
-void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
+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
@@ -182,11 +175,11 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
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 gdisp_lld_fillarea() is defined there is little
- point in defining gdisp_lld_clear() unless the
+ 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
- gdisp_lld_fillarea() and gdisp_lld_blitarea().
+ fillarea() and blitarea().
*/
#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__)
@@ -198,7 +191,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_clear(color_t color) {
+ void GDISP_LLD(clear)(color_t color) {
unsigned i;
lld_lcdSetCursor(0, 0);
@@ -222,7 +215,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_drawline(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
+ void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
/* NOT IMPLEMENTED */
}
#endif
@@ -238,7 +231,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_fillarea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
+ 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;
@@ -268,7 +261,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_blitarea(coord_t x, coord_t y, coord_t cx, coord_t cy, pixel_t *buffer) {
+ 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
@@ -301,7 +294,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_drawcircle(coord_t x, coord_t y, coord_t radius, color_t color) {
+ void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
/* NOT IMPLEMENTED */
}
#endif
@@ -319,7 +312,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_fillcircle(coord_t x, coord_t y, coord_t radius, color_t color) {
+ void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
/* NOT IMPLEMENTED */
}
#endif
@@ -337,7 +330,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_drawellipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
/* NOT IMPLEMENTED */
}
#endif
@@ -355,7 +348,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_fillellipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
/* NOT IMPLEMENTED */
}
#endif
@@ -375,7 +368,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_drawchar(coord_t x, coord_t y, char c, font_t font, color_t color) {
+ void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) {
/* NOT IMPLEMENTED */
}
#endif
@@ -392,7 +385,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_fillchar(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) {
+ void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) {
/* NOT IMPLEMENTED */
}
#endif
@@ -407,7 +400,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- color_t gdisp_lld_getpixelcolor(coord_t x, coord_t y) {
+ color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) {
color_t color;
#if GDISP_NEED_VALIDATION
@@ -440,7 +433,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_verticalscroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
+ 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;
@@ -511,7 +504,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- void gdisp_lld_control(int what, void *value) {
+ void GDISP_LLD(control)(unsigned what, void *value) {
switch(what) {
case GDISP_CONTROL_POWER:
if (GDISP.Powermode == (gdisp_powermode_t)value)
@@ -526,7 +519,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
case powerOn:
lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode
if (GDISP.Powermode != powerSleep)
- gdisp_lld_init();
+ GDISP_LLD(init)();
break;
case powerSleep:
lld_lcdWriteReg(0x0010, 0x0001); // enter sleep mode
@@ -581,5 +574,37 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
}
#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/halext/drivers/gdispSsd1289/gdisp_lld_config.h b/halext/drivers/gdispSsd1289/gdisp_lld_config.h
index 60be3017..123ce875 100644
--- a/halext/drivers/gdispSsd1289/gdisp_lld_config.h
+++ b/halext/drivers/gdispSsd1289/gdisp_lld_config.h
@@ -29,12 +29,15 @@
#ifndef _GDISP_LLD_CONFIG_H
#define _GDISP_LLD_CONFIG_H
-#if HAL_USE_GDISP || defined(__DOXYGEN__)
+#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
@@ -48,22 +51,15 @@
#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_RGB565
+#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
#define GDISP_PACKED_PIXELS FALSE
#define GDISP_PACKED_LINES FALSE
-/*===========================================================================*/
-/* Extra fields for the GDISPDriver structure */
-/*===========================================================================*/
-
-/*
-#define GDISP_DRIVER_EXT_FIELDS int abc; int def;
-*/
-
#endif /* HAL_USE_GDISP */
#endif /* _GDISP_LLD_CONFIG_H */
diff --git a/halext/drivers/gdispTestStub/gdisp_lld.c b/halext/drivers/gdispTestStub/gdisp_lld.c
index 44431e30..fd8410fb 100644
--- a/halext/drivers/gdispTestStub/gdisp_lld.c
+++ b/halext/drivers/gdispTestStub/gdisp_lld.c
@@ -32,27 +32,17 @@
#if HAL_USE_GDISP || defined(__DOXYGEN__)
+/* Include the emulation code for things we don't support */
+#include "gdisp_emulation.c"
+
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
-#ifdef UNUSED
-#elif defined(__GNUC__)
-# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
-#elif defined(__LCLINT__)
-# define UNUSED(x) /*@unused@*/ x
-#else
-# define UNUSED(x) x
-#endif
-
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
-#if !defined(__DOXYGEN__)
- GDISPDriver GDISP;
-#endif
-
/*===========================================================================*/
/* Driver local variables. */
/*===========================================================================*/
@@ -80,12 +70,15 @@
*
* @notapi
*/
-void gdisp_lld_init(void) {
+bool_t GDISP_LLD(init)(void) {
/* Initialise the GDISP structure */
GDISP.Width = 128;
GDISP.Height = 128;
GDISP.Orientation = portrait;
GDISP.Powermode = powerOff;
+ GDISP.Backlight = 100;
+ GDISP.Contrast = 50;
+ return TRUE;
}
/**
@@ -97,7 +90,7 @@ void gdisp_lld_init(void) {
*
* @notapi
*/
-void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(color)) {
+void GDISP_LLD(drawpixel)(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(color)) {
}
/* ---- Optional Routines ---- */
@@ -110,11 +103,11 @@ void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(co
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 gdisp_lld_fillarea() is defined there is little
- point in defining gdisp_lld_clear() unless the
+ eg. If fillarea() is defined there is little
+ point in defining clear() unless the
performance bonus is significant.
For good performance it is suggested to implement
- gdisp_lld_fillarea() and gdisp_lld_blitarea().
+ fillarea() and blitarea().
*/
#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__)
@@ -126,7 +119,7 @@ void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(co
*
* @notapi
*/
- void gdisp_lld_clear(color_t UNUSED(color)) {
+ void GDISP_LLD(clear)(color_t UNUSED(color)) {
}
#endif
@@ -141,7 +134,7 @@ void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(co
*
* @notapi
*/
- void gdisp_lld_drawline(coord_t UNUSED(x0), coord_t UNUSED(y0), coord_t UNUSED(x1), coord_t UNUSED(y1), color_t UNUSED(color)) {
+ void GDISP_LLD(drawline)(coord_t UNUSED(x0), coord_t UNUSED(y0), coord_t UNUSED(x1), coord_t UNUSED(y1), color_t UNUSED(color)) {
}
#endif
@@ -156,7 +149,7 @@ void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(co
*
* @notapi
*/
- void gdisp_lld_fillarea(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), color_t UNUSED(color)) {
+ void GDISP_LLD(fillarea)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), color_t UNUSED(color)) {
}
#endif
@@ -171,7 +164,7 @@ void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(co
*
* @notapi
*/
- void gdisp_lld_blitarea(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), pixel_t *UNUSED(buffer)) {
+ void GDISP_LLD(blitarea)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), const pixel_t *UNUSED(buffer)) {
}
#endif
@@ -189,7 +182,7 @@ void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(co
*
* @notapi
*/
- void gdisp_lld_drawcircle(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) {
+ void GDISP_LLD(drawcircle)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) {
}
#endif
@@ -206,7 +199,7 @@ void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(co
*
* @notapi
*/
- void gdisp_lld_fillcircle(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) {
+ void GDISP_LLD(fillcircle)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) {
}
#endif
@@ -223,7 +216,7 @@ void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(co
*
* @notapi
*/
- void gdisp_lld_drawellipse(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) {
+ void GDISP_LLD(drawellipse)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) {
}
#endif
@@ -240,7 +233,7 @@ void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(co
*
* @notapi
*/
- void gdisp_lld_fillellipse(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) {
+ void GDISP_LLD(fillellipse)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) {
}
#endif
@@ -255,7 +248,7 @@ void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(co
*
* @notapi
*/
- void gdisp_lld_drawchar(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color)) {
+ void GDISP_LLD(drawchar)(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color)) {
}
#endif
@@ -271,7 +264,7 @@ void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(co
*
* @notapi
*/
- void gdisp_lld_fillchar(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color), color_t UNUSED(bgcolor)) {
+ void GDISP_LLD(fillchar)(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color), color_t UNUSED(bgcolor)) {
}
#endif
@@ -285,7 +278,7 @@ void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(co
*
* @notapi
*/
- color_t gdisp_lld_getpixelcolor(coord_t UNUSED(x), coord_t UNUSED(y)) {
+ color_t GDISP_LLD(getpixelcolor)(coord_t UNUSED(x), coord_t UNUSED(y)) {
return 0;
}
#endif
@@ -304,7 +297,7 @@ void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(co
*
* @notapi
*/
- void gdisp_lld_verticalscroll(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), int UNUSED(lines), color_t UNUSED(bgcolor)) {
+ void GDISP_LLD(verticalscroll)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), int UNUSED(lines), color_t UNUSED(bgcolor)) {
}
#endif
@@ -328,8 +321,40 @@ void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(co
*
* @notapi
*/
- void gdisp_lld_control(int UNUSED(what), void *UNUSED(value)) {
+ void GDISP_LLD(control)(unsigned UNUSED(what), void *UNUSED(value)) {
+ }
+#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/halext/drivers/gdispTestStub/gdisp_lld_config.h b/halext/drivers/gdispTestStub/gdisp_lld_config.h
index f58ca878..d66e050f 100644
--- a/halext/drivers/gdispTestStub/gdisp_lld_config.h
+++ b/halext/drivers/gdispTestStub/gdisp_lld_config.h
@@ -29,12 +29,15 @@
#ifndef _GDISP_LLD_CONFIG_H
#define _GDISP_LLD_CONFIG_H
-#if HAL_USE_GDISP || defined(__DOXYGEN__)
+#if HAL_USE_GDISP
/*===========================================================================*/
/* Driver hardware support. */
/*===========================================================================*/
+#define GDISP_DRIVER_NAME "TestStub"
+#define GDISP_LLD(x) gdisp_lld_##x##_TestStub
+
#define GDISP_HARDWARE_LINES FALSE
#define GDISP_HARDWARE_CLEARS FALSE
#define GDISP_HARDWARE_FILLS FALSE
@@ -45,25 +48,18 @@
#define GDISP_HARDWARE_ELLIPSEFILLS FALSE
#define GDISP_HARDWARE_TEXT FALSE
#define GDISP_HARDWARE_TEXTFILLS FALSE
-#define GDISP_HARDWARE_SCROLL FALSE
-#define GDISP_HARDWARE_PIXELREAD FALSE
+#define GDISP_HARDWARE_SCROLL GDISP_NEED_SCROLL
+#define GDISP_HARDWARE_PIXELREAD GDISP_NEED_PIXELREAD
#define GDISP_HARDWARE_CONTROL FALSE
+#define GDISP_HARDWARE_QUERY FALSE
#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE
#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE
-#define GDISP_PIXELFORMAT_RGB565
+#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
#define GDISP_PACKED_PIXELS FALSE
#define GDISP_PACKED_LINES FALSE
-/*===========================================================================*/
-/* Extra fields for the GDISPDriver structure */
-/*===========================================================================*/
-
-/*
-#define GDISP_DRIVER_EXT_FIELDS int abc; int def;
-*/
-
#endif /* HAL_USE_GDISP */
#endif /* _GDISP_LLD_CONFIG_H */
diff --git a/halext/drivers/gdispVMT/gdisp_lld.c b/halext/drivers/gdispVMT/gdisp_lld.c
new file mode 100644
index 00000000..1528f470
--- /dev/null
+++ b/halext/drivers/gdispVMT/gdisp_lld.c
@@ -0,0 +1,249 @@
+/*
+ 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 gdispVMT/gdisp_lld.c
+ * @brief GDISP Graphics Driver subsystem low level driver source for VMT.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+#include "gdisp.h"
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+#define GDISP_LLD_NO_STRUCT
+
+/* Include the emulation code for things we don't support */
+#include "gdisp_emulation.c"
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+#define GDISP_LLD1(x) GDISP_VMT_NAME1(gdisp_lld_##x##_)
+#define GDISP_LLD2(x) GDISP_VMT_NAME2(gdisp_lld_##x##_)
+
+/* Prototypes for lld driver functions */
+bool_t GDISP_LLD1(init)(void);
+void GDISP_LLD1(clear)(color_t color);
+void GDISP_LLD1(drawpixel)(coord_t x, coord_t y, color_t color);
+void GDISP_LLD1(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
+void GDISP_LLD1(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer);
+void GDISP_LLD1(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color);
+#if GDISP_NEED_CIRCLE
+ void GDISP_LLD1(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color);
+ void GDISP_LLD1(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color);
+#endif
+#if GDISP_NEED_ELLIPSE
+ void GDISP_LLD1(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+ void GDISP_LLD1(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+#endif
+#if GDISP_NEED_TEXT
+ void GDISP_LLD1(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color);
+ void GDISP_LLD1(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor);
+#endif
+#if GDISP_NEED_PIXELREAD
+ color_t GDISP_LLD1(getpixelcolor)(coord_t x, coord_t y);
+#endif
+#if GDISP_NEED_SCROLL
+ void GDISP_LLD1(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor);
+#endif
+#if GDISP_NEED_CONTROL
+ void GDISP_LLD1(control)(unsigned what, void *value);
+#endif
+#if GDISP_NEED_QUERY
+ void *GDISP_LLD1(query)(unsigned what);
+#endif
+
+bool_t GDISP_LLD2(init)(void);
+void GDISP_LLD2(clear)(color_t color);
+void GDISP_LLD2(drawpixel)(coord_t x, coord_t y, color_t color);
+void GDISP_LLD2(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
+void GDISP_LLD2(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer);
+void GDISP_LLD2(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color);
+#if GDISP_NEED_CIRCLE
+ void GDISP_LLD2(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color);
+ void GDISP_LLD2(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color);
+#endif
+#if GDISP_NEED_ELLIPSE
+ void GDISP_LLD2(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+ void GDISP_LLD2(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+#endif
+#if GDISP_NEED_TEXT
+ void GDISP_LLD2(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color);
+ void GDISP_LLD2(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor);
+#endif
+#if GDISP_NEED_PIXELREAD
+ color_t GDISP_LLD2(getpixelcolor)(coord_t x, coord_t y);
+#endif
+#if GDISP_NEED_SCROLL
+ void GDISP_LLD2(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor);
+#endif
+#if GDISP_NEED_CONTROL
+ void GDISP_LLD2(control)(unsigned what, void *value);
+#endif
+#if GDISP_NEED_QUERY
+ void *GDISP_LLD2(query)(unsigned what);
+#endif
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/* Our VMT table variables */
+void GDISP_LLD_VMT(clear)(color_t color);
+void GDISP_LLD_VMT(drawpixel)(coord_t x, coord_t y, color_t color);
+void GDISP_LLD_VMT(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
+void GDISP_LLD_VMT(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer);
+void GDISP_LLD_VMT(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color);
+
+#if GDISP_NEED_CIRCLE
+void GDISP_LLD_VMT(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color);
+void GDISP_LLD_VMT(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color);
+#endif
+
+#if GDISP_NEED_ELLIPSE
+void GDISP_LLD_VMT(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+void GDISP_LLD_VMT(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+#endif
+
+/* Text Rendering Functions */
+#if GDISP_NEED_TEXT
+void GDISP_LLD_VMT(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color);
+void GDISP_LLD_VMT(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor);
+#endif
+
+/* Pixel readback */
+#if GDISP_NEED_PIXELREAD
+color_t GDISP_LLD_VMT(getpixelcolor)(coord_t x, coord_t y);
+#endif
+
+/* Scrolling Function - clears the area scrolled out */
+#if GDISP_NEED_SCROLL
+void GDISP_LLD_VMT(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor);
+#endif
+
+/* Set driver specific control */
+#if GDISP_NEED_CONTROL
+void GDISP_LLD_VMT(control)(unsigned what, void *value);
+#endif
+/* Set driver specific control */
+#if GDISP_NEED_QUERY
+void *GDISP_LLD_VMT(query)(unsigned what);
+#endif
+
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+bool_t gdisp_lld_init_VMT(void) {
+ if (GDISP_VMT_NAME1(gdisp_lld_init_)()) {
+ gdisp_lld_clear_VMT = GDISP_VMT_NAME1(gdisp_lld_clear_);
+ gdisp_lld_drawpixel_VMT = GDISP_VMT_NAME1(gdisp_lld_drawpixel_);
+ gdisp_lld_fillarea_VMT = GDISP_VMT_NAME1(gdisp_lld_fillarea_);
+ gdisp_lld_blitarea_VMT = GDISP_VMT_NAME1(gdisp_lld_blitarea_);
+ gdisp_lld_drawline_VMT = GDISP_VMT_NAME1(gdisp_lld_drawline_);
+ #if GDISP_NEED_CIRCLE
+ gdisp_lld_drawcircle_VMT = GDISP_VMT_NAME1(gdisp_lld_drawcircle_);
+ gdisp_lld_fillcircle_VMT = GDISP_VMT_NAME1(gdisp_lld_fillcircle_);
+ #endif
+ #if GDISP_NEED_ELLIPSE
+ gdisp_lld_drawellipse_VMT = GDISP_VMT_NAME1(gdisp_lld_drawellipse_);
+ gdisp_lld_fillellipse_VMT = GDISP_VMT_NAME1(gdisp_lld_fillellipse_);
+ #endif
+ #if GDISP_NEED_TEXT
+ gdisp_lld_drawchar_VMT = GDISP_VMT_NAME1(gdisp_lld_drawchar_);
+ gdisp_lld_fillchar_VMT = GDISP_VMT_NAME1(gdisp_lld_fillchar_);
+ #endif
+ #if GDISP_NEED_PIXELREAD
+ gdisp_lld_getpixelcolor_VMT = GDISP_VMT_NAME1(gdisp_lld_pixelread_);
+ #endif
+ #if GDISP_NEED_SCROLL
+ gdisp_lld_verticalscroll_VMT = GDISP_VMT_NAME1(gdisp_lld_scroll_);
+ #endif
+ #if GDISP_NEED_CONTROL
+ gdisp_lld_control_VMT = GDISP_VMT_NAME1(gdisp_lld_control_);
+ #endif
+ #if GDISP_NEED_QUERY
+ gdisp_lld_query_VMT = GDISP_VMT_NAME1(gdisp_lld_query_);
+ #endif
+
+ return TRUE;
+ }
+
+ if (GDISP_VMT_NAME2(gdisp_lld_init_)()) {
+ gdisp_lld_clear_VMT = GDISP_VMT_NAME2(gdisp_lld_clear_);
+ gdisp_lld_drawpixel_VMT = GDISP_VMT_NAME2(gdisp_lld_drawpixel_);
+ gdisp_lld_fillarea_VMT = GDISP_VMT_NAME2(gdisp_lld_fillarea_);
+ gdisp_lld_blitarea_VMT = GDISP_VMT_NAME2(gdisp_lld_blitarea_);
+ gdisp_lld_drawline_VMT = GDISP_VMT_NAME2(gdisp_lld_drawline_);
+ #if GDISP_NEED_CIRCLE
+ gdisp_lld_drawcircle_VMT = GDISP_VMT_NAME2(gdisp_lld_drawcircle_);
+ gdisp_lld_fillcircle_VMT = GDISP_VMT_NAME2(gdisp_lld_fillcircle_);
+ #endif
+ #if GDISP_NEED_ELLIPSE
+ gdisp_lld_drawellipse_VMT = GDISP_VMT_NAME2(gdisp_lld_drawellipse_);
+ gdisp_lld_fillellipse_VMT = GDISP_VMT_NAME2(gdisp_lld_fillellipse_);
+ #endif
+ #if GDISP_NEED_TEXT
+ gdisp_lld_drawchar_VMT = GDISP_VMT_NAME2(gdisp_lld_drawchar_);
+ gdisp_lld_fillchar_VMT = GDISP_VMT_NAME2(gdisp_lld_fillchar_);
+ #endif
+ #if GDISP_NEED_PIXELREAD
+ gdisp_lld_getpixelcolor_VMT = GDISP_VMT_NAME2(gdisp_lld_pixelread_);
+ #endif
+ #if GDISP_NEED_SCROLL
+ gdisp_lld_verticalscroll_VMT = GDISP_VMT_NAME2(gdisp_lld_scroll_);
+ #endif
+ #if GDISP_NEED_CONTROL
+ gdisp_lld_control_VMT = GDISP_VMT_NAME2(gdisp_lld_control_);
+ #endif
+ #if GDISP_NEED_QUERY
+ gdisp_lld_query_VMT = GDISP_VMT_NAME2(gdisp_lld_query_);
+ #endif
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+#endif /* HAL_USE_GDISP */
+/** @} */
diff --git a/halext/drivers/gdispVMT/gdisp_lld.mk b/halext/drivers/gdispVMT/gdisp_lld.mk
new file mode 100644
index 00000000..ab935370
--- /dev/null
+++ b/halext/drivers/gdispVMT/gdisp_lld.mk
@@ -0,0 +1,7 @@
+# List the required driver.
+HALSRC += ${CHIBIOS}/os/halext/drivers/gdispVMT/gdisp_lld.c \
+ ${CHIBIOS}/os/halext/drivers/gdispVMT/gdisp_lld_driver1.c \
+ ${CHIBIOS}/os/halext/drivers/gdispVMT/gdisp_lld_driver2.c
+
+# Required include directories
+HALINC += ${CHIBIOS}/os/halext/drivers/gdispVMT
diff --git a/halext/drivers/gdispVMT/gdisp_lld_config.h b/halext/drivers/gdispVMT/gdisp_lld_config.h
new file mode 100644
index 00000000..6c6f7c80
--- /dev/null
+++ b/halext/drivers/gdispVMT/gdisp_lld_config.h
@@ -0,0 +1,67 @@
+/*
+ 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 gdispVMT/gdisp_lld_config.h
+ * @brief GDISP Graphic Driver subsystem low level driver header template.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#ifndef _GDISP_LLD_CONFIG_H
+#define _GDISP_LLD_CONFIG_H
+
+#if HAL_USE_GDISP
+
+/*===========================================================================*/
+/* Driver hardware support. */
+/*===========================================================================*/
+
+#define GDISP_DRIVER_NAME "VMT"
+#define GDISP_LLD(x) gdisp_lld_##x##_VMT
+#define GDISP_LLD_VMT(x) (*GDISP_LLD(x))
+
+#define GDISP_HARDWARE_LINES TRUE
+#define GDISP_HARDWARE_CLEARS TRUE
+#define GDISP_HARDWARE_FILLS TRUE
+#define GDISP_HARDWARE_BITFILLS TRUE
+#define GDISP_HARDWARE_CIRCLES TRUE
+#define GDISP_HARDWARE_CIRCLEFILLS TRUE
+#define GDISP_HARDWARE_ELLIPSES TRUE
+#define GDISP_HARDWARE_ELLIPSEFILLS TRUE
+#define GDISP_HARDWARE_TEXT TRUE
+#define GDISP_HARDWARE_TEXTFILLS TRUE
+#define GDISP_HARDWARE_SCROLL TRUE
+#define GDISP_HARDWARE_PIXELREAD TRUE
+#define GDISP_HARDWARE_CONTROL TRUE
+#define GDISP_HARDWARE_QUERY TRUE
+
+#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/halext/drivers/gdispVMT/gdisp_lld_driver1.c b/halext/drivers/gdispVMT/gdisp_lld_driver1.c
new file mode 100644
index 00000000..f088623e
--- /dev/null
+++ b/halext/drivers/gdispVMT/gdisp_lld_driver1.c
@@ -0,0 +1,51 @@
+/*
+ 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 gdispVMT/gdisp_lld.c
+ * @brief GDISP Graphics Driver subsystem low level driver source for VMT.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+#define CONFIGFILE() <../GDISP_VMT_NAME1(gdisp)/gdisp_lld_config.h>
+#define DRIVERFILE() <../GDISP_VMT_NAME1(gdisp)/gdisp_lld.c>
+
+/* We don't need these in our VMT referenced driver */
+#undef GDISP_NEED_MSGAPI
+#define GDISP_NEED_MSGAPI FALSE
+
+/* Include the specific config file we want */
+#include CONFIGFILE()
+
+/* Bring in our API */
+#include "gdisp.h"
+
+/* Add the low level driver */
+#include DRIVERFILE()
+
+#endif /* HAL_USE_GDISP */
+/** @} */
diff --git a/halext/drivers/gdispVMT/gdisp_lld_driver2.c b/halext/drivers/gdispVMT/gdisp_lld_driver2.c
new file mode 100644
index 00000000..325a53e6
--- /dev/null
+++ b/halext/drivers/gdispVMT/gdisp_lld_driver2.c
@@ -0,0 +1,51 @@
+/*
+ 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 gdispVMT/gdisp_lld.c
+ * @brief GDISP Graphics Driver subsystem low level driver source for VMT.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+#define CONFIGFILE() <../GDISP_VMT_NAME2(gdisp)/gdisp_lld_config.h>
+#define DRIVERFILE() <../GDISP_VMT_NAME2(gdisp)/gdisp_lld.c>
+
+/* We don't need these in our VMT referenced driver */
+#undef GDISP_NEED_MSGAPI
+#define GDISP_NEED_MSGAPI FALSE
+
+/* Include the specific config file we want */
+#include CONFIGFILE()
+
+/* Bring in our API */
+#include "gdisp.h"
+
+/* Add the low level driver */
+#include DRIVERFILE()
+
+#endif /* HAL_USE_GDISP */
+/** @} */
diff --git a/halext/drivers/gdispVMT/readme.txt b/halext/drivers/gdispVMT/readme.txt
new file mode 100644
index 00000000..91d3f58c
--- /dev/null
+++ b/halext/drivers/gdispVMT/readme.txt
@@ -0,0 +1,23 @@
+This driver enables you to have two underlying drivers handling different hardware.
+A choice is made at run-time of which driver to call based on which driver succeeds
+to initialise first (init returns TRUE).
+
+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) Define these:
+ #define GDISP_VMT_NAME1(x) x##YourDriver1
+ #define GDISP_VMT_NAME2(x) x##YourDriver2
+ Note YourDriver1 & 2 are the basenames of the directories containing the driver.
+ Note that both drivers must be the same pixel format which is
+ GDISP_PIXELFORMAT_RGB565 by default. Alter gdispVMT/gdisp_lld_config.h if your
+ pixel format is different on both drivers.
+ d) Any driver specific defines. If both drivers use the same defines then they must
+ accept the same values for the define.
+
+2. To your makefile add the following lines:
+ include $(CHIBIOS)/os/halext/halext.mk
+ include $(CHIBIOS)/os/halext/drivers/gdispVMT/gdisp_lld.mk
+ \ No newline at end of file