7.2.4 SPI 驱动程序

/**

* @brief SPI send data/command

* @param dat

*/

void SendDataSPI(unsigned char dat)

{

unsigned char i;

 

for(i=0; i<8; i++)

{

LCD_SCL_LOW;

if( (dat&0x80)!=0 ){

LCD_SDA_HIGH;

}else{

LCD_SDA_LOW;

}

dat <<= 1;

LCD_SCL_HIGH;

}

}

/**

* @brief this function is write command to lcd.

* @param command : 写进去的命令值.

* @retval none

*/

void WriteComm(unsigned char command)

{

LCD_CS_LOW;

LCD_RS_LOW;//拉低选择发送命令

SendDataSPI(command);

LCD_CS_HIGH;

}

/**

* @brief this function is write data to lcd.

* @param data : the data to write.

* @retval none

*/

void WriteData(unsigned char data)

{

LCD_CS_LOW;

LCD_RS_HIGH;//拉高选择发送数据

SendDataSPI(data);

LCD_CS_HIGH;

}

/**

* @brief configures the lcd.

* this function must be called before any write/read operation

* on the lcd.

*/

void lcd_soft_init(void)

{

//软件SPI驱动 参数设置 颜色相反

lcd_port_init(); //引脚初始化

 

LCD_RESET_HIGH; //复位引脚拉高

delay_ms(1);

LCD_RESET_LOW; //复位引脚拉低

delay_ms(10);

LCD_RESET_HIGH;

delay_ms(120);

 

WriteComm(0x36); //行列扫描顺序及RGB/BGR,横放/竖放控制

WriteData(0x00);

 

WriteComm(0x3A); //定义RGB图像数据格式

WriteData(0x05);

 

WriteComm(0xB2); //Porch Setting

WriteData(0x0C);

WriteData(0x0C);

WriteData(0x00);

WriteData(0x33);

WriteData(0x33);

 

WriteComm(0xB7); //Gate Control

WriteData(0x35);

 

WriteComm(0xBB); //VCOM Setting

WriteData(0x19);

 

WriteComm(0xC0); //LCM Control

WriteData(0x2C);

 

WriteComm(0xC2); //VDV and VRH Command Enable

WriteData(0x01);

 

WriteComm(0xC3); //VRH Set

WriteData(0x12);

 

WriteComm(0xC4); //VDV Set

WriteData(0x20);

 

WriteComm(0xC6); //Frame Rate Control in Normal Mode

WriteData(0x0F);

 

WriteComm(0xD0); //Power Control

WriteData(0xA4);

WriteData(0xA1);

 

WriteComm(0xE0); //Positive Voltage Gamma Control

WriteData(0xD0);

WriteData(0x04);

WriteData(0x0D);

WriteData(0x11);

WriteData(0x13);

WriteData(0x2B);

WriteData(0x3F);

WriteData(0x54);

WriteData(0x4C);

WriteData(0x18);

WriteData(0x0D);

WriteData(0x0B);

WriteData(0x1F);

WriteData(0x23);

 

WriteComm(0xE1); //Negative Voltage Gamma Control

WriteData(0xD0);

WriteData(0x04);

WriteData(0x0C);

WriteData(0x11);

WriteData(0x13);

WriteData(0x2C);

WriteData(0x3F);

WriteData(0x44);

WriteData(0x51);

WriteData(0x2F);

WriteData(0x1F);

WriteData(0x1F);

WriteData(0x20);

WriteData(0x23);

 

WriteComm(0x21); //Display Inversion On颜色翻转

 

WriteComm(0x11); //退出睡眠

delay_ms(120);

 

WriteComm(0x29); //Display on开启显示

DispColor(WHITE); //清屏为白色

LCD_BL_LOW; //点亮背光

}

 

显示函数可以参考8080通信,这里不再赘述。

下一页
上一页
    • 联系电话

    • 0755—83453881
    • 服务时间

    • 周一至周五 9:00-18:00
    • 高通GT-HMI交流群