C51模拟PS2键盘(二)

*************************************************************************************

原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。

否则将追究法律责任。http://blog.csdn.net/fulinus/article/details/15115033

*************************************************************************************

C51模拟PS2键盘,这是初始化头文件文件:

#ifndef __INITIALIZE_H__
#define __INITIALIZE_H__


void Oscillator_Init(void);


void Port_Init(void);


#endif

这是初始化C文件:

/*********************************************************************************
 *      Copyright:  (C) 2012 fulinux<[email protected]> 
 *                  All rights reserved.
 *
 *       Filename:  main.c
 *    Description:  This is the initalize file of this program
 *                 
 *        Version:  1.0.0(10/27/2011~)
 *         Author:  2012 fulinux<[email protected]>
 *      ChangeLog:  1, Release initial version on "10/27/2012 11:39:10 AM"
 *                 
 ********************************************************************************/

#include <C8051F310.h>

#include "Initialize.h"

#include "PS_2.h"


//-----------------------------------------------------------------------------
// 
//-----------------------------------------------------------------------------
//
// Return Value : 
// Parameters   : 
//
// This function 
//
//
//
//-----------------------------------------------------------------------------
void Oscillator_Init(void)
{
	OSCICN    = 0x81;
}

//-----------------------------------------------------------------------------
// 
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : 
//
// This function 
//
//
//
//-----------------------------------------------------------------------------

void Port_Init(void)
{
//    P0MDOUT = 0x04;                     // P0.3 is open-drain; P0.2 is push-pull
//    P0     |= 0x08;                     // Set P0.3 latch to '1'
//   	XBR2    = 0x40;                     // Enable crossbar and enable
//	LED = 0;
//   XBR0      = 0x01;
    P2MDOUT   = 0x07;
    XBR0      = 0x01;
    XBR1      = 0x40;

	P2 = 0x07;
	P1 = 0xff;

	PS2_CLK = PS2_CLK_H;
	PS2_DAT = PS2_DAT_H;
}
********************************************************************** ***************

C51模拟PS2键盘(一):原文链接

*************************************************************************************


你可能感兴趣的:(PS2键盘,C51模拟PS2键盘,PS2协议)