📄 app.c
字号:
TargetCylinderAddr = 0x00005000;
TargetSectorAddr = 0x0046;//0010 YTW 2005-9-13
TargetHeadAddr = 0x0000;
SecondSyncMarkMode = 0x0000;
DFMode2 = 0x0004;
DFModeCtrl = 0x000b;
ReadTotalSignal = 0x71d2;
DFRetryCount = 0x000f;
DFFIFOWriPoint = 0x0000;
DFFIFOReadPoint = 0x0000;
//WriteCylinAddr = 0x00000ce5;
//ExtendFieldCount = 0x0c06;
LoopCountNumSector = 0x0010;
//BufTransMode = 0x8c00; //ver
}
void BufManager(void)
{
BufManageCtrl_0 = 0xa840;
BufManageItuptMask= 0xffff;
BufManageCtrl_1 = 0x8000;
BufManageCtrl_2 = 0x0000;
RefreshPeriod = 0x0fff;
HostLinkListPoint = 0x0000;
HostLinkListAddr = 0x0000;
AWSegmentSize = 0x0075;
SectorSize = 0x0100;
HostSegmentSize = 0x0180;
HosSegmentSecCont = 0x0009;
AWSegSecCont = 0x0009;
DiskSegSecCont = 0x0009;
ZSDTablePoint = 0x00008494;
AWSegTransPoint = 0x00021a00;
AWSegStartAddr = 0x00020000;
AWSegEndAddr = 0x0002fffc;
HostSegTransPoint = 0x00011a00;
HostSegStartAddr = 0x00010000;
HostSegEndAddr = 0x0002fffc;
DiskSegTransPoint = 0x00020000;
DiskSegStartAddr = 0x00020000;
DiskSegEndAddr = 0x0002fffc;
DMTablePointer = 0x0000813c;
SubsegStartAddr_0 = 0x00000000;
}
void LoadZSDTable()
{
int j;
INT16U * tmp = (INT16U*)ZSDTable_pointer;
for (j=0;j<5;j++)
{
//* tmp1 &= 0x00000000;
//* tmp1 |= WData[j]; // set
* tmp = ZSDTable[j];
tmp ++;
}
ZSD_Table_Point = 0x20000;
SAIL_Status = 0xffff;
}
void ZSD_Table (void)
{
ZSD_1 = 0x8008;
ZSD_2 = 0x0000;
ZSD_3 = 0x0001;
ZSD_Table_Point = 0x20000;
SAIL_Status = 0xffff;
}
///////////////////////////////////////////////////////////////
//function of preamplifier
/////////////////////////////////////////////////////////////
/*
void WriteRegister(INT8U regnum, INT8U data)
{}
INT8U ReadRegister(INT8U RegNum)
{return RegNum;}
void PREM_SetMode(INT8U Mode,INT8U Detail)//Mode=1:SLEEP;Detail=0
//Mode=2:IDLE; Detail =1:no MR bais;Detail =2:normal MR bais; Detail =3:Low MR bais
//Mode=3:Read; Detail =0
//Mode=4:write;Detail=1:MR bais on IMR;Detail =2:Low MR bais;
//Mode=5:Servo Bank write;Detail=0
{
INT8U ReadData;
switch(Mode)
{
case 1:
ReadData = ReadRegister(5);
ReadData &= 0xFE;
WriteRegister(5,ReadData);
break;
case 2:
ReadData = ReadRegister(9);
ReadData |=0x08;
WriteRegister(9,ReadData);//protection
if(Detail ==1)
{
ReadData = ReadRegister(5);
ReadData &= 0xFC;
ReadData |= 0x01;
WriteRegister(5,ReadData);
ReadData = ReadRegister(6);
ReadData &= 0xEF;
WriteRegister(6,ReadData);
break;
}
else if(Detail ==2)
{ //Valid:Servo Gate is low
ReadData = ReadRegister(5);
ReadData &= 0xFC;
ReadData |= 0x01;
WriteRegister(5,ReadData);
ReadData = ReadRegister(6);
ReadData |= 0x10;
WriteRegister(6,ReadData);
break;
}
else if(Detail ==3)
{ //Valid:Servo Gate is high
ReadData = ReadRegister(5);
ReadData |= 0x03;
WriteRegister(5,ReadData);
break;
}
else
break;
case 3://Valid:Servo Gate is low,Read Gate is high
ReadData = ReadRegister(5);
ReadData |= 0x03;
WriteRegister(5,ReadData);
break;
case 4:
ReadData = ReadRegister(5);
ReadData |= 0x03;
WriteRegister(5,ReadData);
if(Detail == 1)
{ //Valid:SG is low, Write Gate is high
ReadData = ReadRegister(6);
ReadData &= 0xEF;
WriteRegister(6,ReadData);
break;
}
else if(Detail ==2)
{ //Valid:SG is low, Write Gate is high
ReadData = ReadRegister(6);
ReadData |= 0x10;
WriteRegister(6,ReadData);
break;
}
else
break;
case 5://Vaild: Servo gate is high
ReadData = ReadRegister(5);
ReadData |= 0x03;
WriteRegister(5,ReadData);
break;
}
}
void PREM_HeadSelect(INT8U Mode,INT8U Head) //Mode =3 or 4; write and read mode,Head =0 or 1;
//Mode =5;servo bank write mode; Head =0 or 1, if head =3,select all heads, if head=4,no head selected
{
INT8U ReadData;
ReadData = ReadRegister(1);
if((Mode == 3)||(Mode == 4))
{
if(Head == 0)
{
ReadData &= 0xFE;
WriteRegister(1,ReadData);
}
else if(Head == 1)
{
ReadData |= 0x01;
WriteRegister(1,ReadData);
}
}
else if(Mode == 5)
{
if(Head == 0)
{
ReadData |= 0x02;
ReadData &= 0xFA;
WriteRegister(1,ReadData);
}
else if(Head == 1)
{
ReadData |= 0x01;
ReadData &= 0xF9;
WriteRegister(1,ReadData);
}
else if(Head == 3)
{
ReadData |= 0x03;
ReadData &= 0xFB;
WriteRegister(1,ReadData);
}
else if(Head == 4)
{
ReadData |= 0x04;
WriteRegister(1,ReadData);
}
}
}
void PREM_SetReadCurrent(INT8U CurrentNum)//see Table8
{
INT8U ReadData;
CurrentNum = CurrentNum<<3;
ReadData = ReadRegister(1);
ReadData &= 0x07;
ReadData |= CurrentNum;
WriteRegister(1,ReadData);
}
void PREM_SetWriteCurrent(INT8U CurrentNum)//see Table7
{
WriteRegister(2,CurrentNum);
}
void PREM_SetLowCurrentMRBais(INT8U BaisNum)//for write and bank write mode,see table6
{
BaisNum = BaisNum<<4;
WriteRegister(3,BaisNum);
}*/
////////////////////////////////////////////////////////////
//end of function of preamplifier
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
// function of self servo write
///////////////////////////////////////////////////////////////
void SSW_Init(void)
{
SSW_MAINCTRL = 0xA7;// 7th:enable SSW,6th:only write PES,5~0 bits:preamble length
SSW_COMBLOCK = 0x56; // select HFS1
SSW_F0H = 0x00;//set Frequency high bits
SSW_F0L = 0x00;//set Frequency low bits
SSW_DELTAP = 0x00;//set phase
SSW_TIMESTAMP = 0x8f;//TBG timestamp,internal timestamp, ...
SSW_DISTH = 0x1d;
SSW_DISTL = 0x04;// 0x741*4
SSW_DLYH &= 0x00; //high bits are set to 0, //only use 13-8 bit of the register
SSW_DLYL = 0x8F; //dely 5.83us
SSW_ENCODE &= 0xEF;//manchester code
SSW_DISTRESET = 0x06;//reset distance at next SG
/*------------data contral-----------------*/
SSW_PES_CONFIGL4 = 0xc8;// write PES field with normal polarity,write Burst D and erace burat C
SSW_PES_CONFIGH2 &= 0x0F;//pattern is 1
SSW_PES_LEN_MODE_CNT |= SSW_PESLEN;
SSW_PES_LEN_MODE_CNT |= SSW_PESMODE;
SSW_PES_LEN_MODE_CNT |= SSW_PESCNT;
SSW_PESGAP |=0x10;
SSW_SSM = 0x27;//STM pattern, if index sector,set to 14h, else set to 27h
SSW_READBACKEN &= 0x7f; //enable servo gray code read back
SSW_READBACKEN |= 0xa0; //gap between gray code and PES
SSW_GRAYCODELEN = 0xbf;// disable split, gray code length=
SSW_GRAYCODESPLIT = 0xd8;
SSW_GRAYCODEDATA = 0x00000000;
SSW_WGOUT_EN |=0x01;//enable*/
}
void SSW_InterruptSet()
{
SSW_INTCTRL = 0x0100;// select servo interrupt for IRQ
SSW_SERVOSTATUS = 0xffcf;//clear servo status
SSW_SERVOMASK |= 0xef0f;//mask drive Fault interrupt
}
////////////////////////////////////
//change to gray code
///////////////////////////////////
INT8U ChangeToGrayCode(INT8U data)
{
return (data^(data/2));
}
/*
INT32U HexToDec(INT32U data)
{
return data;
}
*/
//////////////////////////////////////////////////////////////
// end of self servo write function
//////////////////////////////////////////////////////////////
OS_STK TestTaskStk[100];
OS_STK TestTaskStk2[100];
void TestTask(void *pdata);
void TestTask2 (void *pdata);
void C_MAIN(void)
{
SSW_INTCTRL = 0x0100; //set interrupt
SSW_SERVOSTATUS = 0xffff;
OSInit();
OSTaskCreate(TestTask,(void *)0,&TestTaskStk[99],1);
OSTaskCreate(TestTask2,(void *)0,&TestTaskStk2[99],2);
OSStart();
}
void TestTask2 (void *pdata)
{
double i;
i = 0;
while(1)
{
if(i<100000000)
i++;
else
i = 0;
}
}
void TestTask (void *pdata)
{
//int r;
#if OS_CRITICAL_METHOD == 3 //Allocate storage for CPU status register
OS_CPU_SR cpu_sr;
#endif
OSInit();
CpuInit();
OS_ENTER_CRITICAL();
//SOFT_RST = 0x80; yaogaihuiqu
//SOFT_RST = 0x00; yaogaihuiqu
SQ_CTL&=0x00000000;
//SetupCPU(); yaogaihuiqu
PwrCtl();
WCSInit();
SetupWCS();
//ChnlInit();
SetupPattern();
SetupPatternTiming();
// CnlOpt();
SetupTxFmt();
SetupSrvctlFmt();
//EnTest();
//start servo controller
/**************The next setting is for Servo mode****************/
IndexsectorCtrl=0x0000;
SQ_CTL|=0x00000001;
Channel_Setting();
Channel_Reg();
DataChan_Reg();//Add by gary 09012005;
SetupWCS(); //verify by Gary 09052005
while (1) //Some information you may watch!
{
WPwrCtl();
WWCSInit();
HDC_Inter_Init();
SailRegistorInit();
DefectManager();
ErrorCorrectUnit();
DiskFormmater();
BufManager();
DataPatternInit();
WgateInitial();
WSetupWCS();
ZSD_Table();
LoadZSDTable();
WgateInitial();
WSequencerStart();
WSequencerStop();
while(1)
{
} */
/************The next setting is for self servo write*******/
EnterINT = 0;
WriteSecCunt = 0;
StartNewStep = 1;
// WriteLosingSec = 0;
LosingSecCunt = 0;
StopWrite = 0;
ArraySubscript = 0;
SSW_InterruptSet();
//open IRQ interrupt
__asm
{
MSR CPSR_c,#0x40|0x13
}
PwrCtl();
// SRV_DATA_CFG = 0x0004;
// SRV_DATA_CFG &= 0xfff8;
//SRV_DATA_CFG = 0x1;
SSW_Init();
while(1)
{
INT8U I;
if(EnterINT == 1)
{
EnterINT = 0;
//if(WriteSecCunt <1000)
WriteSecCunt++;
*(INT32U *)0x10002570 =WriteSecCunt;
//if(WriteSecCunt >=1000)
// {
// for(I=0;I<10000;I++)
// {}
// WriteSecCunt = 0;
// }//end if(WriteSecCunt >= 100)
}// end if(EnterINT == 1)
} //end while
}//end of task
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -