• 嵌入式软件设计第十次


    学号:140201127                 姓名毛倩倩

    组别:第2组                实验地点:D19

     

    一、实验目的:

    1、了解GSM模块SIM900A的使用方法。

    2、掌握使用串口发送AT命令驱动SIM900A的

       方法。

    二、实验内容:

    1.使用AT命令进行模块测试,拨打固定电话。

    2.编写程序利用触摸屏完成任意电话的呼叫。

    三、实验过程描述及结果展示:

    实验器材:STM32F407开发板、LCD显示屏

    1、实验原理

    SIM900A跳线帽连接方式:

    长按PWR_KEY键后网络状态指示灯对应的状态:

    2、常用AT指令_准备工作:

    3、常用AT命令_拨打电话

    4、程序代码

    #include "sys.h"

    #include "delay.h" 

    #include "usart.h"  

    #include "led.h"

    #include "lcd.h"

    #include "key.h" 

    #include "touch.h"

    #include "text.h"

    #include "w25qxx.h"

    #include "malloc.h"

    #include "ff.h"

    #include "exfuns.h" 

    const u16 POINT_COLOR_TBL[OTT_MAX_TOUCH]={RED,GREEN,BLUE,BROWN,GRED}; 

    unsigned char Dialling[12];

    char number[20] = "";

    u8 iscalling=0;

    int i,j;

    //

    void sendtext(char *p){

           while(*p!=''){

                  USART_SendData(USART3,*p);

                  delay_ms(50);

                  p++;

           }

           USART_SendData(USART3,0x0D);

           delay_ms(50);

           USART_SendData(USART3,0x0A);

    }

    //²¦ºÅ

    void call(){

           char text[40]="ATD";//¶¨ÒåÎı¾

           strcat(text,number);

           strcat(text,";");

    //     printf("%s",text);

           sendtext(text);//·¢ËÍÎı¾

          

           POINT_COLOR=YELLOW;

           for(i=180;i<=300;i++)//bohao

                  for(j=690;j<=750;j++)

                         LCD_DrawPoint(i,j);

           POINT_COLOR=BLUE;

           Show_Str(215,710,300,150,"¹Ò¶Ï",24,1);

           iscalling=1;

    }

    void hangup(){

           char text[40]="ATH";

           sendtext(text);

           number[0]='';

          

           POINT_COLOR=YELLOW;

           for(i=180;i<=300;i++)//bohao

                  for(j=690;j<=750;j++)

                         LCD_DrawPoint(i,j);

           POINT_COLOR=BLUE;

           Show_Str(215,710,300,150,"²¦ºÅ",24,1);

           iscalling=0;

           POINT_COLOR=YELLOW;       

           for(i=200;i<=400;i++)

                  for(j=90;j<=140;j++)

                         LCD_DrawPoint(i,j);

    }

    int main(void)

    {

           int i,j;

           delay_init(168);  //³õʼ»¯ÑÓʱº¯Êý

           uart_init(115200);         //³õʼ»¯´®¿Ú²¨ÌØÂÊΪ115200

           uart3_init(115200);

          

          LCD_Init();                                //LCD³õʼ»¯

           tp_dev.init();                 //´¥ÃþÆÁ³õʼ»¯

          

           LCD_Clear(BLACK);

          POINT_COLOR=YELLOW;//ÉèÖÃ×ÖÌåΪ»ÆÉ«

           BACK_COLOR = BLACK;

          

           POINT_COLOR=WHITE;

           Show_Str(100,100,300,150,"ºÅÂëÇø£º",24,1);

           //

           POINT_COLOR=YELLOW;       

           for(i=200;i<=400;i++)

                  for(j=90;j<=140;j++)

                         LCD_DrawPoint(i,j);

           //

           for(i=210;i<=270;i++)//5

                  for(j=370;j<=430;j++)

                         LCD_DrawPoint(i,j);

           for(i=210;i<=270;i++)//2

                  for(j=270;j<=330;j++)

                         LCD_DrawPoint(i,j);

           for(i=210;i<=270;i++)//8

                  for(j=470;j<=530;j++)

                         LCD_DrawPoint(i,j);

           for(i=110;i<=170;i++)//1

                  for(j=270;j<=330;j++)

                         LCD_DrawPoint(i,j);

           for(i=310;i<=370;i++)//3

                  for(j=270;j<=330;j++)

                         LCD_DrawPoint(i,j);

           for(i=110;i<=170;i++)//4

                  for(j=370;j<=430;j++)

                         LCD_DrawPoint(i,j);

           for(i=310;i<=370;i++)//6

                  for(j=370;j<=430;j++)

                         LCD_DrawPoint(i,j);

           for(i=110;i<=170;i++)//7

                  for(j=470;j<=530;j++)

                         LCD_DrawPoint(i,j);

           for(i=310;i<=370;i++)//9

                  for(j=470;j<=530;j++)

                         LCD_DrawPoint(i,j);

           for(i=110;i<=170;i++)//*

                  for(j=570;j<=630;j++)

                         LCD_DrawPoint(i,j);

           for(i=210;i<=270;i++)//0

                  for(j=570;j<=630;j++)

                         LCD_DrawPoint(i,j);

           for(i=310;i<=370;i++)//#

                  for(j=570;j<=630;j++)

                         LCD_DrawPoint(i,j);

           for(i=180;i<=300;i++)//bohao

                  for(j=690;j<=750;j++)

                         LCD_DrawPoint(i,j);

           POINT_COLOR=BLUE;

           Show_Str(215,710,300,150,"²¦ºÅ",24,1);

           BACK_COLOR = BLACK;

           LCD_ShowString(135,290,200,100,24,"1");//1

           LCD_ShowString(235,290,200,100,24,"2");//2

           LCD_ShowString(335,290,200,100,24,"3");//3

           LCD_ShowString(135,390,200,100,24,"4");//4

           LCD_ShowString(235,390,200,100,24,"5");//5

           LCD_ShowString(335,390,200,100,24,"6");//6

           LCD_ShowString(135,490,200,100,24,"7");//7

           LCD_ShowString(235,490,200,100,24,"8");//8

           LCD_ShowString(335,490,200,100,24,"9");//9

           LCD_ShowString(135,590,200,100,24,"*");//*

           LCD_ShowString(235,590,200,100,24,"0");//0

           LCD_ShowString(335,590,200,100,24,"#");//#

          

           //ÊäºÅÂë

           while(1){

                  POINT_COLOR=BLUE;      

                  tp_dev.scan(0);//

                  if(tp_dev.x[0]>110&&tp_dev.y[0]>270&&tp_dev.x[0]<170&&tp_dev.y[0]<330){

                         while((tp_dev.sta & 0x80) == 0x80)

                                {tp_dev.scan(0);}

                         strcat(number,"1");//Ìí¼ÓºÅÂë

                         LCD_ShowString(200,100,336,24,24,number);//ÏÔʾºÅÂë

                        

                  }

                  if(tp_dev.x[0]>210&&tp_dev.y[0]>270&&tp_dev.x[0]<270&&tp_dev.y[0]<330){

                         while((tp_dev.sta & 0x80) == 0x80)

                                {tp_dev.scan(0);}

                         strcat(number,"2");

                         LCD_ShowString(200,100,336,24,24,number);

                  }

                  if(tp_dev.x[0]>310&&tp_dev.y[0]>270&&tp_dev.x[0]<370&&tp_dev.y[0]<330){

                         while((tp_dev.sta & 0x80) == 0x80)

                                {tp_dev.scan(0);}

                         strcat(number,"3");

                         LCD_ShowString(200,100,336,24,24,number);

                 

                  }

                  if(tp_dev.x[0]>110&&tp_dev.y[0]>370&&tp_dev.x[0]<170&&tp_dev.y[0]<430){

                         while((tp_dev.sta & 0x80) == 0x80)

                                {tp_dev.scan(0);}

                         strcat(number,"4");

                         LCD_ShowString(200,100,336,24,24,number);

                        

                  }

                  if(tp_dev.x[0]>210&&tp_dev.y[0]>370&&tp_dev.x[0]<270&&tp_dev.y[0]<430){

                         while((tp_dev.sta & 0x80) == 0x80)

                                {tp_dev.scan(0);}

                         strcat(number,"5");

                         LCD_ShowString(200,100,336,24,24,number);

                        

                  }

                  if(tp_dev.x[0]>310&&tp_dev.y[0]>370&&tp_dev.x[0]<370&&tp_dev.y[0]<430){

                         while((tp_dev.sta & 0x80) == 0x80)

                                {tp_dev.scan(0);}

                         strcat(number,"6");

                         LCD_ShowString(200,100,336,24,24,number);

                        

                  }

                  if(tp_dev.x[0]>110&&tp_dev.y[0]>470&&tp_dev.x[0]<170&&tp_dev.y[0]<530){

                         while((tp_dev.sta & 0x80) == 0x80)

                                {tp_dev.scan(0);}

                         strcat(number,"7");

                         LCD_ShowString(200,100,336,24,24,number);

                        

                  }

                  if(tp_dev.x[0]>210&&tp_dev.y[0]>470&&tp_dev.x[0]<270&&tp_dev.y[0]<530){

                         while((tp_dev.sta & 0x80) == 0x80)

                                {tp_dev.scan(0);}

                         strcat(number,"8");

                         LCD_ShowString(200,100,336,24,24,number);

                        

                  }

                  if(tp_dev.x[0]>310&&tp_dev.y[0]>470&&tp_dev.x[0]<370&&tp_dev.y[0]<530){

                         while((tp_dev.sta & 0x80) == 0x80)

                                {tp_dev.scan(0);}

                         strcat(number,"9");

                         LCD_ShowString(200,100,336,24,24,number);

                 

                  }

                  if(tp_dev.x[0]>110&&tp_dev.y[0]>570&&tp_dev.x[0]<170&&tp_dev.y[0]<630){

                         while((tp_dev.sta & 0x80) == 0x80)

                                {tp_dev.scan(0);}

                         strcat(number,"*");

                         LCD_ShowString(200,100,336,24,24,number);

                 

                  }

                  if(tp_dev.x[0]>210&&tp_dev.y[0]>570&&tp_dev.x[0]<270&&tp_dev.y[0]<630){

                         while((tp_dev.sta & 0x80) == 0x80)

                                {tp_dev.scan(0);}

                         strcat(number,"0");

                  LCD_ShowString(200,100,336,24,24,number);

                 

                  }

                  if(tp_dev.x[0]>310&&tp_dev.y[0]>570&&tp_dev.x[0]<370&&tp_dev.y[0]<630){

                         while((tp_dev.sta & 0x80) == 0x80)

                                {tp_dev.scan(0);}

                         strcat(number,"#");

                         LCD_ShowString(200,100,336,24,24,number);

                 

                  }

                 

                 

                  if(tp_dev.x[0]>180&&tp_dev.y[0]>690&&tp_dev.x[0]<300&&tp_dev.y[0]<750){

                         if(iscalling){

                                hangup();

                         }else{

                                call();

                         }

                         while(tp_dev.x[0]!=65535){tp_dev.scan(0);}

                  }

                 

                  delay_ms(5);

                  tp_dev.x[0] = 0xFFFF;

                  tp_dev.y[0] = 0xFFFF;        

                 

           }

    }

    实验结果展示:

    四、总结及实验心得:

          这次实验主要是编写一个手机打电话功能,我们组用的是我们组的杨鹏飞的手机卡,我们组能用的手机卡也就只有两个。其他都有残缺,通过调整显示器上的数字在键盘的大小和显示数字的位置,起初,我们组做的这个数字的位置总是不在黄色方格里,后来经过几番的调试才把位置调正确,所以说,做实验最重要的不是代码的编写,而是编写完成以后的调试,有小小的瑕疵整个程序都不能运行。

  • 相关阅读:
    C#实现通过拼多多分享微信公众号实现查询优惠券、佣金比率
    淘宝客常用接口整理
    京东联盟开发(1) 商品SKUID采集
    Grafana 安装及 Windows 应用程序服务配置工具 NSSM使用
    Windows Server 2008R2 配置网络负载平衡(NLB)
    IIS 日志分析工具:Log Parser Studio
    curl: (25) Failed FTP upload: 550 解决方案
    搭建TFS 2015 Build Agent环境(四)
    Dump中查看dictionary信息的方法
    Dump中查看DataTime时间方法
  • 原文地址:https://www.cnblogs.com/caoyuanmaomao/p/6623734.html
Copyright © 2020-2023  润新知