/*类型替换*/
typedef unsigned char uint8;
typedef unsigned short int uint16;
typedef unsigned long int uint32;
typedef signed char int8;
typedef signed short int int16;
typedef signed long int int32;
/*10ms延时函数*/
void Delay10ms(uint8 tt)
{
uint8 i, j;
while(tt--)
{
_nop_();
_nop_();
i = 108;
j = 144;
do
{
while (--j);
} while (--i);
}
}
/*100ms延时函数*/
void Delay100ms(uint8 tt) //@11.0592MHz
{
uint8 i, j, k;
while(tt--)
{
i = 5;
j = 52;
k = 195;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
}
///*开关函数*/
//void Off_On (void)
//{
// if (Switch_Flag)
// {
// Stop ();
// }
// Switch_Flag=~Switch_Flag;
//}
//
//void Continue (void)
//{
// switch (Backup)
// {
// case 0x40: SlowTurnLeft ();break;
// case 0x43: SlowTurnRight ();break;
// case 0x15: Backward ();break;
// case 0x09: Forward ();break;
// case 0x08: FastTurnLeft ();break;
// case 0x5A: FastTurnRight ();break;
// }
//}
//
//void IrdAction (uint8 IrdCode)
//{
// switch (IrdCode)
// {
// case 0x45: Off_On ();break;
// case 0x40: if (Switch_Flag)
// {
// SlowTurnLeft ();
// Backup=IrdCode;
// Pause_Flag=0;
// };break;
// case 0x43: if (Switch_Flag)
// {
// SlowTurnRight ();
// Backup=IrdCode;
// Pause_Flag=0;
// };break;
// case 0x15: if (Switch_Flag)
// {
// Backward ();
// Backup=IrdCode;
// Pause_Flag=0;
// };break;
// case 0x09: if (Switch_Flag)
// {
// Forward ();
// Backup=IrdCode;
// Pause_Flag=0;
// };break;
// case 0x08: if (Switch_Flag)
// {
// FastTurnLeft ();
// Backup=IrdCode;
// Pause_Flag=0;
// };break;
// case 0x5A: if (Switch_Flag)
// {
// FastTurnRight ();
// Backup=IrdCode;
// Pause_Flag=0;
// };break;
// case 0x044: if (Switch_Flag)
// {
// Pause_Flag=~Pause_Flag;
// if (Pause_Flag)
// {
// Stop ();
// }
// else
// {
// Continue ();
// }
// };break;
// default :break;
// }
//}
/*循迹函数*/
void Self_Tracing (void)
{
switch (P0_PORT)
{
case 0x0F:FastTurnLeft ();break;
case 0x1F:FastTurnLeft ();break;
case 0x2F:FastTurnLeft ();break;
case 0x3F:FastTurnLeft ();break;
case 0x4F:FastTurnLeft ();break;
case 0x5F:FastTurnLeft ();break;
case 0x6F:FastTurnLeft ();break;
case 0x7F:FastTurnLeft ();break;
case 0x8F:FastTurnLeft ();break;
case 0x9F:FastTurnLeft ();break;
case 0xAF:FastTurnLeft ();break;
case 0xBF:FastTurnLeft ();break;
case 0xCF:FastTurnLeft ();break;
case 0xDF:FastTurnLeft ();break;
case 0xEF:FastTurnLeft ();break;
case 0xF0:FastTurnRight();break;
case 0xF1:FastTurnRight();break;
case 0xF2:FastTurnRight();break;
case 0xF3:FastTurnRight();break;
case 0xF4:FastTurnRight();break;
case 0xF5:FastTurnRight();break;
case 0xF6:FastTurnRight();break;
case 0xF7:FastTurnRight();break;
case 0xF8:FastTurnRight();break;
case 0xF9:FastTurnRight();break;
case 0xFA:FastTurnRight();break;
case 0xFB:FastTurnRight();break;
case 0xFC:FastTurnRight();break;
case 0xFD:FastTurnRight();break;
case 0xFE:FastTurnRight();break;
case 0xE7:Forward();break;
case 0xFF:Stop ();break;
default :Forward();break;
}
}