TA的每日心情 | 无聊 2017-4-26 18:34 |
---|
签到天数: 3 天 连续签到: 1 天 [LV.2]偶尔看看I
|
本帖最后由 dadangjiasp 于 2017-6-13 23:08 编辑
我看了下网友提供的历程,没有ILI9341相关的代码,我参照店家给的代码添加到init程序中,spi屏幕可以正常运行。
1在lcd_driver.h修改定义- //-------------------------ÆÁÄ»ÎïÀíÏñËØÉèÖÃ--------------------------------------//
- #define LCD_X_SIZE 176
- #define LCD_Y_SIZE 220
- #define DIR 4
- /////////////////////////////////////ÎïÀíÅäÖÃÇø///////////////////////////////////
- //Èç¹ûʹÓúáÆÁ
- #define USE_HORIZONTAL 1 //ÊÇ·ñʹÓúáÆÁ 0,²»ÊµÓà 1,ʹÓÃ.
- #if USE_HORIZONTAL//ºáÆÁ
- #define X_MAX_PIXEL LCD_Y_SIZE
- #define Y_MAX_PIXEL LCD_X_SIZE
- #else
- #define X_MAX_PIXEL LCD_X_SIZE
- #define Y_MAX_PIXEL LCD_Y_SIZE
- #endif
- //////////////////////////////////////////////////////////////////////////////////
- //Òº¾§¿ØÖÆ¿ÚÖÃ1²Ù×÷Óï¾äºê¶¨Òå
- #define LCD_RST_SET gpio_bit_set(GPIOB,GPIO_PIN_12)
- #define LCD_RS_SET gpio_bit_set(GPIOB,GPIO_PIN_11)
- #define LCD_SDA_SET gpio_bit_set(GPIOA,GPIO_PIN_7)
- #define LCD_SCL_SET gpio_bit_set(GPIOC,GPIO_PIN_4)
- #define LCD_CS_SET gpio_bit_set(GPIOC,GPIO_PIN_5)
- //Òº¾§¿ØÖÆ¿ÚÖÃ0²Ù×÷Óï¾äºê¶¨Òå
- #define LCD_RST_CLR gpio_bit_reset(GPIOB,GPIO_PIN_12)
- #define LCD_RS_CLR gpio_bit_reset(GPIOB,GPIO_PIN_11)
- #define LCD_SDA_CLR gpio_bit_reset(GPIOA,GPIO_PIN_7)
- #define LCD_SCL_CLR gpio_bit_reset(GPIOC,GPIO_PIN_4)
- #define LCD_CS_CLR gpio_bit_reset(GPIOC,GPIO_PIN_5)
复制代码 2在lcd_driver.c添加一个初始化定义,在main.函数中,注意要设置为Lcd_Init(4); 才使用ILI9341的代码,如果使用其他的spi屏幕,可以在初始化中添加更多的代码。修改好的程序见附件,引脚定义有和原网友提供的一致。- else if(dir==4)//Init for ILI9341
- {
- //************* Start Initial Sequence **********//
- Lcd_WriteIndex(0x02); Lcd_WriteData_16Bit(0x0100); // set 1 line inversion
- #if USE_HORIZONTAL//ºáÆÁ
- //R01H:SM=0,GS=0,SS=0 (for details,See the datasheet of ILI9225)
- LCD_WriteReg(0x01, 0x001C); // set the display line number and display direction
- //R03H:BGR=1,ID0=1,ID1=1,AM=1 (for details,See the datasheet of ILI9225)
- LCD_WriteReg(0x03, 0x1038); // set GRAM write direction .
- #else//ÊúÆÁ
- //R01H:SM=0,GS=0,SS=1 (for details,See the datasheet of ILI9225)
- LCD_WriteReg(0x01, 0x011C); // set the display line number and display direction
- //R03H:BGR=1,ID0=1,ID1=1,AM=0 (for details,See the datasheet of ILI9225)
- LCD_WriteReg(0x03, 0x1030); // set GRAM write direction.
- #endif
- Lcd_WriteIndex(0x08); Lcd_WriteData_16Bit(0x0808); // set BP and FP
- Lcd_WriteIndex(0x0B); Lcd_WriteData_16Bit(0x1100); //frame cycle
- Lcd_WriteIndex(0x0C); Lcd_WriteData_16Bit(0x0000); // RGB interface setting R0Ch=0x0110 for RGB 18Bit and R0Ch=0111for RGB16Bit
- Lcd_WriteIndex(0x0F); Lcd_WriteData_16Bit(0x1401); // Set frame rate----0801
- Lcd_WriteIndex(0x15); Lcd_WriteData_16Bit(0x0000); //set system interface
- Lcd_WriteIndex(0x20); Lcd_WriteData_16Bit(0x0000); // Set GRAM Address
- Lcd_WriteIndex(0x21); Lcd_WriteData_16Bit(0x0000); // Set GRAM Address
- //*************Power On sequence ****************//
- delay_1ms(50); // Delay 50ms
- Lcd_WriteIndex(0x10); Lcd_WriteData_16Bit(0x0800); // Set SAP,DSTB,STB----0A00
- Lcd_WriteIndex(0x11); Lcd_WriteData_16Bit(0x1F3F); // Set APON,PON,AON,VCI1EN,VC----1038
- delay_1ms(50); // Delay 50ms
- Lcd_WriteIndex(0x12); Lcd_WriteData_16Bit(0x0121); // Internal reference voltage= Vci;----1121
- Lcd_WriteIndex(0x13); Lcd_WriteData_16Bit(0x006F); // Set GVDD----0066
- Lcd_WriteIndex(0x14); Lcd_WriteData_16Bit(0x4349); // Set VCOMH/VCOML voltage----5F60
- //-------------- Set GRAM area -----------------//
- Lcd_WriteIndex(0x30); Lcd_WriteData_16Bit(0x0000);
- Lcd_WriteIndex(0x31); Lcd_WriteData_16Bit(0x00DB);
- Lcd_WriteIndex(0x32); Lcd_WriteData_16Bit(0x0000);
- Lcd_WriteIndex(0x33); Lcd_WriteData_16Bit(0x0000);
- Lcd_WriteIndex(0x34); Lcd_WriteData_16Bit(0x00DB);
- Lcd_WriteIndex(0x35); Lcd_WriteData_16Bit(0x0000);
- Lcd_WriteIndex(0x36); Lcd_WriteData_16Bit(0x00AF);
- Lcd_WriteIndex(0x37); Lcd_WriteData_16Bit(0x0000);
- Lcd_WriteIndex(0x38); Lcd_WriteData_16Bit(0x00DB);
- Lcd_WriteIndex(0x39); Lcd_WriteData_16Bit(0x0000);
- // ----------- Adjust the Gamma Curve ----------//
- Lcd_WriteIndex(0x50); Lcd_WriteData_16Bit(0x0001); //0400
- Lcd_WriteIndex(0x51); Lcd_WriteData_16Bit(0x200B); //060B
- Lcd_WriteIndex(0x52); Lcd_WriteData_16Bit(0x0000); //0C0A
- Lcd_WriteIndex(0x53); Lcd_WriteData_16Bit(0x0404); //0105
- Lcd_WriteIndex(0x54); Lcd_WriteData_16Bit(0x0C0C); //0A0C
- Lcd_WriteIndex(0x55); Lcd_WriteData_16Bit(0x000C); //0B06
- Lcd_WriteIndex(0x56); Lcd_WriteData_16Bit(0x0101); //0004
- Lcd_WriteIndex(0x57); Lcd_WriteData_16Bit(0x0400); //0501
- Lcd_WriteIndex(0x58); Lcd_WriteData_16Bit(0x1108); //0E00
- Lcd_WriteIndex(0x59); Lcd_WriteData_16Bit(0x050C); //000E
- delay_1ms(50); // Delay 50ms
- Lcd_WriteIndex(0x07); Lcd_WriteData_16Bit(0x1017);
- Lcd_WriteIndex(0x22);
-
- return;
- }
复制代码 |
|