Rename GDISP driver files to prevent problems when compiling for multiple controllers on platforms that put all generated object files into a single directory.

ugfx_release_2.6
inmarket 2013-10-28 11:03:39 +10:00
parent 9e5ed28f98
commit b05a29f830
36 changed files with 886 additions and 886 deletions

View File

@ -1,2 +1,2 @@
GFXINC += $(GFXLIB)/drivers/gdisp/ED060SC4
GFXSRC += $(GFXLIB)/drivers/gdisp/ED060SC4/gdisp_lld.c
GFXSRC += $(GFXLIB)/drivers/gdisp/ED060SC4/gdisp_lld_ED060SC4.c

View File

@ -1,2 +1,2 @@
GFXINC += $(GFXLIB)/drivers/gdisp/HX8347D
GFXSRC += $(GFXLIB)/drivers/gdisp/HX8347D/gdisp_lld.c
GFXSRC += $(GFXLIB)/drivers/gdisp/HX8347D/gdisp_lld_HX8347D.c

View File

@ -1,236 +1,236 @@
/*
* 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
*/
/**
* @file drivers/gdisp/HX8347D/gdisp_lld.c
* @brief GDISP Graphics Driver subsystem low level driver source for the HX8347D display.
*/
#include "gfx.h"
#if GFX_USE_GDISP
#define GDISP_DRIVER_VMT GDISPVMT_HX8347D
#include "../drivers/gdisp/HX8347D/gdisp_lld_config.h"
#include "gdisp/lld/gdisp_lld.h"
#include "board_HX8347D.h"
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
#ifndef GDISP_SCREEN_HEIGHT
#define GDISP_SCREEN_HEIGHT 320
#endif
#ifndef GDISP_SCREEN_WIDTH
#define GDISP_SCREEN_WIDTH 240
#endif
#ifndef GDISP_INITIAL_CONTRAST
#define GDISP_INITIAL_CONTRAST 50
#endif
#ifndef GDISP_INITIAL_BACKLIGHT
#define GDISP_INITIAL_BACKLIGHT 100
#endif
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
#include "../drivers/gdisp/HX8347D/HX8347D.h"
#define write_reg(g, reg, data) { write_index(g, reg); write_data(g, data); }
static inline void set_viewport(GDisplay* g) {
write_reg(g, HX8347D_REG_SCL, g->p.x);
write_reg(g, HX8347D_REG_SCH, g->p.x >> 8);
write_reg(g, HX8347D_REG_ECL, g->p.x + g->p.cx -1);
write_reg(g, HX8347D_REG_ECH, (g->p.x + g->p.cx -1) >> 8);
write_reg(g, HX8347D_REG_SPL, g->p.y);
write_reg(g, HX8347D_REG_SPH, g->p.y >> 8);
write_reg(g, HX8347D_REG_EPL, g->p.y + g->p.cy -1);
write_reg(g, HX8347D_REG_EPH, (g->p.y + g->p.cy -1) >> 8);
write_index(g, HX8347D_REG_SRAMWC);
}
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
// No private area for this controller
g->priv = 0;
// Initialise the board interface
init_board(g);
// Hardware reset
setpin_reset(g, TRUE);
gfxSleepMilliseconds(1);
setpin_reset(g, FALSE);
gfxSleepMilliseconds(5);
// Get the bus for the following initialisation commands
acquire_bus(g);
/* Start Initial Sequence ----------------------------------------------------*/
write_reg(g, HX8347D_REG_STBAH, 0x00); /* Reset Power Control 1 */
write_reg(g, HX8347D_REG_STBAL, 0x20); /* Power Control 2 */
write_reg(g, HX8347D_REG_PTBAH, 0x0C); /* Power Control 1 */
write_reg(g, HX8347D_REG_PTBAL, 0xC4); /* Power Control 2 */
write_reg(g, HX8347D_REG_OPONN, 0x40); /* Source OPON_N */
write_reg(g, HX8347D_REG_OPONI, 0x38); /* Source OPON_I */
write_reg(g, HX8347D_REG_DC2, 0xA3); /* Display Control 2 */
/* Power On sequence ---------------------------------------------------------*/
write_reg(g, HX8347D_REG_PWC2, 0x1B); /* Power Control 2 */
write_reg(g, HX8347D_REG_PWC1, 0x01); /* Power Control 1 */
write_reg(g, HX8347D_REG_VMH, 0x2F); /* Vcom Control 2 */
write_reg(g, HX8347D_REG_VML, 0x57); /* Vcom Control 3 */
write_reg(g, HX8347D_REG_VMF, 0x8D); /* Vcom Control 1 */
/* Gamma settings -----------------------------------------------------------*/
write_reg(g, HX8347D_REG_VRP0, 0x01); // default setup
write_reg(g, HX8347D_REG_VRP1, 0x0e); //
write_reg(g, HX8347D_REG_VRP2, 0x11); //
write_reg(g, HX8347D_REG_VRP3, 0x1a); //
write_reg(g, HX8347D_REG_VRP4, 0x18); //
write_reg(g, HX8347D_REG_VRP5, 0x24); //
write_reg(g, HX8347D_REG_PRP0, 0x15); //
write_reg(g, HX8347D_REG_PRP1, 0x65); //
write_reg(g, HX8347D_REG_PKP0, 0x0b); //
write_reg(g, HX8347D_REG_PKP1, 0x18); //
write_reg(g, HX8347D_REG_PKP2, 0x19); //
write_reg(g, HX8347D_REG_PKP3, 0x1a); //
write_reg(g, HX8347D_REG_PKP4, 0x18); //
write_reg(g, HX8347D_REG_VRN0, 0x1b); //
write_reg(g, HX8347D_REG_VRN1, 0x27); //
write_reg(g, HX8347D_REG_VRN2, 0x25); //
write_reg(g, HX8347D_REG_VRN3, 0x2e); //
write_reg(g, HX8347D_REG_VRN4, 0x31); //
write_reg(g, HX8347D_REG_VRN5, 0x3e); //
write_reg(g, HX8347D_REG_PRN0, 0x1a); //
write_reg(g, HX8347D_REG_PRN1, 0x6a); //
write_reg(g, HX8347D_REG_PKN0, 0x07); //
write_reg(g, HX8347D_REG_PKN1, 0x05); //
write_reg(g, HX8347D_REG_PKN2, 0x06); //
write_reg(g, HX8347D_REG_PKN3, 0x0b); //
write_reg(g, HX8347D_REG_PKN4, 0x14); //
write_reg(g, HX8347D_REG_CGM, 0xcc); //
/* Power + Osc ---------------------------------------------------------------*/
write_reg(g, HX8347D_REG_OSCCH, 0x36); /* OSC Control 1 */
write_reg(g, HX8347D_REG_OSCCL, 0x01); /* OSC Control 2 */
write_reg(g, HX8347D_REG_DMODE, 0x00); /* Display Mode Control */
write_reg(g, HX8347D_REG_PWC6, 0x88); /* Power Control 6 */
gfxSleepMilliseconds(5); /* Delay 5 ms */
write_reg(g, HX8347D_REG_PWC6, 0x80); /* Power Control 6 */
gfxSleepMilliseconds(5); /* Delay 5 ms */
write_reg(g, HX8347D_REG_PWC6, 0x90); /* Power Control 6 */
gfxSleepMilliseconds(5); /* Delay 5 ms */
write_reg(g, HX8347D_REG_PWC6, 0xD0); /* Power Control 6 */
gfxSleepMilliseconds(5); /* Delay 5 ms */
write_reg(g, HX8347D_REG_COLMOD, 0x05); /* Colmod 16Bit/Pixel */
write_reg(g, HX8347D_REG_PCH, 0x00); /* Panel Characteristic */
write_reg(g, HX8347D_REG_DC3, 0x38); /* Display Control 3 */
gfxSleepMilliseconds(40); /* Delay 40 ms */
write_reg(g, HX8347D_REG_DC3, 0x3C); /* Display Control 3 */
write_reg(g, HX8347D_REG_MAC, 0x08); /* Memory access control */
// Finish Init
post_init_board(g);
// Release the bus
release_bus(g);
/* Turn on the backlight */
set_backlight(g, GDISP_INITIAL_BACKLIGHT);
/* 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;
}
#if GDISP_HARDWARE_STREAM_WRITE
LLDSPEC void gdisp_lld_write_start(GDisplay *g) {
acquire_bus(g);
set_viewport(g);
busmode16(g);
}
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
write_ram16(g, g->p.color);
}
LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
busmode8(g);
release_bus(g);
}
#endif
#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
LLDSPEC void gdisp_lld_control(GDisplay *g) {
switch(g->p.x) {
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_reg(g, HX8347D_REG_MAC, 0x08); /* Memory access control */
release_bus(g);
g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_90:
acquire_bus(g);
write_reg(g, HX8347D_REG_MAC, 0x68); /* Memory access control */
release_bus(g);
g->g.Height = GDISP_SCREEN_WIDTH;
g->g.Width = GDISP_SCREEN_HEIGHT;
break;
case GDISP_ROTATE_180:
acquire_bus(g);
write_reg(g, HX8347D_REG_MAC, 0xc8); /* Memory access control */
release_bus(g);
g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_270:
acquire_bus(g);
write_reg(g, HX8347D_REG_MAC, 0xa8); /* Memory access control */
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;
case GDISP_CONTROL_BACKLIGHT:
if ((unsigned)g->p.ptr > 100)
g->p.ptr = (void *)100;
set_backlight(g, (unsigned)g->p.ptr);
g->g.Backlight = (unsigned)g->p.ptr;
return;
default:
return;
}
}
#endif
#endif /* GFX_USE_GDISP */
/*
* 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
*/
/**
* @file drivers/gdisp/HX8347D/gdisp_lld.c
* @brief GDISP Graphics Driver subsystem low level driver source for the HX8347D display.
*/
#include "gfx.h"
#if GFX_USE_GDISP
#define GDISP_DRIVER_VMT GDISPVMT_HX8347D
#include "../drivers/gdisp/HX8347D/gdisp_lld_config.h"
#include "gdisp/lld/gdisp_lld.h"
#include "board_HX8347D.h"
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
#ifndef GDISP_SCREEN_HEIGHT
#define GDISP_SCREEN_HEIGHT 320
#endif
#ifndef GDISP_SCREEN_WIDTH
#define GDISP_SCREEN_WIDTH 240
#endif
#ifndef GDISP_INITIAL_CONTRAST
#define GDISP_INITIAL_CONTRAST 50
#endif
#ifndef GDISP_INITIAL_BACKLIGHT
#define GDISP_INITIAL_BACKLIGHT 100
#endif
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
#include "../drivers/gdisp/HX8347D/HX8347D.h"
#define write_reg(g, reg, data) { write_index(g, reg); write_data(g, data); }
static inline void set_viewport(GDisplay* g) {
write_reg(g, HX8347D_REG_SCL, g->p.x);
write_reg(g, HX8347D_REG_SCH, g->p.x >> 8);
write_reg(g, HX8347D_REG_ECL, g->p.x + g->p.cx -1);
write_reg(g, HX8347D_REG_ECH, (g->p.x + g->p.cx -1) >> 8);
write_reg(g, HX8347D_REG_SPL, g->p.y);
write_reg(g, HX8347D_REG_SPH, g->p.y >> 8);
write_reg(g, HX8347D_REG_EPL, g->p.y + g->p.cy -1);
write_reg(g, HX8347D_REG_EPH, (g->p.y + g->p.cy -1) >> 8);
write_index(g, HX8347D_REG_SRAMWC);
}
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
// No private area for this controller
g->priv = 0;
// Initialise the board interface
init_board(g);
// Hardware reset
setpin_reset(g, TRUE);
gfxSleepMilliseconds(1);
setpin_reset(g, FALSE);
gfxSleepMilliseconds(5);
// Get the bus for the following initialisation commands
acquire_bus(g);
/* Start Initial Sequence ----------------------------------------------------*/
write_reg(g, HX8347D_REG_STBAH, 0x00); /* Reset Power Control 1 */
write_reg(g, HX8347D_REG_STBAL, 0x20); /* Power Control 2 */
write_reg(g, HX8347D_REG_PTBAH, 0x0C); /* Power Control 1 */
write_reg(g, HX8347D_REG_PTBAL, 0xC4); /* Power Control 2 */
write_reg(g, HX8347D_REG_OPONN, 0x40); /* Source OPON_N */
write_reg(g, HX8347D_REG_OPONI, 0x38); /* Source OPON_I */
write_reg(g, HX8347D_REG_DC2, 0xA3); /* Display Control 2 */
/* Power On sequence ---------------------------------------------------------*/
write_reg(g, HX8347D_REG_PWC2, 0x1B); /* Power Control 2 */
write_reg(g, HX8347D_REG_PWC1, 0x01); /* Power Control 1 */
write_reg(g, HX8347D_REG_VMH, 0x2F); /* Vcom Control 2 */
write_reg(g, HX8347D_REG_VML, 0x57); /* Vcom Control 3 */
write_reg(g, HX8347D_REG_VMF, 0x8D); /* Vcom Control 1 */
/* Gamma settings -----------------------------------------------------------*/
write_reg(g, HX8347D_REG_VRP0, 0x01); // default setup
write_reg(g, HX8347D_REG_VRP1, 0x0e); //
write_reg(g, HX8347D_REG_VRP2, 0x11); //
write_reg(g, HX8347D_REG_VRP3, 0x1a); //
write_reg(g, HX8347D_REG_VRP4, 0x18); //
write_reg(g, HX8347D_REG_VRP5, 0x24); //
write_reg(g, HX8347D_REG_PRP0, 0x15); //
write_reg(g, HX8347D_REG_PRP1, 0x65); //
write_reg(g, HX8347D_REG_PKP0, 0x0b); //
write_reg(g, HX8347D_REG_PKP1, 0x18); //
write_reg(g, HX8347D_REG_PKP2, 0x19); //
write_reg(g, HX8347D_REG_PKP3, 0x1a); //
write_reg(g, HX8347D_REG_PKP4, 0x18); //
write_reg(g, HX8347D_REG_VRN0, 0x1b); //
write_reg(g, HX8347D_REG_VRN1, 0x27); //
write_reg(g, HX8347D_REG_VRN2, 0x25); //
write_reg(g, HX8347D_REG_VRN3, 0x2e); //
write_reg(g, HX8347D_REG_VRN4, 0x31); //
write_reg(g, HX8347D_REG_VRN5, 0x3e); //
write_reg(g, HX8347D_REG_PRN0, 0x1a); //
write_reg(g, HX8347D_REG_PRN1, 0x6a); //
write_reg(g, HX8347D_REG_PKN0, 0x07); //
write_reg(g, HX8347D_REG_PKN1, 0x05); //
write_reg(g, HX8347D_REG_PKN2, 0x06); //
write_reg(g, HX8347D_REG_PKN3, 0x0b); //
write_reg(g, HX8347D_REG_PKN4, 0x14); //
write_reg(g, HX8347D_REG_CGM, 0xcc); //
/* Power + Osc ---------------------------------------------------------------*/
write_reg(g, HX8347D_REG_OSCCH, 0x36); /* OSC Control 1 */
write_reg(g, HX8347D_REG_OSCCL, 0x01); /* OSC Control 2 */
write_reg(g, HX8347D_REG_DMODE, 0x00); /* Display Mode Control */
write_reg(g, HX8347D_REG_PWC6, 0x88); /* Power Control 6 */
gfxSleepMilliseconds(5); /* Delay 5 ms */
write_reg(g, HX8347D_REG_PWC6, 0x80); /* Power Control 6 */
gfxSleepMilliseconds(5); /* Delay 5 ms */
write_reg(g, HX8347D_REG_PWC6, 0x90); /* Power Control 6 */
gfxSleepMilliseconds(5); /* Delay 5 ms */
write_reg(g, HX8347D_REG_PWC6, 0xD0); /* Power Control 6 */
gfxSleepMilliseconds(5); /* Delay 5 ms */
write_reg(g, HX8347D_REG_COLMOD, 0x05); /* Colmod 16Bit/Pixel */
write_reg(g, HX8347D_REG_PCH, 0x00); /* Panel Characteristic */
write_reg(g, HX8347D_REG_DC3, 0x38); /* Display Control 3 */
gfxSleepMilliseconds(40); /* Delay 40 ms */
write_reg(g, HX8347D_REG_DC3, 0x3C); /* Display Control 3 */
write_reg(g, HX8347D_REG_MAC, 0x08); /* Memory access control */
// Finish Init
post_init_board(g);
// Release the bus
release_bus(g);
/* Turn on the backlight */
set_backlight(g, GDISP_INITIAL_BACKLIGHT);
/* 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;
}
#if GDISP_HARDWARE_STREAM_WRITE
LLDSPEC void gdisp_lld_write_start(GDisplay *g) {
acquire_bus(g);
set_viewport(g);
busmode16(g);
}
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
write_ram16(g, g->p.color);
}
LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
busmode8(g);
release_bus(g);
}
#endif
#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
LLDSPEC void gdisp_lld_control(GDisplay *g) {
switch(g->p.x) {
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_reg(g, HX8347D_REG_MAC, 0x08); /* Memory access control */
release_bus(g);
g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_90:
acquire_bus(g);
write_reg(g, HX8347D_REG_MAC, 0x68); /* Memory access control */
release_bus(g);
g->g.Height = GDISP_SCREEN_WIDTH;
g->g.Width = GDISP_SCREEN_HEIGHT;
break;
case GDISP_ROTATE_180:
acquire_bus(g);
write_reg(g, HX8347D_REG_MAC, 0xc8); /* Memory access control */
release_bus(g);
g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_270:
acquire_bus(g);
write_reg(g, HX8347D_REG_MAC, 0xa8); /* Memory access control */
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;
case GDISP_CONTROL_BACKLIGHT:
if ((unsigned)g->p.ptr > 100)
g->p.ptr = (void *)100;
set_backlight(g, (unsigned)g->p.ptr);
g->g.Backlight = (unsigned)g->p.ptr;
return;
default:
return;
}
}
#endif
#endif /* GFX_USE_GDISP */

View File

@ -1,2 +1,2 @@
GFXINC += $(GFXLIB)/drivers/gdisp/ILI9320
GFXSRC += $(GFXLIB)/drivers/gdisp/ILI9320/gdisp_lld.c
GFXSRC += $(GFXLIB)/drivers/gdisp/ILI9320/gdisp_lld_ILI9320.c

View File

@ -1,2 +1,2 @@
GFXINC += $(GFXLIB)/drivers/gdisp/ILI9325
GFXSRC += $(GFXLIB)/drivers/gdisp/ILI9325/gdisp_lld.c
GFXSRC += $(GFXLIB)/drivers/gdisp/ILI9325/gdisp_lld_ILI9325.c

View File

@ -1,2 +1,2 @@
GFXINC += $(GFXLIB)/drivers/gdisp/ILI9341
GFXSRC += $(GFXLIB)/drivers/gdisp/ILI9341/gdisp_lld.c
GFXSRC += $(GFXLIB)/drivers/gdisp/ILI9341/gdisp_lld_ILI9341.c

View File

@ -1,2 +1,2 @@
GFXINC += $(GFXLIB)/drivers/gdisp/ILI9481
GFXSRC += $(GFXLIB)/drivers/gdisp/ILI9481/gdisp_lld.c
GFXSRC += $(GFXLIB)/drivers/gdisp/ILI9481/gdisp_lld_ILI9481.c

View File

@ -1,2 +1,2 @@
GFXINC += $(GFXLIB)/drivers/gdisp/Nokia6610GE12
GFXSRC += $(GFXLIB)/drivers/gdisp/Nokia6610GE12/gdisp_lld.c
GFXSRC += $(GFXLIB)/drivers/gdisp/Nokia6610GE12/gdisp_lld_Nokia6610GE12.c

View File

@ -1,2 +1,2 @@
GFXINC += $(GFXLIB)/drivers/gdisp/Nokia6610GE8
GFXSRC += $(GFXLIB)/drivers/gdisp/Nokia6610GE8/gdisp_lld.c
GFXSRC += $(GFXLIB)/drivers/gdisp/Nokia6610GE8/gdisp_lld_Nokia6610GE8.c

View File

@ -1,2 +1,2 @@
GFXINC += $(GFXLIB)/drivers/gdisp/RA8875
GFXSRC += $(GFXLIB)/drivers/gdisp/RA8875/gdisp_lld.c
GFXSRC += $(GFXLIB)/drivers/gdisp/RA8875/gdisp_lld_RA8875.c

View File

@ -1,2 +1,2 @@
GFXINC += $(GFXLIB)/drivers/gdisp/S6D1121
GFXSRC += $(GFXLIB)/drivers/gdisp/S6D1121/gdisp_lld.c
GFXSRC += $(GFXLIB)/drivers/gdisp/S6D1121/gdisp_lld_S6D1121.c

View File

@ -15,7 +15,7 @@
#include "gfx.h"
#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/
#if GFX_USE_GDISP
#if defined(GDISP_SCREEN_HEIGHT)
#warning "GDISP: This low level driver does not support setting a screen size. It is being ignored."

View File

@ -1,2 +1,2 @@
GFXINC += $(GFXLIB)/drivers/gdisp/SSD1289
GFXSRC += $(GFXLIB)/drivers/gdisp/SSD1289/gdisp_lld.c
GFXSRC += $(GFXLIB)/drivers/gdisp/SSD1289/gdisp_lld_SSD1289.c

View File

@ -1,351 +1,351 @@
/*
* 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
*/
/**
* @file drivers/gdisp/SSD1289/gdisp_lld.c
* @brief GDISP Graphics Driver subsystem low level driver source for the SSD1289 display.
*/
#include "gfx.h"
#if GFX_USE_GDISP
#define GDISP_DRIVER_VMT GDISPVMT_SSD1289
#include "../drivers/gdisp/SSD1289/gdisp_lld_config.h"
#include "gdisp/lld/gdisp_lld.h"
#include "board_SSD1289.h"
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
#ifndef GDISP_SCREEN_HEIGHT
#define GDISP_SCREEN_HEIGHT 320
#endif
#ifndef GDISP_SCREEN_WIDTH
#define GDISP_SCREEN_WIDTH 240
#endif
#ifndef GDISP_INITIAL_CONTRAST
#define GDISP_INITIAL_CONTRAST 50
#endif
#ifndef GDISP_INITIAL_BACKLIGHT
#define GDISP_INITIAL_BACKLIGHT 100
#endif
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
// Some common routines and macros
#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); }
static void set_cursor(GDisplay *g) {
/*
* Reg 0x004E is an 8 bit value - start x position
* Reg 0x004F is 9 bit - start y position
* Use a bit mask to make sure they are not set too high
*/
switch(g->g.Orientation) {
case GDISP_ROTATE_0:
write_reg(g, 0x4e, g->p.x & 0x00FF);
write_reg(g, 0x4f, g->p.y & 0x01FF);
break;
case GDISP_ROTATE_90:
write_reg(g, 0x4e, g->p.y & 0x00FF);
write_reg(g, 0x4f, (GDISP_SCREEN_HEIGHT-1-g->p.x) & 0x01FF);
break;
case GDISP_ROTATE_180:
write_reg(g, 0x4e, (GDISP_SCREEN_WIDTH-1-g->p.x) & 0x00FF);
write_reg(g, 0x4f, (GDISP_SCREEN_HEIGHT-1-g->p.y) & 0x01FF);
break;
case GDISP_ROTATE_270:
write_reg(g, 0x4e, (GDISP_SCREEN_WIDTH-1-g->p.y) & 0x00FF);
write_reg(g, 0x4f, g->p.x & 0x01FF);
break;
}
write_index(g, 0x22);
}
static void set_viewport(GDisplay* g) {
/* 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
* Use a bit mask to make sure they are not set too high
*/
switch(g->g.Orientation) {
case GDISP_ROTATE_0:
write_reg(g, 0x44, (((g->p.x+g->p.cx-1) << 8) & 0xFF00 ) | (g->p.x & 0x00FF));
write_reg(g, 0x45, g->p.y & 0x01FF);
write_reg(g, 0x46, (g->p.y+g->p.cy-1) & 0x01FF);
break;
case GDISP_ROTATE_90:
write_reg(g, 0x44, (((g->p.y+g->p.cy-1) << 8) & 0xFF00 ) | (g->p.y & 0x00FF));
write_reg(g, 0x45, (GDISP_SCREEN_HEIGHT-(g->p.x+g->p.cx)) & 0x01FF);
write_reg(g, 0x46, (GDISP_SCREEN_HEIGHT-1-g->p.x) & 0x01FF);
break;
case GDISP_ROTATE_180:
write_reg(g, 0x44, (((GDISP_SCREEN_WIDTH-1-g->p.x) & 0x00FF) << 8) | ((GDISP_SCREEN_WIDTH - (g->p.x+g->p.cx)) & 0x00FF));
write_reg(g, 0x45, (GDISP_SCREEN_HEIGHT-(g->p.y+g->p.cy)) & 0x01FF);
write_reg(g, 0x46, (GDISP_SCREEN_HEIGHT-1-g->p.y) & 0x01FF);
break;
case GDISP_ROTATE_270:
write_reg(g, 0x44, (((GDISP_SCREEN_WIDTH-1-g->p.y) & 0x00FF) << 8) | ((GDISP_SCREEN_WIDTH-(g->p.y+g->p.cy)) & 0x00FF));
write_reg(g, 0x45, g->p.x & 0x01FF);
write_reg(g, 0x46, (g->p.x+g->p.cx-1) & 0x01FF);
break;
}
}
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
// No private area for this controller
g->priv = 0;
// Initialise the board interface
init_board(g);
// Hardware reset
setpin_reset(g, TRUE);
gfxSleepMilliseconds(20);
setpin_reset(g, FALSE);
gfxSleepMilliseconds(20);
// Get the bus for the following initialisation commands
acquire_bus(g);
write_reg(g, 0x00, 0x0001); gfxSleepMicroseconds(5);
write_reg(g, 0x03, 0xA8A4); gfxSleepMicroseconds(5);
write_reg(g, 0x0C, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x0D, 0x080C); gfxSleepMicroseconds(5);
write_reg(g, 0x0E, 0x2B00); gfxSleepMicroseconds(5);
write_reg(g, 0x1E, 0x00B0); gfxSleepMicroseconds(5);
write_reg(g, 0x01, 0x2B3F); gfxSleepMicroseconds(5);
write_reg(g, 0x02, 0x0600); gfxSleepMicroseconds(5);
write_reg(g, 0x10, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x11, 0x6070); gfxSleepMicroseconds(5);
write_reg(g, 0x05, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x06, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x16, 0xEF1C); gfxSleepMicroseconds(5);
write_reg(g, 0x17, 0x0003); gfxSleepMicroseconds(5);
write_reg(g, 0x07, 0x0133); gfxSleepMicroseconds(5);
write_reg(g, 0x0B, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x0F, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x41, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x42, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x48, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x49, 0x013F); gfxSleepMicroseconds(5);
write_reg(g, 0x4A, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x4B, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x44, 0xEF00); gfxSleepMicroseconds(5);
write_reg(g, 0x45, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x46, 0x013F); gfxSleepMicroseconds(5);
write_reg(g, 0x30, 0x0707); gfxSleepMicroseconds(5);
write_reg(g, 0x31, 0x0204); gfxSleepMicroseconds(5);
write_reg(g, 0x32, 0x0204); gfxSleepMicroseconds(5);
write_reg(g, 0x33, 0x0502); gfxSleepMicroseconds(5);
write_reg(g, 0x34, 0x0507); gfxSleepMicroseconds(5);
write_reg(g, 0x35, 0x0204); gfxSleepMicroseconds(5);
write_reg(g, 0x36, 0x0204); gfxSleepMicroseconds(5);
write_reg(g, 0x37, 0x0502); gfxSleepMicroseconds(5);
write_reg(g, 0x3A, 0x0302); gfxSleepMicroseconds(5);
write_reg(g, 0x3B, 0x0302); gfxSleepMicroseconds(5);
write_reg(g, 0x23, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x24, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x25, 0x8000); gfxSleepMicroseconds(5);
write_reg(g, 0x4f, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x4e, 0x0000); gfxSleepMicroseconds(5);
// Finish Init
post_init_board(g);
// Release the bus
release_bus(g);
/* Turn on the back-light */
set_backlight(g, GDISP_INITIAL_BACKLIGHT);
/* 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;
}
#if GDISP_HARDWARE_STREAM_WRITE
LLDSPEC void gdisp_lld_write_start(GDisplay *g) {
acquire_bus(g);
set_viewport(g);
#if !GDISP_HARDWARE_STREAM_POS
set_cursor(g);
#endif
}
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
write_data(g, g->p.color);
}
LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
release_bus(g);
}
#if GDISP_HARDWARE_STREAM_POS
LLDSPEC void gdisp_lld_write_pos(GDisplay *g) {
set_cursor(g);
}
#endif
#endif
#if GDISP_HARDWARE_STREAM_READ
LLDSPEC void gdisp_lld_read_start(GDisplay *g) {
acquire_bus(g);
set_viewport(g);
set_cursor(g);
setreadmode(g);
dummy_read(g);
}
LLDSPEC color_t gdisp_lld_read_color(GDisplay *g) {
return read_data(g);
}
LLDSPEC void gdisp_lld_read_stop(GDisplay *g) {
setwritemode(g);
release_bus(g);
}
#endif
#if GDISP_HARDWARE_FILLS && defined(GDISP_USE_DMA)
LLDSPEC void gdisp_lld_fill_area(GDisplay *g) {
acquire_bus(g);
set_viewport(g);
set_cursor(g);
dma_with_noinc(g, &color, g->p.cx*g->p.cy)
release_bus(g);
}
#endif
#if GDISP_HARDWARE_BITFILLS && defined(GDISP_USE_DMA)
LLDSPEC void gdisp_lld_blit_area(GDisplay *g) {
pixel_t *buffer;
coord_t ycnt;
buffer = (pixel_t *)g->p.ptr + g->p.x1 + g->p.y1 * g->p.x2;
acquire_bus(g);
set_viewport(g);
set_cursor(g);
if (g->p.x2 == g->p.cx) {
dma_with_inc(g, buffer, g->p.cx*g->p.cy);
} else {
for (ycnt = g->p.cy; ycnt; ycnt--, buffer += g->p.x2)
dma_with_inc(g, buffer, g->p.cy);
}
release_bus(g);
}
#endif
#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_reg(g, 0x10, 0x0000); // leave sleep mode
write_reg(g, 0x07, 0x0000); // halt operation
write_reg(g, 0x00, 0x0000); // turn off oscillator
write_reg(g, 0x10, 0x0001); // enter sleep mode
release_bus(g);
break;
case powerOn:
acquire_bus(g);
write_reg(g, 0x10, 0x0000); // leave sleep mode
write_reg(g, 0x00, 0x0001); // turn on oscillator
gfxSleepMicroseconds(5);
release_bus(g);
break;
case powerSleep:
acquire_bus(g);
write_reg(g, 0x10, 0x0001); // enter sleep mode
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);
/* ID = 11 AM = 0 */
write_reg(g, 0x11, 0x6070);
release_bus(g);
g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_90:
acquire_bus(g);
/* ID = 01 AM = 1 */
write_reg(g, 0x11, 0x6058);
release_bus(g);
g->g.Height = GDISP_SCREEN_WIDTH;
g->g.Width = GDISP_SCREEN_HEIGHT;
break;
case GDISP_ROTATE_180:
acquire_bus(g);
/* ID = 00 AM = 0 */
write_reg(g, 0x11, 0x6040);
release_bus(g);
g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_270:
acquire_bus(g);
/* ID = 10 AM = 1 */
write_reg(g, 0x11, 0x6068);
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;
case GDISP_CONTROL_BACKLIGHT:
if ((unsigned)g->p.ptr > 100)
g->p.ptr = (void *)100;
set_backlight(g, (unsigned)g->p.ptr);
g->g.Backlight = (unsigned)g->p.ptr;
return;
//case GDISP_CONTROL_CONTRAST:
default:
return;
}
}
#endif
#endif /* GFX_USE_GDISP */
/*
* 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
*/
/**
* @file drivers/gdisp/SSD1289/gdisp_lld.c
* @brief GDISP Graphics Driver subsystem low level driver source for the SSD1289 display.
*/
#include "gfx.h"
#if GFX_USE_GDISP
#define GDISP_DRIVER_VMT GDISPVMT_SSD1289
#include "../drivers/gdisp/SSD1289/gdisp_lld_config.h"
#include "gdisp/lld/gdisp_lld.h"
#include "board_SSD1289.h"
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
#ifndef GDISP_SCREEN_HEIGHT
#define GDISP_SCREEN_HEIGHT 320
#endif
#ifndef GDISP_SCREEN_WIDTH
#define GDISP_SCREEN_WIDTH 240
#endif
#ifndef GDISP_INITIAL_CONTRAST
#define GDISP_INITIAL_CONTRAST 50
#endif
#ifndef GDISP_INITIAL_BACKLIGHT
#define GDISP_INITIAL_BACKLIGHT 100
#endif
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
// Some common routines and macros
#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); }
static void set_cursor(GDisplay *g) {
/*
* Reg 0x004E is an 8 bit value - start x position
* Reg 0x004F is 9 bit - start y position
* Use a bit mask to make sure they are not set too high
*/
switch(g->g.Orientation) {
case GDISP_ROTATE_0:
write_reg(g, 0x4e, g->p.x & 0x00FF);
write_reg(g, 0x4f, g->p.y & 0x01FF);
break;
case GDISP_ROTATE_90:
write_reg(g, 0x4e, g->p.y & 0x00FF);
write_reg(g, 0x4f, (GDISP_SCREEN_HEIGHT-1-g->p.x) & 0x01FF);
break;
case GDISP_ROTATE_180:
write_reg(g, 0x4e, (GDISP_SCREEN_WIDTH-1-g->p.x) & 0x00FF);
write_reg(g, 0x4f, (GDISP_SCREEN_HEIGHT-1-g->p.y) & 0x01FF);
break;
case GDISP_ROTATE_270:
write_reg(g, 0x4e, (GDISP_SCREEN_WIDTH-1-g->p.y) & 0x00FF);
write_reg(g, 0x4f, g->p.x & 0x01FF);
break;
}
write_index(g, 0x22);
}
static void set_viewport(GDisplay* g) {
/* 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
* Use a bit mask to make sure they are not set too high
*/
switch(g->g.Orientation) {
case GDISP_ROTATE_0:
write_reg(g, 0x44, (((g->p.x+g->p.cx-1) << 8) & 0xFF00 ) | (g->p.x & 0x00FF));
write_reg(g, 0x45, g->p.y & 0x01FF);
write_reg(g, 0x46, (g->p.y+g->p.cy-1) & 0x01FF);
break;
case GDISP_ROTATE_90:
write_reg(g, 0x44, (((g->p.y+g->p.cy-1) << 8) & 0xFF00 ) | (g->p.y & 0x00FF));
write_reg(g, 0x45, (GDISP_SCREEN_HEIGHT-(g->p.x+g->p.cx)) & 0x01FF);
write_reg(g, 0x46, (GDISP_SCREEN_HEIGHT-1-g->p.x) & 0x01FF);
break;
case GDISP_ROTATE_180:
write_reg(g, 0x44, (((GDISP_SCREEN_WIDTH-1-g->p.x) & 0x00FF) << 8) | ((GDISP_SCREEN_WIDTH - (g->p.x+g->p.cx)) & 0x00FF));
write_reg(g, 0x45, (GDISP_SCREEN_HEIGHT-(g->p.y+g->p.cy)) & 0x01FF);
write_reg(g, 0x46, (GDISP_SCREEN_HEIGHT-1-g->p.y) & 0x01FF);
break;
case GDISP_ROTATE_270:
write_reg(g, 0x44, (((GDISP_SCREEN_WIDTH-1-g->p.y) & 0x00FF) << 8) | ((GDISP_SCREEN_WIDTH-(g->p.y+g->p.cy)) & 0x00FF));
write_reg(g, 0x45, g->p.x & 0x01FF);
write_reg(g, 0x46, (g->p.x+g->p.cx-1) & 0x01FF);
break;
}
}
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
// No private area for this controller
g->priv = 0;
// Initialise the board interface
init_board(g);
// Hardware reset
setpin_reset(g, TRUE);
gfxSleepMilliseconds(20);
setpin_reset(g, FALSE);
gfxSleepMilliseconds(20);
// Get the bus for the following initialisation commands
acquire_bus(g);
write_reg(g, 0x00, 0x0001); gfxSleepMicroseconds(5);
write_reg(g, 0x03, 0xA8A4); gfxSleepMicroseconds(5);
write_reg(g, 0x0C, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x0D, 0x080C); gfxSleepMicroseconds(5);
write_reg(g, 0x0E, 0x2B00); gfxSleepMicroseconds(5);
write_reg(g, 0x1E, 0x00B0); gfxSleepMicroseconds(5);
write_reg(g, 0x01, 0x2B3F); gfxSleepMicroseconds(5);
write_reg(g, 0x02, 0x0600); gfxSleepMicroseconds(5);
write_reg(g, 0x10, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x11, 0x6070); gfxSleepMicroseconds(5);
write_reg(g, 0x05, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x06, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x16, 0xEF1C); gfxSleepMicroseconds(5);
write_reg(g, 0x17, 0x0003); gfxSleepMicroseconds(5);
write_reg(g, 0x07, 0x0133); gfxSleepMicroseconds(5);
write_reg(g, 0x0B, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x0F, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x41, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x42, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x48, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x49, 0x013F); gfxSleepMicroseconds(5);
write_reg(g, 0x4A, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x4B, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x44, 0xEF00); gfxSleepMicroseconds(5);
write_reg(g, 0x45, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x46, 0x013F); gfxSleepMicroseconds(5);
write_reg(g, 0x30, 0x0707); gfxSleepMicroseconds(5);
write_reg(g, 0x31, 0x0204); gfxSleepMicroseconds(5);
write_reg(g, 0x32, 0x0204); gfxSleepMicroseconds(5);
write_reg(g, 0x33, 0x0502); gfxSleepMicroseconds(5);
write_reg(g, 0x34, 0x0507); gfxSleepMicroseconds(5);
write_reg(g, 0x35, 0x0204); gfxSleepMicroseconds(5);
write_reg(g, 0x36, 0x0204); gfxSleepMicroseconds(5);
write_reg(g, 0x37, 0x0502); gfxSleepMicroseconds(5);
write_reg(g, 0x3A, 0x0302); gfxSleepMicroseconds(5);
write_reg(g, 0x3B, 0x0302); gfxSleepMicroseconds(5);
write_reg(g, 0x23, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x24, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x25, 0x8000); gfxSleepMicroseconds(5);
write_reg(g, 0x4f, 0x0000); gfxSleepMicroseconds(5);
write_reg(g, 0x4e, 0x0000); gfxSleepMicroseconds(5);
// Finish Init
post_init_board(g);
// Release the bus
release_bus(g);
/* Turn on the back-light */
set_backlight(g, GDISP_INITIAL_BACKLIGHT);
/* 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;
}
#if GDISP_HARDWARE_STREAM_WRITE
LLDSPEC void gdisp_lld_write_start(GDisplay *g) {
acquire_bus(g);
set_viewport(g);
#if !GDISP_HARDWARE_STREAM_POS
set_cursor(g);
#endif
}
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
write_data(g, g->p.color);
}
LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
release_bus(g);
}
#if GDISP_HARDWARE_STREAM_POS
LLDSPEC void gdisp_lld_write_pos(GDisplay *g) {
set_cursor(g);
}
#endif
#endif
#if GDISP_HARDWARE_STREAM_READ
LLDSPEC void gdisp_lld_read_start(GDisplay *g) {
acquire_bus(g);
set_viewport(g);
set_cursor(g);
setreadmode(g);
dummy_read(g);
}
LLDSPEC color_t gdisp_lld_read_color(GDisplay *g) {
return read_data(g);
}
LLDSPEC void gdisp_lld_read_stop(GDisplay *g) {
setwritemode(g);
release_bus(g);
}
#endif
#if GDISP_HARDWARE_FILLS && defined(GDISP_USE_DMA)
LLDSPEC void gdisp_lld_fill_area(GDisplay *g) {
acquire_bus(g);
set_viewport(g);
set_cursor(g);
dma_with_noinc(g, &color, g->p.cx*g->p.cy)
release_bus(g);
}
#endif
#if GDISP_HARDWARE_BITFILLS && defined(GDISP_USE_DMA)
LLDSPEC void gdisp_lld_blit_area(GDisplay *g) {
pixel_t *buffer;
coord_t ycnt;
buffer = (pixel_t *)g->p.ptr + g->p.x1 + g->p.y1 * g->p.x2;
acquire_bus(g);
set_viewport(g);
set_cursor(g);
if (g->p.x2 == g->p.cx) {
dma_with_inc(g, buffer, g->p.cx*g->p.cy);
} else {
for (ycnt = g->p.cy; ycnt; ycnt--, buffer += g->p.x2)
dma_with_inc(g, buffer, g->p.cy);
}
release_bus(g);
}
#endif
#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_reg(g, 0x10, 0x0000); // leave sleep mode
write_reg(g, 0x07, 0x0000); // halt operation
write_reg(g, 0x00, 0x0000); // turn off oscillator
write_reg(g, 0x10, 0x0001); // enter sleep mode
release_bus(g);
break;
case powerOn:
acquire_bus(g);
write_reg(g, 0x10, 0x0000); // leave sleep mode
write_reg(g, 0x00, 0x0001); // turn on oscillator
gfxSleepMicroseconds(5);
release_bus(g);
break;
case powerSleep:
acquire_bus(g);
write_reg(g, 0x10, 0x0001); // enter sleep mode
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);
/* ID = 11 AM = 0 */
write_reg(g, 0x11, 0x6070);
release_bus(g);
g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_90:
acquire_bus(g);
/* ID = 01 AM = 1 */
write_reg(g, 0x11, 0x6058);
release_bus(g);
g->g.Height = GDISP_SCREEN_WIDTH;
g->g.Width = GDISP_SCREEN_HEIGHT;
break;
case GDISP_ROTATE_180:
acquire_bus(g);
/* ID = 00 AM = 0 */
write_reg(g, 0x11, 0x6040);
release_bus(g);
g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_270:
acquire_bus(g);
/* ID = 10 AM = 1 */
write_reg(g, 0x11, 0x6068);
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;
case GDISP_CONTROL_BACKLIGHT:
if ((unsigned)g->p.ptr > 100)
g->p.ptr = (void *)100;
set_backlight(g, (unsigned)g->p.ptr);
g->g.Backlight = (unsigned)g->p.ptr;
return;
//case GDISP_CONTROL_CONTRAST:
default:
return;
}
}
#endif
#endif /* GFX_USE_GDISP */

View File

@ -1,2 +1,2 @@
GFXINC += $(GFXLIB)/drivers/gdisp/SSD1306
GFXSRC += $(GFXLIB)/drivers/gdisp/SSD1306/gdisp_lld.c
GFXSRC += $(GFXLIB)/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c

View File

@ -1,280 +1,280 @@
/*
* 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
*/
/**
* @file drivers/gdisp/SSD1306/gdisp_lld.c
* @brief GDISP Graphics Driver subsystem low level driver source for the SSD1306 display.
*/
#include "gfx.h"
#if GFX_USE_GDISP
#define GDISP_DRIVER_VMT GDISPVMT_SSD1306
#include "../drivers/gdisp/SSD1306/gdisp_lld_config.h"
#include "gdisp/lld/gdisp_lld.h"
#include "board_SSD1306.h"
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
#ifndef GDISP_SCREEN_HEIGHT
#define GDISP_SCREEN_HEIGHT 64 // This controller should support 32 (untested) or 64
#endif
#ifndef GDISP_SCREEN_WIDTH
#define GDISP_SCREEN_WIDTH 128
#endif
#ifndef GDISP_INITIAL_CONTRAST
#define GDISP_INITIAL_CONTRAST 100
#endif
#ifndef GDISP_INITIAL_BACKLIGHT
#define GDISP_INITIAL_BACKLIGHT 100
#endif
#ifdef SSD1306_PAGE_PREFIX
#define SSD1306_PAGE_WIDTH (GDISP_SCREEN_WIDTH+1)
#define SSD1306_PAGE_OFFSET 1
#else
#define SSD1306_PAGE_WIDTH GDISP_SCREEN_WIDTH
#define SSD1306_PAGE_OFFSET 0
#endif
#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0)
#include "SSD1306.h"
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
// Some common routines and macros
#define RAM(g) ((uint8_t *)g->priv)
#define write_cmd2(g, cmd1, cmd2) { write_cmd(g, cmd1); write_cmd(g, cmd2); }
#define write_cmd3(g, cmd1, cmd2, cmd3) { write_cmd(g, cmd1); write_cmd(g, cmd2); write_cmd(g, cmd3); }
// Some common routines and macros
#define delay(us) gfxSleepMicroseconds(us)
#define delayms(ms) gfxSleepMilliseconds(ms)
#define xyaddr(x, y) (SSD1306_PAGE_OFFSET + (x) + ((y)>>3)*SSD1306_PAGE_WIDTH)
#define xybit(y) (1<<((y)&7))
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/**
* As this controller can't update on a pixel boundary we need to maintain the
* the entire display surface in memory so that we can do the necessary bit
* operations. Fortunately it is a small display in monochrome.
* 64 * 128 / 8 = 1024 bytes.
*/
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
// The private area is the display surface.
g->priv = gfxAlloc(GDISP_SCREEN_HEIGHT/8 * SSD1306_PAGE_WIDTH);
// Fill in the prefix command byte on each page line of the display buffer
// We can do it during initialisation as this byte is never overwritten.
#ifdef SSD1306_PAGE_PREFIX
{
unsigned i;
for(i=0; i < GDISP_SCREEN_HEIGHT/8 * SSD1306_PAGE_WIDTH; i+=SSD1306_PAGE_WIDTH)
RAM(g)[i] = SSD1306_PAGE_PREFIX;
}
#endif
// Initialise the board interface
init_board(g);
// Hardware reset
setpin_reset(g, TRUE);
gfxSleepMilliseconds(20);
setpin_reset(g, FALSE);
gfxSleepMilliseconds(20);
acquire_bus(g);
write_cmd(g, SSD1306_DISPLAYOFF);
write_cmd2(g, SSD1306_SETDISPLAYCLOCKDIV, 0x80);
write_cmd2(g, SSD1306_SETMULTIPLEX, GDISP_SCREEN_HEIGHT-1);
write_cmd2(g, SSD1306_SETPRECHARGE, 0x1F);
write_cmd2(g, SSD1306_SETDISPLAYOFFSET, 0);
write_cmd(g, SSD1306_SETSTARTLINE | 0);
write_cmd2(g, SSD1306_ENABLE_CHARGE_PUMP, 0x14);
write_cmd2(g, SSD1306_MEMORYMODE, 0);
write_cmd(g, SSD1306_SEGREMAP+1);
write_cmd(g, SSD1306_COMSCANDEC);
#if GDISP_SCREEN_HEIGHT == 64
write_cmd2(g, SSD1306_SETCOMPINS, 0x12);
#else
write_cmd2(g, SSD1306_SETCOMPINS, 0x22);
#endif
write_cmd2(g, SSD1306_SETCONTRAST, (uint8_t)(GDISP_INITIAL_CONTRAST*256/101)); // Set initial contrast.
write_cmd2(g, SSD1306_SETVCOMDETECT, 0x10);
write_cmd(g, SSD1306_DISPLAYON);
write_cmd(g, SSD1306_NORMALDISPLAY);
write_cmd3(g, SSD1306_HV_COLUMN_ADDRESS, 0, GDISP_SCREEN_WIDTH-1);
write_cmd3(g, SSD1306_HV_PAGE_ADDRESS, 0, GDISP_SCREEN_HEIGHT/8-1);
// Finish Init
post_init_board(g);
<