求高手指点SSD1289的驱动程序【已解决】

2019-03-24 14:00发布

在网上找到的一些关于ssd1289的驱动程序,想移植到LM3S9B92上,程序为点亮TFT屏,只是没有成功, 求高手指点迷津。。。  #include "hw_ints.h"
#include "hw_memmap.h"
#include "hw_types.h"
#include "hw_ints.h"
#include "gpio.h"
#include "sysctl.h" #define CSPORT GPIO_PORTC_BASE
#define CS GPIO_PIN_2
#define RSPORT GPIO_PORTC_BASE
#define RS GPIO_PIN_1
#define WRPORT GPIO_PORTC_BASE
#define WR GPIO_PIN_0
#define RDPORT GPIO_PORTC_BASE
#define RD GPIO_PIN_3
#define RESPORT GPIO_PORTH_BASE
#define RES GPIO_PIN_7
#define PWMPORT GPIO_PORTE_BASE
#define PWM GPIO_PIN_6
#define DBHPORT GPIO_PORTD_BASE
#define DBH GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
#define DBLPORT GPIO_PORTA_BASE
#define DBL GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7


void GPIOINT(void)
{
 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);//使能外设GPIOA
 GPIOPadConfigSet(GPIO_PORTA_BASE,DBL,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD);//配置管脚驱动
 GPIODirModeSet(GPIO_PORTA_BASE,DBL,GPIO_DIR_MODE_OUT);//设置管脚输出
 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);//使能外设GPIOC
 GPIOPadConfigSet(GPIO_PORTC_BASE,CS|RS|WR|RD,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD);//配置管脚驱动
 GPIODirModeSet(GPIO_PORTC_BASE,CS|RS|WR|RD,GPIO_DIR_MODE_OUT);//设置管脚输出
 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);//使能外设GPIOD
 GPIOPadConfigSet(GPIO_PORTD_BASE,DBH,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD);//配置管脚驱动
 GPIODirModeSet(GPIO_PORTD_BASE,DBH,GPIO_DIR_MODE_OUT);//设置管脚输出
 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);//使能外设GPIOE
 GPIOPadConfigSet(GPIO_PORTE_BASE,PWM,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD);//配置管脚驱动
 GPIODirModeSet(GPIO_PORTE_BASE,PWM,GPIO_DIR_MODE_OUT);//设置管脚输出
 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);//使能外设GPIOH
 GPIOPadConfigSet(GPIO_PORTH_BASE,RES,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD);//配置管脚驱动
 GPIODirModeSet(GPIO_PORTH_BASE,RES,GPIO_DIR_MODE_OUT);//设置管脚输出
}  void WriteCOM(unsigned char DB_H,unsigned char DB_L)
{
 GPIOPinWrite(CSPORT,CS,0X00);//CSB=0;
    GPIOPinWrite(RSPORT,RS,0X00);//RSB=0;
//    GPIOPinWrite(RDPORT,RD,RD);//RDB=1;
//    GPIOPinWrite(WRPORT,WR,WR);//WRB=1;
 GPIOPinWrite(DBHPORT,DBH,DB_H);//DBH=DB_H;
 GPIOPinWrite(DBLPORT,DBL,DB_L);//DBL=DB_L;
 GPIOPinWrite(WRPORT,WR,0X00);//WRB=0;
 GPIOPinWrite(WRPORT,WR,WR);//WRB=1;
// GPIOPinWrite(RSPORT,RS,RS);//RSB=1;
 GPIOPinWrite(CSPORT,CS,CS);//CSB=1;
}  void WriteDAT(unsigned char DB_H,unsigned char DB_L)
{
    GPIOPinWrite(CSPORT,CS,0X00);//CSB=0;
    GPIOPinWrite(RSPORT,RS,RS);//RSB=1;
//    GPIOPinWrite(RDPORT,RD,RD);//RDB=1;
//    GPIOPinWrite(WRPORT,WR,WR);//WRB=1;
    GPIOPinWrite(DBHPORT,DBH,DB_H);//DBH=DB_H;
 GPIOPinWrite(DBLPORT,DBL,DB_L);//DBL=DB_L;
 GPIOPinWrite(WRPORT,WR,0X00);//WRB=0;
 GPIOPinWrite(WRPORT,WR,WR);//WRB=1;
// GPIOPinWrite(RSPORT,RS,0X00);//RSB=0;
 GPIOPinWrite(CSPORT,CS,CS);//CSB=1;
}  void write_com(unsigned int address,unsigned int num)
{
    WriteCOM(address>>8,address);
    WriteDAT(num>>8,num);
}   /*****************************************************/
void delayms(unsigned int delay)
{
 SysCtlDelay(delay*(SysCtlClockGet()/ 3000)); // 延时约ms
}void DelayNS(unsigned int tt)
{
 SysCtlDelay(tt*(SysCtlClockGet()/ 3000000)); // 延时约ns
}  void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
 {
         write_com(0x0044,(x2<<8)+x1);
         write_com(0x0045,y1);
         write_com(0x0046,y2);
         write_com(0x004e,x1);
         write_com(0x004f,y1);
       WriteCOM(0x00,0x22);                        
}   void Initial_IC(void)
{
 GPIOPinWrite(PWMPORT,PWM,PWM);//PWM=1;
 GPIOPinWrite(RESPORT,RES,RES);//res=1;
 delayms(10);
 GPIOPinWrite(RESPORT,RES,0X00);//res=0;
 delayms(10);
 GPIOPinWrite(RESPORT,RES,RES);//res=1;
 delayms(10);
 GPIOPinWrite(CSPORT,CS,CS);//CSB=1;
 GPIOPinWrite(RSPORT,RS,RS);//RSB=1;
 GPIOPinWrite(WRPORT,WR,WR);//WRB=1;
 GPIOPinWrite(RDPORT,RD,RD);//RD=1; write_com(0x0000,0x0001);    delayms(1);  //打开晶振
    write_com(0x0003,0xA8A4);    DelayNS(1000);   //0xA8A4
    write_com(0x000C,0x0000);    DelayNS(1000);  
    write_com(0x000D,0x080C);    DelayNS(1000);  
    write_com(0x000E,0x2B00);    DelayNS(1000);  
    write_com(0x001E,0x00B0);    DelayNS(1000);  
    write_com(0x0001,0x2B3F);    DelayNS(1000);   //驱动输出控制320*240  0x6B3F
    write_com(0x0002,0x0600);    DelayNS(1000);
    write_com(0x0010,0x0000);    DelayNS(1000);
    write_com(0x0011,0x6070);    DelayNS(1000);        //0x4030           //定义数据格式  16位 {MOD}
    write_com(0x0005,0x0000);    DelayNS(1000);
    write_com(0x0006,0x0000);    DelayNS(1000);
    write_com(0x0016,0xEF1C);    DelayNS(1000);
    write_com(0x0017,0x0003);    DelayNS(1000);
    write_com(0x0007,0x0233);    DelayNS(1000);        //0x0233      
    write_com(0x000B,0x0000);    DelayNS(1000);
    write_com(0x000F,0x0000);    DelayNS(1000);        //扫描开始地址
    write_com(0x0041,0x0000);    DelayNS(1000);
    write_com(0x0042,0x0000);    DelayNS(1000);
    write_com(0x0048,0x0000);    DelayNS(1000);
    write_com(0x0049,0x013F);    DelayNS(1000);
    write_com(0x004A,0x0000);    DelayNS(1000);
    write_com(0x004B,0x0000);    DelayNS(1000);
    write_com(0x0044,0xEF00);    DelayNS(1000);
    write_com(0x0045,0x0000);    DelayNS(1000);
    write_com(0x0046,0x013F);    DelayNS(1000);
    write_com(0x0030,0x0707);    DelayNS(1000);
    write_com(0x0031,0x0204);    DelayNS(1000);
    write_com(0x0032,0x0204);    DelayNS(1000);
    write_com(0x0033,0x0502);    DelayNS(1000);
    write_com(0x0034,0x0507);    DelayNS(1000);
    write_com(0x0035,0x0204);    DelayNS(1000);
    write_com(0x0036,0x0204);    DelayNS(1000);
    write_com(0x0037,0x0502);    DelayNS(1000);
    write_com(0x003A,0x0302);    DelayNS(1000);
    write_com(0x003B,0x0302);    DelayNS(1000);
    write_com(0x0023,0x0000);    DelayNS(1000);
    write_com(0x0024,0x0000);    DelayNS(1000);
    write_com(0x0025,0x8000);    DelayNS(1000);
    write_com(0x004f,0);        //行首址0
    write_com(0x004e,0);        //列首址0
 WriteCOM(0x00,0x22);
}  void Pant(unsigned int color1,unsigned int color2)
 {
         int i,j;
         Address_set(0,0,239,319);
 
    for(i=0;i<320;i++)
          {
           for (j=0;j<240;j++)
                    {
          WriteDAT(color1,color2);
             }
 
          }               

int main(void)
{
 SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_OSC|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);//配置系统时钟
 GPIOINT();
 Initial_IC();
 for(;;)
 {
 Pant(0xf8,0x00); //红 {MOD}
 }
}
[ 本帖最后由 olympicjun 于 2012-4-27 17:07 编辑 ] 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
2条回答
slhenryy
2019-03-24 21:40
 精彩回答 2  元偷偷看……0人看过

一周热门 更多>

相关问题

    相关文章