新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 9G-STM32 EWARM開發(fā)過程簡介之四

9G-STM32 EWARM開發(fā)過程簡介之四

作者: 時(shí)間:2016-11-29 來源:網(wǎng)絡(luò) 收藏
// 9G-STM32 EWARM開發(fā)過程簡介之四--移植FSMC的T6963C驅(qū)動(dòng)

/*
一,把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);
}

本文引用地址:http://m.butianyuan.cn/article/201611/323210.htm

/*
三,配置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
/*
五,定義指令訪問接口
*///指令&數(shù)據(jù)讀寫狀態(tài)
static void RWCheck(void)
{
while((LCD_CMD_ADDR & 0x03) != 0x03); //低電平忙
}
//數(shù)據(jù)自動(dòng)寫狀態(tài)
void CheckAutoWrite(void)
{
while((LCD_CMD_ADDR & 0x08) != 0x08); //低電平忙
}
//屏讀/屏考貝出錯(cuò)狀態(tài)
void CheckScreen(void)
{
while(LCD_CMD_ADDR & 0x40); //1出錯(cuò),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);
}
/*


上一頁 1 2 下一頁

關(guān)鍵詞: 9G-STM32EWARM開發(fā)過

評(píng)論


技術(shù)專區(qū)

關(guān)閉