新手入门
- 积分
- 25
- 金钱
- 25
- 注册时间
- 2014-9-7
- 在线时间
- 0 小时
|
5金钱
原子哥,新人。编译出现错误,怎么办,找了好久都没找到原因。
..\Output\STM32-DEMO.axf: Error: L6218E: Undefined symbol err (referred from gsm.o).
未定义的符号错误。。。。。怎么办。。。。
gsm.c源码如下:
#include "stm32f10x.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
//#include "stm32f10x_lib.h"
#include "gsm.h"
#include "usart1.h"
#include "usart3.h"
#include "GsmTime.h"
/*-----------------------------------------------------------------------
-----------------------------------------------------------------------*/
int num_of_sms;
#define SMS_CMD_LEN 64
char at_readsms[SMS_CMD_LEN];
char tpy_sms_content[SMS_CMD_LEN];
char tpy_send_tel_num[SMS_CMD_LEN];
char tp_content[BUFLEN];
unsigned char is_gprs_mode_ok = 1; //gprs start succeed
unsigned char is_gprs_mode_start_succeed = 0; //gprs connect ok
SIM300_STATUS current_status = INIT0;
//REG
#define ATE0_CMD "ATE0\x00D\x00A" /// ????????
#define CREG_CMD "AT+CREG?\x00D\x00A" /// ?é??????×??á?é??
#define SIMCARD_CMD "AT+CPIN?\x00D\x00A"
//SEND SMS
#define GSM_MSG_MODE "AT+CMGF=1\x00D\x00A"
#define GSM_MSG_MODE_CN "AT+CMGF=0\x00D\x00A"
//#define GSM_CENTER_NUM "AT+CSCA=\"+8613800512500\"\x00D\x00A"
#define GSM_CHAR_MODE "AT+CSCS=\"GSM\"\x00D\x00A"
#define GSM_CHAR_MODE_CN "AT+CMEE=0\x00D\x00A"
#define GSM_SEND_TEXT "AT+CMGS=\"+8613512963352\"\x00D\x00A"
/*-----------------------------------------------------------------------
-----------------------------------------------------------------------*/
//static
void S_INIT0() //?????????? ·?????±?????
{
PUT("S_INIT0 \r\n");
// printf("S_INIT0\r\n");
clear_buf_uart3();
send_string_uart3(ATE0_CMD);
current_status = ECHO0 ;
}
//static
void S_ECHO0() //??±????????? ·???SIM?¨?ì??
{
if(buf_uart3.buf[2] == 'O' &&
buf_uart3.buf[3] == 'K')
{
PUT("ECHO0 OK \r\n");
// printf("ECHOO OK\r\n");
delay_GSM(5000);
is_gprs_mode_start_succeed = 1; //???÷GPRS???é????
clear_buf_uart3();
current_status = SIMCARD ;
send_string_uart3(SIMCARD_CMD);
}else{
PUT(buf_uart3.buf);
PUT("ECHO0 ERR \r\n");
clear_buf_uart3();
send_string_uart3(ATE0_CMD);
}
}
/*-----------------------------------------------------------------------
-----------------------------------------------------------------------*/
//static
void S_SIMCARD() //SIM?¨?ì?????? ·????????é??
{
char *t = NULL ;
PUT(buf_uart3.buf);
t = strstr((const char*)buf_uart3.buf,"OK");
if(t)
{
PUT("SIMCARD OK \r\n");
delay_GSM(5000);
clear_buf_uart3();
current_status = CREG ;
send_string_uart3(CREG_CMD);
}else{
PUT(buf_uart3.buf);
PUT("SIMCARD ERR \r\n");
clear_buf_uart3();
send_string_uart3(SIMCARD_CMD);
}
}
/*-----------------------------------------------------------------------
-----------------------------------------------------------------------*/
//static
void S_CREG()
{
if(((buf_uart3.buf[9]=='0')&&
(buf_uart3.buf[11]=='1'))||
((buf_uart3.buf[9]=='0')&&
(buf_uart3.buf[11]=='5')))
{
PUT("S_REG OK \r\n");
current_status = INIT_FINISH_OK;
}else{
PUT(buf_uart3.buf);
PUT("S_REG ERR \r\n");
debug_put_word(buf_uart3.buf[9]);
debug_put_word(buf_uart3.buf[11]);
send_string_uart1("\r\n");
clear_buf_uart3();
current_status = CREG ;
send_string_uart3(CREG_CMD);
}
}
void init_gprs_mode(void)
{
PUT("start init GSM mode\r\n");
while(1)
{
err ++;
if(err > MAX_ERROR_COUNT) //error
{
err = 0 ;
is_gprs_mode_ok = 0;
PUT("GPRS MODE REGISTER [NO]");
break;
}
#if 0
if(is_gprs_mode_start_succeed)
{
PUT("GPRS MODE REGISTER [OK]");
}
#endif
delay_GSM(5000);
switch(current_status)
{
case INIT0:
S_INIT0(); //ATE0
break ;
case ECHO0:
S_ECHO0(); //SIMCARD
break ;
case SIMCARD:
S_SIMCARD(); //REG
break ;
case CREG:
S_CREG(); //FINISH
break ;
case INIT_FINISH_OK:
return ;
default:
clear_buf_uart3();
break ;
}
}
}
//static
void S_GSM_MSG_MODE_S()
{
PUT("S_GSM_MSG_MODE_S OK \r\n");
clear_buf_uart3();
current_status = GSM_MSG_MODE_S ; //?¨??PDP???????°
send_string_uart3(GSM_MSG_MODE);
}
//static
void S_GSM_CHAR_MODE_S()
{
if((buf_uart3.buf[2]=='O')&&(buf_uart3.buf[3]=='K'))
{
PUT("S_GSM_CHAR_MODE_S OK \r\n");
clear_buf_uart3();
current_status = GSM_CHAR_MODE_S;
send_string_uart3(GSM_CHAR_MODE);
}
else
{
PUT("S_GSM_CHAR_MODE_S NO \r\n");
clear_buf_uart3();
send_string_uart3(GSM_MSG_MODE);
}
}
//static
void S_GSM_CHAR_MODE_RET_S()
{
if((buf_uart3.buf[2]=='O')&&(buf_uart3.buf[3]=='K'))
{
PUT("S_GSM_CHAR_MODE_RET_S OK \r\n");
clear_buf_uart3();
current_status = GSM_TEXT_MODE_FINISH;
}
else
{
PUT("S_GSM_CHAR_MODE_RET_S NO \r\n");
clear_buf_uart3();
send_string_uart3(GSM_CHAR_MODE);
}
}
//static
void init_sms_to_send()
{
current_status = GSM_SEND_TEXT_S;
while(1)
{
err ++;
if(err>MAX_ERROR_COUNT)
{
err = 0 ;
break;
}
delay_GSM(1000);
switch(current_status)
{
case GSM_SEND_TEXT_S:
S_GSM_MSG_MODE_S();
break ;
case GSM_MSG_MODE_S:
S_GSM_CHAR_MODE_S();
break ;
case GSM_CHAR_MODE_S:
S_GSM_CHAR_MODE_RET_S();
break ;
case GSM_TEXT_MODE_FINISH:
return ;
default:
clear_buf_uart3();
break ;
}
}
}
void send_gsm_text(unsigned char * buf , unsigned int count)
{
unsigned int i ;
char send_sms_cmd_num[SMS_CMD_LEN];
memset((void*)send_sms_cmd_num,0,SMS_CMD_LEN);
init_sms_to_send(); //·??????°????????
if(current_status != GSM_TEXT_MODE_FINISH)
return ;
sprintf(send_sms_cmd_num,"AT+CMGS=\"+86%s\"\x00D\x00A",TELNUM);
PUT(send_sms_cmd_num);
send_string_uart3(send_sms_cmd_num);
delay_GSM(100);
for( i = 0 ;i < count ; i ++)
{
for ( i = 0 ; i < strlen((const char*)buf) ; i ++)
{
send_data_uart3(buf);
}
}
delay_GSM(100);
send_data_uart3(0X1A);
delay_GSM(10000);
PUT("SEND TEXT\r\n");
}
unsigned char is_gprs_mode_status_ok(void)
{
return is_gprs_mode_ok;
}
|
|