www.pudn.com > HT1621Control.rar > ht1621_drv.c


/*C************************************************************************** 
* NAME:         HT1621_drv.c 
*---------------------------------------------------------------------------- 
* Copyright (c) 2006 Atmel. 
*---------------------------------------------------------------------------- 
* RELEASE:      C51 Sample       
* REVISION:     1.00      
*---------------------------------------------------------------------------- 
* 
*****************************************************************************/ 
#include "system\reg51.h" 
#include "system\compiler.h" 
#include "system\config.h" 
#include "Driver\io_def.h" 
 
#if	CONF_DISPLAY == HT1621 
#include "driver\ht1621_drv.h"                      /* scheduler definition */ 
#endif 
/*----------------------------------------------------------- 
DIRVER IC:	HT1621 
LCD PIN ASSGMENT 
DIRVER IC:	HT1621 
LCD PIN ASSGMENT 
	COM0	COM1	COM2	COM3 
SEG0	|E5		|E3		|E1		|-		;HT1621_CSEG0H 
SEG1	|E4		|E2		|E0		|ANTI	;HT1621_CSEG0L 
SEG2	|BATT	|6B		|6C		|6D		;HT1621_CSEG1 
SEG3	|6A		|6F		|6G		|6E		;HT1621_CSEG1 
SEG4	|HOLD	|5B		|5C		|5D		;HT1621_CSEG2 
SEG5	|5A		|5F		|5G		|5E		;HT1621_CSEG2 
SEG6	|-		|4B		|4C		|4D		;HT1621_CSEG3 
SEG7	|4A		|4F		|4G		|4E		;HT1621_CSEG3 
SEG8	|ALL	|3B		|3C		|3D		;HT1621_CSEG4 
SEG9	|3A		|3F		|3G		|3E		;HT1621_CSEG4 
SEG10	|1		|2B		|2C		|2D		;HT1621_CSEG5 
SEG11	|2A		|2F		|2G		|2E		;HT1621_CSEG5 
SEG12	|VOL	|1B		|1C		|1D		;HT1621_CSEG6 
SEG13	|1A		|1F		|1G		|1E		;HT1621_CSEG6 
SEG14	|REP	|PROG	|RNDOM	|INTRO	;HT1621_CSEG7 
SEG15	|-		|2		|1		|BOST	;HT1621_CSEG7 
SEG16	|-		|7B		|7C		|7D		;HT1621_CSEG8 
SEG17	|7A		|7F		|7G		|7E		;HT1621_CSEG8 
SEG18	|CD		|V		|MP3	| 
------------------------------------------------------------- 
Command Mode: 
1.LCD OFF	1000/0000010X		; 
2.LCD ON	1000/0000011X 
3.BIAS & COM	1000/010ABXCX 
	C=0:	1/2 BIAS OPTION 
	C=1:	1/3 BIAS OPTION 
	AB=00:	2 COMMONS OPTION 
	AB=01:	3 COMMONS OPTION  
	AB=02:	4 COMMONS OPTION 
 
Write Mode: 
		1/01/A5 A4 A3 A2 A1 A0/D0 D1 D2 D3 
------------------------------------------------*/ 
 
#if CONF_DISPLAY == HT1621 
/*F************************************************************************** 
* NAME: ht1621_init 
*---------------------------------------------------------------------------- 
* PARAMS: 
* 
* return: 
*---------------------------------------------------------------------------- 
* PURPOSE:  
*   Keyboard initialisation function 
*---------------------------------------------------------------------------- 
* EXAMPLE: 
*---------------------------------------------------------------------------- 
* NOTE: 
*---------------------------------------------------------------------------- 
* REQUIREMENTS: 
* ram/xram: 
* cycle: 
* stack:  
* code: 
*****************************************************************************/ 
void ht1621_init (void) 
{ 
	LCD_DA = High;		/*DATA禁止*/ 
	LCD_CS = High;		/*CS禁止*/ 
	LCD_RW = High;		/*RW禁止*/ 
} 
 
/*F************************************************************************** 
* NAME: HT1621_command 
*---------------------------------------------------------------------------- 
* PARAMS: 
* 
* return: 
*   Decoded key pressed 
*---------------------------------------------------------------------------- 
* PURPOSE:  
*---------------------------------------------------------------------------- 
* EXAMPLE: 
*---------------------------------------------------------------------------- 
* NOTE: 
*---------------------------------------------------------------------------- 
* REQUIREMENTS: 
*****************************************************************************/ 
void HT1621_command(Byte bByte) { 
  Byte i; //data 
  Byte bBits= 0x80; //write mode command and address is 1000b. 
    
    LCD_CS = 0; 
	LCD_DA = 1; 
	for (i=0; i<4; i++) { //transmit data "1000" 
		LCD_RW = 0; 
		if (bBits & 0x80) LCD_DA = 1; 
    	else LCD_DA = 0; 
		bBits <<= 1; 
		LCD_RW = 1; 
	} 
	//bBits = bByte; 
	HT1621_getMSB(bByte); 
    LCD_CS = 1; 
    LCD_DA = 1; 
} 
 
/*F************************************************************************** 
* NAME: HT1621_getdata 
*---------------------------------------------------------------------------- 
* PARAMS: 
* 
* return: 
*   Decoded key pressed 
*---------------------------------------------------------------------------- 
* PURPOSE:  
*---------------------------------------------------------------------------- 
* EXAMPLE: 
*---------------------------------------------------------------------------- 
* NOTE: 
*---------------------------------------------------------------------------- 
* REQUIREMENTS: 
*****************************************************************************/ 
/***************************************************/ 
void HT1621_getdata(Byte address,Byte bByte) { 
    
	address = (address | 0x40);//write mode command and address is 101000000b. 
    LCD_CS = 0; 
	LCD_RW = 0; 
	LCD_DA = 1; 
	LCD_RW = 1;  
	HT1621_getMSB(address); 
	HT1621_getLSB(bByte); 
	LCD_CS = 1; 
    LCD_DA = 1;  
} 
 
 
/*-----------------------------------------------*/ 
/*LCD所有的显示RAM清除*/ 
void ht1621_cls (void) 
{ 
	Byte i; //data 
    
    LCD_CS = 0; 
	LCD_RW = 0; 
	LCD_DA = 1; 
	LCD_RW = 1; 
	HT1621_getMSB(0x40); 
	for (i=0; i<9; i++){ 
		HT1621_getLSB(0X00); 
		} 
	LCD_CS = 1; 
    LCD_DA = 1; 
} 
 
/*-----------------------------------------------*/ 
/*ht1621秒钟显示*/ 
void glht1621_sec(Byte bByte)  
{ 
	HT1621_getdata(HT1621SEC_ADDH,ht1621disp_Map[bByte/10]);		/*显示十位*/ 
	HT1621_getdata(HT1621SEC_ADDL,ht1621disp_Map[bByte%10]);	/*显示个位*/ 
	//HT1621_getdata(HT1621SEC_ADDL,0x06);	/*显示十位*/ 
	//HT1621_getdata(HT1621SEC_ADDH,0x06);	/*显示个位*/ 
} 
/*-----------------------------------------------*/ 
/*ht1621分钟显示*/ 
void glht1621_min(Byte bByte)  
{ 
	HT1621_getdata(HT1621MIN_ADDH,ht1621disp_Map[bByte/10]);		/*显示十位*/ 
	HT1621_getdata(HT1621MIN_ADDL,ht1621disp_Map[bByte%10] | HT1621COL);	/*显示个位*/	 
} 
 
/*-----------------------------------------------*/ 
/*ht1621曲目数显示*/ 
void glht1621_TRACK(Byte bByte)  
{ 
	HT1621_getdata(HT1621TRACK_ADDH,ht1621disp_Map[bByte/10]);	/*显示十位*/ 
	HT1621_getdata(HT1621TRACK_ADDL,ht1621disp_Map[bByte%10]);	/*显示个位*/	 
} 
 
/*-----------------------------------------------*/ 
/*ht1621“STOP”字符显示*/ 
void glht1621_stop(void)  
{ 
	HT1621_getdata(HT1621_ADDRESS3,0xc7);	/*显示字符“S”*/ 
    HT1621_getdata(HT1621_ADDRESS4,0x8e);	/*显示字符“t”*/ 
	HT1621_getdata(HT1621_ADDRESS5,0xcc);	/*显示字符“o”*/ 
	HT1621_getdata(HT1621_ADDRESS6,0x2f);	/*显示字符“P”*/	 
} 
 
/*-----------------------------------------------*/ 
/*ht1621“REC”字符显示*/ 
void glht1621_rec(void)  
{ 
	HT1621_getdata(HT1621_ADDRESS1,0x8e);	/*显示字符“r”*/ 
    HT1621_getdata(HT1621_ADDRESS2,0x8f);	/*显示字符“E”*/ 
} 
 
/*-----------------------------------------------*/ 
/*ht1621 VOLUME调整显示*/ 
void glht1621_volume(void)  
{ 
	HT1621_getdata(HT1621TRACK_ADDH,ht1621disp_Map[vol_value/10] | HT1621VOL);		/*显示十位*/ 
	HT1621_getdata(HT1621TRACK_ADDL,ht1621disp_Map[vol_value%10]);	/*显示个位*/ 
} 
/*ht1621 P OFF字符显示*/ 
void glht1621_POFF(void)  
{ 
	HT1621_getdata(HT1621TRACK_ADDL,0Xf2);		/*显示“P”*/ 
	HT1621_getdata(HT1621MIN_ADDH,0Xbe);		/*显示“O”*/ 
	HT1621_getdata(HT1621MIN_ADDL,0Xf0);		/*显示“F”*/ 
	HT1621_getdata(HT1621SEC_ADDH,0Xf0);		/*显示“F”*/ 
} 
 
/*F************************************************************************** 
* NAME: dts_DispMem 
*---------------------------------------------------------------------------- 
* PARAMS: 
* 
* return: 
*---------------------------------------------------------------------------- 
* PURPOSE:  
*   Display task initialization 
*---------------------------------------------------------------------------- 
* EXAMPLE: 
*---------------------------------------------------------------------------- 
* NOTE: 
*---------------------------------------------------------------------------- 
* REQUIREMENTS: 
*****************************************************************************/ 
void dts_DispMem (void) 
{ 
	Byte temp; 
 
	temp = (Mem_add - Mem_StartAdd)/2; 
	HT1621_getdata(HT1621_ADDRESS0,0xf7); 
	HT1621_getdata(HT1621SEC_ADDH,ht1621disp_Map[temp/10]);		 
	HT1621_getdata(HT1621SEC_ADDL,ht1621disp_Map[temp%10]);			 
} 
 
/*F************************************************************************** 
* NAME: dts_DispFer 
*---------------------------------------------------------------------------- 
* PARAMS: 
* 
* return: 
*---------------------------------------------------------------------------- 
* PURPOSE:  
*   Display task initialization 
*---------------------------------------------------------------------------- 
* EXAMPLE: 
*---------------------------------------------------------------------------- 
* NOTE: 
*---------------------------------------------------------------------------- 
* REQUIREMENTS: 
*****************************************************************************/ 
void dtsFM_DispFer (void) 
{ 
	char temp; 
	 if(dts_frequency < 1000){ 
	 	temp = dts_frequency/100; 
		//ht1621disp_Buffer[3] = ht1621disp_Map[temp]; 
		HT1621_getdata(HT1621TRACK_ADDH,ht1621disp_Map[temp]); 
		temp = (dts_frequency-temp*100); 
		//ht1621disp_Buffer[4] = ht1621disp_Map[temp/10]; 
		HT1621_getdata(HT1621TRACK_ADDL,ht1621disp_Map[temp/10]); 
		//ht1621disp_Buffer[5] = ht1621disp_Map[temp%10]; 
		HT1621_getdata(HT1621MIN_ADDH,ht1621disp_Map[temp%10]); 
		//ht1621disp_Buffer[7] = 0x00; 
		HT1621_getdata(HT1621TRACK_H_ADD,0x00); 
		} 
		else{ 
			if(dts_frequency ==1000){ 
				//ht1621disp_Buffer[3] = ht1621disp_Map[0]; 
				//ht1621disp_Buffer[4] = ht1621disp_Map[0]; 
				//ht1621disp_Buffer[5] = ht1621disp_Map[0]; 
				HT1621_getdata(HT1621TRACK_ADDH,0xbe); 
				HT1621_getdata(HT1621TRACK_ADDL,0xbe); 
				HT1621_getdata(HT1621MIN_ADDH,0xbe); 
			} 
			else { 
				//ht1621disp_Buffer[3] = ht1621disp_Map[0]; 
				HT1621_getdata(HT1621TRACK_ADDH,0xbe); 
				temp = (dts_frequency-1000); 
				//ht1621disp_Buffer[4] = ht1621disp_Map[temp/10]; 
				//ht1621disp_Buffer[5] = ht1621disp_Map[temp%10]; 
				HT1621_getdata(HT1621TRACK_ADDL,ht1621disp_Map[temp/10]); 
				HT1621_getdata(HT1621MIN_ADDH,ht1621disp_Map[temp%10]); 
			} 
		//ht1621disp_Buffer[7] = 0x60; 
		HT1621_getdata(HT1621TRACK_H_ADD,0x60); 
		} 
		//HT1621_getdata(HT1621TRACK_ADDH,ht1621disp_Buffer[3]); 
		//HT1621_getdata(HT1621TRACK_ADDL,ht1621disp_Buffer[4]); 
		//HT1621_getdata(HT1621MIN_ADDH,ht1621disp_Buffer[5]); 
		//HT1621_getdata(HT1621TRACK_H_ADD,ht1621disp_Buffer[7]); 
}		 
 
/*LCD字码表*/ 
Byte code ht1621disp_Map[]={ 
   0xbe,  //0/ 
   0x06,  //1/ 
   0xda,  //2/ 
   0x5e,  //3/ 
   0x66,  //4/ 
   0x7c,  //5/ 
   0xfc,  //6 
   0x16,  //7 
   0xfe,  //8 
   0x7e,  //9 
}; 
 
#endif