您的位置 首页 嵌入式

9G-STM32 EWARM开发进程简介之四

9G-STM32EWARM开发过程简介之四–移植FSMC的T6963C驱动*一,把VDT6与T6963C连接NOE->RD;NWE->WR;NE1->CE;A16

// 9G-STM32 EWARM开发进程简介之四–移植FSMC的T6963C驱动

/*
一,把VDT6与T6963C衔接
NOE -> /RD ;
NWE -> /WR ;
NE1 -> /CE ;
A16 -> C/D ;A16 最近,接线最便利。
PC4 -> /RST ;
D8 -> DB0 ; D8-D15 最近, 接线最便利。

D15 -> DB7 ;

二,把IO装备成FSMC形式
*/
void LCD_CtrlLinesConfig(void)
{
GPIO_InitTypeDef GPIO_InitStructure;

/* Enable FSMC, GPIOC, GPIOD, GPIOE clocks */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE , ENABLE);

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

/* Set PC.04(LCDRST) as alternate
function push pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_Init(GPIOC, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

/* Set PD.04(NOE), PD.05(NWE), PD.07(NE1), PD.08(D13), PD.09(D14), PD.10(D15), PD.11(A16) as alternate
function push pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 ;
GPIO_Init(GPIOD, &GPIO_InitStructure);

/* Set PE.11(D8), PE.12(D9), PE.13(D10), PE.14(D11), PE.15(D12) as alternate function push pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_Init(GPIOE, &GPIO_InitStructure);
}

/*
三,装备FSMC作业形式
*/
void LCD_FSMCConfig(void)
{
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef p;

/*– FSMC Configuration ——————————————————*/
/*———————– SRAM Bank 1 —————————————-*/
/* FSMC_Bank1_NORSRAM1 configuration */
p.FSMC_AddressSetupTime = 1;
p.FSMC_AddressHoldTime = 1;
p.FSMC_DataSetupTime = 6;
p.FSMC_BusTurnAroundDuration = 1;
p.FSMC_CLKDivision = 1;
p.FSMC_DataLatency = 2;
p.FSMC_AccessMode = FSMC_AccessMode_A;

/* Color LCD configuration ————————————
LCD configured as follow:
– Data/Address MUX = Disable
– Memory Type = SRAM
– Data Width = 16bit
– Write Operation = Enable
– Extended Mode = Enable
– Asynchronous Wait = Disable */
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
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_Enable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;

FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);

/* Enable FSMC_Bank1_NORSRAM1 */
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
}
/*
四,界说物理拜访地址
*///TXEC 240128BDLNW-EY
// T6963C

/*A16=0 — dat*/
#define LCD_DAT_ADDR(*((volatile unsigned char *) 0x60000001))
/*A16=1 — cmd*/
#define LCD_CMD_ADDR(*((volatile unsigned char *) 0x60020001))

#define IMAGE1
#define TEXT0
#define VISION_PIXEL_LENGTH240
#define VISION_PIXEL_WIDTH128
#define FRAME_BUFFER_LENGTH256
#define FRAME_BUFFER_WIDTH128
/*
五,界说指令拜访接口
*///指令&数据读写状况
static void RWCheck(void)
{
while((LCD_CMD_ADDR & 0x03) != 0x03); //低电平忙
}
//数据主动写状况
void CheckAutoWrite(void)
{
while((LCD_CMD_ADDR & 0x08) != 0x08); //低电平忙
}
//屏读/屏考贝犯错状况
void CheckScreen(void)
{
while(LCD_CMD_ADDR & 0x40); //1犯错,0正确
}
static void WriteDATA(unsigned char Data)
{
RWCheck();
LCD_DAT_ADDR = Data;
}
static unsigned char ReadDATA(void)
{
RWCheck();
return LCD_DAT_ADDR;
}
static void WriteCMD0(unsigned char Comd)
{
RWCheck();
LCD_CMD_ADDR = Comd;
}
static void WriteCMD1(unsigned char Para,unsigned char Comd)
{
WriteDATA(Para);
WriteCMD0(Comd);
}
static void WriteCMD2(unsigned char Par1,unsigned char Par2,unsigned char Comd)
{
WriteDATA(Par1);
WriteDATA(Par2);
WriteCMD0(Comd);
}
/*

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qianrushi/319311.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部