diff options
Diffstat (limited to 'drivers/gdisp/SSD1289')
-rw-r--r-- | drivers/gdisp/SSD1289/gdisp_lld.c | 370 | ||||
-rw-r--r-- | drivers/gdisp/SSD1289/gdisp_lld_board_example.h | 125 | ||||
-rw-r--r-- | drivers/gdisp/SSD1289/gdisp_lld_board_example_fsmc.h | 164 | ||||
-rw-r--r-- | drivers/gdisp/SSD1289/gdisp_lld_board_firebullstm32f103.h | 150 | ||||
-rw-r--r-- | drivers/gdisp/SSD1289/readme.txt | 12 | ||||
-rw-r--r-- | drivers/gdisp/SSD1289/ssd1289_lld.c.h | 327 |
6 files changed, 669 insertions, 479 deletions
diff --git a/drivers/gdisp/SSD1289/gdisp_lld.c b/drivers/gdisp/SSD1289/gdisp_lld.c index 3568a6f1..ff1abc19 100644 --- a/drivers/gdisp/SSD1289/gdisp_lld.c +++ b/drivers/gdisp/SSD1289/gdisp_lld.c @@ -35,7 +35,101 @@ /* Include the emulation code for things we don't support */
#include "gdisp_emulation.c"
-#include "ssd1289_lld.c.h"
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+#ifndef GDISP_SCREEN_HEIGHT
+ #define GDISP_SCREEN_HEIGHT 240
+#endif
+#ifndef GDISP_SCREEN_WIDTH
+ #define GDISP_SCREEN_WIDTH 320
+#endif
+
+#define GDISP_INITIAL_CONTRAST 50
+#define GDISP_INITIAL_BACKLIGHT 100
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+#if defined(BOARD_FIREBULL_STM32_F103)
+ #include "gdisp_lld_board_firebullstm32f103.h"
+#else
+ /* Include the user supplied board definitions */
+ #include "gdisp_lld_board.h"
+#endif
+
+// Some common routines and macros
+#define write_reg(reg, data) { write_index(reg); write_data(data); }
+#define stream_start() write_reg(0x0022);
+#define stream_stop()
+#define delay(us) chThdSleepMicroseconds(us)
+#define delayms(ms) chThdSleepMilliseconds(ms)
+
+static __inline void set_cursor(coord_t x, coord_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 GDISP_ROTATE_180:
+ write_reg(0x004e, (GDISP_SCREEN_WIDTH-1-x) & 0x00FF);
+ write_reg(0x004f, (GDISP_SCREEN_HEIGHT-1-y) & 0x01FF);
+ break;
+ case GDISP_ROTATE_0:
+ write_reg(0x004e, x & 0x00FF);
+ write_reg(0x004f, y & 0x01FF);
+ break;
+ case GDISP_ROTATE_270:
+ write_reg(0x004e, y & 0x00FF);
+ write_reg(0x004f, x & 0x01FF);
+ break;
+ case GDISP_ROTATE_90:
+ write_reg(0x004e, (GDISP_SCREEN_WIDTH - y - 1) & 0x00FF);
+ write_reg(0x004f, (GDISP_SCREEN_HEIGHT - x - 1) & 0x01FF);
+ break;
+ }
+}
+
+static __inline void set_viewport(coord_t x, coord_t y, coord_t cx, coord_t cy) {
+
+ set_cursor(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 GDISP_ROTATE_0:
+ write_reg(0x44, (((x+cx-1) << 8) & 0xFF00 ) | (x & 0x00FF));
+ write_reg(0x45, y & 0x01FF);
+ write_reg(0x46, (y+cy-1) & 0x01FF);
+ break;
+ case GDISP_ROTATE_270:
+ write_reg(0x44, (((x+cx-1) << 8) & 0xFF00 ) | (y & 0x00FF));
+ write_reg(0x45, x & 0x01FF);
+ write_reg(0x46, (x+cx-1) & 0x01FF);
+ break;
+ case GDISP_ROTATE_180:
+ write_reg(0x44, (((GDISP_SCREEN_WIDTH-x-1) & 0x00FF) << 8) | ((GDISP_SCREEN_WIDTH - (x+cx)) & 0x00FF));
+ write_reg(0x45, (GDISP_SCREEN_HEIGHT-(y+cy)) & 0x01FF);
+ write_reg(0x46, (GDISP_SCREEN_HEIGHT-y-1) & 0x01FF);
+ break;
+ case GDISP_ROTATE_90:
+ write_reg(0x44, (((GDISP_SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | ((GDISP_SCREEN_WIDTH - (y+cy)) & 0x00FF));
+ write_reg(0x45, (GDISP_SCREEN_HEIGHT - (x+cx)) & 0x01FF);
+ write_reg(0x46, (GDISP_SCREEN_HEIGHT - x - 1) & 0x01FF);
+ break;
+ }
+
+ set_cursor(x, y);
+}
/*===========================================================================*/
/* Driver interrupt handlers. */
@@ -57,98 +151,73 @@ * @notapi
*/
bool_t GDISP_LLD(init)(void) {
-#if defined(GDISP_USE_FSMC)
-
- #if defined(STM32F1XX) || defined(STM32F3XX)
- /* FSMC setup for F1/F3 */
- rccEnableAHB(RCC_AHBENR_FSMCEN, 0);
-
- #if defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM)
- #error "DMA not implemented for F1/F3 Devices"
- #endif
- #elif defined(STM32F4XX) || defined(STM32F2XX)
- /* STM32F2-F4 FSMC init */
- rccEnableAHB3(RCC_AHB3ENR_FSMCEN, 0);
-
- #if defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM)
- if (dmaStreamAllocate(GDISP_DMA_STREAM, 0, NULL, NULL)) chSysHalt();
- dmaStreamSetMemory0(GDISP_DMA_STREAM, &GDISP_RAM);
- dmaStreamSetMode(GDISP_DMA_STREAM, STM32_DMA_CR_PL(0) | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M);
- #endif
- #else
- #error "FSMC not implemented for this device"
- #endif
-
- /* set pins to FSMC mode */
- IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8) |
- (1 << 9) | (1 << 10) | (1 << 11) | (1 << 14) | (1 << 15), 0};
-
- IOBus busE = {GPIOE, (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12) |
- (1 << 13) | (1 << 14) | (1 << 15), 0};
-
- palSetBusMode(&busD, PAL_MODE_ALTERNATE(12));
- palSetBusMode(&busE, PAL_MODE_ALTERNATE(12));
-
- const unsigned char FSMC_Bank = 0;
- /* FSMC timing */
- FSMC_Bank1->BTCR[FSMC_Bank+1] = (FSMC_BTR1_ADDSET_1 | FSMC_BTR1_ADDSET_3) \
- | (FSMC_BTR1_DATAST_1 | FSMC_BTR1_DATAST_3) \
- | (FSMC_BTR1_BUSTURN_1 | FSMC_BTR1_BUSTURN_3) ;
-
- /* Bank1 NOR/SRAM control register configuration
- * This is actually not needed as already set by default after reset */
- FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN;
-#endif
-
- 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 */
+ /* Initialise your display */
+ init_board();
+
+ // Hardware reset
+ setpin_reset(TRUE);
+ delayms(20);
+ setpin_reset(FALSE);
+ delayms(20);
+
+ // Get the bus for the following initialisation commands
+ get_bus();
+
+ write_reg(0x0000,0x0001); delay(5);
+ write_reg(0x0003,0xA8A4); delay(5);
+ write_reg(0x000C,0x0000); delay(5);
+ write_reg(0x000D,0x080C); delay(5);
+ write_reg(0x000E,0x2B00); delay(5);
+ write_reg(0x001E,0x00B0); delay(5);
+ write_reg(0x0001,0x2B3F); delay(5);
+ write_reg(0x0002,0x0600); delay(5);
+ write_reg(0x0010,0x0000); delay(5);
+ write_reg(0x0011,0x6070); delay(5);
+ write_reg(0x0005,0x0000); delay(5);
+ write_reg(0x0006,0x0000); delay(5);
+ write_reg(0x0016,0xEF1C); delay(5);
+ write_reg(0x0017,0x0003); delay(5);
+ write_reg(0x0007,0x0133); delay(5);
+ write_reg(0x000B,0x0000); delay(5);
+ write_reg(0x000F,0x0000); delay(5);
+ write_reg(0x0041,0x0000); delay(5);
+ write_reg(0x0042,0x0000); delay(5);
+ write_reg(0x0048,0x0000); delay(5);
+ write_reg(0x0049,0x013F); delay(5);
+ write_reg(0x004A,0x0000); delay(5);
+ write_reg(0x004B,0x0000); delay(5);
+ write_reg(0x0044,0xEF00); delay(5);
+ write_reg(0x0045,0x0000); delay(5);
+ write_reg(0x0046,0x013F); delay(5);
+ write_reg(0x0030,0x0707); delay(5);
+ write_reg(0x0031,0x0204); delay(5);
+ write_reg(0x0032,0x0204); delay(5);
+ write_reg(0x0033,0x0502); delay(5);
+ write_reg(0x0034,0x0507); delay(5);
+ write_reg(0x0035,0x0204); delay(5);
+ write_reg(0x0036,0x0204); delay(5);
+ write_reg(0x0037,0x0502); delay(5);
+ write_reg(0x003A,0x0302); delay(5);
+ write_reg(0x003B,0x0302); delay(5);
+ write_reg(0x0023,0x0000); delay(5);
+ write_reg(0x0024,0x0000); delay(5);
+ write_reg(0x0025,0x8000); delay(5);
+ write_reg(0x004f,0x0000); delay(5);
+ write_reg(0x004e,0x0000); delay(5);
+
+ // Release the bus
+ release_bus();
+
+ /* Turn on the back-light */
+ set_backlight(GDISP_INITIAL_BACKLIGHT);
+
+ /* Initialise the GDISP structure */
GDISP.Width = GDISP_SCREEN_WIDTH;
GDISP.Height = GDISP_SCREEN_HEIGHT;
GDISP.Orientation = GDISP_ROTATE_0;
GDISP.Powermode = powerOn;
- GDISP.Backlight = 100;
- GDISP.Contrast = 50;
+ GDISP.Backlight = GDISP_INITIAL_BACKLIGHT;
+ GDISP.Contrast = GDISP_INITIAL_CONTRAST;
#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
GDISP.clipx0 = 0;
GDISP.clipy0 = 0;
@@ -171,8 +240,11 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return;
#endif
- lld_lcdSetCursor(x, y);
- lld_lcdWriteReg(0x0022, color);
+
+ get_bus();
+ set_cursor(x, y);
+ write_reg(0x0022, color);
+ release_bus();
}
/* ---- Optional Routines ---- */
@@ -204,13 +276,13 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { void GDISP_LLD(clear)(color_t color) {
unsigned i;
- lld_lcdSetCursor(0, 0);
- lld_lcdWriteStreamStart();
-
+ get_bus();
+ set_cursor(0, 0);
+ stream_start();
for(i = 0; i < GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT; i++)
- lld_lcdWriteData(color);
-
- lld_lcdWriteStreamStop();
+ write_data(color);
+ stream_stop();
+ release_bus();
}
#endif
@@ -226,6 +298,8 @@ 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) {
+ unsigned i, area;
+
#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; }
if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; }
@@ -234,15 +308,15 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y;
#endif
- unsigned i, area;
-
area = cx*cy;
- lld_lcdSetViewPort(x, y, cx, cy);
- lld_lcdWriteStreamStart();
+
+ get_bus();
+ set_viewport(x, y, cx, cy);
+ stream_start();
for(i = 0; i < area; i++)
- lld_lcdWriteData(color);
- lld_lcdWriteStreamStop();
- lld_lcdResetViewPort();
+ write_data(color);
+ stream_stop();
+ release_bus();
}
#endif
@@ -272,8 +346,9 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y;
#endif
- lld_lcdSetViewPort(x, y, cx, cy);
- lld_lcdWriteStreamStart();
+ get_bus();
+ set_viewport(x, y, cx, cy);
+ stream_start();
endx = srcx + cx;
endy = y + cy;
@@ -281,9 +356,9 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { buffer += srcx + srcy * srccx;
for(; y < endy; y++, buffer += lg)
for(x=srcx; x < endx; x++)
- lld_lcdWriteData(*buffer++);
- lld_lcdWriteStreamStop();
- lld_lcdResetViewPort();
+ write_data(*buffer++);
+ stream_stop();
+ release_bus();
}
#endif
@@ -304,14 +379,13 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { if (x < 0 || x >= GDISP.Width || y < 0 || y >= GDISP.Height) return 0;
#endif
- lld_lcdSetCursor(x, y);
- lld_lcdWriteStreamStart();
-
- color = lld_lcdReadData();
- color = lld_lcdReadData();
-
- lld_lcdWriteStreamStop();
-
+ get_bus();
+ set_cursor(x, y);
+ stream_start();
+ color = read_data(); // dummy read
+ color = read_data();
+ stream_stop();
+ release_bus();
return color;
}
#endif
@@ -333,7 +407,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { 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[((GDISP_SCREEN_HEIGHT > GDISP_SCREEN_WIDTH ) ? GDISP_SCREEN_HEIGHT : GDISP_SCREEN_WIDTH)];
coord_t row0, row1;
- unsigned i, gap, abslines;
+ unsigned i, gap, abslines, j;
#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; }
@@ -345,6 +419,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { abslines = lines < 0 ? -lines : lines;
+ get_bus();
if (abslines >= cy) {
abslines = cy;
gap = 0;
@@ -360,25 +435,28 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { }
/* 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();
+ set_viewport(x, row0, cx, 1);
+ stream_start();
+ j = read_data(); // dummy read
+ for (j = 0; j < cx; j++)
+ buf[j] = read_data();
+ stream_stop();
+
+ set_viewport(x, row1, cx, 1);
+ stream_start();
+ for (j = 0; j < cx; j++)
+ write_data(buf[j]);
+ stream_stop();
}
}
/* fill the remaining gap */
- lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines);
- lld_lcdWriteStreamStart();
+ set_viewport(x, lines > 0 ? (y+gap) : y, cx, abslines);
+ stream_start();
gap = cx*abslines;
- for(i = 0; i < gap; i++) lld_lcdWriteData(bgcolor);
- lld_lcdWriteStreamStop();
- lld_lcdResetViewPort();
+ for(i = 0; i < gap; i++) write_data(bgcolor);
+ stream_stop();
+ release_bus();
}
#endif
@@ -409,18 +487,18 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { 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
+ write_reg(0x0010, 0x0000); // leave sleep mode
+ write_reg(0x0007, 0x0000); // halt operation
+ write_reg(0x0000, 0x0000); // turn off oszillator
+ write_reg(0x0010, 0x0001); // enter sleepmode
break;
case powerOn:
- lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode
+ write_reg(0x0010, 0x0000); // leave sleep mode
if (GDISP.Powermode != powerSleep)
GDISP_LLD(init)();
break;
case powerSleep:
- lld_lcdWriteReg(0x0010, 0x0001); // enter sleep mode
+ write_reg(0x0010, 0x0001); // enter sleep mode
break;
default:
return;
@@ -432,30 +510,30 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { return;
switch((gdisp_orientation_t)value) {
case GDISP_ROTATE_0:
- lld_lcdWriteReg(0x0001, 0x2B3F);
+ write_reg(0x0001, 0x2B3F);
/* ID = 11 AM = 0 */
- lld_lcdWriteReg(0x0011, 0x6070);
+ write_reg(0x0011, 0x6070);
GDISP.Height = GDISP_SCREEN_HEIGHT;
GDISP.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_90:
- lld_lcdWriteReg(0x0001, 0x293F);
+ write_reg(0x0001, 0x293F);
/* ID = 11 AM = 1 */
- lld_lcdWriteReg(0x0011, 0x6078);
+ write_reg(0x0011, 0x6078);
GDISP.Height = GDISP_SCREEN_WIDTH;
GDISP.Width = GDISP_SCREEN_HEIGHT;
break;
case GDISP_ROTATE_180:
- lld_lcdWriteReg(0x0001, 0x2B3F);
+ write_reg(0x0001, 0x2B3F);
/* ID = 01 AM = 0 */
- lld_lcdWriteReg(0x0011, 0x6040);
+ write_reg(0x0011, 0x6040);
GDISP.Height = GDISP_SCREEN_HEIGHT;
GDISP.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_270:
- lld_lcdWriteReg(0x0001, 0x293F);
+ write_reg(0x0001, 0x293F);
/* ID = 01 AM = 1 */
- lld_lcdWriteReg(0x0011, 0x6048);
+ write_reg(0x0011, 0x6048);
GDISP.Height = GDISP_SCREEN_WIDTH;
GDISP.Width = GDISP_SCREEN_HEIGHT;
break;
diff --git a/drivers/gdisp/SSD1289/gdisp_lld_board_example.h b/drivers/gdisp/SSD1289/gdisp_lld_board_example.h new file mode 100644 index 00000000..6dcad1b5 --- /dev/null +++ b/drivers/gdisp/SSD1289/gdisp_lld_board_example.h @@ -0,0 +1,125 @@ +/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS/GFX.
+
+ ChibiOS/GFX 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/GFX 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 drivers/gdisp/SSD1289/gdisp_lld_board_example.h
+ * @brief GDISP Graphic Driver subsystem board interface for the SSD1289 display.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#ifndef _GDISP_LLD_BOARD_H
+#define _GDISP_LLD_BOARD_H
+
+/**
+ * @brief Initialise the board for the display.
+ *
+ * @notapi
+ */
+static __inline void init_board(void) {
+ /* Code here */
+#error "SSD1289: You must supply a definition for init_board for your board"
+}
+
+/**
+ * @brief Set or clear the lcd reset pin.
+ *
+ * @param[in] state TRUE = lcd in reset, FALSE = normal operation
+ *
+ * @notapi
+ */
+static __inline void setpin_reset(bool_t state) {
+ /* Code here */
+#error "SSD1289: You must supply a definition for setpin_reset for your board"
+}
+
+/**
+ * @brief Set the lcd back-light level.
+ *
+ * @param[in] percent 0 to 100%
+ *
+ * @notapi
+ */
+static __inline void set_backlight(uint8_t percent) {
+ /* Code here */
+#error "SSD1289: You must supply a definition for set_backlight for your board"
+}
+
+/**
+ * @brief Take exclusive control of the bus
+ *
+ * @notapi
+ */
+static __inline void get_bus(void) {
+#error "SSD1289: You must supply a definition for get_bus for your board"
+}
+
+/**
+ * @brief Release exclusive control of the bus
+ *
+ * @notapi
+ */
+static __inline void release_bus(void) {
+#error "SSD1289: You must supply a definition for release_bus for your board"
+}
+
+/**
+ * @brief Send data to the index register.
+ *
+ * @param[in] index The index register to set
+ *
+ * @notapi
+ */
+static __inline void write_index(uint16_t index) {
+ /* Code here */
+#error "SSD1289: You must supply a definition for write_index for your board"
+}
+
+/**
+ * @brief Send data to the lcd.
+ *
+ * @param[in] data The data to send
+ *
+ * @notapi
+ */
+static __inline void write_data(uint16_t data) {
+ /* Code here */
+#error "SSD1289: You must supply a definition for write_data for your board"
+}
+
+#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__)
+/**
+ * @brief Read data from the lcd.
+ *
+ * @return The data from the lcd
+ * @note The chip select may need to be asserted/de-asserted
+ * around the actual spi read
+ *
+ * @notapi
+ */
+static __inline uint16_t read_data(void) {
+ /* Code here */
+#error "SSD1289: You must supply a definition for read_data for your board"
+}
+#endif
+
+#endif /* _GDISP_LLD_BOARD_H */
+/** @} */
diff --git a/drivers/gdisp/SSD1289/gdisp_lld_board_example_fsmc.h b/drivers/gdisp/SSD1289/gdisp_lld_board_example_fsmc.h new file mode 100644 index 00000000..d3532b76 --- /dev/null +++ b/drivers/gdisp/SSD1289/gdisp_lld_board_example_fsmc.h @@ -0,0 +1,164 @@ +/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS/GFX.
+
+ ChibiOS/GFX 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/GFX 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 drivers/gdisp/SSD1289/gdisp_lld_board_example_fsmc.h
+ * @brief GDISP Graphic Driver subsystem board interface for the SSD1289 display.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#ifndef _GDISP_LLD_BOARD_H
+#define _GDISP_LLD_BOARD_H
+
+#define GDISP_REG ((volatile uint16_t *) 0x60000000)[0] /* RS = 0 */
+#define GDISP_RAM ((volatile uint16_t *) 0x60020000)[0] /* RS = 1 */
+
+/**
+ * @brief Initialise the board for the display.
+ * @notes Performs the following functions:
+ * 1. initialise the io port used by your display
+ * 2. initialise the reset pin (initial state not-in-reset)
+ * 3. initialise the chip select pin (initial state not-active)
+ * 4. initialise the backlight pin (initial state back-light off)
+ *
+ * @notapi
+ */
+static __inline void init_board(void) {
+ const unsigned char FSMC_Bank;
+
+ #if defined(STM32F1XX) || defined(STM32F3XX)
+ /* FSMC setup for F1/F3 */
+ rccEnableAHB(RCC_AHBENR_FSMCEN, 0);
+
+ #if defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM)
+ #error "DMA not implemented for F1/F3 Devices"
+ #endif
+ #elif defined(STM32F4XX) || defined(STM32F2XX)
+ /* STM32F2-F4 FSMC init */
+ rccEnableAHB3(RCC_AHB3ENR_FSMCEN, 0);
+
+ #if defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM)
+ if (dmaStreamAllocate(GDISP_DMA_STREAM, 0, NULL, NULL)) chSysHalt();
+ dmaStreamSetMemory0(GDISP_DMA_STREAM, &GDISP_RAM);
+ dmaStreamSetMode(GDISP_DMA_STREAM, STM32_DMA_CR_PL(0) | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M);
+ #endif
+ #else
+ #error "FSMC not implemented for this device"
+ #endif
+
+ /* set pins to FSMC mode */
+ IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8) |
+ (1 << 9) | (1 << 10) | (1 << 11) | (1 << 14) | (1 << 15), 0};
+
+ IOBus busE = {GPIOE, (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12) |
+ (1 << 13) | (1 << 14) | (1 << 15), 0};
+
+ palSetBusMode(&busD, PAL_MODE_ALTERNATE(12));
+ palSetBusMode(&busE, PAL_MODE_ALTERNATE(12));
+
+ FSMC_Bank = 0;
+
+ /* FSMC timing */
+ FSMC_Bank1->BTCR[FSMC_Bank+1] = (FSMC_BTR1_ADDSET_1 | FSMC_BTR1_ADDSET_3) \
+ | (FSMC_BTR1_DATAST_1 | FSMC_BTR1_DATAST_3) \
+ | (FSMC_BTR1_BUSTURN_1 | FSMC_BTR1_BUSTURN_3) ;
+
+ /* Bank1 NOR/SRAM control register configuration
+ * This is actually not needed as already set by default after reset */
+ FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN;
+}
+
+/**
+ * @brief Set or clear the lcd reset pin.
+ *
+ * @param[in] state TRUE = lcd in reset, FALSE = normal operation
+ *
+ * @notapi
+ */
+static __inline void setpin_reset(bool_t state) {
+ (void) state;
+ /* Nothing to do here */
+}
+
+/**
+ * @brief Set the lcd back-light level.
+ *
+ * @param[in] percent 0 to 100%
+ *
+ * @notapi
+ */
+static __inline void set_backlight(uint8_t percent) {
+ (void) percent;
+ /* Nothing to do here */
+}
+
+/**
+ * @brief Take exclusive control of the bus
+ *
+ * @notapi
+ */
+static __inline void get_bus(void) {
+ /* Nothing to do here */
+}
+
+/**
+ * @brief Release exclusive control of the bus
+ *
+ * @notapi
+ */
+static __inline void release_bus(void) {
+ /* Nothing to do here */
+}
+
+/**
+ * @brief Send data to the index register.
+ *
+ * @param[in] index The index register to set
+ *
+ * @notapi
+ */
+static __inline void write_index(uint16_t index) { GDISP_REG = index; }
+
+/**
+ * @brief Send data to the lcd.
+ *
+ * @param[in] data The data to send
+ *
+ * @notapi
+ */
+static __inline void write_data(uint16_t data) { GDISP_RAM = data; }
+
+#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__)
+/**
+ * @brief Read data from the lcd.
+ *
+ * @return The data from the lcd
+ * @note The chip select may need to be asserted/de-asserted
+ * around the actual spi read
+ *
+ * @notapi
+ */
+static __inline uint16_t read_data(void) { return GDISP_RAM; }
+#endif
+
+#endif /* _GDISP_LLD_BOARD_H */
+/** @} */
diff --git a/drivers/gdisp/SSD1289/gdisp_lld_board_firebullstm32f103.h b/drivers/gdisp/SSD1289/gdisp_lld_board_firebullstm32f103.h new file mode 100644 index 00000000..bab13dda --- /dev/null +++ b/drivers/gdisp/SSD1289/gdisp_lld_board_firebullstm32f103.h @@ -0,0 +1,150 @@ +/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS/GFX.
+
+ ChibiOS/GFX 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/GFX 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 drivers/gdisp/SSD1289/gdisp_lld_board_firebullstm32f103.h
+ * @brief GDISP Graphic Driver subsystem board interface for the SSD1289 display.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#ifndef _GDISP_LLD_BOARD_H
+#define _GDISP_LLD_BOARD_H
+
+#define SET_CS palSetPad(GDISP_CMD_PORT, GDISP_CS);
+#define CLR_CS palClearPad(GDISP_CMD_PORT, GDISP_CS);
+#define SET_RS palSetPad(GDISP_CMD_PORT, GDISP_RS);
+#define CLR_RS palClearPad(GDISP_CMD_PORT, GDISP_RS);
+#define SET_WR palSetPad(GDISP_CMD_PORT, GDISP_WR);
+#define CLR_WR palClearPad(GDISP_CMD_PORT, GDISP_WR);
+#define SET_RD palSetPad(GDISP_CMD_PORT, GDISP_RD);
+#define CLR_RD palClearPad(GDISP_CMD_PORT, GDISP_RD);
+
+/**
+ * @brief Initialise the board for the display.
+ * @notes This board definition uses GPIO and assumes exclusive access to these GPIO pins
+ *
+ * @notapi
+ */
+static __inline void init_board(void) {
+ // This should set the GPIO port up for the correct hardware config here
+
+ // Configure the pins to a well know state
+ SET_RS; SET_RD; SET_RW; CLR_CS;
+}
+
+
+/**
+ * @brief Set or clear the lcd reset pin.
+ *
+ * @param[in] state TRUE = lcd in reset, FALSE = normal operation
+ *
+ * @notapi
+ */
+static __inline void setpin_reset(bool_t state) {
+ (void) state;
+ /* Nothing to do here */
+}
+
+/**
+ * @brief Set the lcd back-light level.
+ *
+ * @param[in] percent 0 to 100%
+ *
+ * @notapi
+ */
+static __inline void set_backlight(uint8_t percent) {
+ (void) percent;
+ /* Nothing to do here */
+}
+
+/**
+ * @brief Take exclusive control of the bus
+ *
+ * @notapi
+ */
+static __inline void get_bus(void) {
+ /* Nothing to do here */
+}
+
+/**
+ * @brief Release exclusive control of the bus
+ *
+ * @notapi
+ */
+static __inline void release_bus(void) {
+ /* Nothing to do here */
+}
+
+/**
+ * @brief Send data to the index register.
+ *
+ * @param[in] index The index register to set
+ *
+ * @notapi
+ */
+static __inline void write_index(uint16_t index) {
+ palWritePort(GDISP_DATA_PORT, index);
+ CLR_RS; CLR_WR; SET_WR; SET_RS;
+}
+
+/**
+ * @brief Send data to the lcd.
+ *
+ * @param[in] data The data to send
+ *
+ * @notapi
+ */
+static __inline void write_data(uint16_t data) {
+ palWritePort(GDISP_DATA_PORT, data);
+ CLR_WR; SET_WR;
+}
+
+#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__)
+/**
+ * @brief Read data from the lcd.
+ *
+ * @return The data from the lcd
+ * @note The chip select may need to be asserted/de-asserted
+ * around the actual spi read
+ *
+ * @notapi
+ */
+static __inline uint16_t read_data(void) {
+ uint16_t value;
+
+ // change pin mode to digital input
+ GDISP_DATA_PORT->CRH = 0x44444444;
+ GDISP_DATA_PORT->CRL = 0x44444444;
+
+ CLR_RD;
+ value = palReadPort(GDISP_DATA_PORT);
+ SET_RD;
+
+ // change pin mode back to digital output
+ GDISP_DATA_PORT->CRH = 0x33333333;
+ GDISP_DATA_PORT->CRL = 0x33333333;
+ return value;
+}
+#endif
+
+#endif /* _GDISP_LLD_BOARD_H */
+/** @} */
diff --git a/drivers/gdisp/SSD1289/readme.txt b/drivers/gdisp/SSD1289/readme.txt index 5bde39f8..b160abbe 100644 --- a/drivers/gdisp/SSD1289/readme.txt +++ b/drivers/gdisp/SSD1289/readme.txt @@ -5,15 +5,15 @@ To use this driver: b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD
- c) One (only) of:
- #define GDISP_USE_GPIO
- #define GDISP_USE_SPI
- #define GDISP_USE_FSMC
+ c) If you are not using a known board then create a gdisp_lld_board.h file
+ and ensure it is on your include path.
+ Use the gdisp_lld_board_example.h or gdisp_lld_board_fsmc.h file as a basis.
+ Currently known boards are:
+ BOARD_FIREBULL_STM32_F103 - GPIO interface: requires GDISP_CMD_PORT and GDISP_DATA_PORT to be defined
- d) All of the following (with appropriate values):
+ d) The following are optional - define them if you are not using the defaults below:
#define GDISP_SCREEN_WIDTH 320
#define GDISP_SCREEN_HEIGHT 240
2. To your makefile add the following lines:
include $(GFXLIB)/drivers/gdisp/SSD1289/gdisp_lld.mk
-
diff --git a/drivers/gdisp/SSD1289/ssd1289_lld.c.h b/drivers/gdisp/SSD1289/ssd1289_lld.c.h deleted file mode 100644 index 14ca3341..00000000 --- a/drivers/gdisp/SSD1289/ssd1289_lld.c.h +++ /dev/null @@ -1,327 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu <joel@unormal.org> - - This file is part of ChibiOS/GFX. - - ChibiOS/GFX 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/GFX 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(GDISP_USE_GPIO) - #define Set_CS palSetPad(GDISP_CMD_PORT, GDISP_CS); - #define Clr_CS palClearPad(GDISP_CMD_PORT, GDISP_CS); - #define Set_RS palSetPad(GDISP_CMD_PORT, GDISP_RS); - #define Clr_RS palClearPad(GDISP_CMD_PORT, GDISP_RS); - #define Set_WR palSetPad(GDISP_CMD_PORT, GDISP_WR); - #define Clr_WR palClearPad(GDISP_CMD_PORT, GDISP_WR); - #define Set_RD palSetPad(GDISP_CMD_PORT, GDISP_RD); - #define Clr_RD palClearPad(GDISP_CMD_PORT, GDISP_RD); - - extern void gdisp_write_gpio_lld(uint16_t data); - extern uint16_t gdisp_read_gpio_lld(void); - - static __inline void lld_lcdWriteIndex(uint16_t index) { - Clr_RS; Set_RD; - gdisp_write_gpio_lld(index); - Clr_WR; Set_WR; - } - static __inline void lld_lcdWriteData(uint16_t data) { - Set_RS; - gdisp_write_gpio_lld(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 = gdisp_read_gpio_lld(); - 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++) { gdisp_write_gpio_lld(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(); - - (void)dummy; - } - -#elif defined(GDISP_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 GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ - #define GDISP_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */ - - static __inline void lld_lcdWriteIndex(uint16_t index) { GDISP_REG = index; } - static __inline void lld_lcdWriteData(uint16_t data) { GDISP_RAM = data; } - static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) { - GDISP_REG = lcdReg; - GDISP_RAM = lcdRegValue; - } - static __inline uint16_t lld_lcdReadData(void) { return (GDISP_RAM); } - static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { - volatile uint16_t dummy; - - GDISP_REG = lcdReg; - dummy = GDISP_RAM; - return (GDISP_RAM); - } - static __inline void lld_lcdWriteStreamStart(void) { GDISP_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++) GDISP_RAM = buffer[i]; - } - static __inline void lld_lcdReadStreamStart(void) { GDISP_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 = GDISP_RAM; /* throw away first value read */ - for(i = 0; i < size; i++) buffer[i] = GDISP_RAM; - } - -#elif defined(GDISP_USE_SPI) - #error "gdispSsd1289: GDISP_USE_SPI not implemented yet" -#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 GDISP_ROTATE_180: - lld_lcdWriteReg(0x004e, (GDISP_SCREEN_WIDTH-1-x) & 0x00FF); - lld_lcdWriteReg(0x004f, (GDISP_SCREEN_HEIGHT-1-y) & 0x01FF); - break; - case GDISP_ROTATE_0: - lld_lcdWriteReg(0x004e, x & 0x00FF); - lld_lcdWriteReg(0x004f, y & 0x01FF); - break; - case GDISP_ROTATE_270: - lld_lcdWriteReg(0x004e, y & 0x00FF); - lld_lcdWriteReg(0x004f, x & 0x01FF); - break; - case GDISP_ROTATE_90: - lld_lcdWriteReg(0x004e, (GDISP_SCREEN_WIDTH - y - 1) & 0x00FF); - lld_lcdWriteReg(0x004f, (GDISP_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 GDISP_ROTATE_0: - lld_lcdWriteReg(0x44, (((x+cx-1) << 8) & 0xFF00 ) | (x & 0x00FF)); - lld_lcdWriteReg(0x45, y & 0x01FF); - lld_lcdWriteReg(0x46, (y+cy-1) & 0x01FF); - break; - case GDISP_ROTATE_270: - lld_lcdWriteReg(0x44, (((x+cx-1) << 8) & 0xFF00 ) | (y & 0x00FF)); - lld_lcdWriteReg(0x45, x & 0x01FF); - lld_lcdWriteReg(0x46, (x+cx-1) & 0x01FF); - break; - case GDISP_ROTATE_180: - lld_lcdWriteReg(0x44, (((GDISP_SCREEN_WIDTH-x-1) & 0x00FF) << 8) | ((GDISP_SCREEN_WIDTH - (x+cx)) & 0x00FF)); - lld_lcdWriteReg(0x45, (GDISP_SCREEN_HEIGHT-(y+cy)) & 0x01FF); - lld_lcdWriteReg(0x46, (GDISP_SCREEN_HEIGHT-y-1) & 0x01FF); - break; - case GDISP_ROTATE_90: - lld_lcdWriteReg(0x44, (((GDISP_SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | ((GDISP_SCREEN_WIDTH - (y+cy)) & 0x00FF)); - lld_lcdWriteReg(0x45, (GDISP_SCREEN_HEIGHT - (x+cx)) & 0x01FF); - lld_lcdWriteReg(0x46, (GDISP_SCREEN_HEIGHT - x - 1) & 0x01FF); - break; - } - - lld_lcdSetCursor(x, y); -} - -static __inline void lld_lcdResetViewPort(void) { - /* ToDo */ -} - -#endif /* SSD1289_H */ - |