• 大小: 15KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-05-16
  • 语言: 其他
  • 标签: STM32  SPI  LIL9341  

资源简介

STM32的硬件SPI驱动的ILI9341,本人产品上亲测通过。如有不解,请联系我。

资源截图

代码片段和文件信息

#define _LCD_ODEV_C_

#include “LCD_odev.h“
#include “fonts.h“ //ASCII字符型字库


void LCD_Delay(unsigned short int i)
{
while(i--);
}

void LCD_wt8bitData(unsigned char da) //发送数据-8位参数
{
LCD_CS_en();
  LCD_DC_data();
SPI1_ReadWriteByte(da);  
LCD_CS_dis();
}

void LCD_wt16bitData(unsigned short int da)
{
LCD_CS_en();
    LCD_DC_data();
SPI1_ReadWriteByte(da>>8);
    SPI1_ReadWriteByte(da&0xFF);
LCD_CS_dis();
}

void LCD_wtREG(unsigned char cmd) 
{
LCD_CS_en();
  LCD_DC_reg();
SPI1_ReadWriteByte(cmd);
LCD_CS_dis();
}

void LCD_wtREG_DATA(unsigned char regunsigned short int da)
{
  LCD_wtREG(reg);
LCD_wt16bitData(da);
}

unsigned char LCD_Read_Data(void)
{
LCD_CS_en();
LCD_DC_data();
//此处禁止disbale掉CS脚,CS脚必须一直使能,否则读取的数据全是0xff
return SPI1_ReadWriteByte(0xFF);
}

void LCD_odev_init(void)
{
ILI9341_io_Init();

lcddev.width = LCD_Wide;
lcddev.height = LCD_High;

LCD_RST_Clr();
delay_ms(20);
LCD_RST_Set();
delay_ms(20);
//LCD_BLK_Set();

//************* Start Initial Sequence **********// 
LCD_wtREG(0xCF);  
LCD_wt8bitData(0x00); 
LCD_wt8bitData(0xD9); 
LCD_wt8bitData(0X30); 
 
LCD_wtREG(0xED);  
LCD_wt8bitData(0x64); 
LCD_wt8bitData(0x03); 
LCD_wt8bitData(0X12); 
LCD_wt8bitData(0X81); 
 
LCD_wtREG(0xE8);  
LCD_wt8bitData(0x85); 
LCD_wt8bitData(0x10); 
LCD_wt8bitData(0x78); 
 
LCD_wtREG(0xCB);  
LCD_wt8bitData(0x39); 
LCD_wt8bitData(0x2C); 
LCD_wt8bitData(0x00); 
LCD_wt8bitData(0x34); 
LCD_wt8bitData(0x02); 
 
LCD_wtREG(0xF7);  
LCD_wt8bitData(0x20); 
 
LCD_wtREG(0xEA);  
LCD_wt8bitData(0x00); 
LCD_wt8bitData(0x00); 
 
LCD_wtREG(0xC0);    //Power control 
LCD_wt8bitData(0x21);   //VRH[5:0] 
 
LCD_wtREG(0xC1);    //Power control 
LCD_wt8bitData(0x12);   //SAP[2:0];BT[3:0] 
 
LCD_wtREG(0xC5);    //VCM control 
LCD_wt8bitData(0x32); 
LCD_wt8bitData(0x3C); 
 
LCD_wtREG(0xC7);    //VCM control2 
LCD_wt8bitData(0XC1); 
 
LCD_wtREG(0x36);    // Memory Access Control 
LCD_wt8bitData(0x68); 

LCD_wtREG(0x2A);  //行地址设置
LCD_wt8bitData(0x00);
LCD_wt8bitData(0x00);
LCD_wt8bitData(0x01);
LCD_wt8bitData(0x3f);

LCD_wtREG(0x2B);  //列地址设置
LCD_wt8bitData(0x00);
LCD_wt8bitData(0x00);
LCD_wt8bitData(0x00);
LCD_wt8bitData(0xef);  
 
LCD_wtREG(0x3A);   
LCD_wt8bitData(0x55); 

LCD_wtREG(0xB1);   
LCD_wt8bitData(0x00);   
LCD_wt8bitData(0x18); 
 
LCD_wtREG(0xB6);    // Display Function Control 
LCD_wt8bitData(0x0A); 
LCD_wt8bitData(0xA2); 
 
LCD_wtREG(0xF2);    // 3Gamma Function Disable 
LCD_wt8bitData(0x00); 
 
LCD_wtREG(0x26);    //Gamma curve selected 
LCD_wt8bitData(0x01); 
 
LCD_wtREG(0xE0);    //Set Gamma 
LCD_wt8bitData(0x0F); 
LCD_wt8bitData(0x20); 
LCD_wt8bitData(0x1E); 
LCD_wt8bitData(0x09); 
LCD_wt8bitData(0x12); 
LCD_wt8bitData(0x0B); 
LCD_wt8bitData(0x50); 
LCD_wt8bitData(0XBA); 
LCD_wt8bitData(0x44); 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      35006  2017-11-13 18:45  STM32的硬件SPI驱动的ILI9341代码\fonts.h

     文件      21304  2018-01-09 11:26  STM32的硬件SPI驱动的ILI9341代码\LCD_odev.c

     文件       6686  2018-01-09 11:26  STM32的硬件SPI驱动的ILI9341代码\LCD_odev.h

     文件       4123  2018-01-04 16:52  STM32的硬件SPI驱动的ILI9341代码\spi_idev.c

     文件        567  2017-09-29 10:06  STM32的硬件SPI驱动的ILI9341代码\spi_idev.h

     目录          0  2018-01-09 13:06  STM32的硬件SPI驱动的ILI9341代码

----------- ---------  ---------- -----  ----

                67686                    6


评论

共有 条评论