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

📄 cheshi.lst

📁 GSM MCU 开发板
💻 LST
📖 第 1 页 / 共 5 页
字号:
 244   4                                       ES=1;                  //设置发送指针
 245   4                                       receive_count=0;
 246   4                                               send_count=0xff;
 247   4                              }
 248   3                              else if(uart_buff[0]=='4'||uart_buff[0]=='3') //错误指令和 无法接通
 249   3                          {  AT_Command_Status=COMMAND_ERROR;}
 250   3                              else AT_Command_Status=COMMAND_UNKNOW;
 251   3                                       txd_rxd_bit=1; //接收成功
 252   3      
 253   3                               uart_buff[receive_count]=0;   //receive_count=2 ;
 254   3                               return;
 255   3                          }
 256   2      
 257   2                      else if(((receive_count>=3)
 258   2                             &&uart_buff[receive_count-1]==0x0d)
 259   2                                 &&(uart_buff[receive_count-3]==0x0a)
 260   2                             &&((uart_buff[receive_count-2]=='0')))
 261   2      
 262   2                          {  ///可能是包含为其他信息的命令返回
 263   3                                uart_buff[receive_count]=0;//RECEIV OK ANSWER, with some message
 264   3                        AT_Command_Status=COMMAND_OK;
 265   3                        txd_rxd_bit=1;
 266   3      
 267   3                      }
 268   2      
 269   2               else if((AT_Command_Type==SMS_CMGS||AT_Command_Type==AT_COMMAND)&&uart_buff[2]=='>')
 270   2                      {       AT_Command_Status=COMMAND_OK;    txd_rxd_bit=1;
 271   3                              return;
 272   3                      }
 273   2      
 274   2      
 275   2              }//End of if(RI)
 276   1      }
 277          /*********************************************************************
 278           *                  C51中字符串函数的扩充                            *
 279           *********************************************************************/
 280          
 281          uchar strsearch(uchar *ptr2)//查字符串*ptr2在*ptr1中的位置
 282          //本函数是用来检查字符串*ptr2是否完全包含在*ptr1中
 283          //返回:  0  没有找到
 284          //       1-255 从第N个字符开始相同
 285          {
 286   1      //、    uchar max_length;
 287   1              uchar i,j,k;
 288   1              uchar flag;
 289   1              if(ptr2[0]==0) return(0);
 290   1              flag=0;
 291   1              for(i=0,j=0;i<MAX_TM-2;i++)
 292   1              {
 293   2              if(uart_buff[i]==ptr2[j])
 294   2              {//第一个字符相同
 295   3                      for(k=i;k<MAX_TM-2;k++,j++)
 296   3                      {
 297   4                              if(ptr2[j]==0)//比较正确
 298   4                                      return(i+1);               //返回值是整数,不含0
 299   4                              if(uart_buff[k]!=ptr2[j]) break;
 300   4                      }
 301   3                      j=0;
 302   3              }
 303   2              }
C51 COMPILER V7.50   CHESHI                                                                11/16/2008 00:57:23 PAGE 6   

 304   1              return(0);
 305   1      }
 306          //=============================================================================
 307          //                  话机被叫程序
 308          //=============================================================================
 309          //=============================================================================
 310          //                  话机被叫程序
 311          //=============================================================================
 312          uchar Read_Call_ID(void)//读出来电显示的号码
 313          //正确  TRUE
 314          //错误  FALSE
 315          //号码  string_temp[0..16],最多显示前16位
 316          //呼叫方式 stringt_temp[20]
 317          {
 318   1              uchar i,j,r;
 319   1      
 320   1              Send_AT_Command(CALL_ID);//+CLCC:1,1,4,0,0,"02138950224",129
 321   1              //      语音呼入
 322   1      
 323   1              //string_temp[0]=0;
 324   1              //string_temp[20]=0;  //读来电显示出错时设为1
 325   1              if(receive_count<15) return(FALSE);
 326   1              uart_buff[receive_count]=0;
 327   1               ring_bit=0;
 328   1      
 329   1            ES=1;                     //设置发送指针
 330   1            receive_count=0;
 331   1                send_count=0xff;
 332   1                RI=0 ;
 333   1              j=0;
 334   1      //      i=strsearch(uart_buff,"CLCC");//查第一个CLCC
 335   1          i=strsearch("CLCC");//查第一个CLCC
 336   1              if(i==0) return(FALSE);
 337   1              j=j+i;
 338   1              for(r=0;r<9;r++)
 339   1              {
 340   2              if(uart_buff[j]==',')   break;
 341   2              else  j=j+1;
 342   2         }
 343   1              if(r>=9) return(FALSE);
 344   1              j=j+1;
 345   1              for(r=0;r<4;r++)
 346   1              {
 347   2                      if(uart_buff[j]==',')    break;
 348   2                      else  j=j+1;
 349   2          }
 350   1              if(r>=4) return(FALSE);
 351   1              j=j+1;
 352   1              //检查是否为来话呼叫
 353   1              if(uart_buff[j]!='4') return(FALSE);
 354   1              for(r=0;r<4;r++)
 355   1              {
 356   2              if(uart_buff[j]==',')    break;
 357   2              else  j=j+1;
 358   2          }
 359   1              if(r>=4) return(FALSE);
 360   1              j=j+1;
 361   1      //      string_temp[20]=uart_buff[j];//读出呼叫类型
 362   1              //只要能读出呼叫类型就认为正确
 363   1         //   i=strsearch(&uart_buff[j],"\x22");//查第一个"号
 364   1              for(r=0;r<6;r++)
 365   1              {
C51 COMPILER V7.50   CHESHI                                                                11/16/2008 00:57:23 PAGE 7   

 366   2              if(uart_buff[j]=='\x22')   break;
 367   2              else  j=j+1;
 368   2          }
 369   1      
 370   1              if(r>=6)
 371   1                      return(FALSE);
 372   1              j=j+1;
 373   1         i=j;
 374   1         //   i=strsearch(&uart_buff[j],"\x22");//查第二个"号
 375   1              for(r=0;r<20;r++)
 376   1              {
 377   2              if(uart_buff[j]=='\x22')   break;
 378   2              else  j=j+1;
 379   2         }
 380   1              if(i<=2) return(FALSE);//没有来电号码
 381   1              for(r=0;r<22;r++)
 382   1              {
 383   2             para_temp[r+2]=uart_buff[i++];
 384   2                 if(uart_buff[i]=='\x22')
 385   2                 { para_temp[r+3]=0x0d;para_temp[r+4]=0x00;uart_buff[i++]=0x0d;uart_buff[i++]=0; break;}
 386   2      
 387   2               }
 388   1           uart_buff[i++]=0;uart_buff[i++]=0;
 389   1              return(TRUE);
 390   1      }
 391          
 392          void ring_auto()   //自动监听  当有电话呼入,只有车主电话可以监听,别的电话会自动挂机
 393          {   uchar i=0;
 394   1               ring_bit=0;
 395   1               ring_cnt=1;
 396   1               LED_INT6=0;
 397   1           timercount=0;
 398   1           i=0;
 399   1      
 400   1                              if(Read_Call_ID())    //读来电显示
 401   1                      {        ring_cnt=0;
 402   2                              timer_S_cnt=0; while(timer_S_cnt<6) watch_dog_clear;
 403   2                          if(ring_cnt>=1)
 404   2                               { ring_cnt=0;  Send_AT_Command(PICK_UP);
 405   3                                                      ES=1;                   //设置发送指针
 406   3                                              receive_count=0;
 407   3                                                  send_count=0xff;
 408   3                                              uart_buff[0]=0;
 409   3                                                       RI=0 ;
 410   3                                              AT_Command_Status=COMMAND_WAIT; //设置接收成功标志
 411   3                                                      while((AT_Command_Status==COMMAND_WAIT))  watch_dog_clear;
 412   3                                               }
 413   2                           Send_AT_Command(HOOKOFF);
 414   2                                               ring_bit=0;
 415   2                                               ring_cnt=0;
 416   2                                               LED_INT6=1;
 417   2                                              return;
 418   2      
 419   2                      }
 420   1                      else   { LED_INT6=1; return;   }
 421   1      
 422   1      
 423   1      
 424   1             LED_INT6=1;
 425   1      }
 426          //----------------------------------------------
 427          //---------这里进行中断查询如果有中断马上处理----------------------
C51 COMPILER V7.50   CHESHI                                                                11/16/2008 00:57:23 PAGE 8   

 428          uchar P2_INIT()
 429          {
 430   1              //---------------------------------------
 431   1          send_count=0xffff;  AT_Command_Status=COMMAND_WAIT;
 432   1            if(!io_p00_on )
 433   1                { io_p00_on=1;system_server=SYS_START; return(0); }
 434   1            else if(!io_p02_on) { io_p02_on=1; system_server=SYS_SBC;return(0); }
 435   1           if(ring_bit) { ring_auto(); return(0);  }
 436   1      
 437   1      
 438   1            if(!io_p03_on )
 439   1             {   io_p03_on=1;
 440   2                 BELL=0;
 441   2                for(tmp_j=0;tmp_j<8;tmp_j++)    //灯闪三下
 442   2               {  timercount=0;  while(timercount<10) watch_dog_clear; }
 443   2               BELL=1;
 444   2               system_server=SYS_DIAL;
 445   2               return(0);
 446   2             }
 447   1           //---------------------------------------------------
 448   1            return(1);
 449   1      }
 450          //----------------------------------------------------------------
 451           //-----灯闪与 无线接键处理,--------------------------------------------
 452          void LED_1()
 453          {
 454   1              LED_P0++;
 455   1              if(LED_P0>=16) LED_P0=0;
 456   1         if((PT2272_TMP>0))      //513M中断后处理。这里只是让灯亮几秒钟
 457   1             {  P0=0;
 458   2                if(PT2272_D0==1)  //A键      D1灯亮
 459   2                { P0_7=1;
 460   3                  timercount=0; while(timercount<215) watch_dog_clear;
 461   3                  P0_7=0;PT2272_D0=0;
 462   3                }
 463   2                if(PT2272_D1==1) //B键       D6灯亮
 464   2                { P0_6=1;
 465   3                  timercount=0; while(timercount<215) watch_dog_clear;
 466   3                  P0_6=0; PT2272_D1=0;
 467   3                }
 468   2                if(PT2272_D2==1) ////C键    D8灯亮
 469   2                { P0_5=1;
 470   3                  timercount=0; while(timercount<215) watch_dog_clear;
 471   3                  P0_5=0; PT2272_D2=0;
 472   3                }
 473   2                if(PT2272_D3==1)  // //D键  D9灯亮
 474   2                { P0_4=1;
 475   3                  timercount=0; while(timercount<215) watch_dog_clear;
 476   3                  P0_4=0; PT2272_D3=0;
 477   3                }
 478   2      
 479   2              }
 480   1             else
 481   1             {
 482   2              if(LED_P0<=7)     //流水灯
 483   2               {
 484   3                      P0=(0x80>>LED_P0);
 485   3               }
 486   2               else
 487   2               {P0=(0x80>>LED_P0-8);}
 488   2             }
 489   1      
C51 COMPILER V7.50   CHESHI                                                                11/16/2008 00:57:23 PAGE 9   

 490   1      
 491   1      
 492   1      
 493   1      }
 494          
 495           //

⌨️ 快捷键说明

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