中级会员
- 积分
- 334
- 金钱
- 334
- 注册时间
- 2019-9-15
- 在线时间
- 126 小时
|
5金钱
最近拿到一块2.4寸 spi驱动的ST779V得屏,但是根据商家给的驱动程序,改写完后,屏幕只是亮起背光没有其他反应,哪位大神有这块屏的stm32的例程啊,可不可以分享一下,谢谢
下面是我改的LCD的初始化
SPILCD_RST_SET ; //LCD_RST=1
delay_ms(1);
SPILCD_RST_RESET ; //LCD_RST=0 //SPI接口复位
delay_ms(1); // delay 20 ms
SPILCD_RST_SET ; //LCD_RST=1
delay_ms(120);
lcddev.width=240;
lcddev.height=320;
lcddev.wramcmd=0X2C; //存储
lcddev.setxcmd=0X2A; //列地址
lcddev.setycmd=0X2B; //页地址
// LCD_RESET=1;
// delay (100); //Delay 100ms
// LCD_RESET=0;
// delay (200); //Delay 200ms
// LCD_RESET=1;
// delay (500); //Delay 500ms
//---------------------------------------------------------------------------------------------------//
LCD_WR_REG(0x11);
delay_ms(120); //Delay 120ms
//------------------------------display and color format setting--------------------------------//
LCD_WR_REG(0x36);
LCD_WR_DATA8(0x00);
LCD_WR_REG(0x3a);
LCD_WR_DATA8(0x05);
//--------------------------------ST7789V Frame rate setting----------------------------------//
LCD_WR_REG(0xb2);
LCD_WR_DATA8(0x0c);
LCD_WR_DATA8(0x0c);
LCD_WR_DATA8(0x00);
LCD_WR_DATA8(0x33);
LCD_WR_DATA8(0x33);
LCD_WR_REG(0xb7);
LCD_WR_DATA8(0x35);
//---------------------------------ST7789V Power setting--------------------------------------//
LCD_WR_REG(0xbb);
LCD_WR_DATA8(0x1c);
LCD_WR_REG(0xc0);
LCD_WR_DATA8(0x2c);
LCD_WR_REG(0xc2);
LCD_WR_DATA8(0x01);
LCD_WR_REG(0xc3);
LCD_WR_DATA8(0x0b);
LCD_WR_REG(0xc4);
LCD_WR_DATA8(0x20);
LCD_WR_REG(0xc6);
LCD_WR_DATA8(0x0f);
LCD_WR_REG(0xd0);
LCD_WR_DATA8(0xa4);
LCD_WR_DATA8(0xa1);
//--------------------------------ST7789V gamma setting---------------------------------------//
LCD_WR_REG(0xe0);
LCD_WR_DATA8(0xd0);
LCD_WR_DATA8(0x00);
LCD_WR_DATA8(0x03);
LCD_WR_DATA8(0x09);
LCD_WR_DATA8(0x13);
LCD_WR_DATA8(0x1c);
LCD_WR_DATA8(0x3a);
LCD_WR_DATA8(0x55);
LCD_WR_DATA8(0x48);
LCD_WR_DATA8(0x18);
LCD_WR_DATA8(0x12);
LCD_WR_DATA8(0x0e);
LCD_WR_DATA8(0x19);
LCD_WR_DATA8(0x1e);
LCD_WR_REG(0xe1);
LCD_WR_DATA8(0xd0);
LCD_WR_DATA8(0x00);
LCD_WR_DATA8(0x03);
LCD_WR_DATA8(0x09);
LCD_WR_DATA8(0x05);
LCD_WR_DATA8(0x25);
LCD_WR_DATA8(0x3a);
LCD_WR_DATA8(0x55);
LCD_WR_DATA8(0x50);
LCD_WR_DATA8(0x3d);
LCD_WR_DATA8(0x1c);
LCD_WR_DATA8(0x1d);
LCD_WR_DATA8(0x1d);
LCD_WR_DATA8(0x1e);
LCD_WR_REG(0x21);
LCD_WR_REG(0x11);
delay_ms(120);
LCD_Clear(BLACK);
LCD_WR_REG(0x29);
SPI_InitTypeDef SPI_InitStructure;
void SPI1_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd( RCC_APB2Periph_SPI1, ENABLE );//SPI1时钟使能
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOD, ENABLE); //使能A端口时钟 //RES
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//速度50MHz
GPIO_Init(GPIOA, &GPIO_InitStructure); //初始化GPIOD3,6
//GPIO_SetBits(GPIOA,GPIO_Pin_5|GPIO_Pin_7|GPIO_Pin_4);
// RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); //使能A端口时钟 PA4 CS PA6 DC
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//速度50MHz
GPIO_Init(GPIOA, &GPIO_InitStructure);
// GPIO_SetBits(GPIOB,GPIO_Pin_4|GPIO_Pin_1|GPIO_Pin_8);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_7; //sck sda
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//速度50MHz
// GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_SetBits(GPIOA ,GPIO_Pin_9|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7);
// GPIO_SetBits(GPIOA,GPIO_Pin_5|GPIO_Pin_7); //PB13/14/15上拉
SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx; //设置SPI单向或者双向的数据模式:SPI设置为双线双向全双工 SPI_Direction_1Line_Tx
SPI_InitStructure.SPI_Mode = SPI_Mode_Master; //设置SPI工作模式:设置为主SPI
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; //设置SPI的数据大小:SPI发送接收8位帧结构
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; //选择了串行时钟的稳态:时钟悬空高
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; //数据捕获于第二个时钟沿
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; //NSS信号由硬件(NSS管脚)还是软件(使用SSI位)管理:内部NSS信号有SSI位控制
SPI_InitStructure.SPI_BaudRatePrescaler =SPI_BaudRatePrescaler_8; //定义波特率预分频的值:波特率预分频值为16
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; //指定数据传输从MSB位还是LSB位开始:数据传输从MSB位开始
SPI_InitStructure.SPI_CRCPolynomial = 7; //CRC值计算的多项式
SPI_Init(SPI1, &SPI_InitStructure); //根据SPI_InitStruct中指定的参数初始化外设SPIx寄存器
SPI_Cmd(SPI1, ENABLE); //使能SPI外设
SPI1_ReadWriteByte(0xff);//启动传输
// SPI1_SetSpeed(SPI_BaudRatePrescaler_256);//设置为18M时钟,高速模式
|
|