⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd_x_1335.c

📁 driver for LCD 320x240 with SED1335 controller. Implementet for XC167 and RTXtiny, small_gui applie
💻 C
字号:
#include <intrins.h>
#include <stdio.h>
#include <math.h>

#include "reg167.h"
#include <rtx166t.h>

void Delay_GUI(unsigned int ms);
void GUI_X_Delay(int ms);

// Set you interface port with graphic controller
// this - for Infineon XC167 
sbit DD0	=		P3 ^ 0;
sbit DD1	=		P3 ^ 1;
sbit DD2	=		P3 ^ 2;
sbit DD3	=		P3 ^ 3;
sbit DD4	=		P3 ^ 4;
sbit DD5	=		P3 ^ 5;
sbit DD6	=		P3 ^ 6;
sbit DD7	=		P3 ^ 7;

sbit DA0		=		P2^13;			// C/D
sbit DCS		=		P2^12;			// LOW active
sbit DWR		=		P2^14;			// LOW active, latch rising edge
sbit DRD		=		P2^15;			// LOW active
sbit DRESET		=		P2^7;	    		// LOW active;


#ifdef RELEASE_II
	#define LCD_CLR_A0()      (DA0 = 0)
	#define LCD_SET_A0()      (DA0 = 1)
	#define LCD_CLR_WR()      (DWR = 0)
	#define LCD_SET_WR()      (DWR = 1)
	#define LCD_CLR_RD()      (DRD = 0)
	#define LCD_SET_RD()      (DRD = 1)
	#define LCD_CLR_RESET()   (DRESET = 0)
	#define LCD_SET_RESET()   (DRESET = 1)
	#define LCD_CLR_CS()      (DCS = 0)
	#define LCD_SET_CS()      (DCS = 1)

	#define LCD_SET_DIR_IN()  _bfld_( DP3, 0x00FF, 0x0000); _nop_(); _nop_()

	#define LCD_SET_DIR_OUT() _bfld_( DP3, 0x00FF, 0x00FF); _nop_(); _nop_()
	
	#define LCD_DELAY(ms)     GUI_X_Delay(ms)

	#define LCD_DATA_IN       (unsigned char) (P3 & 0x00FF); 
	#define LCD_DATA_OUT      (P3 = (P3 & 0xFF00) | (unsigned int) data)

#endif


#define LCD_X_READ()      \
  LCD_SET_DIR_IN();    	  \
  LCD_CLR_CS();           \
  LCD_CLR_RD();           \
  c = LCD_DATA_IN;        \
  LCD_SET_CS();           \
  LCD_SET_RD();           \
  LCD_SET_DIR_OUT();     \
  return c

  //LCD_SET_DIR_OUT();      
#define LCD_X_WRITE(data) \
  P3 = (P3 & 0xFF00) | (unsigned int) data; \
  LCD_CLR_CS();           \
  LCD_CLR_WR();           \
  LCD_SET_WR();           \
  LCD_SET_CS();           
//  LCD_SET_DIR_IN()    


int GUI_X_GetTime(void) { 
int tmp;
  T5R = 0;
  tmp = OS_TimeMS; 
  T5R = 1;	
  return tmp; 
}


void GUI_X_Delay(int ms) { 
  int tEnd = GUI_X_GetTime() + ms;
  while (abs(tEnd - GUI_X_GetTime()) > 0); 
}

void LCD_X_Init(void) {
int i;
  LCD_SET_DIR_OUT();      \
  LCD_SET_CS();
  LCD_SET_RD();
  LCD_SET_WR();
  LCD_CLR_RESET();
//  GUI_X_Delay(10);
	for (i =0; i < 1000; i++) {
		_nop_(); _nop_(); 
	}
  LCD_SET_RESET();
}

/* Write to controller, with A0 = 0 */
//void LCD_X_Write00(char c) {
void LCD_X_Write00(int c) {
  LCD_CLR_A0();
  LCD_X_WRITE(c);
}

/* Write to controller, with A0 = 1 */
//void LCD_X_Write01(char c) {
void LCD_X_Write01(int c) {
  LCD_SET_A0();
  LCD_X_WRITE(c);
}

/* Read from controller, with A0 = 0 */
char LCD_X_Read00(void) {
  char c;
  LCD_CLR_A0();
  LCD_X_READ();
}

/* Read from controller, with A0 = 1 */
char LCD_X_Read01(void) {
  char c;
  LCD_SET_A0();
  LCD_X_READ();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -