高中生
最后登录1970-1-1
在线时间 小时
注册时间2016-6-3
|
如题。
代码如下:#include "MainTask.h"
/**
* @brief 向ILI9341写入命令
* @param usCmd :要写入的命令(表寄存器地址)
* @retval 无
*/
static __inline void ILI9341_Write_Cmd ( uint16_t usCmd )
{
* ( __IO uint16_t * ) ( macFSMC_Addr_ILI9341_CMD ) = usCmd;
}
/**
* @brief 向ILI9341写入数据
* @param usData :要写入的数据
* @retval 无
*/
static __inline void ILI9341_Write_Data ( uint16_t usData )
{
* ( __IO uint16_t * ) ( macFSMC_Addr_ILI9341_DATA ) = usData;
}
/**
* @brief 从ILI9806G读取数据
* @param 无
* @retval 读取到的数据
*/
__inline uint16_t ILI9806G_Read_Data ( void )
{
return ( * ( __IO uint16_t * ) ( macFSMC_Addr_ILI9341_DATA ) );
}
/**
* @brief 用于 ILI9341 简单延时函数
* @param nCount :延时计数值
* @retval 无
*/
static void ILI9341_Delay ( __IO uint32_t nCount )
{
for ( ; nCount != 0; nCount -- );
}
/**
* @brief 初始化ILI9341的IO引脚
* @param 无
* @retval 无
*/
static void ILI9341_GPIO_Config ( void )
{
GPIO_InitTypeDef GPIO_InitStructure;
// RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC,ENABLE);
/* 使能FSMC对应相应管脚时钟*/
RCC_AHB1PeriphClockCmd (
/*控制信号*/
ILI9341_CS_CLK|ILI9341_DC_CLK|ILI9341_WR_CLK|
ILI9341_RD_CLK |ILI9341_BK_CLK|ILI9341_RST_CLK|
/*数据信号*/
ILI9341_D0_CLK|ILI9341_D1_CLK| ILI9341_D2_CLK |
ILI9341_D3_CLK | ILI9341_D4_CLK|ILI9341_D5_CLK|
ILI9341_D6_CLK | ILI9341_D7_CLK|ILI9341_D8_CLK|
ILI9341_D9_CLK | ILI9341_D10_CLK|ILI9341_D11_CLK|
ILI9341_D12_CLK | ILI9341_D13_CLK|ILI9341_D14_CLK|
ILI9341_D15_CLK , ENABLE );
/* 配置FSMC相对应的数据线,FSMC-D0~D15 */
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_Pin = ILI9341_D0_PIN;
GPIO_Init(ILI9341_D0_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_D0_PORT,ILI9341_D0_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_D1_PIN;
GPIO_Init(ILI9341_D1_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_D1_PORT,ILI9341_D1_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_D2_PIN;
GPIO_Init(ILI9341_D2_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_D2_PORT,ILI9341_D2_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_D3_PIN;
GPIO_Init(ILI9341_D3_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_D3_PORT,ILI9341_D3_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_D4_PIN;
GPIO_Init(ILI9341_D4_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_D4_PORT,ILI9341_D4_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_D5_PIN;
GPIO_Init(ILI9341_D5_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_D5_PORT,ILI9341_D5_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_D6_PIN;
GPIO_Init(ILI9341_D6_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_D6_PORT,ILI9341_D6_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_D7_PIN;
GPIO_Init(ILI9341_D7_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_D7_PORT,ILI9341_D7_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_D8_PIN;
GPIO_Init(ILI9341_D8_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_D8_PORT,ILI9341_D8_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_D9_PIN;
GPIO_Init(ILI9341_D9_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_D9_PORT,ILI9341_D9_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_D10_PIN;
GPIO_Init(ILI9341_D10_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_D10_PORT,ILI9341_D10_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_D11_PIN;
GPIO_Init(ILI9341_D11_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_D11_PORT,ILI9341_D11_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_D12_PIN;
GPIO_Init(ILI9341_D12_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_D12_PORT,ILI9341_D12_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_D13_PIN;
GPIO_Init(ILI9341_D13_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_D13_PORT,ILI9341_D13_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_D14_PIN;
GPIO_Init(ILI9341_D14_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_D14_PORT,ILI9341_D14_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_D15_PIN;
GPIO_Init(ILI9341_D15_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_D15_PORT,ILI9341_D15_PinSource,FSMC_AF);
/* 配置FSMC相对应的控制线
* FSMC_NOE CD-RD
* FSMC_NWE CD-WR
* FSMC_NE1 CD-CS
* FSMC_A0 CD-DC
*/
GPIO_InitStructure.GPIO_Pin = ILI9341_RD_PIN;
GPIO_Init(ILI9341_RD_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_RD_PORT,ILI9341_RD_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_WR_PIN;
GPIO_Init(ILI9341_WR_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_WR_PORT,ILI9341_WR_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_CS_PIN;
GPIO_Init(ILI9341_CS_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_CS_PORT,ILI9341_CS_PinSource,FSMC_AF);
GPIO_InitStructure.GPIO_Pin = ILI9341_DC_PIN;
GPIO_Init(ILI9341_DC_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(ILI9341_DC_PORT,ILI9341_DC_PinSource,FSMC_AF);
/* 配置LCD复位RST控制管脚*/
GPIO_InitStructure.GPIO_Pin = ILI9341_RST_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init ( ILI9341_RST_PORT, & GPIO_InitStructure );
/* 配置LCD背光控制管脚BK*/
GPIO_InitStructure.GPIO_Pin = ILI9341_BK_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init ( ILI9341_BK_PORT, & GPIO_InitStructure );
GPIO_SetBits ( ILI9341_BK_PORT, ILI9341_BK_PIN );//先关闭背光
}
/**
* @brief LCD FSMC 模式配置
* @param 无
* @retval 无
*/
static void ILI9341_FSMC_Config ( void )
{
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef p;
/* 使能FSMC时钟*/
RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC,ENABLE);
FSMC_NORSRAMCmd ( FSMC_Bank1_NORSRAM1, DISABLE );
p.FSMC_AddressSetupTime = 0x04; //地址建立时间
p.FSMC_AddressHoldTime = 0x00; //地址保持时间
p.FSMC_DataSetupTime = 0x0B; //数据建立时间
p.FSMC_BusTurnAroundDuration = 0x00;
p.FSMC_CLKDivision = 0x00;
p.FSMC_DataLatency = 0x00;
p.FSMC_AccessMode = FSMC_AccessMode_B; //模式B比较适用于ILI9341
FSMC_NORSRAMInitStructure.FSMC_Bank = macFSMC_Bank1_NORSRAMx;
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_NOR;
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = & p;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = & p;
FSMC_NORSRAMInit ( & FSMC_NORSRAMInitStructure );
/* 使能 FSMC_Bank1_NORSRAM4 */
FSMC_NORSRAMCmd ( FSMC_Bank1_NORSRAM1, ENABLE );
}
/**
* @brief 初始化ILI9341寄存器
* @param 无
* @retval 无
*/
static void ILI9341_REG_Config ( void )
{
/* Power control B (CFh) */
macDEBUG_DELAY ();
ILI9341_Write_Cmd ( 0xCF );
ILI9341_Write_Data ( 0x00 );
ILI9341_Write_Data ( 0x81 );
ILI9341_Write_Data ( 0x30 );
/* Power on sequence control (EDh) */
macDEBUG_DELAY ();
ILI9341_Write_Cmd ( 0xED );
ILI9341_Write_Data ( 0x64 );
ILI9341_Write_Data ( 0x03 );
ILI9341_Write_Data ( 0x12 );
ILI9341_Write_Data ( 0x81 );
/* Driver timing control A (E8h) */
macDEBUG_DELAY ();
ILI9341_Write_Cmd ( 0xE8 );
ILI9341_Write_Data ( 0x85 );
ILI9341_Write_Data ( 0x10 );
ILI9341_Write_Data ( 0x78 );
/* Power control A (CBh) */
macDEBUG_DELAY ();
ILI9341_Write_Cmd ( 0xCB );
ILI9341_Write_Data ( 0x39 );
ILI9341_Write_Data ( 0x2C );
ILI9341_Write_Data ( 0x00 );
ILI9341_Write_Data ( 0x34 );
ILI9341_Write_Data ( 0x02 );
/* Pump ratio control (F7h) */
macDEBUG_DELAY ();
ILI9341_Write_Cmd ( 0xF7 );
ILI9341_Write_Data ( 0x20 );
/* Driver timing control B */
macDEBUG_DELAY ();
ILI9341_Write_Cmd ( 0xEA );
ILI9341_Write_Data ( 0x00 );
ILI9341_Write_Data ( 0x00 );
/* Frame Rate Control (In Normal Mode/Full Colors) (B1h) */
macDEBUG_DELAY ();
ILI9341_Write_Cmd ( 0xB1 );
ILI9341_Write_Data ( 0x00 );
ILI9341_Write_Data ( 0x1B );
/* Display Function Control (B6h) */
macDEBUG_DELAY ();
ILI9341_Write_Cmd ( 0xB6 );
ILI9341_Write_Data ( 0x0A );
ILI9341_Write_Data ( 0xA2 );
/* Power Control 1 (C0h) */
macDEBUG_DELAY ();
ILI9341_Write_Cmd ( 0xC0 );
ILI9341_Write_Data ( 0x35 );
/* Power Control 2 (C1h) */
macDEBUG_DELAY ();
ILI9341_Write_Cmd ( 0xC1 );
ILI9341_Write_Data ( 0x11 );
/* VCOM Control 1 (C5h) */
ILI9341_Write_Cmd ( 0xC5 );
ILI9341_Write_Data ( 0x45 );
ILI9341_Write_Data ( 0x45 );
/* VCOM Control 2 (C7h) */
ILI9341_Write_Cmd ( 0xC7 );
ILI9341_Write_Data ( 0xA2 );
/* Enable 3G (F2h) */
ILI9341_Write_Cmd ( 0xF2 );
ILI9341_Write_Data ( 0x00 );
/* Gamma Set (26h) */
ILI9341_Write_Cmd ( 0x26 );
ILI9341_Write_Data ( 0x01 );
macDEBUG_DELAY ();
/* Positive Gamma Correction */
ILI9341_Write_Cmd ( 0xE0 ); //Set Gamma
ILI9341_Write_Data ( 0x0F );
ILI9341_Write_Data ( 0x26 );
ILI9341_Write_Data ( 0x24 );
ILI9341_Write_Data ( 0x0B );
ILI9341_Write_Data ( 0x0E );
ILI9341_Write_Data ( 0x09 );
ILI9341_Write_Data ( 0x54 );
ILI9341_Write_Data ( 0xA8 );
ILI9341_Write_Data ( 0x46 );
ILI9341_Write_Data ( 0x0C );
ILI9341_Write_Data ( 0x17 );
ILI9341_Write_Data ( 0x09 );
ILI9341_Write_Data ( 0x0F );
ILI9341_Write_Data ( 0x07 );
ILI9341_Write_Data ( 0x00 );
/* Negative Gamma Correction (E1h) */
ILI9341_Write_Cmd ( 0XE1 ); //Set Gamma
ILI9341_Write_Data ( 0x00 );
ILI9341_Write_Data ( 0x19 );
ILI9341_Write_Data ( 0x1B );
ILI9341_Write_Data ( 0x04 );
ILI9341_Write_Data ( 0x10 );
ILI9341_Write_Data ( 0x07 );
ILI9341_Write_Data ( 0x2A );
ILI9341_Write_Data ( 0x47 );
ILI9341_Write_Data ( 0x39 );
ILI9341_Write_Data ( 0x03 );
ILI9341_Write_Data ( 0x06 );
ILI9341_Write_Data ( 0x06 );
ILI9341_Write_Data ( 0x30 );
ILI9341_Write_Data ( 0x38 );
ILI9341_Write_Data ( 0x0F );
/* memory access control set */
macDEBUG_DELAY ();
ILI9341_Write_Cmd ( 0x36 );
ILI9341_Write_Data ( 0xC8 ); /*竖屏 左上角到 (起点)到右下角 (终点)扫描方式*/
macDEBUG_DELAY ();
/* column address control set */
ILI9341_Write_Cmd ( macCMD_SetCoordinateX );
ILI9341_Write_Data ( 0x00 );
ILI9341_Write_Data ( 0x00 );
ILI9341_Write_Data ( 0x00 );
ILI9341_Write_Data ( 0xEF );
/* page address control set */
macDEBUG_DELAY ();
ILI9341_Write_Cmd ( macCMD_SetCoordinateY );
ILI9341_Write_Data ( 0x00 );
ILI9341_Write_Data ( 0x00 );
ILI9341_Write_Data ( 0x01 );
ILI9341_Write_Data ( 0x3F );
/* Pixel Format Set (3Ah) */
macDEBUG_DELAY ();
ILI9341_Write_Cmd ( 0x3a );
ILI9341_Write_Data ( 0x55 );
/* Sleep Out (11h) */
ILI9341_Write_Cmd ( 0x11 );
ILI9341_Delay ( 0xAFFf<<2 );
macDEBUG_DELAY ();
/* Display ON (29h) */
ILI9341_Write_Cmd ( 0x29 );
}
/**
* @brief ILI9341 软件复位
* @param 无
* @retval 无
*/
static void ILI9341_Rst ( void )
{
GPIO_ResetBits ( ILI9341_RST_PORT, ILI9341_RST_PIN ); //低电平复位
ILI9341_Delay ( 0xAFF );
GPIO_SetBits ( ILI9341_RST_PORT, ILI9341_RST_PIN );
ILI9341_Delay ( 0xAFF );
}
/**
* @brief ILI9341初始化函数,如果要用到lcd,一定要调用这个函数
* @param 无
* @retval 无
*/
void ILI9341_Init ( void )
{
ILI9341_GPIO_Config ();
ILI9341_FSMC_Config ();
ILI9341_Rst ();
ILI9341_REG_Config ();
}
/**
* @brief 在ILI9341显示器上开辟一个窗口
* @param usX :在特定扫描方向下窗口的起点X坐标
* @param usY :在特定扫描方向下窗口的起点Y坐标
* @param usWidth :窗口的宽度
* @param usHeight :窗口的高度
* @retval 无
*/
void ILI9341_OpenWindow ( uint16_t usX, uint16_t usY, uint16_t usWidth, uint16_t usHeight )
{
ILI9341_Write_Cmd ( macCMD_SetCoordinateX ); /* 设置X坐标 */
ILI9341_Write_Data ( usX >> 8 ); /* 先高8位,然后低8位 */
ILI9341_Write_Data ( usX & 0xff ); /* 设置起始点和结束点*/
ILI9341_Write_Data ( ( usX + usWidth - 1 ) >> 8 );
ILI9341_Write_Data ( ( usX + usWidth - 1 ) & 0xff );
ILI9341_Write_Cmd ( macCMD_SetCoordinateY ); /* 设置Y坐标*/
ILI9341_Write_Data ( usY >> 8 );
ILI9341_Write_Data ( usY & 0xff );
ILI9341_Write_Data ( ( usY + usHeight - 1 ) >> 8 );
ILI9341_Write_Data ( ( usY + usHeight - 1) & 0xff );
ILI9341_Write_Cmd(macCMD_SetPixel);
}
/**
* @brief 在ILI9806G显示器上以某一颜色填充像素点
* @param ulAmout_Point :要填充颜色的像素点的总数目
* @param usColor :颜色
* @retval 无
*/
static __inline void ILI9341_FillColor ( uint32_t ulAmout_Point, uint16_t usColor )
{
uint32_t i = 0;
/* memory write */
ILI9341_Write_Cmd ( 0x2C );
for ( i = 0; i < ulAmout_Point; i ++ )
ILI9341_Write_Data ( usColor );
}
/**
* @brief 对ILI9806G显示器的某一窗口以某种颜色进行清屏
* @param usX :在特定扫描方向下窗口的起点X坐标
* @param usY :在特定扫描方向下窗口的起点Y坐标
* @param usWidth :窗口的宽度
* @param usHeight :窗口的高度
* @note 可使用LCD_SetBackColor、LCD_SetTextColor、LCD_SetColors函数设置颜色
* @retval 无
*/
void ILI9341_Clear ( uint16_t usX, uint16_t usY, uint16_t usWidth, uint16_t usHeight )
{
ILI9341_OpenWindow ( usX, usY, usWidth, usHeight );
ILI9341_FillColor ( usWidth * usHeight, 0x051F );
// ILI9341_REG_Config();
}
.H中的代码
#ifndef __BSP_ILI9341_LCD_H
#define __BSP_ILI9341_LCD_H
#include "stm32f4xx.h"
/***************************************************************************************
2^26 =0X0400 0000 = 64MB,每个 BANK 有4*64MB = 256MB
64MB:FSMC_Bank1_NORSRAM1:0X6000 0000 ~ 0X63FF FFFF
64MB:FSMC_Bank1_NORSRAM2:0X6400 0000 ~ 0X67FF FFFF
64MB:FSMC_Bank1_NORSRAM3:0X6800 0000 ~ 0X6BFF FFFF
64MB:FSMC_Bank1_NORSRAM4:0X6C00 0000 ~ 0X6FFF FFFF
选择BANK1-BORSRAM4 连接 TFT,地址范围为0X6C00 0000 ~ 0X6FFF FFFF
FSMC_A23 接LCD的DC(寄存器/数据选择)脚
寄存器基地址 = 0X6C00 0000
RAM基地址 = 0X6D00 0000 = 0X6C00 0000+2^23*2 = 0X6C00 0000 + 0X100 0000 = 0X6D00 0000
当选择不同的地址线时,地址要重新计算
****************************************************************************************/
/******************************* ILI9341 显示屏的 FSMC 参数定义 ***************************/
#define macFSMC_Addr_ILI9341_CMD ( ( uint32_t ) 0x60000000 ) //FSMC_Bank1_NORSRAM1用于LCD命令操作的地址
#define macFSMC_Addr_ILI9341_DATA ( ( uint32_t ) 0x60020000 ) //FSMC_Bank1_NORSRAM1用于LCD数据操作的地址
//方便emWin使用
#define macFSMC_ILI9341_REG *(__IO uint16_t *)(0x60000000)
#define macFSMC_ILI9341_RAM *(__IO uint16_t *)(0x60020000)
#define macFSMC_Bank1_NORSRAMx FSMC_Bank1_NORSRAM1
/******************************* ILI9806G 显示屏8080通讯引脚定义 ***************************/
/******控制信号线******/
#define FSMC_AF GPIO_AF_FSMC
//片选,选择NOR/SRAM块
#define ILI9341_CS_CLK RCC_AHB1Periph_GPIOD
#define ILI9341_CS_PORT GPIOD
#define ILI9341_CS_PIN GPIO_Pin_7
#define ILI9341_CS_PinSource GPIO_PinSource7
//DC引脚,使用FSMC的地址信号控制,本引脚决定了访问LCD时使用的地址
//PF0为FSMC_A0
#define ILI9341_DC_CLK RCC_AHB1Periph_GPIOD
#define ILI9341_DC_PORT GPIOD
#define ILI9341_DC_PIN GPIO_Pin_11
#define ILI9341_DC_PinSource GPIO_PinSource11
//写使能
#define ILI9341_WR_CLK RCC_AHB1Periph_GPIOD
#define ILI9341_WR_PORT GPIOD
#define ILI9341_WR_PIN GPIO_Pin_5
#define ILI9341_WR_PinSource GPIO_PinSource5
//读使能
#define ILI9341_RD_CLK RCC_AHB1Periph_GPIOD
#define ILI9341_RD_PORT GPIOD
#define ILI9341_RD_PIN GPIO_Pin_4
#define ILI9341_RD_PinSource GPIO_PinSource4
//复位引脚
#define ILI9341_RST_CLK RCC_AHB1Periph_GPIOE
#define ILI9341_RST_PORT GPIOE
#define ILI9341_RST_PIN GPIO_Pin_1
//背光引脚
#define ILI9341_BK_CLK RCC_AHB1Periph_GPIOB
#define ILI9341_BK_PORT GPIOB
#define ILI9341_BK_PIN GPIO_Pin_1
/********数据信号线***************/
#define ILI9341_D0_CLK RCC_AHB1Periph_GPIOD
#define ILI9341_D0_PORT GPIOD
#define ILI9341_D0_PIN GPIO_Pin_14
#define ILI9341_D0_PinSource GPIO_PinSource14
#define ILI9341_D1_CLK RCC_AHB1Periph_GPIOD
#define ILI9341_D1_PORT GPIOD
#define ILI9341_D1_PIN GPIO_Pin_15
#define ILI9341_D1_PinSource GPIO_PinSource15
#define ILI9341_D2_CLK RCC_AHB1Periph_GPIOD
#define ILI9341_D2_PORT GPIOD
#define ILI9341_D2_PIN GPIO_Pin_0
#define ILI9341_D2_PinSource GPIO_PinSource0
#define ILI9341_D3_CLK RCC_AHB1Periph_GPIOD
#define ILI9341_D3_PORT GPIOD
#define ILI9341_D3_PIN GPIO_Pin_1
#define ILI9341_D3_PinSource GPIO_PinSource1
#define ILI9341_D4_CLK RCC_AHB1Periph_GPIOE
#define ILI9341_D4_PORT GPIOE
#define ILI9341_D4_PIN GPIO_Pin_7
#define ILI9341_D4_PinSource GPIO_PinSource7
#define ILI9341_D5_CLK RCC_AHB1Periph_GPIOE
#define ILI9341_D5_PORT GPIOE
#define ILI9341_D5_PIN GPIO_Pin_8
#define ILI9341_D5_PinSource GPIO_PinSource8
#define ILI9341_D6_CLK RCC_AHB1Periph_GPIOE
#define ILI9341_D6_PORT GPIOE
#define ILI9341_D6_PIN GPIO_Pin_9
#define ILI9341_D6_PinSource GPIO_PinSource9
#define ILI9341_D7_CLK RCC_AHB1Periph_GPIOE
#define ILI9341_D7_PORT GPIOE
#define ILI9341_D7_PIN GPIO_Pin_10
#define ILI9341_D7_PinSource GPIO_PinSource10
#define ILI9341_D8_CLK RCC_AHB1Periph_GPIOE
#define ILI9341_D8_PORT GPIOE
#define ILI9341_D8_PIN GPIO_Pin_11
#define ILI9341_D8_PinSource GPIO_PinSource11
#define ILI9341_D9_CLK RCC_AHB1Periph_GPIOE
#define ILI9341_D9_PORT GPIOE
#define ILI9341_D9_PIN GPIO_Pin_12
#define ILI9341_D9_PinSource GPIO_PinSource12
#define ILI9341_D10_CLK RCC_AHB1Periph_GPIOE
#define ILI9341_D10_PORT GPIOE
#define ILI9341_D10_PIN GPIO_Pin_13
#define ILI9341_D10_PinSource GPIO_PinSource13
#define ILI9341_D11_CLK RCC_AHB1Periph_GPIOE
#define ILI9341_D11_PORT GPIOE
#define ILI9341_D11_PIN GPIO_Pin_14
#define ILI9341_D11_PinSource GPIO_PinSource14
#define ILI9341_D12_CLK RCC_AHB1Periph_GPIOE
#define ILI9341_D12_PORT GPIOE
#define ILI9341_D12_PIN GPIO_Pin_15
#define ILI9341_D12_PinSource GPIO_PinSource15
#define ILI9341_D13_CLK RCC_AHB1Periph_GPIOD
#define ILI9341_D13_PORT GPIOD
#define ILI9341_D13_PIN GPIO_Pin_8
#define ILI9341_D13_PinSource GPIO_PinSource8
#define ILI9341_D14_CLK RCC_AHB1Periph_GPIOD
#define ILI9341_D14_PORT GPIOD
#define ILI9341_D14_PIN GPIO_Pin_9
#define ILI9341_D14_PinSource GPIO_PinSource9
#define ILI9341_D15_CLK RCC_AHB1Periph_GPIOD
#define ILI9341_D15_PORT GPIOD
#define ILI9341_D15_PIN GPIO_Pin_10
#define ILI9341_D15_PinSource GPIO_PinSource10
/*************************************** 调试预用 ******************************************/
#define macDEBUG_DELAY()
/***************** ILI934 显示屏全屏默认(扫描方向为1时)最大宽度和最大高度 *********************/
#define macILI9341_Default_Max_Width 240 //起始点的X坐标
#define macILI9341_Default_Max_Heigth 320 //起始点的Y坐标
/******************************* 定义 ILI9341 常用命令 ********************************/
#define macCMD_SetCoordinateX 0x2A //设置X坐标
#define macCMD_SetCoordinateY 0x2B //设置Y坐标
#define macCMD_SetPixel 0x2C //填充像素
/********************************** 声明 ILI934 函数 ***************************************/
#define LCD_BK_EN GPIO_ResetBits(ILI9341_BK_PORT, ILI9341_BK_PIN)
#define LCD_BK_DIS GPIO_SetBits(ILI9341_BK_PORT, ILI9341_BK_PIN)
void ILI9341_Init ( void );
void ILI9341_OpenWindow ( uint16_t usX, uint16_t usY, uint16_t usWidth, uint16_t usHeight );
void ILI9341_Clear ( uint16_t usX, uint16_t usY, uint16_t usWidth, uint16_t usHeight );
#endif /* __BSP_ILI9341_ILI9341_H */
|
|