Updating SSD1963 driver
This commit is contained in:
parent
052a8e033c
commit
6ff7d90500
@ -16,6 +16,7 @@
|
|||||||
#define CALC_PERIOD(w,b,f,p) (p+b+w+f)
|
#define CALC_PERIOD(w,b,f,p) (p+b+w+f)
|
||||||
#define CALC_FPR(w,h,hb,hf,hp,vb,vf,vp,fps) ((fps * CALC_PERIOD(w,hb,hf,hp) * CALC_PERIOD(h,vb,vf,vp) * 1048576)/100000000)
|
#define CALC_FPR(w,h,hb,hf,hp,vb,vf,vp,fps) ((fps * CALC_PERIOD(w,hb,hf,hp) * CALC_PERIOD(h,vb,vf,vp) * 1048576)/100000000)
|
||||||
|
|
||||||
|
|
||||||
typedef struct LCD_Parameters {
|
typedef struct LCD_Parameters {
|
||||||
coord_t width, height; // Panel width and height
|
coord_t width, height; // Panel width and height
|
||||||
uint16_t hbporch; // Horizontal Back Porch
|
uint16_t hbporch; // Horizontal Back Porch
|
||||||
@ -27,6 +28,26 @@ typedef struct LCD_Parameters {
|
|||||||
uint16_t vpulse; // Vertical Pulse
|
uint16_t vpulse; // Vertical Pulse
|
||||||
uint16_t vperiod; // Vertical Period (Total)
|
uint16_t vperiod; // Vertical Period (Total)
|
||||||
uint32_t fpr; // Calculated FPR
|
uint32_t fpr; // Calculated FPR
|
||||||
|
uint16_t flags; // For command "SSD1963_SET_GDISP_MODE"
|
||||||
|
/* Set the pannel data width */
|
||||||
|
#define LCD_PANEL_DATA_WIDTH_24BIT (1<<5) // 18bit default
|
||||||
|
/* Set the color deeph enhancement */
|
||||||
|
#define LCD_PANEL_ENABLE_FRC ((1<<3) | (1<<4))
|
||||||
|
#define LCD_PANEL_ENABLE_DITHERING (1<<4) // no enhancement default
|
||||||
|
/* Set the dot clock pulse polarity */
|
||||||
|
#define LCD_PANEL_LSHIFT_FALLING_EDGE (1<<2) // default rising edge
|
||||||
|
/* Set the horizontal sync pulse polarity */
|
||||||
|
#define LCD_PANEL_LLINE_ACTIVE_HIGH (1<<1) // default active low
|
||||||
|
/* Set the vertical sync pulse polarity */
|
||||||
|
#define LCD_PANEL_LFRAME_ACTIVE_HIGH (1<0) // default active low
|
||||||
|
/* Set the lcd panel mode */
|
||||||
|
#define LCD_PANEL_MODE_TTL ((1<<7) << 8) // default mode is Hsync+Vsync +DE
|
||||||
|
/* Set the lcd panel interface type */ // default TFT mode
|
||||||
|
#define LCD_PANEL_TYPE_SERIAL_RGB_MODE ((1<<6) << 8) // Serial RGB mode
|
||||||
|
#define LCD_PANEL_TYPE_SERIAL_RGB_DUMMY_MODE (((1<<5) | (1<<6)) << 8) // Serial RGB+dummy mode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} LCD_Parameters;
|
} LCD_Parameters;
|
||||||
|
|
||||||
#include "board_SSD1963.h"
|
#include "board_SSD1963.h"
|
||||||
@ -48,17 +69,55 @@ typedef struct LCD_Parameters {
|
|||||||
|
|
||||||
#include "drivers/gdisp/SSD1963/ssd1963.h"
|
#include "drivers/gdisp/SSD1963/ssd1963.h"
|
||||||
|
|
||||||
|
#define dummy_read(g) { volatile uint16_t dummy; dummy = read_data(g); (void) dummy; }
|
||||||
#define write_reg(g, reg, data) { write_index(g, reg); write_data(g, data); }
|
#define write_reg(g, reg, data) { write_index(g, reg); write_data(g, data); }
|
||||||
#define write_data16(g, data) { write_data(g, (data)>>8); write_data(g, (data) & 0xFF); }
|
#define write_data16(g, data) { write_data(g, (data)>>8); write_data(g, (data) & 0xFF); }
|
||||||
|
|
||||||
static inline void set_viewport(GDisplay* g) {
|
static inline void set_viewport(GDisplay* g) {
|
||||||
write_index(g, SSD1963_SET_PAGE_ADDRESS);
|
|
||||||
write_data16(g, g->p.y);
|
switch(g->g.Orientation) {
|
||||||
write_data16(g, g->p.y+g->p.cy-1);
|
default:
|
||||||
write_index(g, SSD1963_SET_COLUMN_ADDRESS);
|
case GDISP_ROTATE_0:
|
||||||
write_data16(g, g->p.x);
|
write_index(g, SSD1963_SET_COLUMN_ADDRESS);
|
||||||
write_data16(g, g->p.x+g->p.cx-1);
|
write_data16(g, g->p.x);
|
||||||
write_index(g, SSD1963_WRITE_MEMORY_START);
|
write_data16(g, g->p.x+g->p.cx-1);
|
||||||
|
write_index(g, SSD1963_SET_PAGE_ADDRESS);
|
||||||
|
write_data16(g, g->p.y);
|
||||||
|
write_data16(g, g->p.y+g->p.cy-1);
|
||||||
|
write_index(g, SSD1963_WRITE_MEMORY_START);
|
||||||
|
break;
|
||||||
|
case GDISP_ROTATE_90:
|
||||||
|
write_index(g, SSD1963_SET_COLUMN_ADDRESS);
|
||||||
|
write_data16(g, g->p.y);
|
||||||
|
write_data16(g, g->p.y+g->p.cy-1);
|
||||||
|
write_index(g, SSD1963_SET_PAGE_ADDRESS);
|
||||||
|
write_data16(g, GDISP_SCREEN_HEIGHT-1 - (g->p.x+g->p.cx-1) );
|
||||||
|
write_data16(g, GDISP_SCREEN_HEIGHT-1 - (g->p.x));
|
||||||
|
write_index(g, SSD1963_WRITE_MEMORY_START);
|
||||||
|
break;
|
||||||
|
case GDISP_ROTATE_180:
|
||||||
|
write_index(g, SSD1963_SET_COLUMN_ADDRESS);
|
||||||
|
write_data16(g, GDISP_SCREEN_WIDTH-1 - (g->p.x+g->p.cx-1));
|
||||||
|
write_data16(g, GDISP_SCREEN_WIDTH-1 - (g->p.x));
|
||||||
|
write_index(g, SSD1963_SET_PAGE_ADDRESS);
|
||||||
|
write_data16(g, GDISP_SCREEN_HEIGHT-1 - (g->p.y+g->p.cy-1));
|
||||||
|
write_data16(g, GDISP_SCREEN_HEIGHT-1 - (g->p.y));
|
||||||
|
write_index(g, SSD1963_WRITE_MEMORY_START);
|
||||||
|
break;
|
||||||
|
case GDISP_ROTATE_270:
|
||||||
|
write_index(g, SSD1963_SET_COLUMN_ADDRESS);
|
||||||
|
write_data16(g, GDISP_SCREEN_WIDTH-1 - (g->p.y+g->p.cy-1));
|
||||||
|
write_data16(g, GDISP_SCREEN_WIDTH-1 - (g->p.y));
|
||||||
|
write_index(g, SSD1963_SET_PAGE_ADDRESS);
|
||||||
|
write_data16(g, g->p.x);
|
||||||
|
write_data16(g, g->p.x+g->p.cx-1);
|
||||||
|
write_index(g, SSD1963_WRITE_MEMORY_START);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,12 +130,18 @@ static inline void set_backlight(GDisplay *g, uint8_t percent) {
|
|||||||
//Check your LCD's hardware, the PWM connection is default left open and instead
|
//Check your LCD's hardware, the PWM connection is default left open and instead
|
||||||
//connected to a LED connection on the breakout board
|
//connected to a LED connection on the breakout board
|
||||||
write_index(g, SSD1963_SET_PWM_CONF); //set PWM for BackLight
|
write_index(g, SSD1963_SET_PWM_CONF); //set PWM for BackLight
|
||||||
write_data(g, 0x01);
|
write_data(g, 4); // PWMF[7:0] = 4,
|
||||||
write_data(g, (55+percent*2) & 0x00FF);
|
// PWM signal frequency = PLL clock / (256 * (PWMF[7:0] + 1)) / 256
|
||||||
write_data(g, 0x01); //controlled by host (not DBC), enabled
|
// = aprox 366Hz for a PLL freq = 120MHz
|
||||||
write_data(g, 0xFF);
|
if ( percent==0xFF ) // use percent==0xFF to turn off SSD1963 pwm in power SLEEP or DEEP SLEEP mode
|
||||||
write_data(g, 0x60); //don't let it go too dark, avoid a useless LCD
|
write_data(g, 0x00);
|
||||||
write_data(g, 0x0F); //prescaler ???
|
else
|
||||||
|
write_data(g, (55+percent*2) & 0x00FF);
|
||||||
|
write_data(g, 0x01); // controlled by host (not DBC), enabled
|
||||||
|
write_data(g, 0x00); // DBC manual brightness; Set the brightness level: 00 Dimmest, FF Brightest
|
||||||
|
write_data(g, 0x00); // DBC minimum brightness; Set the minimum brightness level: 00 Dimmest, FF Brightest
|
||||||
|
write_data(g, 0x00); // Brightness prescaler of Transition Effect; Set the brightness prescaler: 0 Dimmest, F Brightest
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
@ -121,10 +186,10 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
|||||||
write_index(g, SSD1963_SOFT_RESET);
|
write_index(g, SSD1963_SOFT_RESET);
|
||||||
gfxSleepMilliseconds(5);
|
gfxSleepMilliseconds(5);
|
||||||
|
|
||||||
/* Screen size */
|
/* LCD panel parameters */
|
||||||
write_index(g, SSD1963_SET_GDISP_MODE);
|
write_index(g, SSD1963_SET_GDISP_MODE);
|
||||||
write_data(g, 0x18); //Enabled dithering
|
write_data(g, lcdp->flags & 0xFF);
|
||||||
write_data(g, 0x00);
|
write_data(g, (lcdp->flags >> 8) & 0xFF);
|
||||||
write_data16(g, lcdp->width-1);
|
write_data16(g, lcdp->width-1);
|
||||||
write_data16(g, lcdp->height-1);
|
write_data16(g, lcdp->height-1);
|
||||||
write_data(g, 0x00); // RGB
|
write_data(g, 0x00); // RGB
|
||||||
@ -155,9 +220,10 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
|||||||
/* Tear effect indicator ON. This is used to tell the host MCU when the driver is not refreshing the panel (during front/back porch) */
|
/* Tear effect indicator ON. This is used to tell the host MCU when the driver is not refreshing the panel (during front/back porch) */
|
||||||
write_reg(g, SSD1963_SET_TEAR_ON, 0x00);
|
write_reg(g, SSD1963_SET_TEAR_ON, 0x00);
|
||||||
|
|
||||||
|
|
||||||
/* Turn on */
|
/* Turn on */
|
||||||
write_index(g, SSD1963_SET_DISPLAY_ON);
|
write_index(g, SSD1963_SET_DISPLAY_ON);
|
||||||
|
|
||||||
/* Turn on the back-light */
|
/* Turn on the back-light */
|
||||||
set_backlight(g, GDISP_INITIAL_BACKLIGHT);
|
set_backlight(g, GDISP_INITIAL_BACKLIGHT);
|
||||||
|
|
||||||
@ -190,8 +256,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Not implemented yet.
|
#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
|
||||||
#if 0 && GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
|
|
||||||
LLDSPEC void gdisp_lld_control(GDisplay *g) {
|
LLDSPEC void gdisp_lld_control(GDisplay *g) {
|
||||||
switch(g->p.x) {
|
switch(g->p.x) {
|
||||||
case GDISP_CONTROL_POWER:
|
case GDISP_CONTROL_POWER:
|
||||||
@ -200,23 +265,34 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
|||||||
switch((powermode_t)g->p.ptr) {
|
switch((powermode_t)g->p.ptr) {
|
||||||
case powerOff:
|
case powerOff:
|
||||||
acquire_bus(g);
|
acquire_bus(g);
|
||||||
write_index(g, SSD1963_EXIT_SLEEP_MODE); // leave sleep mode
|
|
||||||
gfxSleepMilliseconds(5);
|
|
||||||
write_index(g, SSD1963_SET_DISPLAY_OFF);
|
|
||||||
write_index(g, SSD1963_SET_DEEP_SLEEP); // enter deep sleep mode
|
|
||||||
release_bus(g);
|
release_bus(g);
|
||||||
break;
|
break;
|
||||||
case powerOn:
|
case powerOn:
|
||||||
acquire_bus(g);
|
acquire_bus(g);
|
||||||
read_reg(0x0000); gfxSleepMilliseconds(5); // 2x Dummy reads to wake up from deep sleep
|
dummy_read(g);
|
||||||
read_reg(0x0000); gfxSleepMilliseconds(5);
|
dummy_read(g);
|
||||||
write_index(g, SSD1963_SET_DISPLAY_ON);
|
/* Wait for 1msec to let the PLL stable if was stopped by deep sleep mode */
|
||||||
|
gfxSleepMilliseconds(100);
|
||||||
|
write_index(g, SSD1963_EXIT_SLEEP_MODE);
|
||||||
|
gfxSleepMilliseconds(5);
|
||||||
|
/* Restore the back-light */
|
||||||
|
set_backlight(g, gdispGGetBacklight(g));
|
||||||
release_bus(g);
|
release_bus(g);
|
||||||
break;
|
break;
|
||||||
case powerSleep:
|
case powerSleep:
|
||||||
acquire_bus(g);
|
acquire_bus(g);
|
||||||
write_index(g, SSD1963_SET_DISPLAY_OFF);
|
/* Turn off the back-light pwm from SSD1963 */
|
||||||
write_index(g, SSD1963_ENTER_SLEEP_MODE); // enter sleep mode
|
set_backlight(g, 0xFF);
|
||||||
|
write_index(g, SSD1963_ENTER_SLEEP_MODE);
|
||||||
|
gfxSleepMilliseconds(5);
|
||||||
|
release_bus(g);
|
||||||
|
break;
|
||||||
|
case powerDeepSleep:
|
||||||
|
acquire_bus(g);
|
||||||
|
/* Turn off the back-light pwm from SSD1963 */
|
||||||
|
set_backlight(g, 0xFF);
|
||||||
|
write_index(g, SSD1963_ENTER_SLEEP_MODE);
|
||||||
|
write_index(g, SSD1963_SET_DEEP_SLEEP);
|
||||||
release_bus(g);
|
release_bus(g);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -228,30 +304,35 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
|||||||
case GDISP_CONTROL_ORIENTATION:
|
case GDISP_CONTROL_ORIENTATION:
|
||||||
if (g->g.Orientation == (orientation_t)g->p.ptr)
|
if (g->g.Orientation == (orientation_t)g->p.ptr)
|
||||||
return;
|
return;
|
||||||
|
switch((orientation_t)g->p.ptr) {
|
||||||
case GDISP_ROTATE_0:
|
case GDISP_ROTATE_0:
|
||||||
acquire_bus(g);
|
acquire_bus(g);
|
||||||
/* Code here */
|
write_index(g, SSD1963_SET_ADDRESS_MODE);
|
||||||
|
write_data(g, 0x00);
|
||||||
release_bus(g);
|
release_bus(g);
|
||||||
g->g.Height = ((LCD_Parameters *)g->priv)->height;
|
g->g.Height = ((LCD_Parameters *)g->priv)->height;
|
||||||
g->g.Width = ((LCD_Parameters *)g->priv)->width;
|
g->g.Width = ((LCD_Parameters *)g->priv)->width;
|
||||||
break;
|
break;
|
||||||
case GDISP_ROTATE_90:
|
case GDISP_ROTATE_90:
|
||||||
acquire_bus(g);
|
acquire_bus(g);
|
||||||
/* Code here */
|
write_index(g, SSD1963_SET_ADDRESS_MODE);
|
||||||
|
write_data(g, SSD1963_ADDR_MODE_PAGE_ADDR_ORDER | SSD1963_ADDR_MODE_PAG_COL_ADDR_ORDER );
|
||||||
release_bus(g);
|
release_bus(g);
|
||||||
g->g.Height = ((LCD_Parameters *)g->priv)->width;
|
g->g.Height = ((LCD_Parameters *)g->priv)->width;
|
||||||
g->g.Width = ((LCD_Parameters *)g->priv)->height;
|
g->g.Width = ((LCD_Parameters *)g->priv)->height;
|
||||||
break;
|
break;
|
||||||
case GDISP_ROTATE_180:
|
case GDISP_ROTATE_180:
|
||||||
acquire_bus(g);
|
acquire_bus(g);
|
||||||
/* Code here */
|
write_index(g, SSD1963_SET_ADDRESS_MODE);
|
||||||
|
write_data(g, SSD1963_ADDR_MODE_PAGE_ADDR_ORDER | SSD1963_ADDR_MODE_COL_ADDR_ORDER);
|
||||||
release_bus(g);
|
release_bus(g);
|
||||||
g->g.Height = ((LCD_Parameters *)g->priv)->height;
|
g->g.Height = ((LCD_Parameters *)g->priv)->height;
|
||||||
g->g.Width = ((LCD_Parameters *)g->priv)->width;
|
g->g.Width = ((LCD_Parameters *)g->priv)->width;
|
||||||
break;
|
break;
|
||||||
case GDISP_ROTATE_270:
|
case GDISP_ROTATE_270:
|
||||||
acquire_bus(g);
|
acquire_bus(g);
|
||||||
/* Code here */
|
write_index(g, SSD1963_SET_ADDRESS_MODE);
|
||||||
|
write_data(g, SSD1963_ADDR_MODE_COL_ADDR_ORDER | SSD1963_ADDR_MODE_PAG_COL_ADDR_ORDER );
|
||||||
release_bus(g);
|
release_bus(g);
|
||||||
g->g.Height = ((LCD_Parameters *)g->priv)->width;
|
g->g.Height = ((LCD_Parameters *)g->priv)->width;
|
||||||
g->g.Width = ((LCD_Parameters *)g->priv)->height;
|
g->g.Width = ((LCD_Parameters *)g->priv)->height;
|
||||||
@ -259,7 +340,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
|||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
g->g.Orientation = (orientation_t)g->p.ptr;
|
g->g.Orientation = (orientation_t)g->p.ptr;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case GDISP_CONTROL_BACKLIGHT:
|
case GDISP_CONTROL_BACKLIGHT:
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
#define GDISP_HARDWARE_STREAM_WRITE TRUE
|
#define GDISP_HARDWARE_STREAM_WRITE TRUE
|
||||||
//#define GDISP_HARDWARE_CONTROL TRUE // Not Yet.
|
#define GDISP_HARDWARE_CONTROL TRUE
|
||||||
|
|
||||||
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
|
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
|
||||||
|
|
||||||
|
@ -93,4 +93,13 @@
|
|||||||
#define SSD1963_PDI_9BIT 6
|
#define SSD1963_PDI_9BIT 6
|
||||||
#define SSD1963_GET_PIXEL_DATA_INTERFACE 0x00F1
|
#define SSD1963_GET_PIXEL_DATA_INTERFACE 0x00F1
|
||||||
|
|
||||||
|
#define SSD1963_ADDR_MODE_FLIP_VERT (1 << 0)
|
||||||
|
#define SSD1963_ADDR_MODE_FLIP_HORZ (1 << 1)
|
||||||
|
#define SSD1963_ADDR_MODE_LATCH_RIGHT_TO_LEFT (1 << 2)
|
||||||
|
#define SSD1963_ADDR_MODE_BGR (1 << 3)
|
||||||
|
#define SSD1963_ADDR_MODE_REFRESH_BOTTOM_UP (1 << 4)
|
||||||
|
#define SSD1963_ADDR_MODE_PAG_COL_ADDR_ORDER (1 << 5)
|
||||||
|
#define SSD1963_ADDR_MODE_COL_ADDR_ORDER (1 << 6)
|
||||||
|
#define SSD1963_ADDR_MODE_PAGE_ADDR_ORDER (1 << 7)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user