[Taranis] Last minute LCD driver major change!!! Not tested at all by me!
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
|
||||
#include "../opentx.h"
|
||||
#include "./STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_gpio.h"
|
||||
|
||||
/**
|
||||
**********send command to lcd**************
|
||||
@@ -38,6 +39,7 @@ void AspiCmd(u8 Command_Byte)
|
||||
LCD_A0_LOW();
|
||||
|
||||
LCD_CLK_HIGH();
|
||||
__no_operation();
|
||||
LCD_NCS_LOW();
|
||||
|
||||
while (i--) {
|
||||
@@ -51,6 +53,7 @@ void AspiCmd(u8 Command_Byte)
|
||||
Command_Byte <<= 1;
|
||||
|
||||
LCD_CLK_HIGH();
|
||||
__no_operation();
|
||||
}
|
||||
|
||||
LCD_NCS_HIGH();
|
||||
@@ -88,12 +91,12 @@ void AspiData(u8 Para_data)
|
||||
LCD_A0_HIGH();
|
||||
LCD_NCS_LOW();
|
||||
while (i--) {
|
||||
LCD_CLK_LOW();
|
||||
if (Para_data&0x80)
|
||||
LCD_MOSI_HIGH();
|
||||
else
|
||||
LCD_MOSI_LOW();
|
||||
Para_data <<= 1;
|
||||
LCD_CLK_LOW();
|
||||
__no_operation();
|
||||
LCD_CLK_HIGH();
|
||||
__no_operation();
|
||||
|
||||
@@ -232,7 +232,7 @@
|
||||
#define PIN_LCD_CLK GPIO_Pin_11 //PD.11
|
||||
#define PIN_LCD_NCS GPIO_Pin_14 //PD.14
|
||||
#define PIN_LCD_A0 GPIO_Pin_13 //PD.13
|
||||
#define PIN_LCD_RST //GPIO_Pin_12 //pd12 test //RESET occurs when powered up,but should delay before initialize
|
||||
#define PIN_LCD_RST GPIO_Pin_12 //pd12 test //RESET occurs when powered up,but should delay before initialize
|
||||
|
||||
// Audio - I2S3
|
||||
#define CODEC_I2S SPI3
|
||||
|
||||
@@ -14,6 +14,70 @@
|
||||
#define WriteData(x) AspiData(x)
|
||||
#define WriteCommand(x) AspiCmd(x)
|
||||
|
||||
static void LCD_Init()
|
||||
{
|
||||
AspiCmd(0x25); //Temperature compensation curve definition: 0x25 = -0.05%/oC
|
||||
AspiCmd(0x2b); //Panel loading set ,Internal VLCD.
|
||||
AspiCmd(0xEA); //set bias=1/10 :Command table NO.27
|
||||
AspiCmd(0x81); //Set Vop
|
||||
AspiCmd(50); //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);
|
||||
|
||||
|
||||
}
|
||||
static void LCD_Init1()
|
||||
{
|
||||
AspiCmd(0x25); //Temperature compensation curve definition: 0x25 = -0.05%/oC
|
||||
AspiCmd(0x2b); //Panel loading set ,Internal VLCD.
|
||||
AspiCmd(0xEA); //set bias=1/10 :Command table NO.27
|
||||
AspiCmd(0x81); //Set Vop
|
||||
AspiCmd(50); //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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Set_Address(u8 x, u8 y)
|
||||
{
|
||||
WriteCommand(x&0x0F); //Set Column Address LSB CA[3:0]
|
||||
@@ -37,6 +101,8 @@ const uint8_t lcdPalette[4] = { 0, 0x03, 0x06, 0x0F };
|
||||
|
||||
void lcdRefresh()
|
||||
{
|
||||
LCD_Init1();
|
||||
|
||||
for (uint32_t y=0; y<LCD_H; y++) {
|
||||
uint8_t *p = &displayBuf[(y>>3)*LCD_W];
|
||||
uint8_t mask = (1 << (y%8));
|
||||
@@ -90,59 +156,57 @@ static void LCD_Hardware_Init()
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIO_LCD, &GPIO_InitStructure);
|
||||
|
||||
LCD_NCS_HIGH();
|
||||
/*!< Configure lcd NCS pin in output pushpull mode ,PULLUP *************/
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_LCD_NCS;
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_LCD_NCS |PIN_LCD_RST;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
|
||||
GPIO_Init(GPIO_LCD, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
static void LCD_Init()
|
||||
//275us
|
||||
void Delay(volatile unsigned int ms)
|
||||
{
|
||||
/*Hardware Reset need delay*/
|
||||
/*LCD_RST_LOW();
|
||||
Delay(50);
|
||||
LCD_RST_HIGH();*/
|
||||
|
||||
AspiCmd(0x25); //Temperature compensation curve definition: 0x25 = -0.05%/oC
|
||||
AspiCmd(0x2b); //Panel loading set ,Internal VLCD.
|
||||
AspiCmd(0xEA); //set bias=1/10 :Command table NO.27
|
||||
AspiCmd(0x81); //Set Vop
|
||||
AspiCmd(50); //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(0x00); //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).
|
||||
volatile u8 i;
|
||||
while(ms != 0)
|
||||
{
|
||||
for(i=0;i<250;i++) {}
|
||||
for(i=0;i<75;i++) {}
|
||||
ms--;
|
||||
}
|
||||
}
|
||||
|
||||
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); //dc2=1, IC into exit SLEEP MODE, dc3=1 gray=ON, dc4=1 Green Enhanc mode disabled
|
||||
void LCD_OFF()
|
||||
{
|
||||
AspiCmd(0xE2);
|
||||
Delay(20);
|
||||
}
|
||||
|
||||
void lcdInit()
|
||||
{
|
||||
LCD_BL_Config();
|
||||
LCD_Hardware_Init();
|
||||
|
||||
LCD_RST_HIGH();
|
||||
Delay(5);
|
||||
|
||||
LCD_RST_LOW();
|
||||
Delay(120); //11ms
|
||||
|
||||
LCD_RST_HIGH();
|
||||
Delay(2500);
|
||||
|
||||
AspiCmd(0xE2);
|
||||
Delay(2500);
|
||||
LCD_Init();
|
||||
Delay(120);
|
||||
|
||||
LCD_Init();
|
||||
Delay(120);
|
||||
AspiCmd(0xAF); //dc2=1, IC into exit SLEEP MODE, dc3=1 gray=ON, dc4=1 Green Enhanc mode disabled
|
||||
}
|
||||
|
||||
void lcdSetRefVolt(uint8_t val)
|
||||
|
||||
Reference in New Issue
Block a user