📄 at.s
字号:
; PPP_Start(PPP_Rom_Username, PPP_Rom_Password); // start a PPP session
ldi R18,<_PPP_Rom_Password
ldi R19,>_PPP_Rom_Password
ldi R16,<_PPP_Rom_Username
ldi R17,>_PPP_Rom_Username
xcall _PPP_Start
.dbline 112
; return true; //
ldi R16,1
.dbline -2
L22:
.dbline 0 ; func end
ret
.dbend
.dbfunc e AT_End _AT_End fV
.even
_AT_End::
.dbline -1
.dbline 126
; #else
; AT_Stage(AT_DialInit1); //
; //
; MainBufferWr_Rx = 0; //
; MainBufferWr_Tx = 0; //
; UART1_RxBufferRd = 0; //
; UART1_RxBufferWr = 0; //
; //
; return true; //
; #endif
; }
;
; void AT_End(void)
; { // terminate a connection
.dbline 127
; if (PPP.Stage != PPPS_None)
lds R2,_PPP+9
tst R2
breq L27
.dbline 128
; { // terminate the PPP first
.dbline 129
; PPP_End();
xcall _PPP_End
.dbline 130
; return;
xjmp L26
L27:
.dbline 134
; }
;
; #ifdef WindowsPPP
; AT_Stage(AT_Idle);
clr R16
xcall _AT_Stage
.dbline -2
L26:
.dbline 0 ; func end
ret
.dbend
.dbfunc e AT_AddNewRxByte _AT_AddNewRxByte fV
; c -> R0
.even
_AT_AddNewRxByte::
.dbline -1
.dbline 161
; #else
; switch (AT.Stage)
; {
; case AT_Idle : break;
; case AT_DialInit1 : AT_Stage(AT_Idle);
; break;
; case AT_DialInit2 : AT_Stage(AT_Idle);
; break;
; case AT_DialInit3 : AT_Stage(AT_Idle);
; break;
; case AT_Dial : AT_Stage(AT_Disc2);
; break;
; case AT_PPP : PPP_End();
; break;
; case AT_Disc1 : break; // already trying to disconnect
; case AT_Disc2 : break; // already trying to disconnect
; default : AT_Stage(AT_Idle);
; break;
; }
; #endif
; }
;
; //*************************************************************************************
; // call this when we have a new byte received from the modem - call from the executive
;
; void AT_AddNewRxByte(u8 c)
; {
.dbline -2
L30:
.dbline 0 ; func end
ret
.dbsym l c 0 c
.dbend
.dbfunc e AT_10ms_Timer _AT_10ms_Timer fV
.even
_AT_10ms_Timer::
.dbline -1
.dbline 249
; #ifndef WindowsPPP
; bool ok = false;
; bool error = false;
; bool ring = false;
; bool failed = false;
; bool connect = false;
;
; if (c != 13)
; {
; if (c < 32) return; // ignore control charcters
; if (MainBufferWr_Rx >= (sizeof(MainBuffer) - 1)) return; // buffer overflow - ignore character
; if (MainBufferWr_Rx < 0) MainBufferWr_Rx = 0;
; MainBuffer[MainBufferWr_Rx++] = tolower((char)c);
; MainBuffer[MainBufferWr_Rx] = 0;
; return;
; }
;
; // CR
;
; strtrim(MainBuffer, ' ');
; MainBufferWr_Rx = 0;
;
; if (MainBuffer[0] == 0) return; // empty line
;
; #ifdef Debug
; SendDebugStr(MainBuffer);
; SendDebugStr("\n");
; #endif
;
; if (strcmp((char*)MainBuffer, "ok") == 0) ok = true;
; else
; if (strcmp((char*)MainBuffer, "error") == 0) error = true;
; else
; if (strcmp((char*)MainBuffer, "ring") == 0) ring = true;
; else
; if (strcmp((char*)MainBuffer, "busy") == 0) failed = true;
; else
; if (strcmp((char*)MainBuffer, "no dialtone") == 0) failed = true;
; else
; if (strcmp((char*)MainBuffer, "no answer") == 0) failed = true;
; else
; if (strcmp((char*)MainBuffer, "no carrier") == 0) failed = true;
; else
; if ((strlen((char*)MainBuffer) >= 7) && (strncmp((char*)MainBuffer, "connect", 7) == 0)) connect = true;
;
; memset(MainBuffer, 0, sizeof(MainBuffer));
;
; if ((AT.Stage != AT_Dial) && failed)
; {
; AT_Stage(AT_Idle);
; return;
; }
;
; switch (AT.Stage)
; {
; case AT_DialInit1 : if (ok) AT_Stage(AT_DialInit2);
; break;
; case AT_DialInit2 : if (ok) AT_Stage(AT_DialInit3);
; break;
; case AT_DialInit3 : if (ok) AT_Stage(AT_Dial);
; break;
; case AT_Dial : if (failed || error)
; {
; u16_Put(&AT.Retry_Timer, AT_Dial_Retry_Time); // try again in 6 seconds
; break;
; }
; case AT_Idle : if (connect)
; {
; AT_Stage(AT_PPP);
; PPP_Start(PPP_Rom_Username, PPP_Rom_Password); // start a PPP session
; }
; break;
; case AT_PPP : break; // PPP is using the modem
; case AT_Disc1 : if (ok || error) AT_Stage(AT_Disc2); // the modem has come out of data mode - we used the '+++' thingy
; break;
; case AT_Disc2 : if (ok) AT_Stage(AT_Idle); // the modem accepted the hangup command(s)
; break;
; default : AT_Stage(AT_Idle);
; break;
; }
; #endif
; }
;
; //*************************************************************************************
; // call this every 10ms - say from a timer interrupt
;
; void AT_10ms_Timer(void)
; { // call this every 10ms
.dbline -2
L31:
.dbline 0 ; func end
ret
.dbend
.dbfunc e AT_Process _AT_Process fV
; c -> R20
.even
_AT_Process::
xcall push_gset1
.dbline -1
.dbline 265
; #ifndef WindowsPPP
; if (AT.Stage == AT_Idle) return;
;
; if (AT.Retry_Timer >= 10)
; AT.Retry_Timer -= 10;
; else
; AT.Retry_Timer = 0;
; #endif
; }
;
; //*************************************************************************************
; // call this as often as possible from your executive loop - NOT from an interrupt
; // it takes care of all the AT modem stuff for you
;
; void AT_Process(void)
; {
.dbline 270
; u8 c;
;
; #ifdef WindowsPPP
; //
; if (PPP.Stage != PPPS_None) return; //
lds R2,_PPP+9
tst R2
breq L33
.dbline 270
xjmp L32
L33:
.dbline 272
; //
; if (!MainBufferWr_Tx)
lds R2,_MainBufferWr_Tx
lds R3,_MainBufferWr_Tx+1
tst R2
brne L36
tst R3
brne L36
X2:
.dbline 273
; {
xjmp L39
L38:
.dbline 275
; while (UART1_RxBufferRd != UART1_RxBufferWr)
; {
.dbline 276
; c = (u8)UART1_RxBuffer[UART1_RxBufferRd++]; // get rx'ed byte
lds R2,_UART1_RxBufferRd
clr R3
mov R24,R2
subi R24,255 ; addi 1
sts _UART1_RxBufferRd,R24
ldi R24,<_UART1_RxBuffer
ldi R25,>_UART1_RxBuffer
mov R30,R2
clr R31
add R30,R24
adc R31,R25
ldd R20,z+0
.dbline 277
; if (UART1_RxBufferRd >= sizeof(UART1_RxBuffer)) UART1_RxBufferRd -= sizeof(UART1_RxBuffer); // wap awound
lds R24,_UART1_RxBufferRd
cpi R24,96
brlo L41
.dbline 277
lds R24,_UART1_RxBufferRd
subi R24,96
sts _UART1_RxBufferRd,R24
L41:
.dbline 278
mov R16,R20
xcall _AT_AddNewRxByte
.dbline 279
L39:
.dbline 274
lds R2,_UART1_RxBufferWr
lds R3,_UART1_RxBufferRd
cp R3,R2
brne L38
.dbline 280
; AT_AddNewRxByte(c); // pass the byte onto the AT RX routine
; }
; }
L36:
.dbline 283
;
; #ifdef ModemHandShaking
; HardwareFlowControl(ModemUart); // tell em to hold it - if need be
ldi R16,1
xcall _HardwareFlowControl
.dbline 286
; #endif
; //
; AT_Stage(AT_Idle); //
clr R16
xcall _AT_Stage
.dbline -2
L32:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r c 20 c
.dbend
.area bss(ram, con, rel)
.dbfile C:\AVR\AT-Modem__PPP__UDP__IC\at.c
_AT::
.blkb 4
.dbstruct 0 4 TAT
.dbfield 0 Retries c
.dbfield 1 Retry_Timer s
.dbfield 3 Stage c
.dbend
.dbsym e AT _AT S[TAT]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -