aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gdisp/Nokia6610/gdisp_lld.c48
-rw-r--r--drivers/gdisp/Nokia6610/gdisp_lld_board_example.h16
-rw-r--r--drivers/gdisp/Nokia6610/gdisp_lld_board_olimexsam7ex256.h64
-rw-r--r--drivers/gdisp/SSD1289/gdisp_lld.c370
-rw-r--r--drivers/gdisp/SSD1289/gdisp_lld_board_example.h125
-rw-r--r--drivers/gdisp/SSD1289/gdisp_lld_board_example_fsmc.h164
-rw-r--r--drivers/gdisp/SSD1289/gdisp_lld_board_firebullstm32f103.h150
-rw-r--r--drivers/gdisp/SSD1289/readme.txt12
-rw-r--r--drivers/gdisp/SSD1289/ssd1289_lld.c.h327
9 files changed, 713 insertions, 563 deletions
diff --git a/drivers/gdisp/Nokia6610/gdisp_lld.c b/drivers/gdisp/Nokia6610/gdisp_lld.c
index e22f2468..97fc34b6 100644
--- a/drivers/gdisp/Nokia6610/gdisp_lld.c
+++ b/drivers/gdisp/Nokia6610/gdisp_lld.c
@@ -81,11 +81,9 @@
#endif
// Some macros just to make reading the code easier
-#define write_data(d1) GDISP_LLD(write_data)(d1)
+#define delayms(ms) chThdSleepMilliseconds(ms)
#define write_data2(d1, d2) { write_data(d1); write_data(d2); }
#define write_data3(d1, d2, d3) { write_data(d1); write_data(d2); write_data(d3); }
-
-#define write_cmd(cmd) GDISP_LLD(write_cmd)(cmd)
#define write_cmd1(cmd, d1) { write_cmd(cmd); write_data(d1); }
#define write_cmd2(cmd, d1, d2) { write_cmd(cmd); write_data2(d1, d2); }
#define write_cmd3(cmd, d1, d2, d3) { write_cmd(cmd); write_data3(d1, d2, d3); }
@@ -118,16 +116,16 @@ static __inline void setviewport(coord_t x, coord_t y, coord_t cx, coord_t cy) {
*/
bool_t GDISP_LLD(init)(void) {
/* Initialise your display */
- GDISP_LLD(init_board)();
+ init_board();
// Hardware reset
- GDISP_LLD(setpin_reset)(TRUE);
- chThdSleepMilliseconds(20);
- GDISP_LLD(setpin_reset)(FALSE);
- chThdSleepMilliseconds(20);
+ setpin_reset(TRUE);
+ delayms(20);
+ setpin_reset(FALSE);
+ delayms(20);
// Get the bus for the following initialisation commands
- GDISP_LLD(get_bus);
+ get_bus();
#if defined(GDISP_USE_GE8)
write_cmd3(DISCTL, 0x00, 0x20, 0x00); // Display control
@@ -145,7 +143,7 @@ bool_t GDISP_LLD(init)(void) {
write_cmd2(VOLCTR, GDISP_INITIAL_CONTRAST, 0x03); // Voltage control (contrast setting)
// P1 = Contrast
// P2 = 3 resistance ratio (only value that works)
- chThdSleepMilliseconds(100); // allow power supply to stabilize
+ delayms(100); // allow power supply to stabilize
write_cmd(DISON); // Turn on the display
#elif defined(GDISP_USE_GE12)
@@ -156,14 +154,14 @@ bool_t GDISP_LLD(init)(void) {
write_cmd1(COLMOD, 0x03); // Color Interface Pixel Format - 0x03 = 12 bits-per-pixel
write_cmd1(MADCTL, 0xC8); // Memory access controler - 0xC0 = mirror x and y, reverse rgb
write_cmd1(SETCON, GDISP_INITIAL_CONTRAST); // Write contrast
- chThdSleepMilliseconds(20);
+ delayms(20);
write_cmd(DISPON); // Display On
#else
// Alternative
write_cmd(SOFTRST); // Software Reset
- chThdSleepMilliseconds(20);
+ delayms(20);
write_cmd(INITESC); // Initial escape
- chThdSleepMilliseconds(20);
+ delayms(20);
write_cmd1(REFSET, 0x00); // Refresh set
write_cmd(DISPCTRL); // Set Display control - really 7 bytes of data
write_data(128); // Set the lenght of one selection term
@@ -203,7 +201,7 @@ bool_t GDISP_LLD(init)(void) {
// write_data(0x7f); // full voltage control
// write_data(0x03); // must be "1"
write_cmd1(CONTRAST, GDISP_INITIAL_CONTRAST); // Write contrast
- chThdSleepMilliseconds(20);
+ delayms(20);
write_cmd(TEMPGRADIENT); // Temperature gradient - really 14 bytes of data
for(i=0; i<14; i++)
write_data(0);
@@ -213,10 +211,10 @@ bool_t GDISP_LLD(init)(void) {
#endif
// Release the bus
- GDISP_LLD(release_bus);
+ release_bus();
/* Turn on the back-light */
- GDISP_LLD(set_backlight)(GDISP_INITIAL_BACKLIGHT);
+ set_backlight(GDISP_INITIAL_BACKLIGHT);
/* Initialise the GDISP structure to match */
GDISP.Width = GDISP_SCREEN_WIDTH;
@@ -247,10 +245,10 @@ 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
- GDISP_LLD(get_bus);
+ get_bus();
setviewport(x, y, 1, 1);
write_cmd3(RAMWR, 0, (color>>8) & 0x0F, color & 0xFF);
- GDISP_LLD(release_bus);
+ release_bus();
}
/* ---- Optional Routines ---- */
@@ -279,12 +277,12 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
tuples = (cx*cy+1)/2; // With an odd sized area we over-print by one pixel.
// This extra pixel is ignored by the controller.
- GDISP_LLD(get_bus);
+ get_bus();
setviewport(x, y, cx, cy);
write_cmd(RAMWR);
for(i=0; i < tuples; i++)
write_data3(((color >> 4) & 0xFF), (((color << 4) & 0xF0)|((color >> 8) & 0x0F)), (color & 0xFF));
- GDISP_LLD(release_bus);
+ release_bus();
}
#endif
@@ -321,7 +319,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
endx = srcx + cx;
endy = y + cy;
- GDISP_LLD(get_bus);
+ get_bus();
setviewport(x, y, cx, cy);
write_cmd(RAMWR);
@@ -397,7 +395,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
}
}
#endif
- GDISP_LLD(release_bus);
+ release_bus();
}
#endif
@@ -534,18 +532,18 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
#endif
case GDISP_CONTROL_BACKLIGHT:
if ((unsigned)value > 100) value = (void *)100;
- GDISP_LLD(set_backlight)((uint8_t)(unsigned)value);
+ set_backlight((unsigned)value);
GDISP.Backlight = (unsigned)value;
return;
case GDISP_CONTROL_CONTRAST:
if ((unsigned)value > 100) value = (void *)100;
- GDISP_LLD(get_bus);
+ get_bus();
#if defined(GDISP_USE_GE8)
write_cmd2(VOLCTR, (unsigned)value, 0x03);
#elif defined(GDISP_USE_GE12)
write_cmd1(CONTRAST,(unsigned)value);
#endif
- GDISP_LLD(release_bus);
+ release_bus();
GDISP.Contrast = (unsigned)value;
return;
}
diff --git a/drivers/gdisp/Nokia6610/gdisp_lld_board_example.h b/drivers/gdisp/Nokia6610/gdisp_lld_board_example.h
index 3a547d09..8b315935 100644
--- a/drivers/gdisp/Nokia6610/gdisp_lld_board_example.h
+++ b/drivers/gdisp/Nokia6610/gdisp_lld_board_example.h
@@ -39,7 +39,7 @@
*
* @notapi
*/
-static __inline void GDISP_LLD(init_board)(void) {
+static __inline void init_board(void) {
/* Code here */
#error "gdispNokia6610: You must supply a definition for init_board for your board"
}
@@ -51,7 +51,7 @@ static __inline void GDISP_LLD(init_board)(void) {
*
* @notapi
*/
-static __inline void GDISP_LLD(setpin_reset)(bool_t state) {
+static __inline void setpin_reset(bool_t state) {
/* Code here */
#error "gdispNokia6610: You must supply a definition for setpin_reset for your board"
}
@@ -66,7 +66,7 @@ static __inline void GDISP_LLD(setpin_reset)(bool_t state) {
*
* @notapi
*/
-static __inline void GDISP_LLD(set_backlight)(uint8_t percent) {
+static __inline void set_backlight(uint8_t percent) {
/* Code here */
#error "gdispNokia6610: You must supply a definition for set_backlight for your board"
}
@@ -76,7 +76,7 @@ static __inline void GDISP_LLD(set_backlight)(uint8_t percent) {
*
* @notapi
*/
-static __inline void GDISP_LLD(get_bus)(void) {
+static __inline void get_bus(void) {
#error "gdispNokia6610: You must supply a definition for get_bus for your board"
}
@@ -85,7 +85,7 @@ static __inline void GDISP_LLD(get_bus)(void) {
*
* @notapi
*/
-static __inline void GDISP_LLD(release_bus)(void) {
+static __inline void release_bus(void) {
#error "gdispNokia6610: You must supply a definition for release_bus for your board"
}
@@ -96,7 +96,7 @@ static __inline void GDISP_LLD(release_bus)(void) {
*
* @notapi
*/
-static __inline void GDISP_LLD(write_cmd)(uint16_t cmd) {
+static __inline void write_cmd(uint16_t cmd) {
/* Code here */
#error "gdispNokia6610: You must supply a definition for write_cmd for your board"
}
@@ -108,7 +108,7 @@ static __inline void GDISP_LLD(write_cmd)(uint16_t cmd) {
*
* @notapi
*/
-static __inline void GDISP_LLD(write_data)(uint16_t data) {
+static __inline void write_data(uint16_t data) {
/* Code here */
#error "gdispNokia6610: You must supply a definition for write_data for your board"
}
@@ -123,7 +123,7 @@ static __inline void GDISP_LLD(write_data)(uint16_t data) {
*
* @notapi
*/
-static __inline uint16_t GDISP_LLD(read_data)(void) {
+static __inline uint16_t read_data(void) {
/* Code here */
#error "gdispNokia6610: You must supply a definition for read_data for your board"
}
diff --git a/drivers/gdisp/Nokia6610/gdisp_lld_board_olimexsam7ex256.h b/drivers/gdisp/Nokia6610/gdisp_lld_board_olimexsam7ex256.h
index 0d4ede73..7b2aed43 100644
--- a/drivers/gdisp/Nokia6610/gdisp_lld_board_olimexsam7ex256.h
+++ b/drivers/gdisp/Nokia6610/gdisp_lld_board_olimexsam7ex256.h
@@ -29,40 +29,6 @@
#ifndef _GDISP_LLD_BOARD_H
#define _GDISP_LLD_BOARD_H
-// mask definitions
-#define BIT0 0x00000001
-#define BIT1 0x00000002
-#define BIT2 0x00000004
-#define BIT3 0x00000008
-#define BIT4 0x00000010
-#define BIT5 0x00000020
-#define BIT6 0x00000040
-#define BIT7 0x00000080
-#define BIT8 0x00000100
-#define BIT9 0x00000200
-#define BIT10 0x00000400
-#define BIT11 0x00000800
-#define BIT12 0x00001000
-#define BIT13 0x00002000
-#define BIT14 0x00004000
-#define BIT15 0x00008000
-#define BIT16 0x00010000
-#define BIT17 0x00020000
-#define BIT18 0x00040000
-#define BIT19 0x00080000
-#define BIT20 0x00100000
-#define BIT21 0x00200000
-#define BIT22 0x00400000
-#define BIT23 0x00800000
-#define BIT24 0x01000000
-#define BIT25 0x02000000
-#define BIT26 0x04000000
-#define BIT27 0x08000000
-#define BIT28 0x10000000
-#define BIT29 0x20000000
-#define BIT30 0x40000000
-#define BIT31 0x80000000
-
// ******************************************************
// Pointers to AT91SAM7X256 peripheral data structures
// ******************************************************
@@ -82,7 +48,7 @@ volatile AT91PS_PDC pPDC = AT91C_BASE_PDC_SPI0;
*
* @notapi
*/
-static __inline void GDISP_LLD(init_board)(void) {
+static __inline void init_board(void) {
// *********************************************************************************************
// InitSpi( )
//
@@ -108,8 +74,8 @@ static __inline void GDISP_LLD(init_board)(void) {
pPIOA->PIO_OER = PIOA_LCD_RESET_MASK; // Configure PA2 as output
// CS pin - this seems to be ignored
- // pPIOA->PIO_SODR = BIT12; // Set PA2 to HIGH
- // pPIOA->PIO_OER = BIT12; // Configure PA2 as output
+ // pPIOA->PIO_SODR = 1<<12; // Set PA2 to HIGH
+ // pPIOA->PIO_OER = 1<<12; // Configure PA2 as output
// Init SPI0
// Disable the following pins from PIO control (will be used instead by the SPI0 peripheral)
@@ -117,8 +83,8 @@ static __inline void GDISP_LLD(init_board)(void) {
// BIT16 = PA16 -> SPI0_MISO Master In - Slave Out (not used in LCD interface)
// BIT17 = PA17 -> SPI0_MOSI Master Out - Slave In pin (Serial Data to LCD slave)
// BIT18 = PA18 -> SPI0_SPCK Serial Clock (to LCD slave)
- pPIOA->PIO_PDR = BIT12 | BIT16 | BIT17 | BIT18;
- pPIOA->PIO_ASR = BIT12 | BIT16 | BIT17 | BIT18;
+ pPIOA->PIO_PDR = (1<<12) | (1<<16) | (1<<17) | (1<<18);
+ pPIOA->PIO_ASR = (1<<12) | (1<<16) | (1<<17) | (1<<18);
pPIOA->PIO_BSR = 0;
//enable the clock of SPI
@@ -142,13 +108,11 @@ static __inline void GDISP_LLD(init_board)(void) {
*
* @notapi
*/
-static __inline void GDISP_LLD(setpin_reset)(bool_t state) {
+static __inline void setpin_reset(bool_t state) {
if (state)
palClearPad(IOPORT1, PIOA_LCD_RESET);
-// pPIOA->PIO_CODR = PIOA_LCD_RESET_MASK;
else
palSetPad(IOPORT1, PIOA_LCD_RESET);
-// pPIOA->PIO_SODR = PIOA_LCD_RESET_MASK;
}
/**
@@ -161,13 +125,11 @@ static __inline void GDISP_LLD(setpin_reset)(bool_t state) {
*
* @notapi
*/
-static __inline void GDISP_LLD(set_backlight)(uint8_t percent) {
+static __inline void set_backlight(uint8_t percent) {
if (percent)
palSetPad(IOPORT2, PIOB_LCD_BL);
-// pPIOB->PIO_SODR = PIOB_LCD_BL_MASK;
else
palClearPad(IOPORT2, PIOB_LCD_BL);
-// pPIOB->PIO_CODR = PIOB_LCD_BL_MASK;
}
/**
@@ -175,7 +137,7 @@ static __inline void GDISP_LLD(set_backlight)(uint8_t percent) {
*
* @notapi
*/
-static __inline void GDISP_LLD(get_bus)(void) {
+static __inline void get_bus(void) {
// Nothing to do for this board as the LCD is the only device on the SPI port
}
@@ -184,7 +146,7 @@ static __inline void GDISP_LLD(get_bus)(void) {
*
* @notapi
*/
-static __inline void GDISP_LLD(release_bus)(void) {
+static __inline void release_bus(void) {
// Nothing to do for this board as the LCD is the only device on the SPI port
}
@@ -195,11 +157,11 @@ static __inline void GDISP_LLD(release_bus)(void) {
*
* @notapi
*/
-static __inline void GDISP_LLD(write_cmd)(uint16_t cmd) {
+static __inline void write_cmd(uint16_t cmd) {
// wait for the previous transfer to complete
while((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0);
// send the command
- pSPI->SPI_TDR = data & 0xFF;
+ pSPI->SPI_TDR = cmd & 0xFF;
}
/**
@@ -209,7 +171,7 @@ static __inline void GDISP_LLD(write_cmd)(uint16_t cmd) {
*
* @notapi
*/
-static __inline void GDISP_LLD(write_data)(uint16_t data) {
+static __inline void write_data(uint16_t data) {
// wait for the previous transfer to complete
while((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0);
// send the data
@@ -224,7 +186,7 @@ static __inline void GDISP_LLD(write_data)(uint16_t data) {
*
* @notapi
*/
-static __inline uint16_t GDISP_LLD(read_data)(void) {
+static __inline uint16_t read_data(void) {
#error "gdispNokia6610: GDISP_HARDWARE_READPIXEL and GDISP_HARDWARE_SCROLL are not supported on this board"
return 0;
}
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 */
-