⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 这是本人参加FREESCAL最牛的智能小车程序
💻 C
字号:
#include <hidef.h>      /* common defines and macros */
#include <mc9s12dg128.h>     /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
#define uchar unsigned char
#define uint unsigned int
#include "sci.h"
#include "init.h"
#include "control.h"
#include "arithmatic.h"
#include "interrupt.h"
uchar hurry;
void main(void) 
{
  EnableInterrupts;
  init_all();
  while(time<120) PWMDTY2=0;
  PWMDTY2=110;
  //init_all();
  for(;;) 
 {
    if(uptime)            //uptime
  { 
    uptime = 0; 
    control_all();                          //路况判断
    if(road_state==curve_b) 
    {
      PWMDTY01=70*curve_btd[MET][SET]+1100;
      servo = curve_btd[MET][SET];
      //PWMDTY2=137;
    }  
    if(road_state==line)
    {
      PWMDTY01=65*line_td[MET][SET]+1100;
      servo = curve_std[MET][SE];
     // PWMDTY2=150;
    }          
    if(road_state==curve_s)
    {
      PWMDTY01=65*curve_std[MET][SET]+1100;
      servo = curve_std[MET][SE];
     // PWMDTY2=150;
    }
    if(road_state==s_like) 
    {
      PWMDTY01=40*s_liketd[MET][SET]+1100;
      servo = s_liketd[MET][SET];
      //PWMDTY2=145;
    // delay(s);
    }
    last_state = road_state;
  if(PORTAD0==0xff&&PORTA==0xff)  
    {                                           
      set_speed = 5;
      PWMDTY01=73*curve_btd[MET][SET]+1100;
      //delay(10);
    }    
   if((SE>9||SE<-9)&&(PORTAD0==0xff&&PORTA==0xff)) 
    {
     hurry = 30;
     //PWMDTY2=50;
     PWMDTY01=75*curve_btd[MET][SET]+1100;
     while(hurry-->0)  
     {
      set_speed = 4;
      speed_control(); 
     } 
    }   
    //SciTx(cur_speed);  
    SciTx(MET); 
    //SciTx(dekt); 
    SciTx('\r');
    SciTx('\n'); 
    //speed_control(); 
   }
 }
} 
                       

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -