智能车制作
标题:
飞思卡尔 k60 iliac25驱动
[打印本页]
作者:
欲望~控♂
时间:
2014-8-29 21:27
标题:
飞思卡尔 k60 iliac25驱动
程序运行, 得到的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;
}
复制代码
#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;
}
复制代码
欢迎光临 智能车制作 (http://dns.znczz.com/)
Powered by Discuz! X3.2