Updates to Mikromedia-Plus-STM32-M4 board and the SSD1963 driver

remotes/origin_old/ugfx_release_2.6
inmarket 2015-02-28 17:09:49 +10:00
parent 8f779effe1
commit a436128e50
3 changed files with 63 additions and 78 deletions

View File

@ -79,8 +79,7 @@ void __early_init(void) {
bool sdc_lld_is_card_inserted(SDCDriver *sdcp) { bool sdc_lld_is_card_inserted(SDCDriver *sdcp) {
(void)sdcp; (void)sdcp;
/* TODO: Fill the implementation.*/ return !palReadPad(GPIOD, GPIOD_SD_CD);
return true;
} }
/** /**

View File

@ -8,8 +8,6 @@
#ifndef _GDISP_LLD_BOARD_H #ifndef _GDISP_LLD_BOARD_H
#define _GDISP_LLD_BOARD_H #define _GDISP_LLD_BOARD_H
//#define SSD1963_INIT_METHOD_2 TRUE
static const LCD_Parameters DisplayTimings[] = { static const LCD_Parameters DisplayTimings[] = {
// You need one of these array elements per display // You need one of these array elements per display
{ {
@ -45,7 +43,7 @@ static const LCD_Parameters DisplayTimings[] = {
#define SET_DC palSetPad(GDISP_CMD_PORT, GDISP_DC); #define SET_DC palSetPad(GDISP_CMD_PORT, GDISP_DC);
#define CLR_DC palClearPad(GDISP_CMD_PORT, GDISP_DC); #define CLR_DC palClearPad(GDISP_CMD_PORT, GDISP_DC);
#define writeStrobe { CLR_WR; asm volatile ("nop;"); SET_WR; } #define writeStrobe { CLR_WR; /*asm volatile ("nop;");*/ SET_WR; }
IOBus busCMD = { GDISP_CMD_PORT, (1 << GDISP_CS) | (1 << GDISP_RST) | (1 << GDISP_WR) | (1 << GDISP_RD) | (1 << GDISP_DC), 11 }; IOBus busCMD = { GDISP_CMD_PORT, (1 << GDISP_CS) | (1 << GDISP_RST) | (1 << GDISP_WR) | (1 << GDISP_RD) | (1 << GDISP_DC), 11 };
IOBus busDataLo = { GDISP_DATA_LO_PORT, 0xFF, 0 }; IOBus busDataLo = { GDISP_DATA_LO_PORT, 0xFF, 0 };
@ -53,82 +51,80 @@ IOBus busDataHi = { GDISP_DATA_HI_PORT, 0xFF, 8 };
static inline void init_board(GDisplay *g) { static inline void init_board(GDisplay *g) {
g->board = 0; g->board = 0;
switch(g->controllerdisplay) { switch(g->controllerdisplay) {
case 0: case 0:
{ palSetBusMode(&busCMD, PAL_MODE_OUTPUT_PUSHPULL);
palSetBusMode(&busCMD, PAL_MODE_OUTPUT_PUSHPULL); palSetBusMode(&busDataLo, PAL_MODE_OUTPUT_PUSHPULL);
palSetBusMode(&busDataLo, PAL_MODE_OUTPUT_PUSHPULL); palSetBusMode(&busDataHi, PAL_MODE_OUTPUT_PUSHPULL);
palSetBusMode(&busDataHi, PAL_MODE_OUTPUT_PUSHPULL); SET_CS; SET_WR; SET_RD; SET_DC; SET_RST;
SET_CS; SET_WR; SET_RD; SET_DC; SET_RST; break;
break; default:
} break;
default: }
break;
}
} }
static inline void post_init_board(GDisplay *g) { static inline void post_init_board(GDisplay *g) {
(void) g; (void) g;
} }
static inline void setpin_reset(GDisplay *g, bool_t state) { static inline void setpin_reset(GDisplay *g, bool_t state) {
(void) g; (void) g;
if (state) { if (state) {
CLR_RST; CLR_RST;
} else { } else {
SET_RST; SET_RST;
} }
} }
static inline void acquire_bus(GDisplay *g) { static inline void acquire_bus(GDisplay *g) {
(void) g; (void) g;
CLR_CS; CLR_CS;
} }
static inline void release_bus(GDisplay *g) { static inline void release_bus(GDisplay *g) {
(void) g; (void) g;
SET_CS; SET_CS;
} }
static inline void write_index(GDisplay *g, uint16_t index) { static inline void write_index(GDisplay *g, uint16_t index) {
(void) g; (void) g;
CLR_DC; CLR_DC;
palWriteBus(&busDataLo, (index & 0xFF)); palWriteBus(&busDataLo, (index & 0xFF));
palWriteBus(&busDataHi, (index >> 8)); palWriteBus(&busDataHi, (index >> 8));
writeStrobe; writeStrobe;
SET_DC; SET_DC;
} }
static inline void write_data(GDisplay *g, uint16_t data) { static inline void write_data(GDisplay *g, uint16_t data) {
(void) g; (void) g;
palWriteBus(&busDataLo, (data & 0xFF)); palWriteBus(&busDataLo, (data & 0xFF));
palWriteBus(&busDataHi, (data >> 8)); palWriteBus(&busDataHi, (data >> 8));
writeStrobe; writeStrobe;
} }
static inline void setreadmode(GDisplay *g) { static inline void setreadmode(GDisplay *g) {
(void) g; (void) g;
palSetBusMode(&busDataLo, PAL_MODE_INPUT_PULLUP); palSetBusMode(&busDataLo, PAL_MODE_INPUT_PULLUP);
palSetBusMode(&busDataHi, PAL_MODE_INPUT_PULLUP); palSetBusMode(&busDataHi, PAL_MODE_INPUT_PULLUP);
} }
static inline void setwritemode(GDisplay *g) { static inline void setwritemode(GDisplay *g) {
(void) g; (void) g;
palSetBusMode(&busDataLo, PAL_MODE_OUTPUT_PUSHPULL); palSetBusMode(&busDataLo, PAL_MODE_OUTPUT_PUSHPULL);
palSetBusMode(&busDataHi, PAL_MODE_OUTPUT_PUSHPULL); palSetBusMode(&busDataHi, PAL_MODE_OUTPUT_PUSHPULL);
} }
static inline uint16_t read_data(GDisplay *g) { static inline uint16_t read_data(GDisplay *g) {
(void) g; uint16_t data;
(void) g;
uint16_t data; CLR_RD;
CLR_RD; data = (palReadBus(&busDataHi) << 8) | palReadBus(&busDataLo);
data = (palReadBus(&busDataHi) << 8) | palReadBus(&busDataLo); SET_RD;
SET_RD; return data;
return data;
} }
#endif /* _GDISP_LLD_BOARD_H */ #endif /* _GDISP_LLD_BOARD_H */

View File

@ -128,29 +128,18 @@ static inline void set_backlight(GDisplay *g, uint8_t percent) {
// 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
#if SSD1963_INIT_METHOD_2 write_data(g, 0x06);
write_data(g, 0x05);
// write_data(g, 0x0E); // PWMF[7:0] = 2, PWM base freq = PLL/(256*(1+5))/256 = 300Hz for a PLL freq = 120MHz (source: Displaytech) // write_data(g, 0x0E); // PWMF[7:0] = 2, PWM base freq = PLL/(256*(1+5))/256 = 300Hz for a PLL freq = 120MHz (source: Displaytech)
write_data(g, 0xFF); // Dummy data (not needed DBC is in control)
#else
write_data(g, 0x01);
// write_data(g, 0x0E); // PWMF[7:0] = 2, PWM base freq = PLL/(256*(1+5))/256 = 300Hz for a PLL freq = 120MHz (source: Displaytech)
#endif
if (percent == 0xFF) // use percent==0xFF to turn off SSD1963 pwm in power SLEEP or DEEP SLEEP mode if (percent == 0xFF) // use percent==0xFF to turn off SSD1963 pwm in power SLEEP or DEEP SLEEP mode
write_data(g, 0x00); write_data(g, 0x00);
else if (percent >= 100) else if (percent >= 100)
write_data(g, 0x00FF); // Fully on for any percentage >= 100 write_data(g, 0xFF); // Fully on for any percentage >= 100
else else
write_data(g, (percent*255)/100 & 0x00FF); write_data(g, (percent*255)/100 & 0x00FF);
#if SSD1963_INIT_METHOD_2
write_data(g, 0x00); // DBC minimum brightness
write_data(g, 0x00); // Brightness prescaler - active when Transition Effect enable A5 = 1
#else
write_data(g, 0x01); // Controlled by host (not DBC), enabled write_data(g, 0x01); // Controlled by host (not DBC), enabled
write_data(g, 0xFF); // DBC manual brightness (not used - zero would work) write_data(g, 0xFF); // DBC manual brightness (not used - zero would work)
write_data(g, 0x60); // DBC minimum brightness (not used - zero would work) write_data(g, 0x00); // DBC minimum brightness
write_data(g, 0x0F); // Brightness prescaler - active when Transition Effect enable A5 = 1 write_data(g, 0x01); // Brightness prescaler - active when Transition Effect enable A5 = 1
#endif
} }
/*===========================================================================*/ /*===========================================================================*/
@ -177,7 +166,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
#if !GDISP_SSD1963_NO_INIT #if !GDISP_SSD1963_NO_INIT
// Hardware reset // Hardware reset
setpin_reset(g, TRUE); setpin_reset(g, TRUE);
gfxSleepMilliseconds(100); gfxSleepMilliseconds(200);
setpin_reset(g, FALSE); setpin_reset(g, FALSE);
gfxSleepMilliseconds(200); gfxSleepMilliseconds(200);
#endif #endif
@ -195,11 +184,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
write_index(g, SSD1963_SET_PLL_MN); write_index(g, SSD1963_SET_PLL_MN);
write_data(g, 35); // PLLclk = REFclk (10Mhz) * 36 (360Mhz) write_data(g, 35); // PLLclk = REFclk (10Mhz) * 36 (360Mhz)
write_data(g, 2); // SYSclk = PLLclk / 3 (120MHz) write_data(g, 2); // SYSclk = PLLclk / 3 (120MHz)
//#if SSD1963_INIT_METHOD_2
write_data(g, 54); // Apply calculation bit, else it is ignored write_data(g, 54); // Apply calculation bit, else it is ignored
//#else
// write_data(g, 4); // Apply calculation bit, else it is ignored
//#endif
write_reg(g, SSD1963_SET_PLL, 0x01); // Enable PLL write_reg(g, SSD1963_SET_PLL, 0x01); // Enable PLL
gfxSleepMilliseconds(100); gfxSleepMilliseconds(100);
write_reg(g, SSD1963_SET_PLL, 0x03); // Use PLL write_reg(g, SSD1963_SET_PLL, 0x03); // Use PLL
@ -220,6 +205,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
write_reg(g, SSD1963_SET_ADDRESS_MODE, 2); // Flip horizontal direction write_reg(g, SSD1963_SET_ADDRESS_MODE, 2); // Flip horizontal direction
write_reg(g, SSD1963_SET_PIXEL_DATA_INTERFACE, SSD1963_PDI_16BIT565); write_reg(g, SSD1963_SET_PIXEL_DATA_INTERFACE, SSD1963_PDI_16BIT565);
write_reg(g, SSD1963_SET_PIXEL_FORMAT, 0x50);
#if !GDISP_SSD1963_NO_INIT #if !GDISP_SSD1963_NO_INIT
/* LCD Clock specs */ /* LCD Clock specs */
@ -231,7 +217,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
write_index(g, SSD1963_SET_HORI_PERIOD); write_index(g, SSD1963_SET_HORI_PERIOD);
write_data16(g, lcdp->hperiod); write_data16(g, lcdp->hperiod);
write_data16(g, lcdp->hpulse + lcdp->hbporch); write_data16(g, lcdp->hpulse + lcdp->hbporch);
write_data(g, lcdp->hpulse); write_data(g, lcdp->hpulse - 1);
write_data(g, 0x00); write_data(g, 0x00);
write_data(g, 0x00); write_data(g, 0x00);
write_data(g, 0x00); write_data(g, 0x00);
@ -239,17 +225,21 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
write_index(g, SSD1963_SET_VERT_PERIOD); write_index(g, SSD1963_SET_VERT_PERIOD);
write_data16(g, lcdp->vperiod); write_data16(g, lcdp->vperiod);
write_data16(g, lcdp->vpulse + lcdp->vbporch); write_data16(g, lcdp->vpulse + lcdp->vbporch);
write_data(g, lcdp->vpulse); write_data(g, lcdp->vpulse - 1);
write_data(g, 0x00); write_data(g, 0x00);
write_data(g, 0x00); write_data(g, 0x00);
/* Enable DBC to control Backlight */ #if 0
write_index(g, SSD1963_SET_DBC_CONF); /* Enable DBC to control Backlight */
write_data(g, 0x2F); write_index(g, SSD1963_SET_DBC_CONF);
write_data(g, 0x2F);
#endif
#endif #endif
/* Tear effect indicator ON. This is used to tell the host MCU when the driver is not refreshing the panel (during front/back porch) */ #if 0
//write_reg(g, SSD1963_SET_TEAR_ON, 0x00); /* 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);
#endif
/* Turn on */ /* Turn on */
write_index(g, SSD1963_SET_DISPLAY_ON); write_index(g, SSD1963_SET_DISPLAY_ON);