本帖最后由 FSL_TICS_A 于 2014-9-15 11:51 编辑
程序运行, 得到的DeviceCode为6783 求有经验的给点建议
int main(void)
{
DelayInit();
LCD_Init();
while(1);
}
#include "ili9325.h"
#include "gpio.h"
uint16_t DeviceCode;
//PTB0~8 DB0~8 **** PTA8~15 DB8~15
void DataToIO(uint16_t val)
{
uint16_t dat=0;
dat = GPIO_ReadPort(HW_GPIOB); // DBL
dat = (dat&0xFF00) | (val&0x00FF);
GPIO_WritePort(HW_GPIOB, dat);
dat = GPIO_ReadPort(HW_GPIOA); // DBH
dat = (dat&0xFF00) | ((val>>8)&0x00FF);
GPIO_WritePort(HW_GPIOA, dat);
}
void LCD_WR_DATA(uint16_t data)
{
LCD_RS_SET;
LCD_CS_CLR;
DataToIO(data);
LCD_WR_CLR;
LCD_WR_SET;
LCD_CS_SET;
}
void LCD_WR_REG(uint16_t data)
{
LCD_RS_CLR;
LCD_CS_CLR;
DataToIO(data);
LCD_WR_CLR;
LCD_WR_SET;
LCD_CS_SET;
}
void LCD_WriteReg(uint16_t LCD_Reg, uint16_t LCD_RegValue)
{
LCD_WR_REG(LCD_Reg);
LCD_WR_DATA(LCD_RegValue);
}
uint16_t LCD_ReadReg(uint16_t LCD_Reg)
{
uint16_t t,i,datH,datL;
LCD_WR_REG(LCD_Reg);
for(i=0;i<7;i++)
{
GPIO_QuickInit(HW_GPIOB,i,kGPIO_Mode_IPU);
}
for(i=8;i<16;i++)
{
GPIO_QuickInit(HW_GPIOA,i,kGPIO_Mode_IPU);
}
PTA->PDOR=0XFFFF;
PTB->PDOR=0XFFFF;
LCD_RS_SET;
LCD_CS_CLR;
LCD_RD_CLR;
DelayUs(5);
datH = PTA->PDIR; /**< Port Data Input Register, offset: 0x10 */
datL = PTB->PDIR; /**< Port Data Input Register, offset: 0x10 */
LCD_CS_SET;
for(i=0;i<7;i++)
{
GPIO_QuickInit(HW_GPIOB,i,kGPIO_Mode_OPP);
}
for(i=8;i<16;i++)
{
GPIO_QuickInit(HW_GPIOA,i,kGPIO_Mode_OPP);
}
DataToIO(0XFFFF);
t = ((datH<<8)&0xFF00) | (datL&0x00FF);
return t;
}
void LCD_Init(void)
{
uint8_t i;
for(i=4;i<10;i++)
{
GPIO_QuickInit(HW_GPIOD,i,kGPIO_Mode_OPP);
}
LCD_CS_SET;
LCD_RD_SET;
LCD_WR_SET;
DelayMs(50); // delay 50 ms
LCD_WriteReg(0x0000,0x0001);
DelayMs(50); // delay 50 ms
LCD_RD_SET;
LCD_WR_SET;
DeviceCode = LCD_ReadReg(0x0000);
DelayMs(20);
LCD_LED_SET;
}
#define LCD_LED_SET PDout(9)=1
#define LCD_LED_CLR PDout(9)=0
#define LCD_CS_SET PDout(8)=1
#define LCD_RS_SET PDout(5)=1
#define LCD_WR_SET PDout(6)=1
#define LCD_RD_SET PDout(7)=1
#define LCD_RST_SET PDout(4)=1
#define LCD_CS_CLR PDout(8)=0
#define LCD_RS_CLR PDout(5)=0
#define LCD_WR_CLR PDout(6)=0
#define LCD_RD_CLR PDout(7)=0
#define LCD_RST_CLR PDout(4)=0
void DataToIO(uint16_t val);
void LCD_Init(void);
void LCD_WR_DATA(uint16_t data);
void LCD_WR_REG(uint16_t data);
void LCD_WriteReg(uint16_t LCD_Reg, uint16_t LCD_RegValue);
uint16_t LCD_ReadReg(uint16_t LCD_Reg);
|