aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gdisp/Nokia6610
diff options
context:
space:
mode:
authorAndrew Hannam <andrewh@inmarket.com.au>2012-11-17 18:11:05 +1000
committerAndrew Hannam <andrewh@inmarket.com.au>2012-11-17 18:11:05 +1000
commitbbb2d434c4d5ebdea76a15ddbf5db688d35850c6 (patch)
tree3a40f0f3af4bdf8fa94a951dadcabd442693f064 /drivers/gdisp/Nokia6610
parent59c13aa33b509ddb5cda070401534440ac7f6d11 (diff)
downloaduGFX-bbb2d434c4d5ebdea76a15ddbf5db688d35850c6.tar.gz
uGFX-bbb2d434c4d5ebdea76a15ddbf5db688d35850c6.tar.bz2
uGFX-bbb2d434c4d5ebdea76a15ddbf5db688d35850c6.zip
gdisp Nokia and SSD1289 updates
Convert SSD1289 to use board files. Update Nokia driver to use short names in the board files. Full expanded names are not needed as they are all static inline routines.
Diffstat (limited to 'drivers/gdisp/Nokia6610')
-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
3 files changed, 44 insertions, 84 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;
}