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

📄 gsmod.c.bak

📁 这是一个利用短信实现抄表的工程的源码,单片机通过串口与TC35通讯.同时单片机通过485与表记通讯,获得表记数据后以短信的形式发给用户.
💻 BAK
字号:
/************************************************************************************
*                                                                                   *
*   File Name   : main.c                                                            *
*   Contents    : definition of R8C/11 Group SFR									*
*   Copyright, 2003 RENESAS TECHNOLOGY CORPORATION									*
*                   AND RENESAS SOLUTIONS CORPORATION								*
*   Version     : 1.00                                                              *
*   note        :                                                                   *
*                                                                                   *
************************************************************************************/
#include "sfr_r811.h"			/* Definition of the R8C/11 SFR */
#include "uart.h"
#include "string.h"
#include "sms.h"
#include "int.h"
static const char s_Aphasebeak[]="53F78868004176F865AD76F8";
static const char s_Bphasebeak[]="53F78868004276F865AD76F8";
static const char s_Cphasebeak[]="53F78868004376F865AD76F8";
static const char s_Alostvolt[]="53F78868004176F85931538B";
static const char s_Blostvolt[]="53F78868004276F85931538B";
static const char s_Clostvolt[]="53F78868004376F85931538B";
static const char s_revphase[]="53F78868900676F85E8F";
static const char s_Alostcurr[]="53F78868004176F859316D41";
static const char s_Blostcurr[]="53F78868004276F859316D41";
static const char s_Clostcurr[]="53F78868004376F859316D41";
static const char s_noload[]="53F7886865E08D1F8377";
static const char s_begin[]="53F788685F0059CB";
static const char s_restore[]="53F788686062590D";
static const char s_nosymmetry[]="53F788684E0D5E7379F0";
static const char s_nobanance[]="53F788684E0D5E738861";
static const char s_aberrance[]="53F78868757853D8";
static const char s_program[]="53F788687A0B7F16";
static const char s_resetzero[]="53F788686E0596F6";
static const char s_clrdemand[]="53F788686E05970091CF";
static const char s_time[]="53F7886865F695F4";
static const char s_powerup[]="53F788684E0A7535";
static const char s_set[]="53F788688BBE7F6E";
static const char s_initenerge[]="53F788688BBE521D59CB753591CF";
static const char s_powerover[]="53F788688D85529F7387";
static const char s_poweroff[]="53F788688DF395F8";
static const char s_settime[]="53F78868682165F6";
static const char s_highcencur[]="53F788689AD84E2D7EBF75356D41";
static const char s_Acurrover[]="53F78868004176F88FC76D41";
static const char s_Bcurrover[]="53F78868004276F88FC76D41";
static const char s_Ccurrover[]="53F78868004376F88FC76D41";
static const char s_powerdown[]="53F7886863897535";
static const char s_number[]="0030003100320033003400350036003700380039";
static const char s_event[]="4E8B4EFB";
static const char tda[]="8613607485620";
static const char com645[14]={0x68,0x99,0x99,0x99,0x99,0x99,0x99,0x68,0x01,0x02,0x43,0xc3,0x6f,0x16};
static const char accii[]="MA123456789012RD9010";
SM_PARAM sms;	
unsigned int batvolt;
unsigned char msta;
char maddr[6]={0x99,0x99,0x99,0x99,0x99,0x99};
const char msg[]="MA999999999999RD43C3";
main(){	unsigned int k,k1;
	unsigned char len;
	asm("FCLR I");				/* Interrupt disable */
	prcr = 1;					/* Protect off */
	cm13 = 1;					/* X-in X-out */
	cm15 = 1;					/* XCIN-XCOUT drive capacity select bit : HIGH */
	cm05 = 0;					/* X-in on */
	cm16 = 0;					/* Main clock = No division mode */
	cm17 = 0;
	cm06 = 0;					/* CM16 and CM17 enable */
	asm("nop");
	asm("nop");
	asm("nop");
	asm("nop");
	ocd2 = 0;					/* Main clock change */
	prcr = 0;					/* Protect on */
	//init_uart0(9600,'n');
	init_uart0(1200,'e');
	init_uart1();
	sfr_init();
	init_timer();
	init_key();
	init_wdc();
	init_adc();
	init_int();
	sfr_ref();
	init_io();
	init_glb_val();
    start_u0rx(); 
    start_u1rx(); 
    batvolt=0;
    flag.bit.newmsg=0; 
	flag.bit.chargestar=1;
	flag.bit.chargeend=0;
    asm("FSET I");
    while(batvolt<690){batvolt=get_bat_volt();}
       //gsm_poweron();
	  
      gsm_IGT(u1,5000); 
      test_gsm(u1,1000);
      sendATcom(u1,"AT+CFUN=1\r","\r\nOK\r\n","ERROR\r\n",300);
    
	   //sendATcom(u0,"AT+CFUN?\r","\r\nOK\r\n","ERROR\r\n",100); 
       //sendATcom(u0,"AT+CPBW=3,012345678901,129,MA\r","\r\nOK\r\n","ERROR",100);
       //sendATcom(u0,"AT+CPBR=3\r","\r\nOK\r\n","ERROR",100);
      // strncpy(maddr,"777777777777",12);
       //sch_pho_num(u0,maddr,&sms,1000);
       //gsmReadMsg(u0,&sms,"14",10000);	
      // sms.TP_DCS=GSM_7BIT;
      // for(k=0;k<20;k++) sms.TP_UD[k]=accii[k];
      // decodemsg(u0,&sms,1000);
      
      //send_n_byte(u0,com645,14);
      //clr_rxbuf(u0);
    // msta=check_mstat(u0,maddr,0x21,100);
   //sch_phobook(u1,200);
   //read_phobook(u0,3,sms.TPA,200);
   //sendATcom(u0,"AT+CFUN?\r","\r\nOK\r\n","ERROR\r\n",200);
  //clr_rxbuf(0);
  //flag.bit.newmsg=1;
  //sms.TP_DCS=GSM_7BIT;
  //news_index[0]='1';
  //news_index[1]='\0';
  //for(k=0;k<20;k++)sms.TP_UD[k]=msg[k];
 while(1){	 
 
    
   
    //send_n_byte(u0,com645,14);
	//while(flag.bit.u0txbusy==1){}
	//delay(20);
    //REDI=1;
	//while(sch_645_frame(u0,txbuf)<=0){}
    //clr_rxbuf(u0);
    // msta=check_mstat(u0,maddr,0x21,100);
    	
    //	send_n_byte(u0,(char *)com645,14);
   //   delay(100);
   
   //   delay(1000);
  // batvolt=bat_charge();
  	if(flag.bit.newmsg==1)
		{   
			if(gsmReadMsg(u1,&sms,news_index,10000)>0)
			{ 
			    
			  if(decodemsg(u0,&sms,50000)>0)
				{
				//decodemsg(u0,&sms,50000);
				sms.SCA[0]='\0';
       				sms.TP_PID=0x00;
       				sms.TP_DCS=GSM_7BIT;
       				gsmSendMessage(u1,&sms,50000);
       				flag.bit.newmsg=0;  
       	                       }
       	    	//gsmDeleteMsg(u1,news_index,10000);
		 	
		       }
		}
      else
	    {
         //delt_allmsg(u1);
           }
        
       
   	}
}

⌨️ 快捷键说明

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