📄 interface.c
字号:
/****************************************************************************
* 公司名称:SITRONIX *
* 模块名称:INTERFACE.C *
* 模块功能:IC接口通用文件,归属于每个IC测试软件包 *
* 创建人员:Jim Yuan *
* 创建日期:2007-6-26 *
* 修改日期:2007-11-22(增加TFT RGB IF FUNCTION *
****************************************************************************/
#include "interface.h"
#if INTERFACE == IF_80_8BIT
sbit nRST =P3^5;
sbit RS =P3^0;
sbit nWR =P3^1;
sbit nRD =P3^2;
sbit nCS =P3^3;
void writec(uint8 cmd)
{
RS = 0;
nRD = 1;
nCS = 0;
nWR = 0;
P1 = cmd;
nWR = 1;
nCS = 1;
}
void writed(uint8 dat)
{
RS = 1;
nRD = 1;
nCS = 0;
nWR = 0;
P1 = dat;
nWR = 1;
nCS = 1;
}
uint8 readd(void)
{
uint8 dat;
P1 = 0xff;
RS = 1;
nWR = 1;
nRD = 1;
nCS = 0;
nRD = 0;
dat = P1;;
nRD = 1;
nCS = 1;
return dat;
}
#endif
#if INTERFACE == IF_SPI_4LINE
sbit nRST =P3^5;
sbit RS =P3^0;
sbit nCS =P3^3;
sbit SCL =P1^0;
sbit SDA =P1^1;
void writec(uint8 cmd)
{
uint8 i;
RS = 0;
nCS = 0;
for (i = 0; i < 8; i++)
{
SCL = 0;
if (((cmd << i) & 0x80) == 0x80){SDA = 1;}
else{SDA = 0;}
SCL = 1;
}
nCS=1;
}
void writed(uint8 dat)
{
uint8 i;
RS = 1;
nCS = 0;
for (i = 0; i < 8; i++)
{
SCL = 0;
if (((dat << i) & 0x80) == 0x80){SDA = 1;}
else{SDA = 0;}
SCL = 1;
}
nCS=1;
}
#endif
/****************************************************************************
* 函数名称:ST7787 RGB IF 函数 *
* 函数功能:实现SPI初始化和RGB/VS/HS/DE/PK信号的产生 *
* 入口参数: *
* 创建日期:2007-11-22 *
* 修改日期: *
* 修改原因: *
****************************************************************************/
#if INTERFACE == IF_SPI_RGB
sbit nRST =P3^5;
sbit SCL =P3^0;
sbit SDA =P3^1;
sbit nCS =P3^3;
sbit DE =P1^0;
sbit PK =P1^1;
sbit HS =P1^2;
sbit VS =P1^3;
void writec(uint8 cmd)
{
uint8 i;
SCL = 1;
SDA = 1;
nCS = 0;
SCL = 0;
SDA = 0;
SCL = 1;
for (i = 0; i < 8; i++)
{
SCL = 0;
if (((cmd << i) & 0x80) == 0x80){SDA = 1;}
else{SDA = 0;}
SCL = 1;
}
nCS=1;
}
void writed(uint8 dat)
{
uint8 i;
SCL = 1;
SDA = 1;
nCS = 0;
SCL = 0;
SDA = 1;
SCL = 1;
for (i = 0; i < 8; i++)
{
SCL = 0;
if (((dat << i) & 0x80) == 0x80){SDA = 1;}
else{SDA = 0;}
SCL = 1;
}
nCS=1;
}
void rgb_scan(void)
{
uint16 i,j;
DE = 0;
PK = 1;
VS = 1;
HS = 1;
PK = 0;
PK = 1;
VS = 0;
PK = 0;
PK = 1;
HS = 0;
PK = 0;
PK = 1;
HS = 1;
PK = 0;
PK = 1;
VS = 1;
PK = 0;
PK = 1;
for (i = 0; i < 320; i++)
{
HS = 0;
PK = 0;
PK = 1;
HS = 1;
PK = 0;
PK = 1;
DE = 1;
PK = 0;
PK = 1;
for (j = 0; j < 240; j++)
{
PK = 0;
PK = 1;
}
DE = 0;
PK = 0;
PK = 1;
}
}
#endif
void hardware_reset(void)
{
P1 = 0XFF;
P3 = 0XFF;
nRST = 0;
delay(1);
nRST = 1;
delay(30);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -