?? hal4sys.c
字號:
/*
//*************************************************************************
//
// P H I L I P S P R O P R I E T A R Y
//
// COPYRIGHT (c) 1999 BY PHILIPS SINGAPORE.
// -- ALL RIGHTS RESERVED --
//
// File Name: Hal4sys.C
// Created: Oct 24, 2000
// Modified:
// Revision: 1.01
//
//*************************************************************************
*/
#include <reg51.h> /* special function register declarations */
#include <intrins.h>
#include "BasicTyp.H"
#include "SysCnfg.h"
#include "Hal4Sys.h"
#include "mainloop.h"
/*
//*************************************************************************
// Public Data
//*************************************************************************
*/
// Timer 0, not ULONG!!!
USHORT Hal4Sys_ClockTicks = 0;
//ULONG Hal4Sys_ClockTicks = 0;
/*
//*************************************************************************
// Private Data
//*************************************************************************
*/
/*
//*************************************************************************
// Functions
//*************************************************************************
*/
//Jan10, WARNING 16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
/*void Hal4Sys_InitTimer0(void)
{
//Init Timer0;
TIMER0_MODE &= 0XF0; // clear Timer 0 amd Keep Timer 1
TIMER0_MODE |= 0X01; // 16bit Timer
TIMER0_PRIORITY = 0; // 0 prority of Timer 0
TIMER0_IRQ_ENABLE = 1; // Enable IRQ Timer0
#ifdef WORK_AT_12MHZ
TIMER0_LOW = 0x00; // 1 MS interval @12MHz
TIMER0_HIGH =TIMER0_AT12MHZ;
#endif
#ifdef WORK_AT_24MHZ
TIMER0_LOW = 0x00; // 1 MS interval @24MHz
TIMER0_HIGH =TIMER0_AT24MHZ;
#endif
#ifdef WORK_AT_36MHZ
TIMER0_LOW = 0x00; // 1 MS interval @36MHz
TIMER0_HIGH =TIMER0_AT36MHZ;
#endif
#ifdef WORK_AT_48MHZ
TIMER0_LOW = 0x00; // 1 MS interval @36MHz
TIMER0_HIGH =TIMER0_AT48MHZ;
#endif
TIMER0_START = 1; // Start Timer 0
}
*/
void Hal4Sys_Wait4US(void)
{
#ifdef WORK_AT_12MHZ
// @12MHz
// LCALL = 2 MC
// RET = 2MC
#endif
#ifdef WORK_AT_24MHZ
// @24MHz
_nop_();
_nop_();
_nop_();
_nop_();
#endif
#ifdef WORK_AT_36MHZ
// @36MHz
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
#endif
#ifdef WORK_AT_48MHZ
// @48MHz
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
#endif
}
void Hal4Sys_WaitInUS(USHORT time)
{
#ifdef WORK_AT_12MHZ
time >>= 3; //time = time * MACHINECYCLE_AT12MHZ/LOOP_MC;
#endif
#ifdef WORK_AT_24MHZ
time >>= 2; //time = time * MACHINECYCLE_AT24MHZ/LOOP_MC;
#endif
#ifdef WORK_AT_36MHZ
time >>= 1; //time = time * MACHINECYCLE_AT36MHZ/LOOP_MC;
#endif
#ifdef WORK_AT_48MHZ
time >>= 1; //time = time * MACHINECYCLE_AT48MHZ/LOOP_MC;
#endif
for( ; time != 0; time -- );
}
/*void Hal4Sys_WaitInMS(USHORT time)
{
LowerIRQL();
time += Hal4Sys_ClockTicks;
while(Hal4Sys_ClockTicks != time );
}
*/
//Jan12, donot use time
void Hal4Sys_WaitInMS(USHORT time)
{
for( ; time != 0; time -- )
Hal4Sys_WaitInUS(1000);
}
void outportb(unsigned char port, unsigned char val)
{
#if 1
unsigned char xdata *ext_address;
D13CS_N = 0; //YAHOO
ext_address=0xff00 + port;
*ext_address = val;
D13CS_N = 1; //YAHOO
#endif
#if 0
if(0 == port )
*((UCHAR pdata *)D13_DATA_PORT) = val;
else
*((UCHAR pdata *)D13_COMMAND_PORT) = val;
#endif
}
unsigned char inportb(unsigned char port)
{
#if 1
unsigned char c;
unsigned char xdata *ext_address;
D13CS_N = 0; //YAHOO
ext_address=0xff00 + port;
c = *ext_address ;
D13CS_N = 1; //YAHOO
return c;
#endif
#if 0
if(0 == port)
return *((UCHAR pdata *)D13_DATA_PORT);
else
return *((UCHAR pdata *)D13_COMMAND_PORT);
#endif
}
/*
void Hal4Sys_D13CmdPortOutB( UCHAR val)
{
*((UCHAR pdata *)D13_COMMAND_PORT) = val;
}
void Hal4Sys_D13DataPortOutB( UCHAR val)
{
*((UCHAR pdata *)D13_DATA_PORT) = val;
}
UCHAR Hal4Sys_D13DataPortInB( void)
{
return *((UCHAR pdata *)D13_DATA_PORT);
}
*/
void Hal4Sys_ResetD13(void)
{
//Feb21, reset CPLD
DMA_RST = 0;
D13CS_N = 1; // CS deactive!!!
Hal4Sys_WaitInUS(400); // !!! CS is driven by weak pull-up resistor, 5V,10uA, 80pF needs 40uS
D13_WAKEUP = 0; // to remote-wakeup, pull D13_wakeup pin high, (not !!! direct conn reset pin, so no need to pull low here)
// D13SUSPD = 0;
D13RST_N = 0; // reset D13 , Holdup time > 2 uS.
Hal4Sys_Wait4US();
D13RST_N = 1;
DMASTART = 0;
D13CS_N = 1;
Hal4Sys_WaitInUS(5000);
DMA_RST = 1;
}
void Hal4Sys_InitD13(void)
{
Hal4Sys_ResetD13();
D13INT_EDGE = 0; // Level trigle for D13INT_N
D13INT_PRIORITY = 0; // 0 Priority Level of D13INT_N
D13INT_ENABLE = 1; // Enalbe External IRQ0 for D13INT_N
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -