📄 main.c
字号:
#include <hidef.h> /* common defines and macros */
#include <mc9s12dg128.h> /* derivative information */
#include "BaseInc.h"
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
int i,j;
int l;
void Delay(uint k){
uint m,n;
for(m=0; m<k; m++)
for(n=0; n<1000; n++);
}
void main(void) {
/* put your own code here */
SystemInit();
PIDInit();
EnableInterrupts;
// OpenMDC();
#if 1
SteerZero();
while(PTT_PTT4); //启动按键
//run_arithmetic(450);
//SetSteerAngle(-70);
//SetSteerAngle(70);
m_cFrameSampeFlag = 0;
m_cFrameCompleteFlag = 0;
m_cCCDFrameShiftFlag = 0;
m_cRowNum = -1;
m_cCCDRowNum = -1;
m_nCnt = 0;
m_nCnt2 = 0;
#endif
//ATD0CTL5=0x06; //启动AD转换
#if 0
for(i=0; i<CCD_ROWS; i++)
for(j=0; j<CCD_COLS; j++)
m_aImage[i][j] = 100;
for(i=90; i<110; i++)
for(j=0; j<CCD_COLS; j++)
{
m_aImage[i][j] = 50;
}
RoadCenterDetect(m_aImage,m_aRoadParam);
#endif
//#if 0
//OpenMDC();
//ATD0CTL5 = 0x06;
//#endif
for(;;)
{
if(m_cFrameCompleteFlag == 1)
{
m_cFrameCompleteFlag = 0;
//RoadCenterDetect();
//CaculRoadParamK();
// FuzzyCtrl();
//m_nCnt++;
//if(m_aRoadParam[0].xPosition>120)SetSteerAngle(-60);
//else if(m_aRoadParam[0].xPosition<80)SetSteerAngle(60);
//else SetSteerAngle(0);
#if 0
SCI_PutByte(1,m_aRoadParam.ValidStart);
SCI_PutByte(1,m_aRoadParam.ValidNum);
SCI_PutByte(1,m_Temp);
for(i = 0; i<CCD_COLS ;i++)
{
SCI_PutByte(1,m_aRoadParam.Unit[i].xPosition);
SCI_PutByte(1,m_aRoadParam.Unit[i].K);
}
SCI_PutByte(1,0);
SCI_PutByte(1,0);
#endif
l++;
if(l >= 100)
{
l = 0;
#if 0
for(i=0; i<CCD_COLS+1; i++)SCI_PutByte(0,0);
for(j=0; j<CCD_COLS; j++)
{
SCI_PutByte(0,m_aRoadParam[j].xPosition);
}
SCI_PutByte(0,0);
for(j=0; j<CCD_COLS-1; j++)
{
SCI_PutByte(0,m_aRoadParam[j].K);
}
SCI_PutByte(0,0);
for(j=0; j<CCD_COLS-2; j++)
{
SCI_PutByte(0,chTemp1[j]);
}
SCI_PutByte(0,0);
for(j=0; j<CCD_COLS-3; j++)
{
SCI_PutByte(0,chTemp2[j]);
}
SCI_PutByte(0,0);
#endif
#if 0
//m_nCnt2 = 0;
for(i=0; i<26; i++)SCI_PutByte(0,0);
for(i=0; i<CCD_ROWS; i++)
{
for(j=0; j<CCD_COLS; j++)
{
SCI_PutByte(0,m_aImage[i][j]);
if((i%25) == 24)SCI_PutByte(0,0);
}
}
//m_nCnt2 = 0;
#endif
}
}
} /* wait forever */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -