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


/*C************************************************************************** 
* NAME:         io_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" 
#include "driver\kbd_drv.h"                      /* scheduler definition */ 
 
/*F************************************************************************** 
* NAME: getByteLSB 
*---------------------------------------------------------------------------- 
* PARAMS: 
* 写入一个字节数据info 
* return: 
*---------------------------------------------------------------------------- 
* PURPOSE:  
*---------------------------------------------------------------------------- 
* EXAMPLE: 
*---------------------------------------------------------------------------- 
* NOTE: 
*---------------------------------------------------------------------------- 
* REQUIREMENTS: 
*****************************************************************************/ 
 
void getByteLSB(Byte bByte) 
{ 
	Byte i;  
 
	for (i=0; i<8; i++)  
	{ 
		DTS_CLK = 0; 
        if (bByte & 0x01) DTS_DOUT = 1; 
        else DTS_DOUT = 0; 
        bByte >>= 1; 
      	DTS_CLK = 1; 
	} 
} 
 
/*F************************************************************************** 
* NAME: getByteLSB 
*---------------------------------------------------------------------------- 
* PARAMS: 
* 写入一个字节数据info 
* return: 
*---------------------------------------------------------------------------- 
* PURPOSE:  
*---------------------------------------------------------------------------- 
* EXAMPLE: 
*---------------------------------------------------------------------------- 
* NOTE: 
*---------------------------------------------------------------------------- 
* REQUIREMENTS: 
*****************************************************************************/ 
 
int dts_scanByte(void) 
{ 
	Byte i;  
	char bByte= 11,temp; 
 
	for (i=0; i<8; i++){ 
		DTS_CLK = Low; 
       	if (DTS_DIN){ 
			temp = 0x80; 
   			temp >>= i; 
       		bByte |= temp; 
			} 
		DTS_CLK = High; 
		} 
	return (bByte); 
} 
 
/*F************************************************************************** 
* NAME: HT1621_getMSB 
*---------------------------------------------------------------------------- 
* PARAMS: 
* 写入一个字节数据info 
* return: 
*---------------------------------------------------------------------------- 
* PURPOSE:  
*---------------------------------------------------------------------------- 
* EXAMPLE: 
*---------------------------------------------------------------------------- 
* NOTE: 
*---------------------------------------------------------------------------- 
* REQUIREMENTS: 
*****************************************************************************/ 
 
void HT1621_getMSB(Byte bByte) 
{ 
	Byte i;  
 
	for (i=0; i<8; i++)  
	{ 
		LCD_RW = 0; 
        if (bByte & 0x80) LCD_DA = 1; 
        else LCD_DA = 0; 
        bByte <<= 1; 
      	LCD_RW = 1; 
	} 
} 
 
/*F************************************************************************** 
* NAME: HT1621_getLSB 
*---------------------------------------------------------------------------- 
* PARAMS: 
* 写入一个字节数据info 
* return: 
*---------------------------------------------------------------------------- 
* PURPOSE:  
*---------------------------------------------------------------------------- 
* EXAMPLE: 
*---------------------------------------------------------------------------- 
* NOTE: 
*---------------------------------------------------------------------------- 
* REQUIREMENTS: 
*****************************************************************************/ 
 
void HT1621_getLSB(Byte bByte) 
{ 
	Byte i;  
 
	for (i=0; i<8; i++)  
	{ 
		LCD_RW = 0; 
        if (bByte & 0x01) LCD_DA = 1; 
        else LCD_DA = 0; 
        bByte >>= 1; 
      	LCD_RW = 1; 
	} 
}