mbrtu.txt 29.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770
; generated by Component: ARM Compiler 5.06 update 6 (build 750) Tool: ArmCC [4d3637]
; commandline ArmCC [--c99 --list --split_sections --debug -c --asm --interleave -o.\flash\obj\mbrtu.o --asm_dir=.\Flash\List\ --list_dir=.\Flash\List\ --depend=.\flash\obj\mbrtu.d --cpu=Cortex-M4.fp --apcs=interwork -O1 --diag_suppress=9931,870 -I..\..\Libraries\CMSIS\Include -I..\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include -I..\..\Libraries\STM32F4xx_StdPeriph_Driver\inc -I..\..\uCOS-III\uC-CPU -I..\..\uCOS-III\uC-LIB -I..\..\uCOS-III\uCOS-III\Ports -I..\..\uCOS-III\uCOS-III\Source -I..\..\uCOS-III\uC-CPU\ARM-Cortex-M4\RealView -I..\..\uCOS-III\uC-LIB\Ports\ARM-Cortex-M4\RealView -I..\..\uCOS-III\uCOS-III\Ports\ARM-Cortex-M4\Generic\RealView -I..\..\User -I..\..\User\bsp -I..\..\User\bsp\inc -I..\..\User\libapp -I..\..\RL-ARM\Config -I..\..\RL-ARM\Driver -I..\..\RL-ARM\RL-RTX\inc -I..\..\User\bsp\BSP -I..\..\RL-ARM\RL-CAN -I..\..\Libraries\DSP_LIB\Include -I..\..\MODBUS\modbus\rtu -I..\..\MODBUS\BARE\port -I..\..\MODBUS\modbus\include -I..\..\User\bsp\BSP -I..\..\PLC -I..\..\Avoid -I..\..\User\parameter -I..\..\User\LaserMotionCtr -I..\..\User\W5100S -I..\..\User\bsp -I..\..\User\CHASSIS -I..\..\User\CONTROLFUNCTION -I..\..\User\DATAUPDATE -I..\..\User\HARAWARE -I..\..\User\MOTORDRIVER -I..\..\User\NAVAGATION -I..\..\User\PLATFORM -I..\..\User\SENSOR -I.\RTE\_Flash -IC:\Users\YDJ\AppData\Local\Arm\Packs\ARM\CMSIS\5.5.1\CMSIS\Core\Include -IC:\Users\YDJ\AppData\Local\Arm\Packs\Keil\STM32F4xx_DFP\2.13.0\Drivers\CMSIS\Device\ST\STM32F4xx\Include -D__UVISION_VERSION=527 -D_RTE_ -DSTM32F407xx -DUSE_STDPERIPH_DRIVER -DSTM32F40_41xxx -D__RTX -D__FPU_USED=1 --omf_browse=.\flash\obj\mbrtu.crf ..\..\MODBUS\modbus\rtu\mbrtu.c]
                          THUMB

                          AREA ||i.eMBRTUInit||, CODE, READONLY, ALIGN=2

                  eMBRTUInit PROC
;;;80     eMBErrorCode
;;;81     eMBRTUInit( UCHAR ucSlaveAddress, UCHAR ucPort, ULONG ulBaudRate, eMBParity eParity )
000000  b570              PUSH     {r4-r6,lr}
;;;82     {
000002  4608              MOV      r0,r1
000004  4615              MOV      r5,r2
;;;83         CPU_SR_ALLOC();
;;;84         eMBErrorCode    eStatus = MB_ENOERR;
000006  2400              MOVS     r4,#0
;;;85         ULONG           usTimerT35_50us;
;;;86     
;;;87         ( void )ucSlaveAddress;
;;;88         ENTER_CRITICAL_SECTION(  );
;;;89     
;;;90         /* Modbus RTU uses 8 Databits. */
;;;91         if( xMBPortSerialInit( ucPort, ulBaudRate, 8, eParity ) != TRUE )
000008  2208              MOVS     r2,#8
00000a  4629              MOV      r1,r5
00000c  f7fffffe          BL       xMBPortSerialInit
000010  2801              CMP      r0,#1
000012  d001              BEQ      |L1.24|
;;;92         {
;;;93             eStatus = MB_EPORTERR;
000014  2403              MOVS     r4,#3
000016  e00e              B        |L1.54|
                  |L1.24|
;;;94         }
;;;95         else
;;;96         {
;;;97             /* If baudrate > 19200 then we should use the fixed timer values
;;;98              * t35 = 1750us. Otherwise t35 must be 3.5 times the character time.
;;;99              */
;;;100            if( ulBaudRate > 19200 )
000018  f5b54f96          CMP      r5,#0x4b00
00001c  d901              BLS      |L1.34|
;;;101            {
;;;102                usTimerT35_50us = 35;       /* 1800us. */
00001e  2023              MOVS     r0,#0x23
000020  e003              B        |L1.42|
                  |L1.34|
;;;103            }
;;;104            else
;;;105            {
;;;106                /* The timer reload value for a character is given by:
;;;107                 *
;;;108                 * ChTimeValue = Ticks_per_1s / ( Baudrate / 11 )
;;;109                 *             = 11 * Ticks_per_1s / Baudrate
;;;110                 *             = 220000 / Baudrate
;;;111                 * The reload for t3.5 is 1.5 times this value and similary
;;;112                 * for t3.5.
;;;113                 */
;;;114                usTimerT35_50us = ( 7UL * 220000UL ) / ( 2UL * ulBaudRate );
000022  4906              LDR      r1,|L1.60|
000024  0068              LSLS     r0,r5,#1
000026  fbb1f0f0          UDIV     r0,r1,r0
                  |L1.42|
;;;115            }
;;;116            if( xMBPortTimersInit( ( USHORT ) usTimerT35_50us ) != TRUE )
00002a  b280              UXTH     r0,r0
00002c  f7fffffe          BL       xMBPortTimersInit
000030  2801              CMP      r0,#1
000032  d000              BEQ      |L1.54|
;;;117            {
;;;118                eStatus = MB_EPORTERR;
000034  2403              MOVS     r4,#3
                  |L1.54|
;;;119            }
;;;120        }
;;;121        EXIT_CRITICAL_SECTION(  );
;;;122    
;;;123        return eStatus;
000036  4620              MOV      r0,r4
;;;124    }
000038  bd70              POP      {r4-r6,pc}
;;;125    
                          ENDP

00003a  0000              DCW      0x0000
                  |L1.60|
                          DCD      0x00177fa0

                          AREA ||i.eMBRTUReceive||, CODE, READONLY, ALIGN=2

                  eMBRTUReceive PROC
;;;153    eMBErrorCode
;;;154    eMBRTUReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, USHORT * pusLength )
000000  e92d41f0          PUSH     {r4-r8,lr}
;;;155    {
000004  4680              MOV      r8,r0
000006  460e              MOV      r6,r1
000008  4617              MOV      r7,r2
;;;156        CPU_SR_ALLOC();
;;;157        BOOL            xFrameReceived = FALSE;
;;;158        eMBErrorCode    eStatus = MB_ENOERR;
00000a  2400              MOVS     r4,#0
;;;159    
;;;160        ENTER_CRITICAL_SECTION(  );
;;;161        assert( usRcvBufferPos < MB_SER_PDU_SIZE_MAX );
00000c  4d0f              LDR      r5,|L2.76|
00000e  88a8              LDRH     r0,[r5,#4]  ; usRcvBufferPos
000010  28ff              CMP      r0,#0xff
000012  d80b              BHI      |L2.44|
;;;162    
;;;163        /* Length and CRC check */
;;;164        if( ( usRcvBufferPos >= MB_SER_PDU_SIZE_MIN )
000014  88a8              LDRH     r0,[r5,#4]  ; usRcvBufferPos
000016  2804              CMP      r0,#4
000018  d304              BCC      |L2.36|
;;;165            && ( usMBCRC16( ( UCHAR * ) ucRTUBuf, usRcvBufferPos ) == 0 ) )
00001a  88a9              LDRH     r1,[r5,#4]  ; usRcvBufferPos
00001c  480c              LDR      r0,|L2.80|
00001e  f7fffffe          BL       usMBCRC16
000022  b140              CBZ      r0,|L2.54|
                  |L2.36|
;;;166        {
;;;167            /* Save the address field. All frames are passed to the upper layed
;;;168             * and the decision if a frame is used is done there.
;;;169             */
;;;170            *pucRcvAddress = ucRTUBuf[MB_SER_PDU_ADDR_OFF];
;;;171    
;;;172            /* Total length of Modbus-PDU is Modbus-Serial-Line-PDU minus
;;;173             * size of address field and CRC checksum.
;;;174             */
;;;175            *pusLength = ( USHORT )( usRcvBufferPos - MB_SER_PDU_PDU_OFF - MB_SER_PDU_SIZE_CRC );
;;;176    
;;;177            /* Return the start of the Modbus PDU to the caller. */
;;;178            *pucFrame = ( UCHAR * ) & ucRTUBuf[MB_SER_PDU_PDU_OFF];
;;;179            xFrameReceived = TRUE;
;;;180        }
;;;181        else
;;;182        {
;;;183            eStatus = MB_EIO;
000024  2405              MOVS     r4,#5
                  |L2.38|
;;;184        }
;;;185    
;;;186        EXIT_CRITICAL_SECTION(  );
;;;187        return eStatus;
000026  4620              MOV      r0,r4
;;;188    }
000028  e8bd81f0          POP      {r4-r8,pc}
                  |L2.44|
00002c  22a1              MOVS     r2,#0xa1              ;161
00002e  a109              ADR      r1,|L2.84|
000030  a010              ADR      r0,|L2.116|
000032  f7fffffe          BL       __aeabi_assert
                  |L2.54|
000036  4806              LDR      r0,|L2.80|
000038  7800              LDRB     r0,[r0,#0]            ;170  ; ucRTUBuf
00003a  f8880000          STRB     r0,[r8,#0]            ;170
00003e  88a8              LDRH     r0,[r5,#4]            ;175  ; usRcvBufferPos
000040  1ec0              SUBS     r0,r0,#3              ;175
000042  8038              STRH     r0,[r7,#0]            ;175
000044  4802              LDR      r0,|L2.80|
000046  1c40              ADDS     r0,r0,#1              ;178
000048  6030              STR      r0,[r6,#0]            ;178
00004a  e7ec              B        |L2.38|
;;;189    
                          ENDP

                  |L2.76|
                          DCD      ||.data||
                  |L2.80|
                          DCD      ||.bss||
                  |L2.84|
000054  2e2e5c2e          DCB      "..\\..\\MODBUS\\modbus\\rtu\\mbrtu.c",0
000058  2e5c4d4f
00005c  44425553
000060  5c6d6f64
000064  6275735c
000068  7274755c
00006c  6d627274
000070  752e6300
                  |L2.116|
000074  75735263          DCB      "usRcvBufferPos < MB_SER_PDU_SIZE_MAX",0
000078  76427566
00007c  66657250
000080  6f73203c
000084  204d425f
000088  5345525f
00008c  5044555f
000090  53495a45
000094  5f4d4158
000098  00      
000099  00                DCB      0
00009a  00                DCB      0
00009b  00                DCB      0

                          AREA ||i.eMBRTUSend||, CODE, READONLY, ALIGN=2

                  eMBRTUSend PROC
;;;190    eMBErrorCode
;;;191    eMBRTUSend( UCHAR ucSlaveAddress, const UCHAR * pucFrame, USHORT usLength )
000000  b570              PUSH     {r4-r6,lr}
;;;192    {
000002  4603              MOV      r3,r0
000004  4608              MOV      r0,r1
;;;193        CPU_SR_ALLOC();
;;;194        eMBErrorCode    eStatus = MB_ENOERR;
000006  2500              MOVS     r5,#0
;;;195        USHORT          usCRC16;
;;;196    
;;;197        ENTER_CRITICAL_SECTION(  );
;;;198    
;;;199        /* Check if the receiver is still in idle state. If not we where to
;;;200         * slow with processing the received frame and the master sent another
;;;201         * frame on the network. We have to abort sending the frame.
;;;202         */
;;;203        if( eRcvState == STATE_RX_IDLE )
000008  4c10              LDR      r4,|L3.76|
00000a  7866              LDRB     r6,[r4,#1]  ; eRcvState
00000c  2e01              CMP      r6,#1
00000e  d002              BEQ      |L3.22|
;;;204        {
;;;205            /* First byte before the Modbus-PDU is the slave address. */
;;;206            pucSndBufferCur = ( UCHAR * ) pucFrame - 1;
;;;207            usSndBufferCount = 1;
;;;208    
;;;209            /* Now copy the Modbus-PDU into the Modbus-Serial-Line-PDU. */
;;;210            pucSndBufferCur[MB_SER_PDU_ADDR_OFF] = ucSlaveAddress;
;;;211            usSndBufferCount += usLength;
;;;212    
;;;213            /* Calculate CRC16 checksum for Modbus-Serial-Line-PDU. */
;;;214            usCRC16 = usMBCRC16( ( UCHAR * ) pucSndBufferCur, usSndBufferCount );
;;;215            ucRTUBuf[usSndBufferCount++] = ( UCHAR )( usCRC16 & 0xFF );
;;;216            ucRTUBuf[usSndBufferCount++] = ( UCHAR )( usCRC16 >> 8 );
;;;217    
;;;218            /* Activate the transmitter. */
;;;219            eSndState = STATE_TX_XMIT;
;;;220            vMBPortSerialEnable( FALSE, TRUE );
;;;221        }
;;;222        else
;;;223        {
;;;224            eStatus = MB_EIO;
000010  2505              MOVS     r5,#5
                  |L3.18|
;;;225        }
;;;226        EXIT_CRITICAL_SECTION(  );
;;;227        return eStatus;
000012  4628              MOV      r0,r5
;;;228    }
000014  bd70              POP      {r4-r6,pc}
                  |L3.22|
000016  1e40              SUBS     r0,r0,#1              ;206
000018  60a0              STR      r0,[r4,#8]            ;206  ; pucSndBufferCur
00001a  2601              MOVS     r6,#1                 ;207
00001c  8066              STRH     r6,[r4,#2]            ;207
00001e  7003              STRB     r3,[r0,#0]            ;210
000020  8861              LDRH     r1,[r4,#2]            ;211  ; usSndBufferCount
000022  4411              ADD      r1,r1,r2              ;211
000024  8061              STRH     r1,[r4,#2]            ;211
000026  8861              LDRH     r1,[r4,#2]            ;214  ; usSndBufferCount
000028  f7fffffe          BL       usMBCRC16
00002c  8861              LDRH     r1,[r4,#2]            ;215  ; usSndBufferCount
00002e  1c4a              ADDS     r2,r1,#1              ;215
000030  8062              STRH     r2,[r4,#2]            ;215
000032  4a07              LDR      r2,|L3.80|
000034  5450              STRB     r0,[r2,r1]            ;215
000036  0a03              LSRS     r3,r0,#8              ;216
000038  8860              LDRH     r0,[r4,#2]            ;216  ; usSndBufferCount
00003a  1c41              ADDS     r1,r0,#1              ;216
00003c  8061              STRH     r1,[r4,#2]            ;216
00003e  5413              STRB     r3,[r2,r0]            ;216
000040  7026              STRB     r6,[r4,#0]            ;219
000042  2101              MOVS     r1,#1                 ;220
000044  2000              MOVS     r0,#0                 ;220
000046  f7fffffe          BL       vMBPortSerialEnable
00004a  e7e2              B        |L3.18|
;;;229    
                          ENDP

                  |L3.76|
                          DCD      ||.data||
                  |L3.80|
                          DCD      ||.bss||

                          AREA ||i.eMBRTUStart||, CODE, READONLY, ALIGN=2

                  eMBRTUStart PROC
;;;126    void
;;;127    eMBRTUStart( void )
000000  b510              PUSH     {r4,lr}
;;;128    {
;;;129        CPU_SR_ALLOC();
;;;130        ENTER_CRITICAL_SECTION(  );
;;;131        /* Initially the receiver is in the state STATE_RX_INIT. we start
;;;132         * the timer and if no character is received within t3.5 we change
;;;133         * to STATE_RX_IDLE. This makes sure that we delay startup of the
;;;134         * modbus protocol stack until the bus is free.
;;;135         */
;;;136        eRcvState = STATE_RX_INIT;
000002  4905              LDR      r1,|L4.24|
000004  2000              MOVS     r0,#0
000006  7048              STRB     r0,[r1,#1]
;;;137        vMBPortSerialEnable( TRUE, FALSE );
000008  2100              MOVS     r1,#0
00000a  2001              MOVS     r0,#1
00000c  f7fffffe          BL       vMBPortSerialEnable
;;;138        vMBPortTimersEnable(  );
000010  e8bd4010          POP      {r4,lr}
000014  f7ffbffe          B.W      vMBPortTimersEnable
;;;139    
;;;140        EXIT_CRITICAL_SECTION(  );
;;;141    }
;;;142    
                          ENDP

                  |L4.24|
                          DCD      ||.data||

                          AREA ||i.eMBRTUStop||, CODE, READONLY, ALIGN=1

                  eMBRTUStop PROC
;;;143    void
;;;144    eMBRTUStop( void )
000000  b510              PUSH     {r4,lr}
;;;145    {
;;;146        CPU_SR_ALLOC();
;;;147        ENTER_CRITICAL_SECTION(  );
;;;148        vMBPortSerialEnable( FALSE, FALSE );
000002  2100              MOVS     r1,#0
000004  4608              MOV      r0,r1
000006  f7fffffe          BL       vMBPortSerialEnable
;;;149        vMBPortTimersDisable(  );
00000a  e8bd4010          POP      {r4,lr}
00000e  f7ffbffe          B.W      vMBPortTimersDisable
;;;150        EXIT_CRITICAL_SECTION(  );
;;;151    }
;;;152    
                          ENDP


                          AREA ||i.xMBRTUReceiveFSM||, CODE, READONLY, ALIGN=2

                  xMBRTUReceiveFSM PROC
;;;230    BOOL
;;;231    xMBRTUReceiveFSM( void )
000000  b538              PUSH     {r3-r5,lr}
;;;232    {
;;;233        BOOL            xTaskNeedSwitch = FALSE;
000002  2500              MOVS     r5,#0
;;;234        UCHAR           ucByte;
;;;235    
;;;236        assert( eSndState == STATE_TX_IDLE );
000004  4c1c              LDR      r4,|L6.120|
000006  7820              LDRB     r0,[r4,#0]  ; eSndState
000008  2800              CMP      r0,#0
00000a  d004              BEQ      |L6.22|
00000c  22ec              MOVS     r2,#0xec
00000e  a11b              ADR      r1,|L6.124|
000010  a022              ADR      r0,|L6.156|
000012  f7fffffe          BL       __aeabi_assert
                  |L6.22|
;;;237    
;;;238        /* Always read the character. */
;;;239        ( void )xMBPortSerialGetByte( ( CHAR * ) & ucByte );
000016  4668              MOV      r0,sp
000018  f7fffffe          BL       xMBPortSerialGetByte
;;;240    
;;;241        switch ( eRcvState )
00001c  7861              LDRB     r1,[r4,#1]  ; eRcvState
00001e  b139              CBZ      r1,|L6.48|
;;;242        {
;;;243            /* If we have received a character in the init state we have to
;;;244             * wait until the frame is finished.
;;;245             */
;;;246        case STATE_RX_INIT:
;;;247            vMBPortTimersEnable(  );
;;;248            break;
;;;249    
;;;250            /* In the error state we wait until all characters in the
;;;251             * damaged frame are transmitted.
;;;252             */
;;;253        case STATE_RX_ERROR:
;;;254            vMBPortTimersEnable(  );
;;;255            break;
;;;256    
;;;257            /* In the idle state we wait for a new character. If a character
;;;258             * is received the t1.5 and t3.5 timers are started and the
;;;259             * receiver is in the state STATE_RX_RECEIVCE.
;;;260             */
;;;261        case STATE_RX_IDLE:
;;;262            usRcvBufferPos = 0;
;;;263            ucRTUBuf[usRcvBufferPos++] = ucByte;
000020  4825              LDR      r0,|L6.184|
000022  2901              CMP      r1,#1                 ;241
000024  d00a              BEQ      |L6.60|
000026  2902              CMP      r1,#2                 ;241
000028  d015              BEQ      |L6.86|
00002a  2903              CMP      r1,#3                 ;241
00002c  d121              BNE      |L6.114|
00002e  e002              B        |L6.54|
                  |L6.48|
000030  f7fffffe          BL       vMBPortTimersEnable
000034  e01d              B        |L6.114|
                  |L6.54|
000036  f7fffffe          BL       vMBPortTimersEnable
00003a  e01a              B        |L6.114|
                  |L6.60|
00003c  2100              MOVS     r1,#0                 ;262
00003e  80a1              STRH     r1,[r4,#4]            ;262
000040  f89d3000          LDRB     r3,[sp,#0]
000044  88a1              LDRH     r1,[r4,#4]  ; usRcvBufferPos
000046  1c4a              ADDS     r2,r1,#1
000048  80a2              STRH     r2,[r4,#4]
00004a  5443              STRB     r3,[r0,r1]
;;;264            eRcvState = STATE_RX_RCV;
00004c  2002              MOVS     r0,#2
00004e  7060              STRB     r0,[r4,#1]
;;;265    
;;;266            /* Enable t3.5 timers. */
;;;267            vMBPortTimersEnable(  );
000050  f7fffffe          BL       vMBPortTimersEnable
;;;268            break;
000054  e00d              B        |L6.114|
                  |L6.86|
;;;269    
;;;270            /* We are currently receiving a frame. Reset the timer after
;;;271             * every character received. If more than the maximum possible
;;;272             * number of bytes in a modbus frame is received the frame is
;;;273             * ignored.
;;;274             */
;;;275        case STATE_RX_RCV:
;;;276            if( usRcvBufferPos < MB_SER_PDU_SIZE_MAX )
000056  88a1              LDRH     r1,[r4,#4]  ; usRcvBufferPos
000058  29ff              CMP      r1,#0xff
00005a  d806              BHI      |L6.106|
;;;277            {
;;;278                ucRTUBuf[usRcvBufferPos++] = ucByte;
00005c  f89d3000          LDRB     r3,[sp,#0]
000060  88a1              LDRH     r1,[r4,#4]  ; usRcvBufferPos
000062  1c4a              ADDS     r2,r1,#1
000064  80a2              STRH     r2,[r4,#4]
000066  5443              STRB     r3,[r0,r1]
000068  e001              B        |L6.110|
                  |L6.106|
;;;279            }
;;;280            else
;;;281            {
;;;282                eRcvState = STATE_RX_ERROR;
00006a  2003              MOVS     r0,#3
00006c  7060              STRB     r0,[r4,#1]
                  |L6.110|
;;;283            }
;;;284            vMBPortTimersEnable(  );
00006e  f7fffffe          BL       vMBPortTimersEnable
                  |L6.114|
;;;285            break;
;;;286        }
;;;287        return xTaskNeedSwitch;
000072  4628              MOV      r0,r5
;;;288    }
000074  bd38              POP      {r3-r5,pc}
;;;289    
                          ENDP

000076  0000              DCW      0x0000
                  |L6.120|
                          DCD      ||.data||
                  |L6.124|
00007c  2e2e5c2e          DCB      "..\\..\\MODBUS\\modbus\\rtu\\mbrtu.c",0
000080  2e5c4d4f
000084  44425553
000088  5c6d6f64
00008c  6275735c
000090  7274755c
000094  6d627274
000098  752e6300
                  |L6.156|
00009c  65536e64          DCB      "eSndState == STATE_TX_IDLE",0
0000a0  53746174
0000a4  65203d3d
0000a8  20535441
0000ac  54455f54
0000b0  585f4944
0000b4  4c4500  
0000b7  00                DCB      0
                  |L6.184|
                          DCD      ||.bss||

                          AREA ||i.xMBRTUTimerT35Expired||, CODE, READONLY, ALIGN=2

                  xMBRTUTimerT35Expired PROC
;;;328    BOOL
;;;329    xMBRTUTimerT35Expired( void )
000000  b570              PUSH     {r4-r6,lr}
;;;330    {
;;;331        BOOL            xNeedPoll = FALSE;
000002  2400              MOVS     r4,#0
;;;332    
;;;333        switch ( eRcvState )
000004  4d12              LDR      r5,|L7.80|
000006  7868              LDRB     r0,[r5,#1]  ; eRcvState
000008  2800              CMP      r0,#0
00000a  d011              BEQ      |L7.48|
00000c  2802              CMP      r0,#2
00000e  d014              BEQ      |L7.58|
000010  2803              CMP      r0,#3
000012  d016              BEQ      |L7.66|
;;;334        {
;;;335            /* Timer t35 expired. Startup phase is finished. */
;;;336        case STATE_RX_INIT:
;;;337            xNeedPoll = xMBPortEventPost( EV_READY );
;;;338            break;
;;;339    
;;;340            /* A frame was received and t35 expired. Notify the listener that
;;;341             * a new frame was received. */
;;;342        case STATE_RX_RCV:
;;;343            xNeedPoll = xMBPortEventPost( EV_FRAME_RECEIVED );
;;;344            break;
;;;345    
;;;346            /* An error occured while receiving the frame. */
;;;347        case STATE_RX_ERROR:
;;;348            break;
;;;349    
;;;350            /* Function called in an illegal state. */
;;;351        default:
;;;352    
;;;353            assert( ( eRcvState == STATE_RX_INIT ) ||
000014  7868              LDRB     r0,[r5,#1]  ; eRcvState
000016  b1a0              CBZ      r0,|L7.66|
000018  7868              LDRB     r0,[r5,#1]  ; eRcvState
00001a  2802              CMP      r0,#2
00001c  d011              BEQ      |L7.66|
00001e  7868              LDRB     r0,[r5,#1]  ; eRcvState
000020  2803              CMP      r0,#3
000022  d00e              BEQ      |L7.66|
000024  f2401261          MOV      r2,#0x161
000028  a10a              ADR      r1,|L7.84|
00002a  4812              LDR      r0,|L7.116|
00002c  f7fffffe          BL       __aeabi_assert
                  |L7.48|
000030  2000              MOVS     r0,#0                 ;337
000032  f7fffffe          BL       xMBPortEventPost
000036  4604              MOV      r4,r0                 ;337
000038  e003              B        |L7.66|
                  |L7.58|
00003a  2001              MOVS     r0,#1                 ;343
00003c  f7fffffe          BL       xMBPortEventPost
000040  4604              MOV      r4,r0                 ;343
                  |L7.66|
;;;354                    ( eRcvState == STATE_RX_RCV ) || ( eRcvState == STATE_RX_ERROR ) );
;;;355        }
;;;356    
;;;357        vMBPortTimersDisable(  );
000042  f7fffffe          BL       vMBPortTimersDisable
;;;358        eRcvState = STATE_RX_IDLE;
000046  2001              MOVS     r0,#1
000048  7068              STRB     r0,[r5,#1]
;;;359    
;;;360        return xNeedPoll;
00004a  4620              MOV      r0,r4
;;;361    }
00004c  bd70              POP      {r4-r6,pc}
                          ENDP

00004e  0000              DCW      0x0000
                  |L7.80|
                          DCD      ||.data||
                  |L7.84|
000054  2e2e5c2e          DCB      "..\\..\\MODBUS\\modbus\\rtu\\mbrtu.c",0
000058  2e5c4d4f
00005c  44425553
000060  5c6d6f64
000064  6275735c
000068  7274755c
00006c  6d627274
000070  752e6300
                  |L7.116|
                          DCD      ||.conststring||

                          AREA ||i.xMBRTUTransmitFSM||, CODE, READONLY, ALIGN=2

                  xMBRTUTransmitFSM PROC
;;;290    BOOL
;;;291    xMBRTUTransmitFSM( void )
000000  b570              PUSH     {r4-r6,lr}
;;;292    {
;;;293        BOOL            xNeedPoll = FALSE;
000002  2500              MOVS     r5,#0
;;;294    
;;;295        assert( eRcvState == STATE_RX_IDLE );
000004  4c16              LDR      r4,|L8.96|
000006  7860              LDRB     r0,[r4,#1]  ; eRcvState
000008  2801              CMP      r0,#1
00000a  d005              BEQ      |L8.24|
00000c  f2401227          MOV      r2,#0x127
000010  a114              ADR      r1,|L8.100|
000012  a01c              ADR      r0,|L8.132|
000014  f7fffffe          BL       __aeabi_assert
                  |L8.24|
;;;296    
;;;297        switch ( eSndState )
000018  7820              LDRB     r0,[r4,#0]  ; eSndState
00001a  b110              CBZ      r0,|L8.34|
00001c  2801              CMP      r0,#1
00001e  d11c              BNE      |L8.90|
000020  e004              B        |L8.44|
                  |L8.34|
;;;298        {
;;;299            /* We should not get a transmitter event if the transmitter is in
;;;300             * idle state.  */
;;;301        case STATE_TX_IDLE:
;;;302            /* enable receiver/disable transmitter. */
;;;303            vMBPortSerialEnable( TRUE, FALSE );
000022  2100              MOVS     r1,#0
000024  2001              MOVS     r0,#1
000026  f7fffffe          BL       vMBPortSerialEnable
;;;304            break;
00002a  e016              B        |L8.90|
                  |L8.44|
;;;305    
;;;306        case STATE_TX_XMIT:
;;;307            /* check if we are finished. */
;;;308            if( usSndBufferCount != 0 )
00002c  8860              LDRH     r0,[r4,#2]  ; usSndBufferCount
00002e  b150              CBZ      r0,|L8.70|
;;;309            {
;;;310                xMBPortSerialPutByte( ( CHAR )*pucSndBufferCur );
000030  68a0              LDR      r0,[r4,#8]  ; pucSndBufferCur
000032  7800              LDRB     r0,[r0,#0]
000034  f7fffffe          BL       xMBPortSerialPutByte
;;;311                pucSndBufferCur++;  /* next byte in sendbuffer. */
000038  68a0              LDR      r0,[r4,#8]  ; pucSndBufferCur
00003a  1c40              ADDS     r0,r0,#1
00003c  60a0              STR      r0,[r4,#8]  ; pucSndBufferCur
;;;312                usSndBufferCount--;
00003e  8860              LDRH     r0,[r4,#2]  ; usSndBufferCount
000040  1e40              SUBS     r0,r0,#1
000042  8060              STRH     r0,[r4,#2]
000044  e009              B        |L8.90|
                  |L8.70|
;;;313            }
;;;314            else
;;;315            {
;;;316                xNeedPoll = xMBPortEventPost( EV_FRAME_SENT );
000046  2003              MOVS     r0,#3
000048  f7fffffe          BL       xMBPortEventPost
00004c  4605              MOV      r5,r0
;;;317                /* Disable transmitter. This prevents another transmit buffer
;;;318                 * empty interrupt. */
;;;319                vMBPortSerialEnable( TRUE, FALSE );
00004e  2100              MOVS     r1,#0
000050  2001              MOVS     r0,#1
000052  f7fffffe          BL       vMBPortSerialEnable
;;;320                eSndState = STATE_TX_IDLE;
000056  2000              MOVS     r0,#0
000058  7020              STRB     r0,[r4,#0]
                  |L8.90|
;;;321            }
;;;322            break;
;;;323        }
;;;324    
;;;325        return xNeedPoll;
00005a  4628              MOV      r0,r5
;;;326    }
00005c  bd70              POP      {r4-r6,pc}
;;;327    
                          ENDP

00005e  0000              DCW      0x0000
                  |L8.96|
                          DCD      ||.data||
                  |L8.100|
000064  2e2e5c2e          DCB      "..\\..\\MODBUS\\modbus\\rtu\\mbrtu.c",0
000068  2e5c4d4f
00006c  44425553
000070  5c6d6f64
000074  6275735c
000078  7274755c
00007c  6d627274
000080  752e6300
                  |L8.132|
000084  65526376          DCB      "eRcvState == STATE_RX_IDLE",0
000088  53746174
00008c  65203d3d
000090  20535441
000094  54455f52
000098  585f4944
00009c  4c4500  
00009f  00                DCB      0

                          AREA ||.bss||, DATA, NOINIT, ALIGN=0

                  ucRTUBuf
                          %        256

                          AREA ||.conststring||, DATA, READONLY, MERGE=1, STRINGS, ALIGN=2

000000  28206552          DCB      "( eRcvState == STATE_RX_INIT ) || ( eRcvState == STATE_"
000004  63765374
000008  61746520
00000c  3d3d2053
000010  54415445
000014  5f52585f
000018  494e4954
00001c  2029207c
000020  7c202820
000024  65526376
000028  53746174
00002c  65203d3d
000030  20535441
000034  54455f  
000037  52585f52          DCB      "RX_RCV ) || ( eRcvState == STATE_RX_ERROR )",0
00003b  43562029
00003f  207c7c20
000043  28206552
000047  63765374
00004b  61746520
00004f  3d3d2053
000053  54415445
000057  5f52585f
00005b  4552524f
00005f  52202900

                          AREA ||.data||, DATA, ALIGN=2

                  eSndState
000000  00                DCB      0x00
                  eRcvState
000001  00                DCB      0x00
                  usSndBufferCount
000002  0000              DCB      0x00,0x00
                  usRcvBufferPos
000004  00000000          DCB      0x00,0x00,0x00,0x00
                  pucSndBufferCur
                          DCD      0x00000000

;*** Start embedded assembler ***

#line 1 "..\\..\\MODBUS\\modbus\\rtu\\mbrtu.c"
	AREA ||.rev16_text||, CODE
	THUMB
	EXPORT |__asm___7_mbrtu_c_0485e010____REV16|
#line 129 "..\\..\\Libraries\\CMSIS\\Include\\core_cmInstr.h"
|__asm___7_mbrtu_c_0485e010____REV16| PROC
#line 130

 rev16 r0, r0
 bx lr
	ENDP
	AREA ||.revsh_text||, CODE
	THUMB
	EXPORT |__asm___7_mbrtu_c_0485e010____REVSH|
#line 144
|__asm___7_mbrtu_c_0485e010____REVSH| PROC
#line 145

 revsh r0, r0
 bx lr
	ENDP
	AREA ||.rrx_text||, CODE
	THUMB
	EXPORT |__asm___7_mbrtu_c_0485e010____RRX|
#line 300
|__asm___7_mbrtu_c_0485e010____RRX| PROC
#line 301

 rrx r0, r0
 bx lr
	ENDP

;*** End   embedded assembler ***