Mike's Taranis+ lcd driver

This commit is contained in:
bsongis
2014-06-30 12:08:01 +02:00
parent 0e0b1792e4
commit f643f0be85
3 changed files with 112 additions and 38 deletions
+1 -1
View File
@@ -251,7 +251,7 @@ LIBS = $(DLIBS) $(ULIBS)
MCFLAGS = -mcpu=$(MCU)
#ASFLAGS = $(MCFLAGS) -g -gdwarf-2 -Wa,-amhls=$(OBJDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
CPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb -fomit-frame-pointer -Wall -Wstrict-prototypes -fverbose-asm $(DEFS)
CPFLAGS = $(MCFLAGS) $(OPT) -fdata-sections -ffunction-sections -gdwarf-2 -mthumb -fomit-frame-pointer -Wall -Wstrict-prototypes -fverbose-asm $(DEFS)
LDFLAGS = $(MCFLAGS) -mthumb -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(FULL_PRJ).map,--cref,--no-warn-mismatch $(LIBDIR)
CPPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb -fomit-frame-pointer -Wall -fverbose-asm $(DEFS)
+1 -1
View File
@@ -257,7 +257,7 @@
// LCD
#if defined(REVPLUS)
#define RCC_AHB1Periph_LCD RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD
#define RCC_AHB1Periph_LCD (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD)
#define GPIO_LCD_SPI GPIOC
#define GPIO_LCD_NCS GPIOA
#define GPIO_LCD_RST GPIOD
+110 -36
View File
@@ -13,8 +13,48 @@
#define WriteData(x) AspiData(x)
#define WriteCommand(x) AspiCmd(x)
#define CONTRAST_OFS 5
#if defined(REVPLUS)
#define CONTRAST_OFS 120
#else
#define CONTRAST_OFS 5
#endif
#if defined(REVPLUS)
static void LCD_Init()
{
AspiCmd(0x25); //(5) Temperature compensation curve definition: 0x25 = -0.05%/oC
AspiCmd(0x2b); //(6) Panel loading set ,Internal VLCD.
AspiCmd(0xEA); //(27) set bias=1/10
AspiCmd(0x81); //(11) Set Vop + next byte
#if defined(BOOT)
AspiCmd(CONTRAST_OFS+25);
#else
AspiCmd(CONTRAST_OFS+g_eeGeneral.contrast);
#endif
AspiCmd(0xA6); //inverse display off
AspiCmd(0xA1); //line rates,24 Klps
AspiCmd(0x84); //Disable Partial Display
AspiCmd(0xC8); //SET N-LINE INVERSION
AspiCmd(0x00); //Disable NIV
AspiCmd(0xF1); //Set CEN
AspiCmd(0x3F); // 1/64DUTY
AspiCmd(0xC0); //(21) Set mapping
AspiCmd(0x05); // MY=1, MX=0, MSF=0
AspiCmd(0x89); //(15) WA=1,column (CA) increment (+1) first until CA reaches CA boundary, then RA will increment by (+1).
AspiCmd(0xF8); //Set Window Program Enable ,inside modle
AspiCmd(0xD0); //(23) SET 4 bits/pixel, pattern 0
AspiCmd(0xF4); //starting column address of RAM program window.
AspiCmd(0x00);
AspiCmd(0xF5); //starting row address of RAM program window.
AspiCmd(0x00);
AspiCmd(0xF6); //ending column address of RAM program window.
AspiCmd(0xD3);
AspiCmd(0xF7); //ending row address of RAM program window.
AspiCmd(0x3F);
AspiCmd(0xAF); // Active and 16-grey scale
}
#else
static void LCD_Init()
{
AspiCmd(0x2b); //Panel loading set ,Internal VLCD.
@@ -47,40 +87,6 @@ static void LCD_Init()
AspiCmd(0x47);
AspiCmd(0xF7); //ending row address of RAM program window.
AspiCmd(0x9F);
}
#if 0 // to be removed later if nobody complains!
static void lcdRefreshInit()
{
AspiCmd(0x2b); //Panel loading set ,Internal VLCD.
AspiCmd(0x25); //Temperature compensation curve definition: 0x25 = -0.05%/oC
AspiCmd(0xEA); //set bias=1/10 :Command table NO.27
AspiCmd(0x81); //Set Vop
AspiCmd(g_eeGeneral.contrast+CONTRAST_OFS); //0--255
AspiCmd(0xA6); //inverse display off
AspiCmd(0xD1); //SET RGB:Command table NO.21 .SET RGB or BGR. D1=RGB
AspiCmd(0xD5); //set color mode 4K and 12bits :Command table NO.22
AspiCmd(0xA0); //line rates,25.2 Klps
AspiCmd(0xC8); //SET N-LINE INVERSION
AspiCmd(0x1D); //Disable NIV
AspiCmd(0xF1); //Set CEN
AspiCmd(0x3F); // 1/64DUTY
AspiCmd(0x84); //Disable Partial Display
AspiCmd(0xC4); //MY=1,MX=0
AspiCmd(0x89); //WA=1,column (CA) increment (+1) first until CA reaches CA boundary, then RA will increment by (+1).
AspiCmd(0xF8); //Set Window Program Enable ,inside modle
AspiCmd(0xF4); //starting column address of RAM program window.
AspiCmd(0x00);
AspiCmd(0xF5); //starting row address of RAM program window.
AspiCmd(0x60);
AspiCmd(0xF6); //ending column address of RAM program window.
AspiCmd(0x47);
AspiCmd(0xF7); //ending row address of RAM program window.
AspiCmd(0x9F);
AspiCmd(0xAF);
}
#endif
@@ -105,6 +111,73 @@ const uint8_t lcdPalette[4] = { 0, 0x03, 0x06, 0x0F };
__no_operation(); \
LCD_CLK_HIGH();
#if defined(REVPLUS)
void lcdRefresh()
{
for (uint32_t y=0; y<LCD_H; y+=2) {
uint8_t *p = &displayBuf[(y>>3)*LCD_W];
uint8_t mask = (1 << (y%8));
Set_Address(0, y/2);
AspiCmd(0xAF);
LCD_CLK_HIGH();
LCD_A0_HIGH();
LCD_NCS_LOW();
for (uint32_t x=0; x<LCD_W; x++) {
uint8_t a, b, c ;
uint8_t val = 0 ;
a = p[3*DISPLAY_PLAN_SIZE+x] ;
if ( a & mask ) {
val |= 1 ;
}
if ( (a>>1) & mask ) {
val |= 0x10 ;
}
b = p[2*DISPLAY_PLAN_SIZE+x] ;
if ( b & mask ) {
val |= 2 ;
}
if ( (b>>1) & mask ) {
val |= 0x20 ;
}
c = p[DISPLAY_PLAN_SIZE+x] ;
if ( c & mask ) {
val |= 4 ;
}
if ( (c>>1) & mask ) {
val |= 0x40 ;
}
c = p[x] ;
if ( c & mask ) {
val |= 8 ;
}
if ( (c>>1) & mask ) {
val |= 0x80 ;
}
LCD_WRITE_BIT(val & 1);
LCD_WRITE_BIT(val & 2);
LCD_WRITE_BIT(val & 4);
LCD_WRITE_BIT(val & 8);
LCD_WRITE_BIT(val & 0x10);
LCD_WRITE_BIT(val & 0x20);
LCD_WRITE_BIT(val & 0x40);
LCD_WRITE_BIT(val & 0x80);
}
LCD_NCS_HIGH();
LCD_A0_HIGH();
WriteData(0);
}
}
#else
void lcdRefresh()
{
for (uint32_t y=0; y<LCD_H; y++) {
@@ -131,6 +204,7 @@ void lcdRefresh()
WriteData(0);
}
}
#endif
/**Init the Backlight GPIO */
static void LCD_BL_Config()
@@ -184,7 +258,7 @@ static void LCD_BL_Config()
static void LCD_Hardware_Init()
{
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_LCD, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
/*!< Configure lcd CLK\ MOSI\ A0pin in output pushpull mode *************/