9GSTM32EWARM开发过程简介之四

2020-02-15 18:58:50 来源: 延边信息港

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

// 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_IO_Mode = GPIO_Mode_Out_PP;

GPIO_IO_Speed = GPIO_Speed_50MHz;

/* Set PC.04(LCDRST) as alternate

function push pull */

GPIO_IO_Pin = GPIO_Pin_4;

GPIO_Init(GPIOC, &GPIO_InitStructure);

GPIO_IO_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_IO_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_IO_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 */

MC_AddressSetupTime = 1;

MC_AddressHoldTime = 1;

MC_DataSetupTime = 6;

MC_BusTurnAroundDuration = 1;

MC_CLKDivision = 1;

MC_DataLatency = 2;

MC_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_MC_Bank = FSMC_Bank1_NORSRAM1;

FSMC_MC_DataAddressMux = FSMC_DataAddressMux_Disable;

FSMC_MC_MemoryType = FSMC_MemoryType_SRAM;

FSMC_MC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;

FSMC_MC_BurstAccessMode = FSMC_BurstAccessMode_Disable;

FSMC_MC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;

FSMC_MC_WrapMode = FSMC_WrapMode_Disable;

FSMC_MC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;

FSMC_MC_WriteOperation = FSMC_WriteOperation_Enable;

FSMC_MC_WaitSignal = FSMC_WaitSignal_Disable;

FSMC_MC_ExtendedMode = FSMC_ExtendedMode_Enable;

FSMC_MC_WriteBurst = FSMC_WriteBurst_Disable;

FSMC_MC_ReadWriteTimingStruct =

FSMC_MC_WriteTimingStruct =

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 *) 0x))

/*A16=1 -- cmd*/

#define LCD_CMD_ADDR(*((volatile unsigned char *) 0x))

#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);

}

/*[page]

六,定义API访问接口

*/

void LCD_Reset(void)

{

GPIO_SetBits(GPIOC, GPIO_Pin_4);//置1 LCDRST = 1;

OSTimeDlyHMSM(0, 0, 0, 10);

GPIO_ResetBits(GPIOC, GPIO_Pin_4);//清0 LCDRST = 0;

OSTimeDlyHMSM(0, 0, 0, 50);

GPIO_SetBits(GPIOC, GPIO_Pin_4);//置1 LCDRST = 1;

OSTimeDlyHMSM(0, 0, 0, 50);

}

void STM32_T6963C_Init(void)

{

unsigned int i;

/* Configure the LCD Control pins --------------------------------------------*/

LCD_CtrlLinesConfig();

/* Configure the FSMC Parallel interface -------------------------------------*/

LCD_FSMCConfig();

/* initialize sequence -------------------------------*/

LCD_Reset();

WriteCMD2(0x00,0x08,0x42);//设置显示图形首地址

WriteCMD2((FRAME_BUFFER_LENGTH/8),0x00,0x43);//设置图形显示区域宽度

WriteCMD0(0x98);//图形显示开

WriteCMD0(0x88);//设定显示方式,图形/文本或的方式

}

void STM32_T6963C_Clear(void)

{

unsigned int i;

WriteCMD2(0x00,0x00,0x24);

WriteCMD0(0xb0);

for(i=0;i

成都不孕不育医院靠谱吗
河北省老年病医院怎么样
山西白癜风专科医院哪家好
柳州治疗阴道炎方法
合肥出名的牛皮癣医院
本文标签: