📄 fun_rgb.c
字号:
/******************************Copyright (c)*********************************
** 文件说明
**---------------------------------------------------------------------------
**文 件 名: fun_rgb.c
**创 建 人: 杨宏伟
**修 改 人: 杨宏伟
**创 建 日 期:2003年10月19日
**最后修改日期: 2005年10月20日
**描 述: FOR NT3912/PXC3100,SPI+RGB
**
****************************************************************************/
#include "config.h"
extern void delay(uint32 dly);
extern uint8 G_CurrContrastValue; // 全局变量,设置对比度值
#define COMMAND_START_BYTE 0x00
#define DATA_START_BYTE 0x80
/****************************************************************************
** 函数实现
*****************************************************************************/
/*===========================================================================
** 函数名称: send()
** 功能描述: 软件模拟SPI串行,发送数据
============================================================================*/
void delayNS(uint32 dly)
{
uint32 i;
for(; dly>0; dly--)
for(i=0; i<100; i++);
}
void send(uint8 A0,uint8 data)
{
uint8 i;
IO1CLR = SCK; // SCK = 0
if( ((A0<<i)&0x80)!=0 ) IO1SET = SDA;
else IO1CLR = SDA;
IO1SET = SCK; // SCK = 1
for(i=0; i<8; i++) // 发送8位数据
{
IO1CLR = SCK; // SCK = 0
// 设置SPI的DATA输出值
//if( (data&0x80)!=0 ) IO1SET = SDA;
// else IO1CLR = SDA;
//data <<= 1;
if( ((data<<i)&0x80)!=0 ) IO1SET = SDA;
else IO1CLR = SDA;
IO1SET = SCK; // SCK = 1
}
}
/*===========================================================================
** 函数名称: data_out()
** 功能描述: 输出数据,并行,软件模拟8080
============================================================================*/
void data_out(uint16 i,uint16 j)
{
// interface 8080
//IO0CLR = 0x0000FFFF;
IO1CLR = CS0;
IO1SET = DC0;
send(DATA_START_BYTE,i);
send(DATA_START_BYTE,j);
IO1SET = CS0;
}
/*===========================================================================
** 函数名称: comm_out()
** 功能描述: 输出指令,并行,软件模拟8080
============================================================================*/
void comm_out(uint16 i,uint16 j)
{
// interface 8080
//IO0CLR = 0x0000FFFF;
IO1CLR = CS0;
IO1CLR = DC0;
send(COMMAND_START_BYTE,i);
send(COMMAND_START_BYTE,j);
IO1SET = CS0;
}
/*===========================================================================
** 函数名称: ini_lcd()
** 功能描述: 实现对LCD的初始化操作
============================================================================*/
void ini_lcd(void)
{
// S1D19122
comm_out(0x00,0x00);
data_out(0x00,0x01);
comm_out(0x00,0x01);
data_out(0x00,0x00);
comm_out(0x00,0x02);
data_out(0x07,0x00);
comm_out(0x00,0x03);
data_out(0x10,0x20);
comm_out(0x00,0x04);
data_out(0x00,0x00);
comm_out(0x00,0x08);
data_out(0x02,0x02);
comm_out(0x00,0x09);
data_out(0x00,0x00);
comm_out(0x00,0x0A);
data_out(0x00,0x00);
comm_out(0x00,0x0C);
data_out(0x00,0x00);
comm_out(0x00,0x0D);
data_out(0x00,0x00);
comm_out(0x00,0x0F);
data_out(0x00,0x00);
comm_out(0x00,0x10);
data_out(0x00,0x00);
comm_out(0x00,0x11);
data_out(0x00,0x07);
comm_out(0x00,0x12);
data_out(0x00,0x00);
comm_out(0x00,0x13);
data_out(0x00,0x00);
delay(200);
comm_out(0x00,0x10);
data_out(0x17,0xb0);
comm_out(0x00,0x11);
data_out(0x00,0x07);
delay(50);
comm_out(0x00,0x12);
data_out(0x01,0x3a);
delay(50);
comm_out(0x00,0x13);
data_out(0x1a,0x00);
comm_out(0x00,0x29);
data_out(0x00,0x0c);
delay(50);
comm_out(0x00,0x20);
data_out(0x00,0xef);
comm_out(0x00,0x21);
data_out(0x00,0x00);
comm_out(0x00,0x30);
data_out(0x00,0x00);
comm_out(0x00,0x31);
data_out(0x05,0x05);
comm_out(0x00,0x32);
data_out(0x00,0x04);
comm_out(0x00,0x35);
data_out(0x00,0x06);
comm_out(0x00,0x36);
data_out(0x07,0x07);
comm_out(0x00,0x37);
data_out(0x01,0x05);
comm_out(0x00,0x38);
data_out(0x00,0x02);
comm_out(0x00,0x39);
data_out(0x07,0x07);
comm_out(0x00,0x3c);
data_out(0x07,0x04);
comm_out(0x00,0x3d);
data_out(0x08,0x07);
comm_out(0x00,0x50);
data_out(0x00,0x00);
comm_out(0x00,0x51);
data_out(0x00,0xef);
comm_out(0x00,0x52);
data_out(0x00,0x00);
comm_out(0x00,0x53);
data_out(0x01,0x3f);
comm_out(0x00,0x60);
data_out(0x27,0x00);
comm_out(0x00,0x61);
data_out(0x00,0x01);
comm_out(0x00,0x6a);
data_out(0x00,0x00);
comm_out(0x00,0x80);
data_out(0x00,0x00);
comm_out(0x00,0x81);
data_out(0x00,0x00);
comm_out(0x00,0x82);
data_out(0x00,0x00);
comm_out(0x00,0x83);
data_out(0x00,0x00);
comm_out(0x00,0x84);
data_out(0x00,0x00);
comm_out(0x00,0x85);
data_out(0x00,0x00);
comm_out(0x00,0x90);
data_out(0x00,0x10);
comm_out(0x00,0x92);
data_out(0x00,0x00);
comm_out(0x00,0x93);
data_out(0x00,0x03);
comm_out(0x00,0x95);
data_out(0x01,0x10);
comm_out(0x00,0x97);
data_out(0x00,0x00);
comm_out(0x00,0x98);
data_out(0x00,0x00);
comm_out(0x00,0x07);
data_out(0x01,0x73);
comm_out(0x00,0x22);
}
/*===========================================================================
** 函数名称: selectSeries()
** 功能描述: 时序选择,0-8080,1-6800
============================================================================*/
void selectSeries(uint8 i)
{
//SELECT SERIES
switch(i)
{
case 0:
//SELECT 8080
IO1SET = RD0;
IO1SET = WR0;
break;
case 1:
//SELECT 6800
IO1CLR = RD0;
IO1CLR = WR0;
break;
default:
;
}
}
/*
void setSPIMode(void)
{
comm_out(0x0C); //SET SYSTEM INTERFACE
data_out(0x00);
data_out(0x00);
}
void setRGBMode(void)
{
comm_out(0x03); //SET RGB INTERFACE,HWM=1,AM=0
data_out(0x72);
data_out(0x30);
comm_out(0x0C); //SET RGB INTERFACE(16bit)
data_out(0x01);
data_out(0x11);
}
void writeRGBdata(uint16 row,uint16 col,uint16 dataH,uint16 dataL)
{
uint16 i,j;
IO0CLR = 0x0000FFFF;
IO1CLR = CS0;
IO0CLR = VSYNC;
IO0SET = VSYNC;
for(i=0;i<row;i++)
{
IO0CLR=HSYNC;
IO0SET=HSYNC;
IO0CLR=ENABLE;
for(j=0;j<col;j++)
{
IO0SET = (dataH<<8)|(dataL);
IO1CLR = DOTCLK;
//delayNS(1);
IO1SET = DOTCLK;
}
IO0SET=ENABLE;
}
IO0SET=ENABLE;
IO0CLR=VSYNC; //VSYNC=0;
IO0CLR=HSYNC; //HSYNC=0;
IO1SET=CS0;
}
void dispColor_RGB(uint16 row,uint16 col,uint16 rgb1,uint16 rgb2)
{
comm_out(0x21);
data_out(0x00);
data_out(0x00);
setRGBMode();
comm_out(0x22);
writeRGBdata(row,col,rgb1,rgb2);
setSPIMode();
}
void dispPic_RGB(uint16 row,uint16 col,const uint8 *picture)
{
uint16 i,j;
uint16 temp1,temp2;
IO0CLR = 0x0000FFFF;
setRGBMode();
comm_out(0x22);
IO1CLR = CS0;
IO0CLR = VSYNC;
IO0SET = VSYNC;
for(i=0;i<row;i++)
{
IO0CLR=HSYNC;
IO0SET=HSYNC;
IO0CLR=ENABLE;
for(j=0;j<col;j++)
{
temp1 = *(picture++);
temp2 = *(picture++);
IO0SET= (temp1<<8)&(0xff00)|(temp2)&(0x00ff);
IO1CLR = DOTCLK;
//delayNS(1);
IO1SET = DOTCLK;
}
IO0SET=ENABLE;
}
IO0SET=ENABLE;
IO0CLR=VSYNC; //VSYNC=0;
IO0CLR=HSYNC; //HSYNC=0;
IO1SET=CS0;
setSPIMode();
}
*/
/*===========================================================================
** 函数名称: dispColor()
** 功能描述: 显示颜色
============================================================================*/
void dispColor(uint16 row,uint16 col,uint8 rgb1,uint8 rgb2,uint16 dly)
{
uint16 i,j;
comm_out(0x00,0x22);
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
data_out(rgb1,rgb2);
delay(dly);
}
}
}
/*********************************************************************************************************
** End Of File
**********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -