📄 uart.s
字号:
; {
.dbline 277
; return(true);
ldi R16,1
xjmp L30
L31:
.dbline 279
; }
; return(false);
clr R16
.dbline -2
L30:
.dbline 0 ; func end
ret
.dbsym r ptr 16 pX
.dbend
.dbfunc e sbGetTxBufferEmptyStatus _sbGetTxBufferEmptyStatus fc
; ptr -> R16,R17
.even
_sbGetTxBufferEmptyStatus::
.dbline -1
.dbline 289
; }
;
; //********************************************************************
; // Function : sbGetTxBufferNoEmptyStatus
; // Input : ptr-pointer to SCI Buffer
; // Output : Status of SCI TX Buffer
; // Description : Check whether the SCI TX Buffer is empty or not
; //********************************************************************
; INT8U sbGetTxBufferEmptyStatus(struct SCI_Buffer *ptr)
; {
.dbline 290
; if(ptr->bTxBufferLength == 0)
movw R30,R16
ldd R2,z+2
tst R2
brne L34
.dbline 291
; {
.dbline 292
; return(true);
ldi R16,1
xjmp L33
L34:
.dbline 294
; }
; return(false);
clr R16
.dbline -2
L33:
.dbline 0 ; func end
ret
.dbsym r ptr 16 pX
.dbend
.dbfunc e sbGetRxBufferEmptyStatus _sbGetRxBufferEmptyStatus fc
; ptr -> R16,R17
.even
_sbGetRxBufferEmptyStatus::
.dbline -1
.dbline 304
; }
;
; //********************************************************************
; // Function : sbGetRxBufferEmptyStatus
; // Input : ptr-pointer to SCI Buffer
; // Output : Status of SCI TX Buffer
; // Description : Check whether the SCI TX Buffer is empty or not
; //********************************************************************
; INT8U sbGetRxBufferEmptyStatus(struct SCI_Buffer *ptr)
; {
.dbline 305
; if(ptr->bRxLength == 0)
movw R30,R16
ldd R2,z+0
tst R2
brne L37
.dbline 306
; {
.dbline 307
; return(true);
ldi R16,1
xjmp L36
L37:
.dbline 309
; }
; return(false);
clr R16
.dbline -2
L36:
.dbline 0 ; func end
ret
.dbsym r ptr 16 pX
.dbend
.dbfunc e SciBuffer_Rx_Reset _SciBuffer_Rx_Reset fV
; ptr -> R16,R17
.even
_SciBuffer_Rx_Reset::
.dbline -1
.dbline 319
; }
;
; //********************************************************************
; // Function : SciBuffer_Rx_Reset
; // Input : ptr-pointer to SCI Buffer
; // Output : none
; // Description : Reset RX Buffer Length to zero
; //********************************************************************
; void SciBuffer_Rx_Reset(struct SCI_Buffer *ptr)
; {
.dbline 320
; ptr->bRxLength = 0;
clr R2
movw R30,R16
std z+0,R2
.dbline -2
.dbline 321
; }
L39:
.dbline 0 ; func end
ret
.dbsym r ptr 16 pX
.dbend
.dbfunc e SciBuffer_Tx_Reset _SciBuffer_Tx_Reset fV
; ptr -> R16,R17
.even
_SciBuffer_Tx_Reset::
.dbline -1
.dbline 330
;
; //********************************************************************
; // Function : SciBuffer_Tx_Reset
; // Input : ptr-pointer to SCI Buffer
; // Output : none
; // Description : Reset TX Buffer Length to zero
; //********************************************************************
; void SciBuffer_Tx_Reset(struct SCI_Buffer *ptr)
; {
.dbline 331
; ptr->bTxLength = 0;
clr R2
movw R30,R16
std z+1,R2
.dbline 332
; ptr->bTxBufferLength = 0;
movw R30,R16
std z+2,R2
.dbline -2
.dbline 333
; }
L40:
.dbline 0 ; func end
ret
.dbsym r ptr 16 pX
.dbend
.dbfunc e SciBuffer_Tx_Inc _SciBuffer_Tx_Inc fV
; ptr -> R16,R17
.even
_SciBuffer_Tx_Inc::
.dbline -1
.dbline 342
;
; //********************************************************************
; // Function : SciBuffer_Tx_Inc
; // Input : ptr-pointer to SCI Buffer
; // Output : none
; // Description : Increase TX Buffer Length
; //********************************************************************
; void SciBuffer_Tx_Inc(struct SCI_Buffer *ptr)
; {
.dbline 343
; ptr->bTxLength++;
movw R24,R16
adiw R24,1
movw R30,R24
ldd R24,z+0
subi R24,255 ; addi 1
std z+0,R24
.dbline -2
.dbline 344
; }
L41:
.dbline 0 ; func end
ret
.dbsym r ptr 16 pX
.dbend
.dbfunc e UART_WRITE_DATA _UART_WRITE_DATA fV
; ptr -> R20,R21
.even
_UART_WRITE_DATA::
xcall push_gset1
movw R20,R16
.dbline -1
.dbline 353
;
; //********************************************************************
; // Function : UART_WRITE_DATA
; // Input : ptr-pointer to SCI Buffer
; // Output : none
; // Description : Send the firstIncrease TX Buffer Length
; //********************************************************************
; void UART_WRITE_DATA(struct SCI_Buffer *ptr)
; {
.dbline 354
; UART_TX_DATA(ptr->bTxBuffer[0]);
movw R30,R20
ldd R16,z+53
xcall _UART_TX_DATA
.dbline 355
; SciBuffer_Tx_Inc(ptr);
movw R16,R20
xcall _SciBuffer_Tx_Inc
.dbline 356
; Enable_UART_TX_INT();
xcall _Enable_UART_TX_INT
.dbline -2
.dbline 357
; }
L42:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r ptr 20 pX
.dbend
.area data(ram, con, rel)
.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\RS232通信协议应用设计\UART.c
L44:
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\RS232通信协议应用设计\UART.c
.area text(rom, con, rel)
.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\RS232通信协议应用设计\UART.c
.dbfunc e C1Command _C1Command fV
.dbsym s bCount L44 c
.even
_C1Command::
.dbline -1
.dbline 366
;
; //********************************************************************
; // Function : C1Command
; // Input : none
; // Output : none
; // Description : C1
; //********************************************************************
; void C1Command(void)
; {
.dbline 368
; static INT8U bCount = 0;
; bCount++;
lds R24,L44
subi R24,255 ; addi 1
sts L44,R24
.dbline -2
.dbline 369
; }
L43:
.dbline 0 ; func end
ret
.dbend
.dbfunc e C2Command _C2Command fV
.even
_C2Command::
.dbline -1
.dbline 378
;
; //********************************************************************
; // Function : C2Command
; // Input : none
; // Output : none
; // Description : C2,MM
; //********************************************************************
; void C2Command(void)
; {
.dbline -2
.dbline 379
; }
L45:
.dbline 0 ; func end
ret
.dbend
.dbfunc e D1Command _D1Command fV
.even
_D1Command::
.dbline -1
.dbline 388
;
; //********************************************************************
; // Function : D1Command
; // Input : none
; // Output : none
; // Description : D1
; //********************************************************************
; void D1Command(void)
; {
.dbline 389
; SciBuffer_Tx_In(&stSciBuffer,'I');
ldi R18,73
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 390
; SciBuffer_Tx_In(&stSciBuffer,' ');
ldi R18,32
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 391
; SciBuffer_Tx_In(&stSciBuffer,'L');
ldi R18,76
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 392
; SciBuffer_Tx_In(&stSciBuffer,'O');
ldi R18,79
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 393
; SciBuffer_Tx_In(&stSciBuffer,'V');
ldi R18,86
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 394
; SciBuffer_Tx_In(&stSciBuffer,'E');
ldi R18,69
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 395
; SciBuffer_Tx_In(&stSciBuffer,' ');
ldi R18,32
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 396
; SciBuffer_Tx_In(&stSciBuffer,'Y');
ldi R18,89
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 397
; SciBuffer_Tx_In(&stSciBuffer,'O');
ldi R18,79
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 398
; SciBuffer_Tx_In(&stSciBuffer,'U');
ldi R18,85
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 399
; SciBuffer_Tx_In(&stSciBuffer,' ');
ldi R18,32
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 400
; SciBuffer_Tx_In(&stSciBuffer,'!');
ldi R18,33
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 401
; SciBuffer_Tx_In(&stSciBuffer,'\n');
ldi R18,10
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 403
;
; UART_WRITE_DATA(&stSciBuffer);
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
.dbline -2
.dbline 404
; }
L46:
.dbline 0 ; func end
xjmp _UART_WRITE_DATA
.dbend
.dbfunc e D2Command _D2Command fV
.even
_D2Command::
sbiw R28,4
.dbline -1
.dbline 421
;
; //********************************************************************
; // Function : D2Command
; // Input : none
; // Output : none
; // Description : D2
; //********************************************************************
; extern INT16S wLineVoltRMS;
; extern INT16S wLineVoltReal;
; extern INT16S wLineVoltSample;
; extern INT16U wLinePeriod;
; extern INT16U wLinePeriodTemp;
; extern INT16U wLineCaptureTime;
; extern INT16U wLineCaptureTimeLast;
;
; void D2Command(void)
; {
.dbline 423
; //INT32U dwTest = 0xFFFFFFFF; //4294967295
; sDataToNumber(wLineVoltSample,5,&stSciBuffer);
ldi R24,<_stSciBuffer
ldi R25,>_stSciBuffer
std y+3,R25
std y+2,R24
ldi R24,5
std y+0,R24
lds R2,_wLineVoltSample
lds R3,_wLineVoltSample+1
clr R4
sbrc R3,7
com R4
clr R5
sbrc R4,7
com R5
movw R16,R2
movw R18,R4
xcall _sDataToNumber
.dbline 424
; SciBuffer_Tx_In(&stSciBuffer,' ');
ldi R18,32
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 426
;
; sDataToNumber(wLineVoltReal,5,&stSciBuffer);
ldi R24,<_stSciBuffer
ldi R25,>_stSciBuffer
std y+3,R25
std y+2,R24
ldi R24,5
std y+0,R24
lds R2,_wLineVoltReal
lds R3,_wLineVoltReal+1
clr R4
sbrc R3,7
com R4
clr R5
sbrc R4,7
com R5
movw R16,R2
movw R18,R4
xcall _sDataToNumber
.dbline 427
; SciBuffer_Tx_In(&stSciBuffer,' ');
ldi R18,32
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 429
;
; sDataToNumber(wLineVoltRMS,5,&stSciBuffer);
ldi R24,<_stSciBuffer
ldi R25,>_stSciBuffer
std y+3,R25
std y+2,R24
ldi R24,5
std y+0,R24
lds R2,_wLineVoltRMS
lds R3,_wLineVoltRMS+1
clr R4
sbrc R3,7
com R4
clr R5
sbrc R4,7
com R5
movw R16,R2
movw R18,R4
xcall _sDataToNumber
.dbline 430
; SciBuffer_Tx_In(&stSciBuffer,' ');
ldi R18,32
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 432
;
; sDataToNumber(wLineCaptureTime,5,&stSciBuffer);
ldi R24,<_stSciBuffer
ldi R25,>_stSciBuffer
std y+3,R25
std y+2,R24
ldi R24,5
std y+0,R24
lds R2,_wLineCaptureTime
lds R3,_wLineCaptureTime+1
clr R4
clr R5
movw R16,R2
movw R18,R4
xcall _sDataToNumber
.dbline 433
; SciBuffer_Tx_In(&stSciBuffer,'\n');
ldi R18,10
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 435
;
; UART_WRITE_DATA(&stSciBuffer);
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _UART_WRITE_DATA
.dbline -2
.dbline 436
; }
L47:
adiw R28,4
.dbline 0 ; func end
ret
.dbend
.dbfunc e D3Command _D3Command fV
; dwTest -> y+4
.even
_D3Command::
xcall push_gset2
sbiw R28,8
.dbline -1
.dbline 445
;
; //********************************************************************
; // Function : D3Command
; // Input : none
; // Output : none
; // Description : D3
; //********************************************************************
; void D3Command(void)
; {
.dbline 446
; INT32U dwTest = 0x12345678;
ldi R20,120
ldi R21,86
ldi R22,52
ldi R23,18
movw R30,R28
std z+4,R20
std z+5,R21
std z+6,R22
std z+7,R23
.dbline 448
;
; sDataToChar(dwTest,8,&stSciBuffer);
ldi R24,<_stSciBuffer
ldi R25,>_stSciBuffer
std y+3,R25
std y+2,R24
ldi R24,8
std y+0,R24
movw R30,R28
ldd R16,z+4
ldd R17,z+5
ldd R18,z+6
ldd R19,z+7
xcall _sDataToChar
.dbline 449
; SciBuffer_Tx_In(&stSciBuffer,' ');
ldi R18,32
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 451
;
; sDataToChar(dwTest,4,&stSciBuffer);
ldi R24,<_stSciBuffer
ldi R25,>_stSciBuffer
std y+3,R25
std y+2,R24
ldi R24,4
std y+0,R24
movw R30,R28
ldd R16,z+4
ldd R17,z+5
ldd R18,z+6
ldd R19,z+7
xcall _sDataToChar
.dbline 452
; SciBuffer_Tx_In(&stSciBuffer,' ');
ldi R18,32
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 454
;
; sDataToChar(dwTest,2,&stSciBuffer);
ldi R24,<_stSciBuffer
ldi R25,>_stSciBuffer
std y+3,R25
std y+2,R24
ldi R24,2
std y+0,R24
movw R30,R28
ldd R16,z+4
ldd R17,z+5
ldd R18,z+6
ldd R19,z+7
xcall _sDataToChar
.dbline 455
; SciBuffer_Tx_In(&stSciBuffer,' ');
ldi R18,32
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 457
;
; sDataToChar(dwTest,1,&stSciBuffer);
ldi R24,<_stSciBuffer
ldi R25,>_stSciBuffer
std y+3,R25
std y+2,R24
ldi R24,1
std y+0,R24
movw R30,R28
ldd R16,z+4
ldd R17,z+5
ldd R18,z+6
ldd R19,z+7
xcall _sDataToChar
.dbline 458
; SciBuffer_Tx_In(&stSciBuffer,'\n');
ldi R18,10
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _SciBuffer_Tx_In
.dbline 460
;
; UART_WRITE_DATA(&stSciBuffer);
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
xcall _UART_WRITE_DATA
.dbline -2
.dbline 461
; }
L48:
adiw R28,8
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym l dwTest 4 l
.dbend
.dbfunc e XXCommand _XXCommand fV
.even
_XXCommand::
.dbline -1
.dbline 470
;
; //********************************************************************
; // Function : XXCommand
; // Input : none
; // Output : none
; // Description : XX
; //********************************************************************
; void XXCommand(void)
; {
.dbline 471
; sStringToChar("Received XX Command.\n",&stSciBuffer);
ldi R18,<_stSciBuffer
ldi R19,>_stSciBuffer
ldi R16,<L50
ldi R17,>L50
xcall _sStringToChar
.dbline 472
; UART_WRITE_DATA(&stSciBuffer);
ldi R16,<_stSciBuffer
ldi R17,>_stSciBuffer
.dbline -2
.dbline 473
; }
L49:
.dbline 0 ; func end
xjmp _UART_WRITE_DATA
.dbend
.dbfunc e YYCommand _YYCommand fV
; bChar -> y+0
.even
_YYCommand::
sbiw R28,3
.dbline -1
.dbline 482
;
; //********************************************************************
; // Function : YYCommand
; // Input : none
; // Output : none
; // Description : YY,MM
; //********************************************************************
; void YYCommand(void)
; {
.dbline 484
; INT8U bChar[3];
; bChar[0] = stSciBuffer.bRxBuffer[2];
lds R2,_stSciBuffer+3+2
std y+0,R2
.dbline 485
; bChar[1] = stSciBuffer.bRxBuffer[3];
lds R2,_stSciBuffer+3+3
std y+1,R2
.dbline 486
; bChar[2] = stSciBuffer.bRxBuffer[4];
lds R2,_stSciBuffer+3+4
std y+2,R2
.dbline 487
; sStringToChar("Received YY Command , ",&stSciBuffer);
ldi R18,<_stSciBuffer
ldi R19,>_stSciBuffer
ldi R16,<L60
ldi R17,>L60
xcall _sStringToChar
.dbline 488
; if((bChar[0] == ',') && \
ldd R24,y+0
cpi R24,44
brne L61
ldd R24,y+1
cpi R24,48
brlo L61
ldi R24,57
ldd R2,y+1
cp R24,R2
brlo L61
ldd R24,y+2
cpi R24,48
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -