mb.txt
28.5 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
; 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\mb.o --asm_dir=.\Flash\List\ --list_dir=.\Flash\List\ --depend=.\flash\obj\mb.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\mb.crf ..\..\MODBUS\modbus\mb.c]
THUMB
AREA ||i.eMBClose||, CODE, READONLY, ALIGN=2
eMBClose PROC
;;;273 eMBErrorCode
;;;274 eMBClose( void )
000000 b510 PUSH {r4,lr}
;;;275 {
;;;276 eMBErrorCode eStatus = MB_ENOERR;
000002 2400 MOVS r4,#0
;;;277
;;;278 if( eMBState == STATE_DISABLED )
000004 4805 LDR r0,|L1.28|
000006 7801 LDRB r1,[r0,#0] ; eMBState
000008 2901 CMP r1,#1
00000a d002 BEQ |L1.18|
;;;279 {
;;;280 if( pvMBFrameCloseCur != NULL )
;;;281 {
;;;282 pvMBFrameCloseCur( );
;;;283 }
;;;284 }
;;;285 else
;;;286 {
;;;287 eStatus = MB_EILLSTATE;
00000c 2406 MOVS r4,#6
|L1.14|
;;;288 }
;;;289 return eStatus;
00000e 4620 MOV r0,r4
;;;290 }
000010 bd10 POP {r4,pc}
|L1.18|
000012 69c1 LDR r1,[r0,#0x1c] ;280 ; pvMBFrameCloseCur
000014 2900 CMP r1,#0 ;280
000016 d0fa BEQ |L1.14|
000018 4788 BLX r1 ;282
00001a e7f8 B |L1.14|
;;;291
ENDP
|L1.28|
DCD ||.data||
AREA ||i.eMBDisable||, CODE, READONLY, ALIGN=2
eMBDisable PROC
;;;310 eMBErrorCode
;;;311 eMBDisable( void )
000000 b510 PUSH {r4,lr}
;;;312 {
;;;313 eMBErrorCode eStatus;
;;;314
;;;315 if( eMBState == STATE_ENABLED )
000002 4c08 LDR r4,|L2.36|
000004 7820 LDRB r0,[r4,#0] ; eMBState
000006 2800 CMP r0,#0
000008 d003 BEQ |L2.18|
;;;316 {
;;;317 pvMBFrameStopCur( );
;;;318 eMBState = STATE_DISABLED;
;;;319 eStatus = MB_ENOERR;
;;;320 }
;;;321 else if( eMBState == STATE_DISABLED )
00000a 2801 CMP r0,#1
00000c d007 BEQ |L2.30|
;;;322 {
;;;323 eStatus = MB_ENOERR;
;;;324 }
;;;325 else
;;;326 {
;;;327 eStatus = MB_EILLSTATE;
00000e 2006 MOVS r0,#6
;;;328 }
;;;329 return eStatus;
;;;330 }
000010 bd10 POP {r4,pc}
|L2.18|
000012 6960 LDR r0,[r4,#0x14] ;317 ; pvMBFrameStopCur
000014 4780 BLX r0 ;317
000016 2001 MOVS r0,#1 ;318
000018 7020 STRB r0,[r4,#0] ;318
00001a 2000 MOVS r0,#0 ;319
00001c bd10 POP {r4,pc}
|L2.30|
00001e 2000 MOVS r0,#0 ;323
000020 bd10 POP {r4,pc}
;;;331
ENDP
000022 0000 DCW 0x0000
|L2.36|
DCD ||.data||
AREA ||i.eMBEnable||, CODE, READONLY, ALIGN=2
eMBEnable PROC
;;;292 eMBErrorCode
;;;293 eMBEnable( void )
000000 b570 PUSH {r4-r6,lr}
;;;294 {
;;;295 eMBErrorCode eStatus = MB_ENOERR;
000002 2400 MOVS r4,#0
;;;296
;;;297 if( eMBState == STATE_DISABLED )
000004 4d05 LDR r5,|L3.28|
000006 7828 LDRB r0,[r5,#0] ; eMBState
000008 2801 CMP r0,#1
00000a d002 BEQ |L3.18|
;;;298 {
;;;299 /* Activate the protocol stack. */
;;;300 pvMBFrameStartCur( );
;;;301 eMBState = STATE_ENABLED;
;;;302 }
;;;303 else
;;;304 {
;;;305 eStatus = MB_EILLSTATE;
00000c 2406 MOVS r4,#6
|L3.14|
;;;306 }
;;;307 return eStatus;
00000e 4620 MOV r0,r4
;;;308 }
000010 bd70 POP {r4-r6,pc}
|L3.18|
000012 6928 LDR r0,[r5,#0x10] ;300 ; pvMBFrameStartCur
000014 4780 BLX r0 ;300
000016 2000 MOVS r0,#0 ;301
000018 7028 STRB r0,[r5,#0] ;301
00001a e7f8 B |L3.14|
;;;309
ENDP
|L3.28|
DCD ||.data||
AREA ||i.eMBInit||, CODE, READONLY, ALIGN=2
eMBInit PROC
;;;129 eMBErrorCode
;;;130 eMBInit( eMBMode eMode, UCHAR ucSlaveAddress, UCHAR ucPort, ULONG ulBaudRate, eMBParity eParity )
000000 b570 PUSH {r4-r6,lr}
;;;131 {
000002 4614 MOV r4,r2
000004 461a MOV r2,r3
000006 9b04 LDR r3,[sp,#0x10]
000008 4606 MOV r6,r0
;;;132 eMBErrorCode eStatus = MB_ENOERR;
;;;133
;;;134 /* check preconditions */
;;;135 if( ( ucSlaveAddress == MB_ADDRESS_BROADCAST ) ||
00000a 2900 CMP r1,#0
00000c d001 BEQ |L4.18|
;;;136 ( ucSlaveAddress < MB_ADDRESS_MIN ) || ( ucSlaveAddress > MB_ADDRESS_MAX ) )
00000e 29f7 CMP r1,#0xf7
000010 d901 BLS |L4.22|
|L4.18|
;;;137 {
;;;138 eStatus = MB_EINVAL;
000012 2402 MOVS r4,#2
000014 e021 B |L4.90|
|L4.22|
;;;139 }
;;;140 else
;;;141 {
;;;142 ucMBAddress = ucSlaveAddress;
000016 4d13 LDR r5,|L4.100|
000018 4608 MOV r0,r1
00001a 7129 STRB r1,[r5,#4]
;;;143
;;;144 switch ( eMode )
00001c b116 CBZ r6,|L4.36|
;;;145 {
;;;146 #if MB_RTU_ENABLED > 0
;;;147 case MB_RTU:
;;;148 pvMBFrameStartCur = eMBRTUStart;
;;;149 pvMBFrameStopCur = eMBRTUStop;
;;;150 peMBFrameSendCur = eMBRTUSend;
;;;151 peMBFrameReceiveCur = eMBRTUReceive;
;;;152 pvMBFrameCloseCur = MB_PORT_HAS_CLOSE ? vMBPortClose : NULL;
;;;153 pxMBFrameCBByteReceived = xMBRTUReceiveFSM;
;;;154 pxMBFrameCBTransmitterEmpty = xMBRTUTransmitFSM;
;;;155 pxMBPortCBTimerExpired = xMBRTUTimerT35Expired;
;;;156
;;;157 eStatus = eMBRTUInit( ucMBAddress, ucPort, ulBaudRate, eParity );
;;;158 break;
;;;159 #endif
;;;160 #if MB_ASCII_ENABLED > 0
;;;161 case MB_ASCII:
;;;162 pvMBFrameStartCur = eMBASCIIStart;
;;;163 pvMBFrameStopCur = eMBASCIIStop;
;;;164 peMBFrameSendCur = eMBASCIISend;
;;;165 peMBFrameReceiveCur = eMBASCIIReceive;
;;;166 pvMBFrameCloseCur = MB_PORT_HAS_CLOSE ? vMBPortClose : NULL;
;;;167 pxMBFrameCBByteReceived = xMBASCIIReceiveFSM;
;;;168 pxMBFrameCBTransmitterEmpty = xMBASCIITransmitFSM;
;;;169 pxMBPortCBTimerExpired = xMBASCIITimerT1SExpired;
;;;170
;;;171 eStatus = eMBASCIIInit( ucMBAddress, ucPort, ulBaudRate, eParity );
;;;172 break;
;;;173 #endif
;;;174 default:
;;;175 eStatus = MB_EINVAL;
00001e 2402 MOVS r4,#2
|L4.32|
;;;176 }
;;;177
;;;178 if( eStatus == MB_ENOERR )
000020 b1ac CBZ r4,|L4.78|
000022 e01a B |L4.90|
|L4.36|
000024 4910 LDR r1,|L4.104|
000026 6129 STR r1,[r5,#0x10] ;148 ; pvMBFrameStartCur
000028 4910 LDR r1,|L4.108|
00002a 6169 STR r1,[r5,#0x14] ;149 ; pvMBFrameStopCur
00002c 4910 LDR r1,|L4.112|
00002e 60e9 STR r1,[r5,#0xc] ;150 ; peMBFrameSendCur
000030 4910 LDR r1,|L4.116|
000032 61a9 STR r1,[r5,#0x18] ;151 ; peMBFrameReceiveCur
000034 2100 MOVS r1,#0 ;152
000036 61e9 STR r1,[r5,#0x1c] ;152 ; pvMBFrameCloseCur
000038 490f LDR r1,|L4.120|
00003a 6229 STR r1,[r5,#0x20] ;153 ; pxMBFrameCBByteReceived
00003c 490f LDR r1,|L4.124|
00003e 6269 STR r1,[r5,#0x24] ;154 ; pxMBFrameCBTransmitterEmpty
000040 490f LDR r1,|L4.128|
000042 62a9 STR r1,[r5,#0x28] ;155 ; pxMBPortCBTimerExpired
000044 4621 MOV r1,r4 ;157
000046 f7fffffe BL eMBRTUInit
00004a 4604 MOV r4,r0 ;157
00004c e7e8 B |L4.32|
|L4.78|
;;;179 {
;;;180 if( !xMBPortEventInit( ) )
00004e f7fffffe BL xMBPortEventInit
000052 b120 CBZ r0,|L4.94|
;;;181 {
;;;182 /* port dependent event module initalization failed. */
;;;183 eStatus = MB_EPORTERR;
;;;184 }
;;;185 else
;;;186 {
;;;187 eMBCurrentMode = eMode;
000054 716e STRB r6,[r5,#5]
;;;188 eMBState = STATE_DISABLED;
000056 2001 MOVS r0,#1
000058 7028 STRB r0,[r5,#0]
|L4.90|
;;;189 }
;;;190 }
;;;191 }
;;;192 return eStatus;
00005a 4620 MOV r0,r4
;;;193 }
00005c bd70 POP {r4-r6,pc}
|L4.94|
00005e 2403 MOVS r4,#3 ;183
000060 e7fb B |L4.90|
;;;194
ENDP
000062 0000 DCW 0x0000
|L4.100|
DCD ||.data||
|L4.104|
DCD eMBRTUStart
|L4.108|
DCD eMBRTUStop
|L4.112|
DCD eMBRTUSend
|L4.116|
DCD eMBRTUReceive
|L4.120|
DCD xMBRTUReceiveFSM
|L4.124|
DCD xMBRTUTransmitFSM
|L4.128|
DCD xMBRTUTimerT35Expired
AREA ||i.eMBPoll||, CODE, READONLY, ALIGN=2
eMBPoll PROC
;;;332 eMBErrorCode
;;;333 eMBPoll( void )
000000 b5f8 PUSH {r3-r7,lr}
;;;334 {
;;;335 static UCHAR *ucMBFrame;
;;;336 static UCHAR ucRcvAddress;
;;;337 static UCHAR ucFunctionCode;
;;;338 static USHORT usLength;
;;;339 static eMBException eException;
;;;340
;;;341 int i;
;;;342 eMBErrorCode eStatus = MB_ENOERR;
;;;343 eMBEventType eEvent;
;;;344
;;;345 /* Check if the protocol stack is ready. */
;;;346 if( eMBState != STATE_ENABLED )
000002 4d29 LDR r5,|L5.168|
000004 7828 LDRB r0,[r5,#0] ; eMBState
000006 2800 CMP r0,#0
000008 d001 BEQ |L5.14|
;;;347 {
;;;348 return MB_EILLSTATE;
00000a 2006 MOVS r0,#6
;;;349 }
;;;350
;;;351 /* Check if there is a event available. If not return control to caller.
;;;352 * Otherwise we will handle the event. */
;;;353 if( xMBPortEventGet( &eEvent ) == TRUE )
;;;354 {
;;;355 switch ( eEvent )
;;;356 {
;;;357 case EV_READY:
;;;358 break;
;;;359
;;;360 case EV_FRAME_RECEIVED:
;;;361 eStatus = peMBFrameReceiveCur( &ucRcvAddress, &ucMBFrame, &usLength );
;;;362 if( eStatus == MB_ENOERR )
;;;363 {
;;;364 /* Check if the frame is for us. If not ignore the frame. */
;;;365 if( ( ucRcvAddress == ucMBAddress ) || ( ucRcvAddress == MB_ADDRESS_BROADCAST ) )
;;;366 {
;;;367 ( void )xMBPortEventPost( EV_EXECUTE );
;;;368 }
;;;369 }
;;;370 break;
;;;371
;;;372 case EV_EXECUTE:
;;;373 ucFunctionCode = ucMBFrame[MB_PDU_FUNC_OFF];
;;;374 eException = MB_EX_ILLEGAL_FUNCTION;
;;;375 for( i = 0; i < MB_FUNC_HANDLERS_MAX; i++ )
;;;376 {
;;;377 /* No more function handlers registered. Abort. */
;;;378 if( xFuncHandlers[i].ucFunctionCode == 0 )
;;;379 {
;;;380 break;
;;;381 }
;;;382 else if( xFuncHandlers[i].ucFunctionCode == ucFunctionCode )
;;;383 {
;;;384 eException = xFuncHandlers[i].pxHandler( ucMBFrame, &usLength );
;;;385 break;
;;;386 }
;;;387 }
;;;388
;;;389 /* If the request was not sent to the broadcast address we
;;;390 * return a reply. */
;;;391 if( ucRcvAddress != MB_ADDRESS_BROADCAST )
;;;392 {
;;;393 if( eException != MB_EX_NONE )
;;;394 {
;;;395 /* An exception occured. Build an error frame. */
;;;396 usLength = 0;
;;;397 ucMBFrame[usLength++] = ( UCHAR )( ucFunctionCode | MB_FUNC_ERROR );
;;;398 ucMBFrame[usLength++] = eException;
;;;399 }
;;;400 if( ( eMBCurrentMode == MB_ASCII ) && MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS )
;;;401 {
;;;402 vMBPortTimersDelay( MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS );
;;;403 }
;;;404 eStatus = peMBFrameSendCur( ucMBAddress, ucMBFrame, usLength );
;;;405 }
;;;406 break;
;;;407
;;;408 case EV_FRAME_SENT:
;;;409 break;
;;;410 }
;;;411 }
;;;412 return MB_ENOERR;
;;;413 }
00000c bdf8 POP {r3-r7,pc}
|L5.14|
00000e 4668 MOV r0,sp ;353
000010 f7fffffe BL xMBPortEventGet
000014 2801 CMP r0,#1 ;353
000016 d144 BNE |L5.162|
000018 f89d0000 LDRB r0,[sp,#0] ;355
00001c b3e8 CBZ r0,|L5.154|
00001e 2801 CMP r0,#1 ;355
000020 d002 BEQ |L5.40|
000022 2802 CMP r0,#2 ;355
000024 d13d BNE |L5.162|
000026 e00f B |L5.72|
|L5.40|
000028 4a1f LDR r2,|L5.168|
00002a 69ab LDR r3,[r5,#0x18] ;361 ; peMBFrameReceiveCur
00002c 1d92 ADDS r2,r2,#6 ;361
00002e 1c91 ADDS r1,r2,#2 ;361
000030 1fc8 SUBS r0,r1,#7 ;361
000032 4798 BLX r3 ;361
000034 bb88 CBNZ r0,|L5.154|
000036 7868 LDRB r0,[r5,#1] ;365 ; ucRcvAddress
000038 7929 LDRB r1,[r5,#4] ;365 ; ucMBAddress
00003a 4288 CMP r0,r1 ;365
00003c d000 BEQ |L5.64|
00003e bb60 CBNZ r0,|L5.154|
|L5.64|
000040 2002 MOVS r0,#2 ;367
000042 f7fffffe BL xMBPortEventPost
000046 e02c B |L5.162|
|L5.72|
000048 68a8 LDR r0,[r5,#8] ;373 ; ucMBFrame
00004a 7804 LDRB r4,[r0,#0] ;373
00004c 70ac STRB r4,[r5,#2] ;373
00004e 2601 MOVS r6,#1 ;374
000050 70ee STRB r6,[r5,#3] ;374
000052 2100 MOVS r1,#0 ;375
000054 4b14 LDR r3,|L5.168|
000056 332c ADDS r3,r3,#0x2c ;378
|L5.88|
000058 f8132031 LDRB r2,[r3,r1,LSL #3] ;378
00005c b162 CBZ r2,|L5.120|
00005e 42a2 CMP r2,r4 ;382
000060 d107 BNE |L5.114|
000062 eb0301c1 ADD r1,r3,r1,LSL #3 ;384
000066 684a LDR r2,[r1,#4] ;384
000068 490f LDR r1,|L5.168|
00006a 1d89 ADDS r1,r1,#6 ;384
00006c 4790 BLX r2 ;384
00006e 70e8 STRB r0,[r5,#3] ;384
000070 e002 B |L5.120|
|L5.114|
000072 1c49 ADDS r1,r1,#1 ;375
000074 2910 CMP r1,#0x10 ;375
000076 dbef BLT |L5.88|
|L5.120|
000078 7868 LDRB r0,[r5,#1] ;391 ; ucRcvAddress
00007a b170 CBZ r0,|L5.154|
00007c 78e9 LDRB r1,[r5,#3] ;393 ; eException
00007e b149 CBZ r1,|L5.148|
000080 78a8 LDRB r0,[r5,#2] ;397 ; ucFunctionCode
000082 80ee STRH r6,[r5,#6] ;397
000084 68aa LDR r2,[r5,#8] ;397 ; ucMBFrame
000086 f0400080 ORR r0,r0,#0x80 ;397
00008a 7010 STRB r0,[r2,#0] ;397
00008c 88e8 LDRH r0,[r5,#6] ;398 ; usLength
00008e 1c43 ADDS r3,r0,#1 ;398
000090 80eb STRH r3,[r5,#6] ;398
000092 5411 STRB r1,[r2,r0] ;398
|L5.148|
000094 88ea LDRH r2,[r5,#6] ;404 ; usLength
000096 7928 LDRB r0,[r5,#4] ;404 ; ucMBAddress
000098 e000 B |L5.156|
|L5.154|
00009a e002 B |L5.162|
|L5.156|
00009c e9d51302 LDRD r1,r3,[r5,#8] ;404
0000a0 4798 BLX r3 ;404
|L5.162|
0000a2 2000 MOVS r0,#0 ;412
0000a4 bdf8 POP {r3-r7,pc}
ENDP
0000a6 0000 DCW 0x0000
|L5.168|
DCD ||.data||
AREA ||i.eMBRegisterCB||, CODE, READONLY, ALIGN=2
eMBRegisterCB PROC
;;;225 eMBErrorCode
;;;226 eMBRegisterCB( UCHAR ucFunctionCode, pxMBFunctionHandler pxHandler )
000000 b510 PUSH {r4,lr}
;;;227 {
;;;228 CPU_SR_ALLOC();
;;;229 int i;
;;;230 eMBErrorCode eStatus;
;;;231
;;;232 if( ( 0 < ucFunctionCode ) && ( ucFunctionCode <= 127 ) )
000002 1e42 SUBS r2,r0,#1
000004 2a7e CMP r2,#0x7e
000006 d828 BHI |L6.90|
;;;233 {
;;;234 ENTER_CRITICAL_SECTION( );
;;;235 if( pxHandler != NULL )
;;;236 {
;;;237 for( i = 0; i < MB_FUNC_HANDLERS_MAX; i++ )
;;;238 {
;;;239 if( ( xFuncHandlers[i].pxHandler == NULL ) ||
000008 4c15 LDR r4,|L6.96|
00000a b1a9 CBZ r1,|L6.56|
00000c 2200 MOVS r2,#0 ;237
|L6.14|
00000e eb0403c2 ADD r3,r4,r2,LSL #3
000012 685b LDR r3,[r3,#4]
000014 b10b CBZ r3,|L6.26|
;;;240 ( xFuncHandlers[i].pxHandler == pxHandler ) )
000016 428b CMP r3,r1
000018 d105 BNE |L6.38|
|L6.26|
;;;241 {
;;;242 xFuncHandlers[i].ucFunctionCode = ucFunctionCode;
00001a f8040032 STRB r0,[r4,r2,LSL #3]
;;;243 xFuncHandlers[i].pxHandler = pxHandler;
00001e eb0400c2 ADD r0,r4,r2,LSL #3
000022 6041 STR r1,[r0,#4]
;;;244 break;
000024 e002 B |L6.44|
|L6.38|
000026 1c52 ADDS r2,r2,#1 ;237
000028 2a10 CMP r2,#0x10 ;237
00002a dbf0 BLT |L6.14|
|L6.44|
;;;245 }
;;;246 }
;;;247 eStatus = ( i != MB_FUNC_HANDLERS_MAX ) ? MB_ENOERR : MB_ENORES;
00002c 2a10 CMP r2,#0x10
00002e d001 BEQ |L6.52|
000030 2000 MOVS r0,#0
;;;248 }
;;;249 else
;;;250 {
;;;251 for( i = 0; i < MB_FUNC_HANDLERS_MAX; i++ )
;;;252 {
;;;253 if( xFuncHandlers[i].ucFunctionCode == ucFunctionCode )
;;;254 {
;;;255 xFuncHandlers[i].ucFunctionCode = 0;
;;;256 xFuncHandlers[i].pxHandler = NULL;
;;;257 break;
;;;258 }
;;;259 }
;;;260 /* Remove can't fail. */
;;;261 eStatus = MB_ENOERR;
;;;262 }
;;;263 EXIT_CRITICAL_SECTION( );
;;;264 }
;;;265 else
;;;266 {
;;;267 eStatus = MB_EINVAL;
;;;268 }
;;;269 return eStatus;
;;;270 }
000032 bd10 POP {r4,pc}
|L6.52|
000034 2004 MOVS r0,#4 ;247
000036 bd10 POP {r4,pc}
|L6.56|
000038 2100 MOVS r1,#0 ;251
|L6.58|
00003a f8142031 LDRB r2,[r4,r1,LSL #3] ;253
00003e 4282 CMP r2,r0 ;253
000040 d106 BNE |L6.80|
000042 2000 MOVS r0,#0 ;255
000044 f8040031 STRB r0,[r4,r1,LSL #3] ;255
000048 eb0401c1 ADD r1,r4,r1,LSL #3 ;256
00004c 6048 STR r0,[r1,#4] ;256
00004e e002 B |L6.86|
|L6.80|
000050 1c49 ADDS r1,r1,#1 ;251
000052 2910 CMP r1,#0x10 ;251
000054 dbf1 BLT |L6.58|
|L6.86|
000056 2000 MOVS r0,#0 ;261
000058 bd10 POP {r4,pc}
|L6.90|
00005a 2002 MOVS r0,#2 ;267
00005c bd10 POP {r4,pc}
;;;271
ENDP
00005e 0000 DCW 0x0000
|L6.96|
DCD ||.data||+0x2c
AREA ||.data||, DATA, ALIGN=2
eMBState
000000 02 DCB 0x02
ucRcvAddress
000001 00 DCB 0x00
ucFunctionCode
000002 00 DCB 0x00
eException
000003 00 DCB 0x00
ucMBAddress
000004 00 DCB 0x00
eMBCurrentMode
000005 00 DCB 0x00
usLength
000006 0000 DCB 0x00,0x00
ucMBFrame
DCD 0x00000000
peMBFrameSendCur
DCD 0x00000000
pvMBFrameStartCur
DCD 0x00000000
pvMBFrameStopCur
DCD 0x00000000
peMBFrameReceiveCur
DCD 0x00000000
pvMBFrameCloseCur
DCD 0x00000000
pxMBFrameCBByteReceived
DCD 0x00000000
pxMBFrameCBTransmitterEmpty
DCD 0x00000000
pxMBPortCBTimerExpired
DCD 0x00000000
xFuncHandlers
00002c 11000000 DCB 0x11,0x00,0x00,0x00
DCD eMBFuncReportSlaveID
000034 04000000 DCB 0x04,0x00,0x00,0x00
DCD eMBFuncReadInputRegister
00003c 03000000 DCB 0x03,0x00,0x00,0x00
DCD eMBFuncReadHoldingRegister
000044 10000000 DCB 0x10,0x00,0x00,0x00
DCD eMBFuncWriteMultipleHoldingRegister
00004c 06000000 DCB 0x06,0x00,0x00,0x00
DCD eMBFuncWriteHoldingRegister
000054 17000000 DCB 0x17,0x00,0x00,0x00
DCD eMBFuncReadWriteMultipleHoldingRegister
00005c 01000000 DCB 0x01,0x00,0x00,0x00
DCD eMBFuncReadCoils
000064 05000000 DCB 0x05,0x00,0x00,0x00
DCD eMBFuncWriteCoil
00006c 0f000000 DCB 0x0f,0x00,0x00,0x00
DCD eMBFuncWriteMultipleCoils
000074 02000000 DCB 0x02,0x00,0x00,0x00
DCD eMBFuncReadDiscreteInputs
% 48
AREA ||area_number.10||, DATA, ALIGN=2
EXPORTAS ||area_number.10||, ||.data||
pxMBFrameCBReceiveFSMCur
DCD 0x00000000
AREA ||area_number.11||, DATA, ALIGN=2
EXPORTAS ||area_number.11||, ||.data||
pxMBFrameCBTransmitFSMCur
DCD 0x00000000
;*** Start embedded assembler ***
#line 1 "..\\..\\MODBUS\\modbus\\mb.c"
AREA ||.rev16_text||, CODE
THUMB
EXPORT |__asm___4_mb_c_eMBInit____REV16|
#line 129 "..\\..\\Libraries\\CMSIS\\Include\\core_cmInstr.h"
|__asm___4_mb_c_eMBInit____REV16| PROC
#line 130
rev16 r0, r0
bx lr
ENDP
AREA ||.revsh_text||, CODE
THUMB
EXPORT |__asm___4_mb_c_eMBInit____REVSH|
#line 144
|__asm___4_mb_c_eMBInit____REVSH| PROC
#line 145
revsh r0, r0
bx lr
ENDP
AREA ||.rrx_text||, CODE
THUMB
EXPORT |__asm___4_mb_c_eMBInit____RRX|
#line 300
|__asm___4_mb_c_eMBInit____RRX| PROC
#line 301
rrx r0, r0
bx lr
ENDP
;*** End embedded assembler ***