__hal.c

来自「C语言版的USB单片机固件源代码」· C语言 代码 · 共 79 行

C
79
字号
//===================================================================//
//     Project Name : ZBoard
//      Module Name : Master Firmware Program
//     Product Type : License
//      OS/Dev Tool : AT89C52, uVision 2
//  Original Author : Ray Yang
//     Organization : YBWork.com
//    Original Date : July, 25, 2001
//             Addr : Room 402, No. 131, Meilong No. 9
//              TEL : 86-21-54630718
//            EMail : rayyang2000@yahoo.com
//          Website : http://www.ybwork.com
//		  Copyright : Copyright (L) YBWork.com, 2001
//         Comments : 
//                    
//					<< History >> 
//					July, 25, 2001		The first release
//===================================================================//

#include "ZBoard.H"
#include "HAL.H"
#include "USBD12.H"

void outportb(unsigned short nPort, unsigned char nVal)
{
#ifdef PARALLEL_BUS
	unsigned char xdata *exAddress;
	exAddress = nPort;
	*exAddress = nVal;
#else
	P1 &= 0xf1;	// Enable D12
	IC_D12_A0 = nPort & 0x01 ? 1 : 0;
	IC_D12_WR = 0;
	P0 = nVal;
	IC_D12_WR = 1;
	P1 |= 0x0e;	// Disable D12
#endif

}

unsigned char inportb(unsigned short nPort)
{
	unsigned char nVal;
#ifdef PARALLEL_BUS
	unsigned char xdata *exAddress;
	exAddress = nPort;
	nVal = *exAddress;
#else
	P1 &= 0xf1;	// Enable D12
	IC_D12_A0 = nPort & 0x01 ? 1 : 0;
	IC_D12_RD = 0;
	nVal = P0;
	IC_D12_RD = 1;
	P1 |= 0x0e;	// Disable D12
#endif

	return nVal;
}

void Delay(unsigned char nFactor)
{
	unsigned char i;

	for(i=0; i<nFactor; i++)
		i=i;

}

void DelayMs(unsigned char nFactor)
{
	unsigned char i;

	for(i=0; i<nFactor; i++)
		Delay(2);
}



⌨️ 快捷键说明

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