diff --git a/boards/base/Mikromedia-Plus-STM32-M4/ChibiOS_Board/board.c b/boards/base/Mikromedia-Plus-STM32-M4/ChibiOS_Board/board.c index 41c13fe9..8445765a 100644 --- a/boards/base/Mikromedia-Plus-STM32-M4/ChibiOS_Board/board.c +++ b/boards/base/Mikromedia-Plus-STM32-M4/ChibiOS_Board/board.c @@ -79,8 +79,7 @@ void __early_init(void) { bool sdc_lld_is_card_inserted(SDCDriver *sdcp) { (void)sdcp; - /* TODO: Fill the implementation.*/ - return true; + return !palReadPad(GPIOD, GPIOD_SD_CD); } /** diff --git a/boards/base/Mikromedia-Plus-STM32-M4/board_SSD1963.h b/boards/base/Mikromedia-Plus-STM32-M4/board_SSD1963.h index b0114ca9..bcda3e71 100644 --- a/boards/base/Mikromedia-Plus-STM32-M4/board_SSD1963.h +++ b/boards/base/Mikromedia-Plus-STM32-M4/board_SSD1963.h @@ -8,8 +8,6 @@ #ifndef _GDISP_LLD_BOARD_H #define _GDISP_LLD_BOARD_H -//#define SSD1963_INIT_METHOD_2 TRUE - static const LCD_Parameters DisplayTimings[] = { // 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 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 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) { - g->board = 0; - switch(g->controllerdisplay) { - case 0: - { - palSetBusMode(&busCMD, PAL_MODE_OUTPUT_PUSHPULL); - palSetBusMode(&busDataLo, PAL_MODE_OUTPUT_PUSHPULL); - palSetBusMode(&busDataHi, PAL_MODE_OUTPUT_PUSHPULL); - SET_CS; SET_WR; SET_RD; SET_DC; SET_RST; - break; - } - default: - break; - } + g->board = 0; + switch(g->controllerdisplay) { + case 0: + palSetBusMode(&busCMD, PAL_MODE_OUTPUT_PUSHPULL); + palSetBusMode(&busDataLo, PAL_MODE_OUTPUT_PUSHPULL); + palSetBusMode(&busDataHi, PAL_MODE_OUTPUT_PUSHPULL); + SET_CS; SET_WR; SET_RD; SET_DC; SET_RST; + break; + default: + break; + } } static inline void post_init_board(GDisplay *g) { - (void) g; + (void) g; } static inline void setpin_reset(GDisplay *g, bool_t state) { - (void) g; - if (state) { - CLR_RST; - } else { - SET_RST; - } + (void) g; + if (state) { + CLR_RST; + } else { + SET_RST; + } } static inline void acquire_bus(GDisplay *g) { - (void) g; - CLR_CS; + (void) g; + CLR_CS; } static inline void release_bus(GDisplay *g) { - (void) g; - SET_CS; + (void) g; + SET_CS; } static inline void write_index(GDisplay *g, uint16_t index) { - (void) g; + (void) g; - CLR_DC; - palWriteBus(&busDataLo, (index & 0xFF)); - palWriteBus(&busDataHi, (index >> 8)); - writeStrobe; - SET_DC; + CLR_DC; + palWriteBus(&busDataLo, (index & 0xFF)); + palWriteBus(&busDataHi, (index >> 8)); + writeStrobe; + SET_DC; } static inline void write_data(GDisplay *g, uint16_t data) { - (void) g; + (void) g; - palWriteBus(&busDataLo, (data & 0xFF)); - palWriteBus(&busDataHi, (data >> 8)); - writeStrobe; + palWriteBus(&busDataLo, (data & 0xFF)); + palWriteBus(&busDataHi, (data >> 8)); + writeStrobe; } static inline void setreadmode(GDisplay *g) { - (void) g; - palSetBusMode(&busDataLo, PAL_MODE_INPUT_PULLUP); - palSetBusMode(&busDataHi, PAL_MODE_INPUT_PULLUP); + (void) g; + palSetBusMode(&busDataLo, PAL_MODE_INPUT_PULLUP); + palSetBusMode(&busDataHi, PAL_MODE_INPUT_PULLUP); } static inline void setwritemode(GDisplay *g) { - (void) g; - palSetBusMode(&busDataLo, PAL_MODE_OUTPUT_PUSHPULL); - palSetBusMode(&busDataHi, PAL_MODE_OUTPUT_PUSHPULL); + (void) g; + palSetBusMode(&busDataLo, PAL_MODE_OUTPUT_PUSHPULL); + palSetBusMode(&busDataHi, PAL_MODE_OUTPUT_PUSHPULL); } static inline uint16_t read_data(GDisplay *g) { - (void) g; + uint16_t data; + (void) g; - uint16_t data; - CLR_RD; - data = (palReadBus(&busDataHi) << 8) | palReadBus(&busDataLo); - SET_RD; - return data; + CLR_RD; + data = (palReadBus(&busDataHi) << 8) | palReadBus(&busDataLo); + SET_RD; + return data; } #endif /* _GDISP_LLD_BOARD_H */ diff --git a/drivers/gdisp/SSD1963/gdisp_lld_SSD1963.c b/drivers/gdisp/SSD1963/gdisp_lld_SSD1963.c index c7312a29..af2d907e 100644 --- a/drivers/gdisp/SSD1963/gdisp_lld_SSD1963.c +++ b/drivers/gdisp/SSD1963/gdisp_lld_SSD1963.c @@ -128,29 +128,18 @@ static inline void set_backlight(GDisplay *g, uint8_t percent) { // connected to a LED connection on the breakout board write_index(g, SSD1963_SET_PWM_CONF); //set PWM for BackLight -#if SSD1963_INIT_METHOD_2 - write_data(g, 0x05); + write_data(g, 0x06); // 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 write_data(g, 0x00); 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 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, 0xFF); // DBC manual brightness (not used - zero would work) - write_data(g, 0x60); // DBC minimum brightness (not used - zero would work) - write_data(g, 0x0F); // Brightness prescaler - active when Transition Effect enable A5 = 1 -#endif + write_data(g, 0x00); // DBC minimum brightness + write_data(g, 0x01); // Brightness prescaler - active when Transition Effect enable A5 = 1 } /*===========================================================================*/ @@ -177,7 +166,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { #if !GDISP_SSD1963_NO_INIT // Hardware reset setpin_reset(g, TRUE); - gfxSleepMilliseconds(100); + gfxSleepMilliseconds(200); setpin_reset(g, FALSE); gfxSleepMilliseconds(200); #endif @@ -195,11 +184,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { write_index(g, SSD1963_SET_PLL_MN); write_data(g, 35); // PLLclk = REFclk (10Mhz) * 36 (360Mhz) write_data(g, 2); // SYSclk = PLLclk / 3 (120MHz) -//#if SSD1963_INIT_METHOD_2 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 gfxSleepMilliseconds(100); 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_PIXEL_DATA_INTERFACE, SSD1963_PDI_16BIT565); + write_reg(g, SSD1963_SET_PIXEL_FORMAT, 0x50); #if !GDISP_SSD1963_NO_INIT /* LCD Clock specs */ @@ -231,7 +217,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { write_index(g, SSD1963_SET_HORI_PERIOD); write_data16(g, lcdp->hperiod); 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); @@ -239,17 +225,21 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { write_index(g, SSD1963_SET_VERT_PERIOD); write_data16(g, lcdp->vperiod); 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); - /* Enable DBC to control Backlight */ - write_index(g, SSD1963_SET_DBC_CONF); - write_data(g, 0x2F); + #if 0 + /* Enable DBC to control Backlight */ + write_index(g, SSD1963_SET_DBC_CONF); + write_data(g, 0x2F); + #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) */ - //write_reg(g, SSD1963_SET_TEAR_ON, 0x00); + #if 0 + /* 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 */ write_index(g, SSD1963_SET_DISPLAY_ON);