📄 gsm.c
字号:
#ifndef WIN32
#include <avr/io.h>
//#include <avr/signal.h>
//#include <avr/interrupt.h>
//#include <avr/pgmspace.h>
//#include <avr/sleep.h>
#endif
//define the uart buffer size,the uart buffer is to received PDU data
#define UART_RX_BUFFER_SIZE 200
#define UARTSW_RX_BUFFER_SIZE 200
#include "global.h"
//uartsw need the timer.c
//#include "timer.h"
#include "uart.h"
//#include "uartsw.h"
#include "extint.h"
#include "extint_chris.h"
//uart can be attached to the rprintf
#include "rprintf.h"
#include "my_description.h"
//no use but do delete it
u08 k,CD_TxStart,CD_UartTxRecCmdStart;
u08 newSMS=0;
//the tt[] is use for testing
u08 tt[]={"\r\n+CMT: ,50\r\n0891683108200005F00409A126606193F90108601180123342232000310033003700390038003100370035003400320033FF1A665A003100320033\r\n"};
//#include "timer.c"
#include "uart.c" //#include "buffer.c"
//#include "uartsw.c"
typedef void (*voidFuncPtr)(void);
//the orignal "typedef void (*voidFuncPtr)(void);" in extint02.c
//comflict with the one in timer.c
#include "extint02.c"
#include "rprintf.c"
#include "my_description.c"//#include "extint_chris.c"
//#include "uartsw_chris.h"
//#include "uartsw_chris.c"
#include "extint_chris.c"
#include "PDU_chris.c"
//****** main ******
void main(void)
{
cli();
//KeyScan
outb(DDRC,0x00);
outb(PORTC,0xFF);
//initialize uartsw IO
outb(DDRD,0xFF);
outb(PORTD,0xFF);
//LED indicator
outb(DDRB,0xFF);
outb(PORTB,0x00);
//exint initialize
//WHY?\;why can not this subprogram be placed behined uartswInit02();
//if do so ,it will send error data to PC in uartsw
//But if not use the subprogram, it can send the correct
//data to PC in uartsw
extintInit();
extintInit_IO_M16( INT0 );
extintAttach(EXTINT0, newSMSIndicator );
extintConfigure(EXTINT0, EXTINT_EDGE_FALLING);
extintEnable_M16(INT0);
//timerInit();
uartInit();
//uartswInit();// trigger on rising edge
//uartswInit02();// trigger on falling edge
rprintfInit(uartSendByte);
sei();
//uartswSendByte(0x51);
//uartswSendByte(0xa1);
rprintf("AT+CNMI=3,2,0,0,1\r\n");
delay_ms02(254);
delay_ms02(254);
delay_ms02(254);
delay_ms02(254);
delay_ms02(254);
delay_ms02(254);
uartInitBuffers();
while(1)//uart hardware
{
if(newSMS==1)
{
delay_ms02(254);
delay_ms02(254);
delay_ms02(254);
delay_ms02(254);
delay_ms02(254);
delay_ms02(254);
//close the function if(newSMS==1),when process complete
newSMS=0;
//process the received new message
newSMSProcess();
/* //display the data
uartswSendByte(0xaa);
uartswSendByte( TP_UD[0].SCAddressLength );//08//08
uartswSendByte( TP_UD[0].SCAddressValue[0] );// //8
uartswSendByte( TP_UD[0].SCAddressValue[1] );// //6
uartswSendByte( TP_UD[0].FirstOctet );//04//04
uartswSendByte(0x55);
*/
}
}//while(1)
}//main
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -