📄 main.c
字号:
/*=============================================================================
* Copyright (C) 2001 Acer Labs, Inc. All Rights Reserved.
*
* File: MAIN.C
*
* Contents: -
*
* History:
* 04/18/2001 develop 5705
******************************************************************************/
#include <reg52.h>
#include "typedef.h"
#include "defs.h"
#include "function.h"
#include "global.h"
#include "regdef.h"
#include "macro.h"
/*-----------------------------------------------------------------------------
Function: main program
Input: -
Output: -
-----------------------------------------------------------------------------*/
//#define testmain
#ifdef testmain
WORD code trk_num_in=0;
WORD code trk_num_ot=1;
BYTE code jumptest=1;
BYTE code two_point_seek=0;
BYTE code layerjmptst=0;
WORD code dev_trk=45500;
void main(void)
{
BYTE deca=0;
InitMCU();
InitCPS();
while(bServoState<0x04){ServoState();}
if(layerjmptst&&(fTOC==1))
{
if ((bServoState>=0x06))
{
if(deca==1)
{
while(JumpTracks(0,trk_num_ot)==BUSY);
do{
ServoState();
}while(bPStatus==BUSY);
deca--;
Delay10ms(100);
}
if (fServoDieFlag)
deca=1;
if(fDVDDual)
{
if(fCurrentLayer==fLayerNumber)
{
fDisRdQ=1;
fLayerNumber=~fLayerNumber;
}
else
{
TP_BYTE_0=JumpLayer(fLayerNumber);
if(TP_BYTE_0==READY)
{
WrDSP(TACTION,0x05);
fNewID=0;
}
else
{
do{
ServoState();
}while(bPStatus==BUSY);
}
}
}
}
}
while(jumptest)
{
#if 1
while(JumpTracks(1,trk_num_ot)==BUSY);
#else
while(JumpTracks(0,trk_num_ot)==BUSY);
#endif
while(RdSectorID()==BUSY);
Current.Min=Q.AMin;
Current.Sec=Q.ASec;
Current.Frm=Q.AFrm;
TP_TIME0.Min=Target.Min;
TP_TIME0.Sec=Target.Sec;
TP_TIME0.Frm=Target.Frm;
iwTrackNumber=CalculateTracks((PBYTE)&Q.AMin,(PBYTE)&TP_TIME0);
Target.Min=Current.Min;
Target.Sec=Current.Sec;
Target.Frm=Current.Frm;
Delay1ms(100);
#if 1
if(Q.AMin<=0x05)
{
while(JumpTracks(0,40000)==BUSY);
while(RdSectorID()==BUSY);
}
#else
if(Q.AMin>=0x20)
{
while(JumpTracks(1,40000)==BUSY);
while(RdSectorID()==BUSY);
}
#endif
/* Current.Min=Q.AMin;
Current.Sec=Q.ASec;
Current.Frm=Q.AFrm;
TP_TIME0.Min=Target.Min;
TP_TIME0.Sec=Target.Sec;
TP_TIME0.Frm=Target.Frm;
iwTrackNumber=CalculateTracks((PBYTE)&Q.AMin,(PBYTE)&TP_TIME0);
Target.Min=Current.Min;
Target.Sec=Current.Sec;
Target.Frm=Current.Frm;*/
}
while(two_point_seek)
{
Seek(0,2,0);
do{
ServoState();
}while(bPStatus==BUSY);
Target.Min=ilLeadOut/4500;
Target.Sec=0;
Target.Frm=0;
Seek(Target.Min,Target.Sec,Target.Frm);
do{
ServoState();
}while(bPStatus==BUSY);
}
while(fTOC)
{
CheckFlashDisc();
ProcessReseek();
GetIDECommand();
DecodeState();
VanderState();
RuninState();
}
}
#else
void main(void)
{
InitMCU();
InitCPS();
InitUART();// 3b07a01j
#if 0 // for testing RFZC & TEZC signal (FLAG2 & FLAG3) .
WrReg( 0x15c,(RdReg(0x15c))|0x80 );
WrReg( 0x149,(RdReg(0x149))&0xc0|0x0c );
#endif
while(TRUE)
{
if( (!fMaster) && fCheckFlashCD && (bServoState==MONITOR_STATE) && fTOC && fRuninJ ) //1b02a04j
CheckFlashDisc(); //1b02a04j
if(fTOC && bStateFlowNo>=0xA0)
ProcessReseek();
if((fATACmdInt||fPktCmdInt) )//&& (bStateFlowNo==DEFAULT)) //1b02a05j***
{
if(bStateFlowNo==DEFAULT)
GetIDECommand();
else if(RdReg(ATAPIPKT0)==0x1B)
{
WrReg(MPACKREG2,0x04);
WrReg(MPACKREG1,0x20);
bStateFlowNo=DEFAULT;
GetIDECommand();
}
else if((fRead10Exed||fReadCDExed)&&!fCheckFlashCD)
{
if(fXDone)
{
fXDone=0;
bECCErrTimes=0;
bDecoderState=NORMAL;
ilBuffStartALBA+=UXL.WLength;
if(!fDMA && (bCommandPacket[0]!=0x28) && (bCommandPacket[0]!=0xAD))
{
bStateFlowNo=DEFAULT;
WrReg(RAIE1,RdReg(RAIE1)&0x77);
WrReg(0xb3,0x03);
WrReg(0xb1,0x50);
WrReg(0xb4,0x01);
}
else
{
WrReg(MPEGCFG,RdReg(MPEGCFG)&0xFD); //RS EDC always OK
WrReg(RAIE1,RdReg(RAIE1)&0x77);
}
}
else
{ //abort command as time_out condition
fRead10Exed=0;
fReadCDExed=0;
fBufferFull=0;
fDSPErr=fECCErr=fEDCErr=0;
bTargetErrTimes=0;
bECCErrTimes=0;
ibXferCount=0;
ibSubChannalBit=0;
iwTotalSector=0;
bReseekFlowNo=CHECK_RESEEK;
bStateFlowNo=DEFAULT;
SetSenseCode(0x03,0x11,0x05);
WrReg(MPACKREG2,0x04);
WrReg(MPACKREG1,0x20);
WrReg(RAIE1,RdReg(RAIE1)&0x77);
WrReg(0x02,0x04); //2406a04j
SetCmdPhaseOver(0x51,0x05);
WrReg(ATASGNCTL,ASSERT_IRQ);
}
GetIDECommand();
}
} //1b02a05j&&&
DecodeState();
VanderState();
ServoState();
RuninState();
// 3b07a01j***
#ifdef _rs232
ReData();
#endif
// 3b07a01j&&&
}
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -