aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gdisp
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@embedded.pro>2017-05-23 09:57:16 +0200
committerJoel Bodenmann <joel@embedded.pro>2017-05-23 09:57:16 +0200
commit4d06ef9145a3d7cb7fca99cd4dd6a48a02689e81 (patch)
tree190ce7f73b293499cab86e3c90d507e53a9e31e3 /drivers/gdisp
parent09402b6bde18b49e746093b107f64dc25df79e9e (diff)
downloaduGFX-4d06ef9145a3d7cb7fca99cd4dd6a48a02689e81.tar.gz
uGFX-4d06ef9145a3d7cb7fca99cd4dd6a48a02689e81.tar.bz2
uGFX-4d06ef9145a3d7cb7fca99cd4dd6a48a02689e81.zip
Adding RA6963 driver
Diffstat (limited to 'drivers/gdisp')
-rwxr-xr-xdrivers/gdisp/RA6963/board_RA6963.h320
-rwxr-xr-xdrivers/gdisp/RA6963/gdisp_lld_RA6963.c407
-rwxr-xr-xdrivers/gdisp/RA6963/gdisp_lld_config.h25
-rw-r--r--drivers/gdisp/readme.txt80
4 files changed, 793 insertions, 39 deletions
diff --git a/drivers/gdisp/RA6963/board_RA6963.h b/drivers/gdisp/RA6963/board_RA6963.h
new file mode 100755
index 00000000..a7e1426b
--- /dev/null
+++ b/drivers/gdisp/RA6963/board_RA6963.h
@@ -0,0 +1,320 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+/* RA6963 Driver
+ * Pinout:
+ * Version 1:
+ * 1 - Vee Negative Voltage Output
+ * 2 - GND GND
+ * 3 - +5V
+ * 4 - Vo LCD Driver Supply (10-20k Pot between +5V and Vee)
+ * 5 - /WR Write (Low active)
+ * 6 - /RD Read (Low active)
+ * 7 - /CE Chip Enable (Low active)
+ * 8 - C/D Command or Data
+ * 9 - /RST Reset (Low active)
+ * 10..17 - D0..7
+ * 18 - FS Font Select
+ * 19 - A Backlight Anode (~4.3V)
+ * 20 - K Backlight Cathode (GND)
+ */
+#ifndef _GDISP_LLD_BOARD_H
+#define _GDISP_LLD_BOARD_H
+
+// My Settings
+#define RA6963_NEED_READ FALSE //works, but is very slow!
+#define RA6963_HAS_RESET FALSE
+#define RA6963_NEED_FONT_SELECT FALSE
+#define RA6963_NEED_BACKLIGHT FALSE
+#define RA6963_NEED_PWMBACKLIGHT FALSE
+#define GDISP_SCREEN_HEIGHT 64
+#define GDISP_SCREEN_WIDTH 128
+#define GDISP_INITIAL_CONTRAST 50
+#define GDISP_INITIAL_BACKLIGHT 100
+
+#define RA6963_delay(n) {asm("nop");asm("nop");asm("nop");asm("nop");}
+
+#define LINE_WR PAL_LINE(GPIOB, 8U)
+#if RA6963_NEED_READ
+#define LINE_RD PAL_LINE(GPIOB, 9U)
+#endif
+#define LINE_CE PAL_LINE(GPIOB, 10U)
+#define LINE_CD PAL_LINE(GPIOB, 11U)
+#if RA6963_HAS_RESET
+#define LINE_RST PAL_LINE(GPIOB, 12U)
+#endif
+#define LINE_D0 PAL_LINE(GPIOB, 0U)
+#define LINE_D1 PAL_LINE(GPIOB, 1U)
+#define LINE_D2 PAL_LINE(GPIOB, 2U)
+#define LINE_D3 PAL_LINE(GPIOB, 3U)
+#define LINE_D4 PAL_LINE(GPIOB, 4U)
+#define LINE_D5 PAL_LINE(GPIOB, 5U)
+#define LINE_D6 PAL_LINE(GPIOB, 6U)
+#define LINE_D7 PAL_LINE(GPIOB, 7U)
+#if RA6963_NEED_FONT_SELECT
+#define LINE_FS PAL_LINE(GPIOA, 13U)
+#endif
+#if RA6963_NEED_BACKLIGHT
+#define LINE_BL PAL_LINE(GPIOA, 14U)
+#endif
+
+typedef struct {
+ ioline_t WR; //Write PIN
+#if RA6963_NEED_READ
+ ioline_t RD; //Read PIN (tie to +5V if not needed)
+#endif
+ ioline_t CE; //Chip Enable PIN
+ ioline_t CD; //Command/Data Select PIN
+#if RA6963_HAS_RESET
+ ioline_t RST; //Reset PIN (tie to +5V if not needed)
+#endif
+ ioline_t D[8]; //Data PINs
+#if RA6963_NEED_BACKLIGHT
+ ioline_t BL; //Backlight PIN
+#endif
+#if RA6963_NEED_FONT_SELECT
+ ioline_t FS; //Font Select PIN (tie to GND if not needed)
+#endif
+} lcd_pins_t;
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+static const lcd_pins_t lcdpins = {
+ LINE_WR,
+#if RA6963_NEED_READ
+ LINE_RD,
+#endif
+ LINE_CE,
+ LINE_CD,
+#if RA6963_HAS_RESET
+ LINE_RST,
+#endif
+ {
+ LINE_D0,
+ LINE_D1,
+ LINE_D2,
+ LINE_D3,
+ LINE_D4,
+ LINE_D5,
+ LINE_D6,
+ LINE_D7
+ },
+#if RA6963_NEED_BACKLIGHT
+ LINE_BL,
+#endif
+#if RA6963_NEED_FONT_SELECT
+ LINE_FS,
+#endif
+};
+
+static GFXINLINE void init_board(GDisplay* g){
+ (void) g;
+ g->board = 0;
+ int ii;
+//################################DEBUG#######################################
+#define DEB13_ON palClearLine(PAL_LINE(GPIOB, 13U))
+#define DEB13_OFF palSetLine(PAL_LINE(GPIOB, 13U))
+#define DEB14_ON palClearLine(PAL_LINE(GPIOB, 14U))
+#define DEB14_OFF palSetLine(PAL_LINE(GPIOB, 14U))
+
+ palSetLineMode(PAL_LINE(GPIOB, 13U), PAL_MODE_OUTPUT_PUSHPULL);
+ DEB13_OFF;
+ palSetLineMode(PAL_LINE(GPIOB, 14U), PAL_MODE_OUTPUT_PUSHPULL);
+ DEB14_OFF;
+
+ //################################DEBUG#######################################
+
+ palSetLineMode(lcdpins.WR, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetLine(lcdpins.WR);
+#if RA6963_NEED_READ
+ palSetLineMode(lcdpins.RD, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetLine(lcdpins.RD);
+#endif
+ palSetLineMode(lcdpins.CE, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetLine(lcdpins.CE);
+ palSetLineMode(lcdpins.CD, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetLine(lcdpins.CD);
+#if RA6963_HAS_RESET
+ palSetLine(lcdpins.RST);
+ palSetLineMode(lcdpins.RST, PAL_MODE_OUTPUT_PUSHPULL);
+
+#endif
+ for(ii = 0; ii < 8; ii++) {
+ palSetLineMode(lcdpins.D[ii], PAL_MODE_OUTPUT_PUSHPULL);
+ palClearLine(lcdpins.D[ii]);
+ }
+#if RA6963_NEED_BACKLIGHT
+#if RA6963_NEED_PWMBACKLIGHT
+ palSetLineMode(lcdpins.BL, PAL_MODE_ALTERNATE(1));
+#else
+ palSetLineMode(lcdpins.BL, PAL_MODE_OUTPUT_PUSHPULL);
+#endif
+#endif
+#if RA6963_NEED_FONT_SELECT
+ palSetLineMode(lcdpins.FS, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetLine(lcdpins.FS);
+#endif
+}
+
+static GFXINLINE void post_init_board(GDisplay *g) {
+ (void) g;
+}
+
+static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) {
+ (void) g;
+#if RA6963_HAS_RESET //Make Hardware Reset
+ if (state)
+ palClearLine(lcdpins.RST);
+ else
+ palSetLine(lcdpins.RST);
+#else
+ (void) state;
+#endif
+}
+
+static GFXINLINE void set_backlight(GDisplay *g, uint8_t percent) {
+ (void) g;
+ (void) percent;
+#if RA6963_NEED_BACKLIGHT
+#if RA6963_NEED_PWMBACKLIGHT
+
+#else
+
+#endif
+#endif
+}
+
+static GFXINLINE void acquire_bus(GDisplay *g) {
+ (void) g;
+}
+
+static GFXINLINE void release_bus(GDisplay *g) {
+ (void) g;
+}
+
+
+#if RA6963_NEED_READ
+static GFXINLINE uint8_t RA6963_busy_wait(uint8_t pattern, bool_t lh){
+
+ uint8_t data;
+ int ii;
+
+ for(ii = 0; ii < 2; ii++) //Only interested in Bit 0 and 1
+ palSetLineMode(lcdpins.D[ii], PAL_MODE_INPUT); //Set pads to input
+
+ palClearLine(lcdpins.CE);
+ palClearLine(lcdpins.RD);
+ do{
+ data = 0;
+
+ for(ii = 0; ii < 2; ii++){
+ if (palReadLine(lcdpins.D[ii]) == PAL_HIGH){ //Read output
+ data |= (1<<ii);
+ }
+ }
+ } while ((data & pattern) == lh);
+
+ palSetLine(lcdpins.CE);
+ palSetLine(lcdpins.RD);
+ for(ii = 0; ii < 2; ii++) {
+ palSetLineMode(lcdpins.D[ii], PAL_MODE_OUTPUT_PUSHPULL); //Set pads to output
+ }
+
+ return data;
+}
+#endif
+
+static GFXINLINE void RA6963_write(uint8_t value){
+ int ii;
+ for(ii = 0; ii < 8; ii++){
+ if(value & (1 << ii))
+ palSetLine(lcdpins.D[ii]);
+ else
+ palClearLine(lcdpins.D[ii]);
+ }
+}
+
+static GFXINLINE void write_data(GDisplay* g, uint8_t data){
+ (void)g;
+#if RA6963_NEED_READ
+ RA6963_busy_wait(RA6963_STATUS_BUSY1 | RA6963_STATUS_BUSY2, ~(RA6963_STATUS_BUSY1 | RA6963_STATUS_BUSY2));
+#endif
+ RA6963_write(data);
+ palClearLine(lcdpins.CD);
+ palClearLine(lcdpins.CE);
+ palClearLine(lcdpins.WR);
+ RA6963_delay(1);
+ palSetLine(lcdpins.WR);
+ palSetLine(lcdpins.CE);
+ palSetLine(lcdpins.CD);
+}
+
+static GFXINLINE void write_cmd(GDisplay* g, uint8_t data){
+ (void)g;
+#if RA6963_NEED_READ
+ RA6963_busy_wait(RA6963_STATUS_BUSY1 | RA6963_STATUS_BUSY2, ~(RA6963_STATUS_BUSY1 | RA6963_STATUS_BUSY2));
+#endif
+ RA6963_write(data);
+ palClearLine(lcdpins.CE);
+ palClearLine(lcdpins.WR);
+ RA6963_delay(1);
+ palSetLine(lcdpins.WR);
+ palSetLine(lcdpins.CE);
+}
+
+static GFXINLINE void setreadmode(GDisplay *g) {
+ (void) g;
+}
+
+static GFXINLINE void setwritemode(GDisplay *g) {
+ (void) g;
+}
+
+static GFXINLINE uint8_t read_data(GDisplay *g) {
+ (void) g;
+#if RA6963_NEED_READ
+ int ii;
+ uint8_t data;
+ write_cmd(g, RA6963_DATA_READ_AND_NONVARIABLE);
+ //RA6963_busy_wait(RA6963_STATUS_BUSY1 | RA6963_STATUS_BUSY2, ~(RA6963_STATUS_BUSY1 | RA6963_STATUS_BUSY2));
+
+ for(ii = 0; ii < 8; ii++)
+ palSetLineMode(lcdpins.D[ii], PAL_MODE_INPUT); //Set pads to input
+
+ palClearLine(lcdpins.CE);
+ palClearLine(lcdpins.RD);
+ do{
+ data = 0;
+
+ for(ii = 0; ii < 2; ii++){
+ if (palReadLine(lcdpins.D[ii]) == PAL_HIGH){ //Read output
+ data |= (1<<ii);
+ }
+ }
+ } while ((data & (RA6963_STATUS_BUSY1 | RA6963_STATUS_BUSY2)) == ~(RA6963_STATUS_BUSY1 | RA6963_STATUS_BUSY2));
+
+ palClearLine(lcdpins.CD);
+// RA6963_delay(1);
+ data = 0;
+ for(ii = 0; ii < 8; ii++){
+ if (palReadLine(lcdpins.D[ii]) == PAL_HIGH){ //Read output
+ data |= (1<<ii);
+ }
+ }
+ palSetLine(lcdpins.CE);
+ palSetLine(lcdpins.RD);
+ palSetLine(lcdpins.CD);
+ for(ii = 0; ii < 8; ii++) {
+ palSetLineMode(lcdpins.D[ii], PAL_MODE_OUTPUT_PUSHPULL); //Set pads to output
+ }
+ return data;
+#else
+ return 0;
+#endif
+}
+#endif /* _GDISP_LLD_BOARD_H */
diff --git a/drivers/gdisp/RA6963/gdisp_lld_RA6963.c b/drivers/gdisp/RA6963/gdisp_lld_RA6963.c
new file mode 100755
index 00000000..bad7f38d
--- /dev/null
+++ b/drivers/gdisp/RA6963/gdisp_lld_RA6963.c
@@ -0,0 +1,407 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+/* Robert Offner 2017
+ * This is a driver for the RA6963 or T6963 Displays.
+ * It should work with displays up to 240 pixel in width and 64 pixel in height
+ * ATTENTION some newer displays on ebay look like T6963 Type but they're not!
+ * They use a new controller: ST7920. These are easy to identify: NO CS pin but
+ * a PSB Pin which switches from parallel to serial communication mode.
+ * If it cost less than 10.- it is probably a ST7920.
+ *
+ * Version: 0.1
+ *
+ * History:
+ *
+ * v0.1 Initial Release
+ * .) tested with readback and without on a 72MHz STM32F103. Display ws a 128x64
+ * type Graphic LCD (Looks like KS0108 Types). STREAM_READ is not implemented.
+ */
+#include "gfx.h"
+
+#if GFX_USE_GDISP
+#define GDISP_DRIVER_VMT GDISPVMT_RA6963
+
+#include "gdisp_lld_config.h"
+#include "src/gdisp/gdisp_driver.h"
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+#if defined(GDISP_SCREEN_HEIGHT)
+#warning "GDISP: This low level driver does not support setting a screen size. It is being ignored."
+#undef GISP_SCREEN_HEIGHT
+#endif
+#if defined(GDISP_SCREEN_WIDTH)
+#warning "GDISP: This low level driver does not support setting a screen size. It is being ignored."
+#undef GDISP_SCREEN_WIDTH
+#endif
+#include "board_RA6963.h"
+
+// RA6963 Commands
+//Register Setting
+#define RA6963_SET_CURSOR_POINTER 0x21
+#define RA6963_SET_OFFSET_REGISTER 0x22
+#define RA6963_SET_ADDRESS_POINTER 0x24
+//Set Control Word
+#define RA6963_SET_TEXT_HOME_ADDRESS 0x40
+#define RA6963_SET_TEXT_AREA 0x41
+#define RA6963_SET_GRAPHIC_HOME_ADDRESS 0x42
+#define RA6963_SET_GRAPHIC_AREA 0x43
+//Mode Set
+#define RA6963_MODE_SET 0x80
+#define RA6963_MODE_OR 0x00
+#define RA6963_MODE_XOR 0x01
+#define RA6963_MODE_AND 0x03
+#define RA6963_MODE_TEXT_ATTRIBUTE 0x04
+#define RA6963_MODE_INTERNAL_CGROM 0x00
+#define RA6963_MODE_EXTERNAL_CGRAM 0x08
+//Display Mode
+#define RA6963_DISPLAY_MODE 0x90
+#define RA6963_CURSOR_BLINK_ON 0x01
+#define RA6963_CURSOR_DISPLAY_ON 0x02
+#define RA6963_TEXT_DISPLAY_ON 0x04
+#define RA6963_GRAPHIC_DISPLAY_ON 0x08
+//Cursor Pattern Select
+#define RA6963_CURSOR_PATTERN_SELECT 0xA0
+#define RA6963_CURSOR_1_LINE 0x00
+#define RA6963_CURSOR_2_LINE 0x01
+#define RA6963_CURSOR_3_LINE 0x02
+#define RA6963_CURSOR_4_LINE 0x03
+#define RA6963_CURSOR_5_LINE 0x04
+#define RA6963_CURSOR_6_LINE 0x05
+#define RA6963_CURSOR_7_LINE 0x06
+#define RA6963_CURSOR_8_LINE 0x07
+//Data Read/Write
+#define RA6963_DATA_WRITE_AND_INCREMENT 0xC0
+#define RA6963_DATA_READ_AND_INCREMENT 0xC1
+#define RA6963_DATA_WRITE_AND_DECREMENT 0xC2
+#define RA6963_DATA_READ_AND_DECREMENT 0xC3
+#define RA6963_DATA_WRITE_AND_NONVARIALBE 0xC4
+#define RA6963_DATA_READ_AND_NONVARIABLE 0xC5
+//Data auto Read/Write
+#define RA6963_SET_DATA_AUTO_WRITE 0xB0
+#define RA6963_SET_DATA_AUTO_READ 0xB1
+#define RA6963_AUTO_RESET 0xB2
+//Screen Peek
+#define RA6963_SCREEN_PEEK 0xE0
+//Screen copy
+#define RA6963_SCREEN_COPY 0xE8
+// Status Register Bits
+#define RA6963_STATUS_BUSY1 0x01
+#define RA6963_STATUS_BUSY2 0x02
+#define RA6963_STATUS_DARRDY 0x04
+#define RA6963_STATUS_DAWRDY 0x08
+
+#ifndef GDISP_SCREEN_HEIGHT
+ #define GDISP_SCREEN_HEIGHT 64
+#endif
+#ifndef GDISP_SCREEN_WIDTH
+ #define GDISP_SCREEN_WIDTH 128
+#endif
+
+#define RA6963_FONT_WIDTH 8
+
+#define RA6963_GRAPHIC_AREA (GDISP_SCREEN_WIDTH / RA6963_FONT_WIDTH) //16
+#define RA6963_TEXT_AREA (GDISP_SCREEN_WIDTH / RA6963_FONT_WIDTH) //16
+#define RA6963_GRAPHIC_SIZE (RA6963_GRAPHIC_AREA * GDISP_SCREEN_HEIGHT) //1024
+#define RA6963_TEXT_SIZE (RA6963_TEXT_AREA * (GDISP_SCREEN_HEIGHT/8))//128
+//#define RA6963_TEXT_HOME 0
+//#define RA6963_GRAPHIC_HOME (RA6963_TEXT_HOME + RA6963_TEXT_SIZE) //128
+#define RA6963_GRAPHIC_HOME 0
+#define RA6963_TEXT_HOME (RA6963_GRAPHIC_HOME + RA6963_GRAPHIC_SIZE)
+//#define RA6963_OFFSET_REGISTER 2
+
+#if (RA6963_NEED_READ == FALSE)
+#define BUFFSZ (RA6963_GRAPHIC_SIZE)
+#define RAM(g) ((uint8_t *)g->priv)
+#define POS (((g->p.x) / RA6963_FONT_WIDTH) + ((g->p.y) * RA6963_GRAPHIC_AREA))
+#endif
+#ifndef GDISP_INITIAL_CONTRAST
+#define GDISP_INITIAL_CONTRAST 50
+#endif
+#ifndef GDISP_INITIAL_BACKLIGHT
+#define GDISP_INITIAL_BACKLIGHT 100
+#endif
+
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+#ifndef write_data_repeat
+#define write_data_repeat(g, data, count) { int i; for (i = 0; i < count; ++i) write_data (g, data); }
+#endif
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
+#if (RA6963_NEED_READ == FALSE)
+ // The private area is the display surface.
+ g->priv = gfxAlloc(BUFFSZ);
+#else
+ g->priv = 0;
+#endif
+ // Initialise the board interface
+ init_board(g);
+
+#if RA6963_HAS_RESET //Make Hardware Reset
+ setpin_reset(g, TRUE);
+ gfxSleepMilliseconds(100);
+ setpin_reset(g, FALSE);
+#endif
+ gfxSleepMilliseconds(50);
+ //RA6963 needs Data first THEN command!
+
+ write_data(g, (uint8_t)RA6963_GRAPHIC_HOME); //0
+ write_data(g, (uint8_t)(RA6963_GRAPHIC_HOME>>8)); //0
+ write_cmd(g, RA6963_SET_GRAPHIC_HOME_ADDRESS); //0x42
+
+ write_data(g, (uint8_t)RA6963_GRAPHIC_AREA); //16
+ write_data(g, 0); //0
+ write_cmd(g, RA6963_SET_GRAPHIC_AREA); //0x43
+
+ write_data(g, (uint8_t)RA6963_TEXT_HOME); //0x00
+ write_data(g, (uint8_t)(RA6963_TEXT_HOME>>8)); //0x04 = 0x400
+ write_cmd(g, RA6963_SET_TEXT_HOME_ADDRESS); //0x40
+
+ write_data(g, (uint8_t)RA6963_TEXT_AREA); //16
+ write_data(g, (uint8_t)(RA6963_TEXT_AREA>>8)); //0
+ write_cmd(g, RA6963_SET_TEXT_AREA); //0x41
+
+/* write_data(g, (uint8_t)RA6963_OFFSET_REGISTER);
+ write_data(g, 0);
+ write_cmd(g, RA6963_SET_OFFSET_REGISTER);*/
+
+ write_data(g, 0x00);
+ write_data(g, 0x00);
+ write_cmd(g, RA6963_SET_ADDRESS_POINTER);
+
+ write_data(g, 0x00);
+ write_data(g, 0x00);
+ write_cmd(g, RA6963_SET_CURSOR_POINTER);
+
+
+ //write_cmd(g, RA6963_CURSOR_PATTERN_SELECT | RA6963_CURSOR_1_LINE);
+ write_cmd(g, RA6963_MODE_SET | RA6963_MODE_OR);
+ //write_cmd(g, RA6963_DISPLAY_MODE | RA6963_TEXT_DISPLAY_ON | RA6963_GRAPHIC_DISPLAY_ON);
+ write_cmd(g, RA6963_DISPLAY_MODE | RA6963_GRAPHIC_DISPLAY_ON);
+
+ // Finish Init
+ post_init_board(g);
+#if RA6963_NEED_BACKLIGHT
+ // Turn on the back-light
+ set_backlight(g, GDISP_INITIAL_BACKLIGHT);
+#endif
+ // Initialise the GDISP structure
+ g->g.Width = GDISP_SCREEN_WIDTH;
+ g->g.Height = GDISP_SCREEN_HEIGHT;
+ g->g.Orientation = GDISP_ROTATE_0;
+ g->g.Powermode = powerOn;
+ g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
+ g->g.Contrast = GDISP_INITIAL_CONTRAST;
+
+ return TRUE;
+}
+
+static void set_viewport(GDisplay *g) {
+ if ((g->p.x >= GDISP_SCREEN_WIDTH) || (g->p.y >= GDISP_SCREEN_HEIGHT))
+ return; // 0 + ( x / 8 ) + ( y * 16 )
+ //uint16_t addr = (RA6963_GRAPHIC_HOME + ((g->p.x) / RA6963_FONT_WIDTH) + ((g->p.y) * RA6963_GRAPHIC_AREA));
+ uint16_t addr = (RA6963_GRAPHIC_HOME + ((g->p.x >> 3) + (g->p.y << 4)));
+#warning "check function set_viewport about the shift operations if you change the resolution!"
+ write_data(g, (uint8_t)addr);
+ write_data(g, (uint8_t)(addr>>8));
+ write_cmd(g, RA6963_SET_ADDRESS_POINTER);
+}
+
+LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
+ uint8_t temp;
+
+#if (RA6963_NEED_READ == FALSE)
+ temp = RAM(g)[POS];
+#else
+ temp = read_data(g);
+#endif
+
+ if (g->p.color != White) {
+ temp |= (1 << (RA6963_FONT_WIDTH - 1 - ((g->p.x) % RA6963_FONT_WIDTH)));
+ }
+ else {
+ temp &= ~(1 << (RA6963_FONT_WIDTH - 1 - ((g->p.x) % RA6963_FONT_WIDTH)));
+ }
+
+ write_data(g, temp);
+#if (RA6963_NEED_READ == FALSE)
+ RAM(g)[POS] = temp;
+#endif
+ //write_cmd(g, RA6963_DATA_WRITE_AND_INCREMENT);
+ write_cmd(g, RA6963_DATA_WRITE_AND_NONVARIALBE);
+
+}
+
+LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
+ set_viewport(g);
+ gdisp_lld_write_color(g);
+}
+
+#if GDISP_HARDWARE_STREAM_WRITE
+LLDSPEC void gdisp_lld_write_start(GDisplay *g) {
+ //acquire_bus(g);
+ set_viewport(g);
+}
+
+LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
+ //release_bus(g);
+}
+#endif
+
+#if GDISP_HARDWARE_STREAM_READ
+LLDSPEC void gdisp_lld_read_start(GDisplay *g) {
+ acquire_bus(g);
+ set_viewport(g);
+ setreadmode(g);
+ dummy_read(g);
+}
+
+LLDSPEC color_t gdisp_lld_read_color(GDisplay *g) {
+ uint16_t data;
+
+ data = read_data(g);
+ return gdispNative2Color(data);
+}
+
+LLDSPEC void gdisp_lld_read_stop(GDisplay *g) {
+ setwritemode(g);
+ release_bus(g);
+}
+#endif
+
+#if GDISP_HARDWARE_FILLS
+LLDSPEC void gdisp_lld_fill_area(GDisplay *g) {
+ uint8_t data, j;
+ set_viewport(g);
+
+ if (g->p.color != White) {
+ data = 0xFF; // set dot
+ }
+ else {
+ data = 0; // clr dot
+ }
+ for (j=0; j < (g->p.cy)/8; j++) {
+ write_data_repeat(g, data, (g->p.cx));
+ (g->p.cy) +=8;
+ set_viewport(g);
+ }
+
+}
+#endif // GDISP_HARDWARE_FILLS
+
+#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
+LLDSPEC void gdisp_lld_control(GDisplay *g) {
+ switch(g->p.x) {
+ case GDISP_CONTROL_POWER:
+ if (g->g.Powermode == (powermode_t)g->p.ptr)
+ return;
+
+ switch((powermode_t)g->p.ptr) {
+ case powerOff:
+ acquire_bus(g);
+ write_index(g, 0x28);
+ gfxSleepMilliseconds(10);
+ write_index(g, 0x10);
+ release_bus(g);
+ break;
+
+ case powerOn:
+ acquire_bus(g);
+ write_index(g, 0x11);
+ gfxSleepMilliseconds(120);
+ write_index(g, 0x29);
+ release_bus(g);
+ if (g->g.Powermode != powerSleep)
+ gdisp_lld_init(g);
+ break;
+
+ case powerSleep:
+ acquire_bus(g);
+ write_index(g, 0x28);
+ gfxSleepMilliseconds(10);
+ write_index(g, 0x10);
+ release_bus(g);
+ break;
+
+ default:
+ return;
+ }
+
+ g->g.Powermode = (powermode_t)g->p.ptr;
+ return;
+
+ case GDISP_CONTROL_ORIENTATION:
+ if (g->g.Orientation == (orientation_t)g->p.ptr)
+ return;
+
+ switch((orientation_t)g->p.ptr) {
+ case GDISP_ROTATE_0:
+ acquire_bus(g);
+
+ write_index(g, 0x36);
+ write_data(g, 0x08);
+
+ release_bus(g);
+ g->g.Height = GDISP_SCREEN_HEIGHT;
+ g->g.Width = GDISP_SCREEN_WIDTH;
+ break;
+
+ case GDISP_ROTATE_90:
+ acquire_bus(g);
+
+ write_index(g, 0x36);
+ write_data(g, 0x68);
+
+ release_bus(g);
+ g->g.Height = GDISP_SCREEN_WIDTH;
+ g->g.Width = GDISP_SCREEN_HEIGHT;
+ break;
+
+ case GDISP_ROTATE_180:
+ acquire_bus(g);
+
+ write_index(g, 0x36);
+ write_data(g, 0xC8);
+
+ release_bus(g);
+ g->g.Height = GDISP_SCREEN_HEIGHT;
+ g->g.Width = GDISP_SCREEN_WIDTH;
+ break;
+
+ case GDISP_ROTATE_270:
+ acquire_bus(g);
+
+ write_index(g, 0x36);
+ write_data(g, 0xA8);
+
+ release_bus(g);
+ g->g.Height = GDISP_SCREEN_WIDTH;
+ g->g.Width = GDISP_SCREEN_HEIGHT;
+ break;
+
+ default:
+ return;
+ }
+
+ g->g.Orientation = (orientation_t)g->p.ptr;
+ return;
+
+ default:
+ return;
+ }
+}
+#endif
+
+#endif /* GFX_USE_GDISP */
diff --git a/drivers/gdisp/RA6963/gdisp_lld_config.h b/drivers/gdisp/RA6963/gdisp_lld_config.h
new file mode 100755
index 00000000..15c81d70
--- /dev/null
+++ b/drivers/gdisp/RA6963/gdisp_lld_config.h
@@ -0,0 +1,25 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+//#ifndef _GDISP_LLD_CONFIG_H
+//#define _GDISP_LLD_CONFIG_H
+
+#if GFX_USE_GDISP
+/*===========================================================================*/
+/* Driver hardware support. */
+/*===========================================================================*/
+
+#define GDISP_HARDWARE_STREAM_WRITE FALSE
+#define GDISP_HARDWARE_STREAM_READ FALSE
+#define GDISP_HARDWARE_CONTROL FALSE
+#define GDISP_HARDWARE_DRAWPIXEL TRUE
+#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO
+#define GDISP_HARDWARE_FILLS FALSE
+
+#endif /* GFX_USE_GDISP */
+
+//#endif /* _GDISP_LLD_CONFIG_H */
diff --git a/drivers/gdisp/readme.txt b/drivers/gdisp/readme.txt
index 710288f6..c34363b9 100644
--- a/drivers/gdisp/readme.txt
+++ b/drivers/gdisp/readme.txt
@@ -1,39 +1,41 @@
-A list of current display drivers:
-
-AlteraFramereader - Support for the "Altera Frame Reader IP Core"
-ED060SC4 - E-Ink display
-framebuffer - Supports any non-palletized, non-bitpacked color display with a framebuffer
-Fb24bpp - Same as 'framebuffer' driver but supports RGB888 and BGR888 packed framebuffer formats.
-HX8347D - Mid-sized color LCD displays eg RGB565 320x240
-ILI9320 - Mid-sized color LCD displays eg RGB565 320x240
-ILI9325 - Mid-sized color LCD displays eg RGB565 320x240
-ILI9341 - Mid-sized color LCD displays eg RGB565 320x240
-ILI9342 - Mid-sized color LCD displays eg RGB565 320x240
-ILI93xx - Mid-sized color LCD displays eg RGB565 320x240 (attempt at a common driver)
-ILI9481 - Mid-sized color LCD displays eg RGB565 320x240
-LGDP4532 - Mid-sized color LCD displays eg RGB565 320x240
-Nokia6610GE8 - Small (130x130) 12bit color LCD
-Nokia6610GE12 - Small (130x130) 12bit color LCD (untested)
-PCD8544 - Small monochrome LCD
-PCF8812 - Small monochrome LCD
-R61505U - Mid-sized color LCD displays eg RGB565 320x240
-RA8875 - Mid-sized color LCD displays eg RGB565 320x240
-S6D1121 - Mid-sized color LCD displays eg RGB565 320x240
-SPFD54124B - Mid-sized color LCD displays eg RGB565 320x240
-SSD1289 - Mid-sized color LCD displays eg RGB565 320x240
-SSD1306 - Small monochrome LCD
-SSD1331 - Small hardware accelerated OLED display RGB565 96x64
-SSD1351 - Mid-sized color LCD displays eg RGB565 320x240
-SSD1848 - Small grayscale LCD eg 2-Bit 130x130
-SSD1963 - Mid-sized color LCD displays eg RGB565 320x240
-SSD2119 - Mid-sized color LCD displays eg RGB565 320x240
-ST7565 - Small monochrome LCD
-STM32LTDC - STM32 ART graphics STM32F4 and STM32F7 series CPU's
-TestStub - NULL driver just to test compile
-TLS8204 - Small monochrome LCD
-UC8173 - E-Ink display driver
-UC1601s - Small (64x132) monochrome LCD
-QImage - Driver that allows rendering into a QImage object (of the Qt framework)
-uGFXnet - Remote Network display (in drivers/multiple/uGFXnet directory)
-Win32 - Microsoft Windows (in drivers/multiple/Win32 directory)
-X - X Windows (Xlib) (in drivers/multiple/X directory)
+A list of current display drivers:
+
+AlteraFramereader - Support for the "Altera Frame Reader IP Core"
+ED060SC4 - E-Ink display
+framebuffer - Supports any non-palletized, non-bitpacked color display with a framebuffer
+Fb24bpp - Same as 'framebuffer' driver but supports RGB888 and BGR888 packed framebuffer formats.
+HX8347D - Mid-sized color LCD displays eg RGB565 320x240
+ILI9320 - Mid-sized color LCD displays eg RGB565 320x240
+ILI9325 - Mid-sized color LCD displays eg RGB565 320x240
+ILI9341 - Mid-sized color LCD displays eg RGB565 320x240
+ILI9342 - Mid-sized color LCD displays eg RGB565 320x240
+ILI93xx - Mid-sized color LCD displays eg RGB565 320x240 (attempt at a common driver)
+ILI9481 - Mid-sized color LCD displays eg RGB565 320x240
+KS0108 - Small monochrome LCD
+LGDP4532 - Mid-sized color LCD displays eg RGB565 320x240
+Nokia6610GE8 - Small (130x130) 12bit color LCD
+Nokia6610GE12 - Small (130x130) 12bit color LCD (untested)
+PCD8544 - Small monochrome LCD
+PCF8812 - Small monochrome LCD
+R61505U - Mid-sized color LCD displays eg RGB565 320x240
+RA6963 - Small monochrom LCD
+RA8875 - Mid-sized color LCD displays eg RGB565 320x240
+S6D1121 - Mid-sized color LCD displays eg RGB565 320x240
+SPFD54124B - Mid-sized color LCD displays eg RGB565 320x240
+SSD1289 - Mid-sized color LCD displays eg RGB565 320x240
+SSD1306 - Small monochrome LCD
+SSD1331 - Small hardware accelerated OLED display RGB565 96x64
+SSD1351 - Mid-sized color LCD displays eg RGB565 320x240
+SSD1848 - Small grayscale LCD eg 2-Bit 130x130
+SSD1963 - Mid-sized color LCD displays eg RGB565 320x240
+SSD2119 - Mid-sized color LCD displays eg RGB565 320x240
+ST7565 - Small monochrome LCD
+STM32LTDC - STM32 ART graphics STM32F4 and STM32F7 series CPU's
+TestStub - NULL driver just to test compile
+TLS8204 - Small monochrome LCD
+UC8173 - E-Ink display driver
+UC1601s - Small (64x132) monochrome LCD
+QImage - Driver that allows rendering into a QImage object (of the Qt framework)
+uGFXnet - Remote Network display (in drivers/multiple/uGFXnet directory)
+Win32 - Microsoft Windows (in drivers/multiple/Win32 directory)
+X - X Windows (Xlib) (in drivers/multiple/X directory)