aboutsummaryrefslogtreecommitdiffstats
path: root/halext
diff options
context:
space:
mode:
authorAndrew Hannam <andrewh@inmarket.com.au>2012-08-06 11:30:02 +1000
committerAndrew Hannam <andrewh@inmarket.com.au>2012-08-06 11:30:02 +1000
commit34075031de2dd0695e0e239c1dad0429fcc3e2f1 (patch)
tree653b83b6a38039a6800cdf283618976da7280cf6 /halext
parent9a0521a85e7c065ccde55ce0de2bcc7db64b3439 (diff)
downloaduGFX-34075031de2dd0695e0e239c1dad0429fcc3e2f1.tar.gz
uGFX-34075031de2dd0695e0e239c1dad0429fcc3e2f1.tar.bz2
uGFX-34075031de2dd0695e0e239c1dad0429fcc3e2f1.zip
Backport GDISP low level drivers to GLCD
see GLCD/readme.txt
Diffstat (limited to 'halext')
-rw-r--r--halext/drivers/gdispS6d1121/s6d1121_lld.c.h735
-rw-r--r--halext/drivers/gdispTestStub/gdisp_lld.c2
-rw-r--r--halext/include/gdisp.h20
-rw-r--r--halext/include/gdisp_lld.h24
-rw-r--r--halext/include/glcd.h30
5 files changed, 288 insertions, 523 deletions
diff --git a/halext/drivers/gdispS6d1121/s6d1121_lld.c.h b/halext/drivers/gdispS6d1121/s6d1121_lld.c.h
index bc929660..c1539fe7 100644
--- a/halext/drivers/gdispS6d1121/s6d1121_lld.c.h
+++ b/halext/drivers/gdispS6d1121/s6d1121_lld.c.h
@@ -1,491 +1,244 @@
-<<<<<<< HEAD
-/*
- ChibiOS/RT - Copyright (C) 2012
- Joel Bodenmann aka Tectu <joel@unormal.org>
-
- This file is part of ChibiOS-LCD-Driver.
-
- ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef S6D1121_H
-#define S6D1121_H
-
-// I/O assignments
-#define LCD_BL_GPIO GPIOB
-#define LCD_BL_PIN 8
-
-#define LCD_CS_GPIO GPIOD
-#define LCD_CS_PIN 7
-
-#define LCD_RS_GPIO GPIOD
-#define LCD_RS_PIN 11
-
-#define LCD_RST_GPIO GPIOD
-#define LCD_RST_PIN 10
-
-#define LCD_RD_GPIO GPIOD
-#define LCD_RD_PIN 9
-
-#define LCD_WR_GPIO GPIOD
-#define LCD_WR_PIN 8
-
-#define LCD_D0_GPIO GPIOD
-#define LCD_D4_GPIO GPIOE
-
-/* all interfaces use RST via GPIO */
-/* TODO: option to disable RST; assumes RST is tied high */
-#define LCD_RST_LOW palClearPad(LCD_RST_GPIO, LCD_RST_PIN)
-#define LCD_RST_HIGH palSetPad(LCD_RST_GPIO, LCD_RST_PIN)
-
-#define s6d1121_delay(n) halPolledDelay(MS2RTT(n));
-
-#if defined(LCD_USE_GPIO)
-
- #define LCD_CS_LOW palClearPad(LCD_CS_GPIO, LCD_CS_PIN)
- #define LCD_CS_HIGH palSetPad(LCD_CS_GPIO, LCD_CS_PIN)
-
- #define LCD_RS_LOW palClearPad(LCD_RS_GPIO, LCD_RS_PIN)
- #define LCD_RS_HIGH palSetPad(LCD_RS_GPIO, LCD_RS_PIN)
-
- #define LCD_RD_LOW palClearPad(LCD_RD_GPIO, LCD_RD_PIN)
- #define LCD_RD_HIGH palSetPad(LCD_RD_GPIO, LCD_RD_PIN)
-
- #define LCD_WR_LOW palClearPad(LCD_WR_GPIO, LCD_WR_PIN)
- #define LCD_WR_HIGH palSetPad(LCD_WR_GPIO, LCD_WR_PIN)
-
- #define LCD_BL_LOW palClearPad(LCD_BL_GPIO, LCD_BL_PIN)
- #define LCD_BL_HIGH palSetPad(LCD_BL_GPIO, LCD_BL_PIN)
-
-
- static inline void lld_lcddelay(void) { asm volatile ("nop"); asm volatile ("nop"); }
- static inline void lld_lcdwrite(uint16_t db) {
- LCD_D4_GPIO->BSRR.W=((~db&0xFFF0)<<16)|(db&0xFFF0);
- LCD_D0_GPIO->BSRR.W=((~db&0x000F)<<16)|(db&0x000F);
- LCD_WR_LOW;
- lld_lcddelay();
- LCD_WR_HIGH;
- }
- static __inline uint16_t lld_lcdReadData(void) {
- uint16_t value=0;
-
- LCD_RS_HIGH; LCD_WR_HIGH; LCD_RD_LOW;
- #ifndef STM32F4XX
- // change pin mode to digital input
- LCD_DATA_PORT->CRH = 0x47444444;
- LCD_DATA_PORT->CRL = 0x47444444;
- #endif
- #ifndef STM32F4XX
- // change pin mode back to digital output
- LCD_DATA_PORT->CRH = 0x33333333;
- LCD_DATA_PORT->CRL = 0x33333333;
- #endif
- LCD_RD_HIGH;
- return value;
- }
- static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) {
- uint16_t lcdRAM;
-
- LCD_CS_LOW; LCD_RS_LOW;
- lld_lcdwrite(lcdReg);
- LCD_RS_HIGH;
- lcdRAM = lld_lcdReadData();
- LCD_CS_HIGH;
- return lcdRAM;
- }
- static void lld_lcdWriteIndex(uint16_t lcdReg) {
- LCD_RS_LOW;
- lld_lcdwrite(lcdReg);
- LCD_RS_HIGH;
- }
- static void lld_lcdWriteData(uint16_t lcdData) {
- lld_lcdwrite(lcdData);
- }
- static void lld_lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) {
- LCD_CS_LOW;
- lld_lcdWriteIndex(lcdReg);
- lld_lcdWriteData(lcdRegValue);
- LCD_CS_HIGH;
- }
- static __inline void lld_lcdWriteStreamStart(void) {
- LCD_CS_LOW;
- lld_lcdWriteIndex(0x0022);
- }
- static __inline void lld_lcdWriteStreamStop(void) {
- LCD_CS_HIGH;
- }
- static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
- uint16_t i;
-
- for(i = 0; i < size; i++) { lld_lcdwrite(buffer[i]); }
- }
- static __inline void lld_lcdReadStreamStart(void) { /* TODO */ }
- static __inline void lld_lcdReadStreamStop(void) { /* TODO */ }
- static __inline void lld_lcdReadStream(uint16_t *UNUSED(buffer), size_t UNUSED(size)) { /* TODO */ }
-
-#elif defined(LCD_USE_FSMC)
- #define LCD_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */
- #define LCD_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */
-
- static __inline void lld_lcdWriteIndex(uint16_t index) { LCD_REG = index; }
- static __inline void lld_lcdWriteData(uint16_t data) { LCD_RAM = data; }
- static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) {
- LCD_REG = lcdReg;
- LCD_RAM = lcdRegValue;
- }
- static __inline uint16_t lld_lcdReadData(void) { return (LCD_RAM); }
- static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) {
- LCD_REG = lcdReg;
- return LCD_RAM;
- }
- static __inline void lld_lcdWriteStreamStart(void) { LCD_REG = 0x0022; }
- static __inline void lld_lcdWriteStreamStop(void) {}
- static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
- uint16_t i;
- for(i = 0; i < size; i++) LCD_RAM = buffer[i];
- }
- static __inline void lld_lcdReadStreamStart(void) { LCD_REG = 0x0022; }
- static __inline void lld_lcdReadStreamStop(void) {}
- static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) {
- uint16_t i;
- volatile uint16_t dummy;
-
- /* throw away first value read */
- dummy = LCD_RAM;
- for(i = 0; i < size; i++) buffer[i] = LCD_RAM;
- }
-
-#elif defined(LCD_USE_SPI)
- #error "gdispS6d1121: LCD_USE_SPI not implemented yet"
-
-#else
- #error "gdispS6d1121: No known LCD_USE_XXX has been defined"
-#endif
-
-static void lld_lcdSetCursor(coord_t x, coord_t y) {
- /* R20h - 8 bit
- * R21h - 9 bit
- */
- switch(GDISP.Orientation) {
- case portraitInv:
- lld_lcdWriteReg(0x0020, (SCREEN_WIDTH-1-x) & 0x00FF);
- lld_lcdWriteReg(0x0021, (SCREEN_HEIGHT-1-y) & 0x01FF);
- break;
- case portrait:
- lld_lcdWriteReg(0x0020, x & 0x00FF);
- lld_lcdWriteReg(0x0021, y & 0x01FF);
- break;
- case landscape:
- lld_lcdWriteReg(0x0020, y & 0x00FF);
- lld_lcdWriteReg(0x0021, x & 0x01FF);
- break;
- case landscapeInv:
- lld_lcdWriteReg(0x0020, (SCREEN_WIDTH - y - 1) & 0x00FF);
- lld_lcdWriteReg(0x0021, (SCREEN_HEIGHT - x - 1) & 0x01FF);
- break;
- }
-}
-
-static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) {
- /* HSA / HEA are 8 bit
- * VSA / VEA are 9 bit
- * use masks 0x00FF and 0x01FF to enforce this
- */
-
- switch(GDISP.Orientation) {
- case portrait:
- lld_lcdWriteReg(0x46, (((x+cx-1) << 8) & 0xFF00 ) | (x & 0x00FF));
- lld_lcdWriteReg(0x48, y & 0x01FF);
- lld_lcdWriteReg(0x47, (y+cy-1) & 0x01FF);
- break;
- case landscape:
- lld_lcdWriteReg(0x46, (((x+cx-1) << 8) & 0xFF00) | ((y+cy) & 0x00FF));
- lld_lcdWriteReg(0x48, x & 0x01FF);
- lld_lcdWriteReg(0x47, (x+cx-1) & 0x01FF);
- break;
- case portraitInv:
- lld_lcdWriteReg(0x46, (((SCREEN_WIDTH-x-1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (x+cx)) & 0x00FF));
- lld_lcdWriteReg(0x48, (SCREEN_HEIGHT-(y+cy)) & 0x01FF);
- lld_lcdWriteReg(0x47, (SCREEN_HEIGHT-y-1) & 0x01FF);
- break;
- case landscapeInv:
- lld_lcdWriteReg(0x46, (((SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (y+cy)) & 0x00FF));
- lld_lcdWriteReg(0x48, (SCREEN_HEIGHT - (x+cx)) & 0x01FF);
- lld_lcdWriteReg(0x47, (SCREEN_HEIGHT - x - 1) & 0x01FF);
- break;
- }
-
- lld_lcdSetCursor(x, y);
-}
-
-static void lld_lcdResetViewPort(void) {
- switch(GDISP.Orientation) {
- case portrait:
- case portraitInv:
- lld_lcdSetViewPort(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
- break;
- case landscape:
- case landscapeInv:
- lld_lcdSetViewPort(0, 0, SCREEN_HEIGHT, SCREEN_WIDTH);
- break;
- }
-}
-
-#endif /* S6D1121_H */
-=======
-/*
- ChibiOS/RT - Copyright (C) 2012
- Joel Bodenmann aka Tectu <joel@unormal.org>
-
- This file is part of ChibiOS-LCD-Driver.
-
- ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef S6D1121_H
-#define S6D1121_H
-
-// I/O assignments
-#define LCD_BL_GPIO GPIOB
-#define LCD_BL_PIN 8
-
-#define LCD_CS_GPIO GPIOD
-#define LCD_CS_PIN 7
-
-#define LCD_RS_GPIO GPIOD
-#define LCD_RS_PIN 11
-
-#define LCD_RST_GPIO GPIOD
-#define LCD_RST_PIN 10
-
-#define LCD_RD_GPIO GPIOD
-#define LCD_RD_PIN 9
-
-#define LCD_WR_GPIO GPIOD
-#define LCD_WR_PIN 8
-
-#define LCD_D0_GPIO GPIOD
-#define LCD_D4_GPIO GPIOE
-
-/* all interfaces use RST via GPIO */
-/* TODO: option to disable RST; assumes RST is tied high */
-#define LCD_RST_LOW palClearPad(LCD_RST_GPIO, LCD_RST_PIN)
-#define LCD_RST_HIGH palSetPad(LCD_RST_GPIO, LCD_RST_PIN)
-
-#define s6d1121_delay(n) halPolledDelay(MS2RTT(n));
-
-#if defined(LCD_USE_GPIO)
-
- #define LCD_CS_LOW palClearPad(LCD_CS_GPIO, LCD_CS_PIN)
- #define LCD_CS_HIGH palSetPad(LCD_CS_GPIO, LCD_CS_PIN)
-
- #define LCD_RS_LOW palClearPad(LCD_RS_GPIO, LCD_RS_PIN)
- #define LCD_RS_HIGH palSetPad(LCD_RS_GPIO, LCD_RS_PIN)
-
- #define LCD_RD_LOW palClearPad(LCD_RD_GPIO, LCD_RD_PIN)
- #define LCD_RD_HIGH palSetPad(LCD_RD_GPIO, LCD_RD_PIN)
-
- #define LCD_WR_LOW palClearPad(LCD_WR_GPIO, LCD_WR_PIN)
- #define LCD_WR_HIGH palSetPad(LCD_WR_GPIO, LCD_WR_PIN)
-
- #define LCD_BL_LOW palClearPad(LCD_BL_GPIO, LCD_BL_PIN)
- #define LCD_BL_HIGH palSetPad(LCD_BL_GPIO, LCD_BL_PIN)
-
-
- static inline void lld_lcddelay(void) { asm volatile ("nop"); asm volatile ("nop"); }
- static inline void lld_lcdwrite(uint16_t db) {
- LCD_D4_GPIO->BSRR.W=((~db&0xFFF0)<<16)|(db&0xFFF0);
- LCD_D0_GPIO->BSRR.W=((~db&0x000F)<<16)|(db&0x000F);
- LCD_WR_LOW;
- lld_lcddelay();
- LCD_WR_HIGH;
- }
- static __inline uint16_t lld_lcdReadData(void) {
- uint16_t value=0;
-
- LCD_RS_HIGH; LCD_WR_HIGH; LCD_RD_LOW;
- #ifndef STM32F4XX
- // change pin mode to digital input
- LCD_DATA_PORT->CRH = 0x47444444;
- LCD_DATA_PORT->CRL = 0x47444444;
- #endif
- #ifndef STM32F4XX
- // change pin mode back to digital output
- LCD_DATA_PORT->CRH = 0x33333333;
- LCD_DATA_PORT->CRL = 0x33333333;
- #endif
- LCD_RD_HIGH;
- return value;
- }
- static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) {
- uint16_t lcdRAM;
-
- LCD_CS_LOW; LCD_RS_LOW;
- lld_lcdwrite(lcdReg);
- LCD_RS_HIGH;
- lcdRAM = lld_lcdReadData();
- LCD_CS_HIGH;
- return lcdRAM;
- }
- static void lld_lcdWriteIndex(uint16_t lcdReg) {
- LCD_RS_LOW;
- lld_lcdwrite(lcdReg);
- LCD_RS_HIGH;
- }
- static void lld_lcdWriteData(uint16_t lcdData) {
- lld_lcdwrite(lcdData);
- }
- static void lld_lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) {
- LCD_CS_LOW;
- lld_lcdWriteIndex(lcdReg);
- lld_lcdWriteData(lcdRegValue);
- LCD_CS_HIGH;
- }
- static __inline void lld_lcdWriteStreamStart(void) {
- LCD_CS_LOW;
- lld_lcdWriteIndex(0x0022);
- }
- static __inline void lld_lcdWriteStreamStop(void) {
- LCD_CS_HIGH;
- }
- static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
- uint16_t i;
-
- for(i = 0; i < size; i++) { lld_lcdwrite(buffer[i]); }
- }
- static __inline void lld_lcdReadStreamStart(void) { /* TODO */ }
- static __inline void lld_lcdReadStreamStop(void) { /* TODO */ }
- static __inline void lld_lcdReadStream(uint16_t *UNUSED(buffer), size_t UNUSED(size)) { /* TODO */ }
-
-#elif defined(LCD_USE_FSMC)
- #define LCD_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */
- #define LCD_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */
-
- static __inline void lld_lcdWriteIndex(uint16_t index) { LCD_REG = index; }
- static __inline void lld_lcdWriteData(uint16_t data) { LCD_RAM = data; }
- static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) {
- LCD_REG = lcdReg;
- LCD_RAM = lcdRegValue;
- }
- static __inline uint16_t lld_lcdReadData(void) { return (LCD_RAM); }
- static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) {
- LCD_REG = lcdReg;
- return LCD_RAM;
- }
- static __inline void lld_lcdWriteStreamStart(void) { LCD_REG = 0x0022; }
- static __inline void lld_lcdWriteStreamStop(void) {}
- static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
- uint16_t i;
- for(i = 0; i < size; i++) LCD_RAM = buffer[i];
- }
- static __inline void lld_lcdReadStreamStart(void) { LCD_REG = 0x0022; }
- static __inline void lld_lcdReadStreamStop(void) {}
- static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) {
- uint16_t i;
- volatile uint16_t dummy;
-
- /* throw away first value read */
- dummy = LCD_RAM;
- for(i = 0; i < size; i++) buffer[i] = LCD_RAM;
- }
-
-#elif defined(LCD_USE_SPI)
- #error "gdispS6d1121: LCD_USE_SPI not implemented yet"
-
-#else
- #error "gdispS6d1121: No known LCD_USE_XXX has been defined"
-#endif
-
-static void lld_lcdSetCursor(coord_t x, coord_t y) {
- /* R20h - 8 bit
- * R21h - 9 bit
- */
- switch(GDISP.Orientation) {
- case portraitInv:
- lld_lcdWriteReg(0x0020, (SCREEN_WIDTH-1-x) & 0x00FF);
- lld_lcdWriteReg(0x0021, (SCREEN_HEIGHT-1-y) & 0x01FF);
- break;
- case portrait:
- lld_lcdWriteReg(0x0020, x & 0x00FF);
- lld_lcdWriteReg(0x0021, y & 0x01FF);
- break;
- case landscape:
- lld_lcdWriteReg(0x0020, y & 0x00FF);
- lld_lcdWriteReg(0x0021, x & 0x01FF);
- break;
- case landscapeInv:
- lld_lcdWriteReg(0x0020, (SCREEN_WIDTH - y - 1) & 0x00FF);
- lld_lcdWriteReg(0x0021, (SCREEN_HEIGHT - x - 1) & 0x01FF);
- break;
- }
-}
-
-static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) {
- /* HSA / HEA are 8 bit
- * VSA / VEA are 9 bit
- * use masks 0x00FF and 0x01FF to enforce this
- */
-
- switch(GDISP.Orientation) {
- case portrait:
- lld_lcdWriteReg(0x46, (((x+cx-1) << 8) & 0xFF00 ) | (x & 0x00FF));
- lld_lcdWriteReg(0x48, y & 0x01FF);
- lld_lcdWriteReg(0x47, (y+cy-1) & 0x01FF);
- break;
- case landscape:
- lld_lcdWriteReg(0x46, (((x+cx-1) << 8) & 0xFF00) | ((y+cy) & 0x00FF));
- lld_lcdWriteReg(0x48, x & 0x01FF);
- lld_lcdWriteReg(0x47, (x+cx-1) & 0x01FF);
- break;
- case portraitInv:
- lld_lcdWriteReg(0x46, (((SCREEN_WIDTH-x-1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (x+cx)) & 0x00FF));
- lld_lcdWriteReg(0x48, (SCREEN_HEIGHT-(y+cy)) & 0x01FF);
- lld_lcdWriteReg(0x47, (SCREEN_HEIGHT-y-1) & 0x01FF);
- break;
- case landscapeInv:
- lld_lcdWriteReg(0x46, (((SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (y+cy)) & 0x00FF));
- lld_lcdWriteReg(0x48, (SCREEN_HEIGHT - (x+cx)) & 0x01FF);
- lld_lcdWriteReg(0x47, (SCREEN_HEIGHT - x - 1) & 0x01FF);
- break;
- }
-
- lld_lcdSetCursor(x, y);
-}
-
-static void lld_lcdResetViewPort(void) {
- switch(GDISP.Orientation) {
- case portrait:
- case portraitInv:
- lld_lcdSetViewPort(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
- break;
- case landscape:
- case landscapeInv:
- lld_lcdSetViewPort(0, 0, SCREEN_HEIGHT, SCREEN_WIDTH);
- break;
- }
-}
-
-#endif /* S6D1121_H */
->>>>>>> d61cff7a7976cd9097e5c3634ae4b1be64f736c3
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef S6D1121_H
+#define S6D1121_H
+
+// I/O assignments
+#define LCD_BL_GPIO GPIOB
+#define LCD_BL_PIN 8
+
+#define LCD_CS_GPIO GPIOD
+#define LCD_CS_PIN 7
+
+#define LCD_RS_GPIO GPIOD
+#define LCD_RS_PIN 11
+
+#define LCD_RST_GPIO GPIOD
+#define LCD_RST_PIN 10
+
+#define LCD_RD_GPIO GPIOD
+#define LCD_RD_PIN 9
+
+#define LCD_WR_GPIO GPIOD
+#define LCD_WR_PIN 8
+
+#define LCD_D0_GPIO GPIOD
+#define LCD_D4_GPIO GPIOE
+
+/* all interfaces use RST via GPIO */
+/* TODO: option to disable RST; assumes RST is tied high */
+#define LCD_RST_LOW palClearPad(LCD_RST_GPIO, LCD_RST_PIN)
+#define LCD_RST_HIGH palSetPad(LCD_RST_GPIO, LCD_RST_PIN)
+
+#define s6d1121_delay(n) halPolledDelay(MS2RTT(n));
+
+#if defined(LCD_USE_GPIO)
+
+ #define LCD_CS_LOW palClearPad(LCD_CS_GPIO, LCD_CS_PIN)
+ #define LCD_CS_HIGH palSetPad(LCD_CS_GPIO, LCD_CS_PIN)
+
+ #define LCD_RS_LOW palClearPad(LCD_RS_GPIO, LCD_RS_PIN)
+ #define LCD_RS_HIGH palSetPad(LCD_RS_GPIO, LCD_RS_PIN)
+
+ #define LCD_RD_LOW palClearPad(LCD_RD_GPIO, LCD_RD_PIN)
+ #define LCD_RD_HIGH palSetPad(LCD_RD_GPIO, LCD_RD_PIN)
+
+ #define LCD_WR_LOW palClearPad(LCD_WR_GPIO, LCD_WR_PIN)
+ #define LCD_WR_HIGH palSetPad(LCD_WR_GPIO, LCD_WR_PIN)
+
+ #define LCD_BL_LOW palClearPad(LCD_BL_GPIO, LCD_BL_PIN)
+ #define LCD_BL_HIGH palSetPad(LCD_BL_GPIO, LCD_BL_PIN)
+
+
+ static inline void lld_lcddelay(void) { asm volatile ("nop"); asm volatile ("nop"); }
+ static inline void lld_lcdwrite(uint16_t db) {
+ LCD_D4_GPIO->BSRR.W=((~db&0xFFF0)<<16)|(db&0xFFF0);
+ LCD_D0_GPIO->BSRR.W=((~db&0x000F)<<16)|(db&0x000F);
+ LCD_WR_LOW;
+ lld_lcddelay();
+ LCD_WR_HIGH;
+ }
+ static __inline uint16_t lld_lcdReadData(void) {
+ uint16_t value=0;
+
+ LCD_RS_HIGH; LCD_WR_HIGH; LCD_RD_LOW;
+ #ifndef STM32F4XX
+ // change pin mode to digital input
+ LCD_DATA_PORT->CRH = 0x47444444;
+ LCD_DATA_PORT->CRL = 0x47444444;
+ #endif
+ #ifndef STM32F4XX
+ // change pin mode back to digital output
+ LCD_DATA_PORT->CRH = 0x33333333;
+ LCD_DATA_PORT->CRL = 0x33333333;
+ #endif
+ LCD_RD_HIGH;
+ return value;
+ }
+ static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) {
+ uint16_t lcdRAM;
+
+ LCD_CS_LOW; LCD_RS_LOW;
+ lld_lcdwrite(lcdReg);
+ LCD_RS_HIGH;
+ lcdRAM = lld_lcdReadData();
+ LCD_CS_HIGH;
+ return lcdRAM;
+ }
+ static void lld_lcdWriteIndex(uint16_t lcdReg) {
+ LCD_RS_LOW;
+ lld_lcdwrite(lcdReg);
+ LCD_RS_HIGH;
+ }
+ static void lld_lcdWriteData(uint16_t lcdData) {
+ lld_lcdwrite(lcdData);
+ }
+ static void lld_lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) {
+ LCD_CS_LOW;
+ lld_lcdWriteIndex(lcdReg);
+ lld_lcdWriteData(lcdRegValue);
+ LCD_CS_HIGH;
+ }
+ static __inline void lld_lcdWriteStreamStart(void) {
+ LCD_CS_LOW;
+ lld_lcdWriteIndex(0x0022);
+ }
+ static __inline void lld_lcdWriteStreamStop(void) {
+ LCD_CS_HIGH;
+ }
+ static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
+ uint16_t i;
+
+ for(i = 0; i < size; i++) { lld_lcdwrite(buffer[i]); }
+ }
+ static __inline void lld_lcdReadStreamStart(void) { /* TODO */ }
+ static __inline void lld_lcdReadStreamStop(void) { /* TODO */ }
+ static __inline void lld_lcdReadStream(uint16_t *UNUSED(buffer), size_t UNUSED(size)) { /* TODO */ }
+
+#elif defined(LCD_USE_FSMC)
+ #define LCD_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */
+ #define LCD_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */
+
+ static __inline void lld_lcdWriteIndex(uint16_t index) { LCD_REG = index; }
+ static __inline void lld_lcdWriteData(uint16_t data) { LCD_RAM = data; }
+ static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) {
+ LCD_REG = lcdReg;
+ LCD_RAM = lcdRegValue;
+ }
+ static __inline uint16_t lld_lcdReadData(void) { return (LCD_RAM); }
+ static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) {
+ LCD_REG = lcdReg;
+ return LCD_RAM;
+ }
+ static __inline void lld_lcdWriteStreamStart(void) { LCD_REG = 0x0022; }
+ static __inline void lld_lcdWriteStreamStop(void) {}
+ static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
+ uint16_t i;
+ for(i = 0; i < size; i++) LCD_RAM = buffer[i];
+ }
+ static __inline void lld_lcdReadStreamStart(void) { LCD_REG = 0x0022; }
+ static __inline void lld_lcdReadStreamStop(void) {}
+ static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) {
+ uint16_t i;
+ volatile uint16_t dummy;
+
+ /* throw away first value read */
+ dummy = LCD_RAM;
+ for(i = 0; i < size; i++) buffer[i] = LCD_RAM;
+ }
+
+#elif defined(LCD_USE_SPI)
+ #error "gdispS6d1121: LCD_USE_SPI not implemented yet"
+
+#else
+ #error "gdispS6d1121: No known LCD_USE_XXX has been defined"
+#endif
+
+static void lld_lcdSetCursor(coord_t x, coord_t y) {
+ /* R20h - 8 bit
+ * R21h - 9 bit
+ */
+ switch(GDISP.Orientation) {
+ case portraitInv:
+ lld_lcdWriteReg(0x0020, (SCREEN_WIDTH-1-x) & 0x00FF);
+ lld_lcdWriteReg(0x0021, (SCREEN_HEIGHT-1-y) & 0x01FF);
+ break;
+ case portrait:
+ lld_lcdWriteReg(0x0020, x & 0x00FF);
+ lld_lcdWriteReg(0x0021, y & 0x01FF);
+ break;
+ case landscape:
+ lld_lcdWriteReg(0x0020, y & 0x00FF);
+ lld_lcdWriteReg(0x0021, x & 0x01FF);
+ break;
+ case landscapeInv:
+ lld_lcdWriteReg(0x0020, (SCREEN_WIDTH - y - 1) & 0x00FF);
+ lld_lcdWriteReg(0x0021, (SCREEN_HEIGHT - x - 1) & 0x01FF);
+ break;
+ }
+}
+
+static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) {
+ /* HSA / HEA are 8 bit
+ * VSA / VEA are 9 bit
+ * use masks 0x00FF and 0x01FF to enforce this
+ */
+
+ switch(GDISP.Orientation) {
+ case portrait:
+ lld_lcdWriteReg(0x46, (((x+cx-1) << 8) & 0xFF00 ) | (x & 0x00FF));
+ lld_lcdWriteReg(0x48, y & 0x01FF);
+ lld_lcdWriteReg(0x47, (y+cy-1) & 0x01FF);
+ break;
+ case landscape:
+ lld_lcdWriteReg(0x46, (((x+cx-1) << 8) & 0xFF00) | ((y+cy) & 0x00FF));
+ lld_lcdWriteReg(0x48, x & 0x01FF);
+ lld_lcdWriteReg(0x47, (x+cx-1) & 0x01FF);
+ break;
+ case portraitInv:
+ lld_lcdWriteReg(0x46, (((SCREEN_WIDTH-x-1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (x+cx)) & 0x00FF));
+ lld_lcdWriteReg(0x48, (SCREEN_HEIGHT-(y+cy)) & 0x01FF);
+ lld_lcdWriteReg(0x47, (SCREEN_HEIGHT-y-1) & 0x01FF);
+ break;
+ case landscapeInv:
+ lld_lcdWriteReg(0x46, (((SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (y+cy)) & 0x00FF));
+ lld_lcdWriteReg(0x48, (SCREEN_HEIGHT - (x+cx)) & 0x01FF);
+ lld_lcdWriteReg(0x47, (SCREEN_HEIGHT - x - 1) & 0x01FF);
+ break;
+ }
+
+ lld_lcdSetCursor(x, y);
+}
+
+static void lld_lcdResetViewPort(void) {
+ switch(GDISP.Orientation) {
+ case portrait:
+ case portraitInv:
+ lld_lcdSetViewPort(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+ break;
+ case landscape:
+ case landscapeInv:
+ lld_lcdSetViewPort(0, 0, SCREEN_HEIGHT, SCREEN_WIDTH);
+ break;
+ }
+}
+
+#endif /* S6D1121_H */
diff --git a/halext/drivers/gdispTestStub/gdisp_lld.c b/halext/drivers/gdispTestStub/gdisp_lld.c
index 2b80f997..44431e30 100644
--- a/halext/drivers/gdispTestStub/gdisp_lld.c
+++ b/halext/drivers/gdispTestStub/gdisp_lld.c
@@ -308,7 +308,7 @@ void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(co
}
#endif
-#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__)
+#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__)
/**
* @brief Driver Control
* @detail Unsupported control codes are ignored.
diff --git a/halext/include/gdisp.h b/halext/include/gdisp.h
index 24a8b1b4..d284c125 100644
--- a/halext/include/gdisp.h
+++ b/halext/include/gdisp.h
@@ -59,26 +59,6 @@
#define Pink HTML2COLOR(0xFFC0CB)
#define SkyBlue HTML2COLOR(0x87CEEB)
-/**
- * @brief Driver Control Constants
- * @detail Unsupported control codes are ignored.
- * @note The value parameter should always be typecast to (void *).
- * @note There are some predefined and some specific to the low level driver.
- * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t
- * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t
- * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver
- * that only supports off/on anything other
- * than zero is on.
- * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100.
- * GDISP_CONTROL_LLD - Low level driver control constants start at
- * this value.
- */
-#define GDISP_CONTROL_POWER 0
-#define GDISP_CONTROL_ORIENTATION 1
-#define GDISP_CONTROL_BACKLIGHT 2
-#define GDISP_CONTROL_CONTRAST 3
-#define GDISP_CONTROL_LLD 1000
-
/*===========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
diff --git a/halext/include/gdisp_lld.h b/halext/include/gdisp_lld.h
index bef4f96a..970fd712 100644
--- a/halext/include/gdisp_lld.h
+++ b/halext/include/gdisp_lld.h
@@ -37,6 +37,30 @@
#include "gdisp_lld_config.h"
/*===========================================================================*/
+/* Constants. */
+/*===========================================================================*/
+
+/**
+ * @brief Driver Control Constants
+ * @detail Unsupported control codes are ignored.
+ * @note The value parameter should always be typecast to (void *).
+ * @note There are some predefined and some specific to the low level driver.
+ * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t
+ * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t
+ * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver
+ * that only supports off/on anything other
+ * than zero is on.
+ * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100.
+ * GDISP_CONTROL_LLD - Low level driver control constants start at
+ * this value.
+ */
+#define GDISP_CONTROL_POWER 0
+#define GDISP_CONTROL_ORIENTATION 1
+#define GDISP_CONTROL_BACKLIGHT 2
+#define GDISP_CONTROL_CONTRAST 3
+#define GDISP_CONTROL_LLD 1000
+
+/*===========================================================================*/
/* Error checks. */
/*===========================================================================*/
diff --git a/halext/include/glcd.h b/halext/include/glcd.h
index 0712ed02..54c5158d 100644
--- a/halext/include/glcd.h
+++ b/halext/include/glcd.h
@@ -45,13 +45,21 @@ enum powermode {powerOff, powerOn, sleepOn, sleepOff};
#define sleepOn powerSleep
#define sleepOff powerOn
-#define font_Small (&fontSmall)
-#define font_Larger (&fontLarger)
-#define font_MediumBold (&fontUI1)
-#define font_LargeNumbers (&fontLargeNumbers)
+#define font_Small (&fontSmall)
+#define font_SmallDouble (&fontSmallDouble)
+#define font_SmallNarrow (&fontSmall)
+#define font_Larger (&fontLarger)
+#define font_LargerDouble (&fontLargerDouble)
+#define font_LargerNarrow (&fontLargerNarrow)
+#define font_MediumBold (&fontUI1)
+#define font_MediumBoldDouble (&fontUI1Double)
+#define font_MediumBoldNarrow (&fontUI1Narrow)
+#define font_LargeNumbers (&fontLargeNumbers)
+#define font_LargeNumbersDouble (&fontLargeNumbersDouble)
+#define font_LargeNumbersNarrow (&fontLargeNumbersNarrow)
#define GLCDDriver GDISPDriver
-#define GLCDD1 GDISP1
+#define GLCDD GDISP
enum glcd_result { GLCD_DONE,
GLCD_FAILED,
@@ -63,10 +71,10 @@ typedef enum glcd_result glcd_result_t;
/* Core functions */
#define lcdInit(dvr) gdispInit(dvr)
#define lcdClear(color) (gdispClear(color), GLCD_DONE)
-#define lcdSetOrientation(newO) (gdispSetOrientation(newO), (GDISP1.Orientation == (newO) ? GLCD_DONE : GLCD_FAILED))
+#define lcdSetOrientation(newO) (gdispControl(GDISP_CONTROL_ORIENTATION, (void *)(int)newO), (GDISP1.Orientation == (newO) ? GLCD_DONE : GLCD_FAILED))
#define lcdFillArea(x0,y0,x1,y1,c) (gdispFillArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c)), GLCD_DONE)
#define lcdWriteArea(x0,y0,x1,y1,b,n) (gdispBlitArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(b)), GLCD_DONE)
-#define lcdSetPowerMode(pm) (gdispSetPowerMode(pm), (GDISP1.Powermode == (pm) ? GLCD_DONE : GLCD_FAILED))
+#define lcdSetPowerMode(pm) (gdispControl(GDISP_CONTROL_POWER, (void *)(int)pm), (GDISP1.Powermode == (pm) ? GLCD_DONE : GLCD_FAILED))
/* Drawing functions */
#define lcdDrawPixel(x,y,c) (gdispDrawPixel((x),(y),(c)), GLCD_DONE)
@@ -83,12 +91,12 @@ typedef enum glcd_result glcd_result_t;
/* Character measuring functions */
#define lcdMeasureChar(h,f) (gdispGetCharWidth((h),(f))+(f)->charPadding)
#define lcdMeasureString(s,f) (gdispGetStringWidth((s),(f))+(f)->charPadding)
-#define lcdGetFontHeight(font) gdispGetFontMetric(font, fontHeight)
+#define lcdGetFontHeight(f) gdispGetFontMetric((f), fontHeight)
/* Size and orientation related */
-#define lcdGetHeight() (GDISP1.Height)
-#define lcdGetWidth() (GDISP1.Width)
-#define lcdGetOrientation() (GDISP1.Orientation)
+#define lcdGetHeight() (GDISP.Height)
+#define lcdGetWidth() (GDISP.Width)
+#define lcdGetOrientation() (GDISP.Orientation)
/* BGR->RGB and pixel readback */
#define lcdBGR2RGB(c) RGB2COLOR(BLUE_OF(c),GREEN_OF(c),RED_OF(c))