int check_crossline( void ) { unsigned char b; int ret=0; b = bit_change(P7DR); if((b&0xc0) && (b&0x3c) && (b&0x03)) ret = 1; return ret; }
//车辆自动控制使用 int getLightLedSum() //灯亮数目,双排线:是否可以替换 { int i,sum=0; unsigned led = bit_change(P7DR); for(i=0; i<8; i++) { if(led&0x80)sum++; led<<=1; } return sum; }
int check_blackArea(void) //优化 { unsigned char b = bit_change(P7DR); if((b&0x07)==0x07 && (b&0x38) && !(b&0xc0)) { blackArea_direction = 1; return 1; } else if((b&0xe0)==0xe0 && (b&0x1c) && !(b&0x03)) { blackArea_direction = -1; return -1; } else return 0; }
void interrupt_timer0( void ) { ITU0_TSR &= 0xfe; /* Flag clear */ cnt0++; cnt1++; cnt2++; timerCnt++; if((eSpeedNum) == timerCnt) //100,时计数 { //此时进行一次速度的计算 eCurSpeed=(double)((iPulesNumAll*abvSpeed)/10); //速度计算公式: // 脉冲数 × 周长 // 实时速度=--------------------------- // 一圈的脉冲数 × 采集时间 //复位 iPulesNumAll = 0; //复位脉冲数目 timerCnt = 0; //复位时间数目 }//if /* if(!isDebug) { if(1==angleFlag) { if((int)eCurSpeed>150) { ITU4_BRA=(unsigned long)(PWM_CYCLE-1)*(-10)/100; ITU3_BRB=(unsigned long)(PWM_CYCLE-1)*(-10)/100; //brake time for(speedBrake_var=200;speedBrake_var!=0;speedBrake_var--); } else if((int)eCurSpeed<145) { ITU4_BRA=(unsigned long)(PWM_CYCLE-1)*40/100; ITU3_BRB=(unsigned long)(PWM_CYCLE-1)*40/100; for(speedBrake_var=200;speedBrake_var!=0;speedBrake_var--); } } } */ if(isStart) { if(isDebug) { if(!printNow) { if((~PBDR&0x01) && pushSw){ isStart = 0;isDebug = 0;printNow = 1;}//行进中途读调试数据 curLedValue = P7DR; if(curLedValue!=lastLedValue) getData(curLedValue,0); else if(bit_change(P7DR)==0xff && cnt0>800) //调试出轨 before p7dr=0xff { printNow = 1; } } } else //非调试出轨 { if(lastLedValue!=P7DR) { lastLedValue = P7DR; cnt0 = 0; }else if(bit_change(P7DR) ==0xff && cnt0>800) isStop = 1;// before p7dr=0xff } } }