mbfunccoils.txt
18.4 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
; 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\mbfunccoils.o --asm_dir=.\Flash\List\ --list_dir=.\Flash\List\ --depend=.\flash\obj\mbfunccoils.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\mbfunccoils.crf ..\..\MODBUS\modbus\functions\mbfunccoils.c]
THUMB
AREA ||i.eMBFuncReadCoils||, CODE, READONLY, ALIGN=1
eMBFuncReadCoils PROC
;;;68 eMBException
;;;69 eMBFuncReadCoils( UCHAR * pucFrame, USHORT * usLen )
000000 e92d41f0 PUSH {r4-r8,lr}
;;;70 {
000004 460c MOV r4,r1
;;;71 USHORT usRegAddress;
;;;72 USHORT usCoilCount;
;;;73 UCHAR ucNBytes;
;;;74 UCHAR *pucFrameCur;
;;;75
;;;76 eMBException eStatus = MB_EX_NONE;
000006 2600 MOVS r6,#0
;;;77 eMBErrorCode eRegStatus;
;;;78
;;;79 if( *usLen == ( MB_PDU_FUNC_READ_SIZE + MB_PDU_SIZE_MIN ) )
000008 8821 LDRH r1,[r4,#0]
00000a 2905 CMP r1,#5
00000c d003 BEQ |L1.22|
;;;80 {
;;;81 usRegAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_ADDR_OFF] << 8 );
;;;82 usRegAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_ADDR_OFF + 1] );
;;;83 usRegAddress++;
;;;84
;;;85 usCoilCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_COILCNT_OFF] << 8 );
;;;86 usCoilCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_COILCNT_OFF + 1] );
;;;87
;;;88 /* Check if the number of registers to read is valid. If not
;;;89 * return Modbus illegal data value exception.
;;;90 */
;;;91 if( ( usCoilCount >= 1 ) &&
;;;92 ( usCoilCount < MB_PDU_FUNC_READ_COILCNT_MAX ) )
;;;93 {
;;;94 /* Set the current PDU data pointer to the beginning. */
;;;95 pucFrameCur = &pucFrame[MB_PDU_FUNC_OFF];
;;;96 *usLen = MB_PDU_FUNC_OFF;
;;;97
;;;98 /* First byte contains the function code. */
;;;99 *pucFrameCur++ = MB_FUNC_READ_COILS;
;;;100 *usLen += 1;
;;;101
;;;102 /* Test if the quantity of coils is a multiple of 8. If not last
;;;103 * byte is only partially field with unused coils set to zero. */
;;;104 if( ( usCoilCount & 0x0007 ) != 0 )
;;;105 {
;;;106 ucNBytes = ( UCHAR )( usCoilCount / 8 + 1 );
;;;107 }
;;;108 else
;;;109 {
;;;110 ucNBytes = ( UCHAR )( usCoilCount / 8 );
;;;111 }
;;;112 *pucFrameCur++ = ucNBytes;
;;;113 *usLen += 1;
;;;114
;;;115 eRegStatus =
;;;116 eMBRegCoilsCB( pucFrameCur, usRegAddress, usCoilCount,
;;;117 MB_REG_READ );
;;;118
;;;119 /* If an error occured convert it into a Modbus exception. */
;;;120 if( eRegStatus != MB_ENOERR )
;;;121 {
;;;122 eStatus = prveMBError2Exception( eRegStatus );
;;;123 }
;;;124 else
;;;125 {
;;;126 /* The response contains the function code, the starting address
;;;127 * and the quantity of registers. We reuse the old values in the
;;;128 * buffer because they are still valid. */
;;;129 *usLen += ucNBytes;;
;;;130 }
;;;131 }
;;;132 else
;;;133 {
;;;134 eStatus = MB_EX_ILLEGAL_DATA_VALUE;
;;;135 }
;;;136 }
;;;137 else
;;;138 {
;;;139 /* Can't be a valid read coil register request because the length
;;;140 * is incorrect. */
;;;141 eStatus = MB_EX_ILLEGAL_DATA_VALUE;
00000e 2603 MOVS r6,#3
|L1.16|
;;;142 }
;;;143 return eStatus;
000010 4630 MOV r0,r6
;;;144 }
000012 e8bd81f0 POP {r4-r8,pc}
|L1.22|
000016 7841 LDRB r1,[r0,#1] ;81
000018 020a LSLS r2,r1,#8 ;81
00001a 7881 LDRB r1,[r0,#2] ;82
00001c 4311 ORRS r1,r1,r2 ;82
00001e 1c49 ADDS r1,r1,#1 ;83
000020 b28f UXTH r7,r1 ;83
000022 78c1 LDRB r1,[r0,#3] ;85
000024 0209 LSLS r1,r1,#8 ;85
000026 7902 LDRB r2,[r0,#4] ;86
000028 430a ORRS r2,r2,r1 ;86
00002a 1e51 SUBS r1,r2,#1 ;91
00002c f24073cf MOV r3,#0x7cf ;91
000030 4299 CMP r1,r3 ;91
000032 d221 BCS |L1.120|
000034 2100 MOVS r1,#0 ;96
000036 8021 STRH r1,[r4,#0] ;96
000038 2101 MOVS r1,#1 ;99
00003a f8001b01 STRB r1,[r0],#1 ;99
00003e 8823 LDRH r3,[r4,#0] ;100
000040 1c5b ADDS r3,r3,#1 ;100
000042 8023 STRH r3,[r4,#0] ;100
000044 0753 LSLS r3,r2,#29 ;104
000046 d003 BEQ |L1.80|
000048 eb0101d2 ADD r1,r1,r2,LSR #3 ;106
00004c b2cd UXTB r5,r1 ;106
00004e e001 B |L1.84|
|L1.80|
000050 f3c205c7 UBFX r5,r2,#3,#8 ;110
|L1.84|
000054 f8005b01 STRB r5,[r0],#1 ;112
000058 8821 LDRH r1,[r4,#0] ;113
00005a 1c49 ADDS r1,r1,#1 ;113
00005c 8021 STRH r1,[r4,#0] ;113
00005e 2300 MOVS r3,#0 ;115
000060 4639 MOV r1,r7 ;115
000062 f7fffffe BL eMBRegCoilsCB
000066 b118 CBZ r0,|L1.112|
000068 f7fffffe BL prveMBError2Exception
00006c 4606 MOV r6,r0 ;122
00006e e7cf B |L1.16|
|L1.112|
000070 8820 LDRH r0,[r4,#0] ;129
000072 4428 ADD r0,r0,r5 ;129
000074 8020 STRH r0,[r4,#0] ;129
000076 e7cb B |L1.16|
|L1.120|
000078 2603 MOVS r6,#3 ;134
00007a e7c9 B |L1.16|
;;;145
ENDP
AREA ||i.eMBFuncWriteCoil||, CODE, READONLY, ALIGN=1
eMBFuncWriteCoil PROC
;;;147 eMBException
;;;148 eMBFuncWriteCoil( UCHAR * pucFrame, USHORT * usLen )
000000 b538 PUSH {r3-r5,lr}
;;;149 {
;;;150 USHORT usRegAddress;
;;;151 UCHAR ucBuf[2];
;;;152
;;;153 eMBException eStatus = MB_EX_NONE;
000002 2400 MOVS r4,#0
;;;154 eMBErrorCode eRegStatus;
;;;155
;;;156 if( *usLen == ( MB_PDU_FUNC_WRITE_SIZE + MB_PDU_SIZE_MIN ) )
000004 8809 LDRH r1,[r1,#0]
000006 2905 CMP r1,#5
000008 d002 BEQ |L2.16|
;;;157 {
;;;158 usRegAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_ADDR_OFF] << 8 );
;;;159 usRegAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_ADDR_OFF + 1] );
;;;160 usRegAddress++;
;;;161
;;;162 if( ( pucFrame[MB_PDU_FUNC_WRITE_VALUE_OFF + 1] == 0x00 ) &&
;;;163 ( ( pucFrame[MB_PDU_FUNC_WRITE_VALUE_OFF] == 0xFF ) ||
;;;164 ( pucFrame[MB_PDU_FUNC_WRITE_VALUE_OFF] == 0x00 ) ) )
;;;165 {
;;;166 ucBuf[1] = 0;
;;;167 if( pucFrame[MB_PDU_FUNC_WRITE_VALUE_OFF] == 0xFF )
;;;168 {
;;;169 ucBuf[0] = 1;
;;;170 }
;;;171 else
;;;172 {
;;;173 ucBuf[0] = 0;
;;;174 }
;;;175 eRegStatus =
;;;176 eMBRegCoilsCB( &ucBuf[0], usRegAddress, 1, MB_REG_WRITE );
;;;177
;;;178 /* If an error occured convert it into a Modbus exception. */
;;;179 if( eRegStatus != MB_ENOERR )
;;;180 {
;;;181 eStatus = prveMBError2Exception( eRegStatus );
;;;182 }
;;;183 }
;;;184 else
;;;185 {
;;;186 eStatus = MB_EX_ILLEGAL_DATA_VALUE;
;;;187 }
;;;188 }
;;;189 else
;;;190 {
;;;191 /* Can't be a valid write coil register request because the length
;;;192 * is incorrect. */
;;;193 eStatus = MB_EX_ILLEGAL_DATA_VALUE;
00000a 2403 MOVS r4,#3
|L2.12|
;;;194 }
;;;195 return eStatus;
00000c 4620 MOV r0,r4
;;;196 }
00000e bd38 POP {r3-r5,pc}
|L2.16|
000010 7841 LDRB r1,[r0,#1] ;158
000012 0209 LSLS r1,r1,#8 ;158
000014 7882 LDRB r2,[r0,#2] ;159
000016 430a ORRS r2,r2,r1 ;159
000018 1c52 ADDS r2,r2,#1 ;160
00001a b291 UXTH r1,r2 ;160
00001c 7902 LDRB r2,[r0,#4] ;162
00001e b91a CBNZ r2,|L2.40|
000020 78c2 LDRB r2,[r0,#3] ;163
000022 2aff CMP r2,#0xff ;163
000024 d002 BEQ |L2.44|
000026 b10a CBZ r2,|L2.44|
|L2.40|
000028 2403 MOVS r4,#3 ;186
00002a e7ef B |L2.12|
|L2.44|
00002c 2200 MOVS r2,#0 ;166
00002e f88d2001 STRB r2,[sp,#1] ;166
000032 78c0 LDRB r0,[r0,#3] ;167
000034 28ff CMP r0,#0xff ;167
000036 d00c BEQ |L2.82|
000038 f88d2000 STRB r2,[sp,#0] ;173
|L2.60|
00003c 2301 MOVS r3,#1 ;175
00003e 461a MOV r2,r3 ;175
000040 4668 MOV r0,sp ;175
000042 f7fffffe BL eMBRegCoilsCB
000046 2800 CMP r0,#0 ;179
000048 d0e0 BEQ |L2.12|
00004a f7fffffe BL prveMBError2Exception
00004e 4604 MOV r4,r0 ;181
000050 e7dc B |L2.12|
|L2.82|
000052 2001 MOVS r0,#1 ;169
000054 f88d0000 STRB r0,[sp,#0] ;169
000058 e7f0 B |L2.60|
;;;197
ENDP
AREA ||i.eMBFuncWriteMultipleCoils||, CODE, READONLY, ALIGN=1
eMBFuncWriteMultipleCoils PROC
;;;201 eMBException
;;;202 eMBFuncWriteMultipleCoils( UCHAR * pucFrame, USHORT * usLen )
000000 e92d41f0 PUSH {r4-r8,lr}
;;;203 {
000004 460d MOV r5,r1
;;;204 USHORT usRegAddress;
;;;205 USHORT usCoilCnt;
;;;206 UCHAR ucByteCount;
;;;207 UCHAR ucByteCountVerify;
;;;208
;;;209 eMBException eStatus = MB_EX_NONE;
000006 2400 MOVS r4,#0
;;;210 eMBErrorCode eRegStatus;
;;;211
;;;212 if( *usLen > ( MB_PDU_FUNC_WRITE_SIZE + MB_PDU_SIZE_MIN ) )
000008 8829 LDRH r1,[r5,#0]
00000a 2905 CMP r1,#5
00000c d927 BLS |L3.94|
;;;213 {
;;;214 usRegAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_MUL_ADDR_OFF] << 8 );
00000e 7841 LDRB r1,[r0,#1]
000010 0209 LSLS r1,r1,#8
;;;215 usRegAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_MUL_ADDR_OFF + 1] );
000012 7882 LDRB r2,[r0,#2]
000014 430a ORRS r2,r2,r1
;;;216 usRegAddress++;
000016 1c52 ADDS r2,r2,#1
000018 b291 UXTH r1,r2
;;;217
;;;218 usCoilCnt = ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_MUL_COILCNT_OFF] << 8 );
00001a 78c2 LDRB r2,[r0,#3]
00001c 0213 LSLS r3,r2,#8
;;;219 usCoilCnt |= ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_MUL_COILCNT_OFF + 1] );
00001e 7902 LDRB r2,[r0,#4]
000020 431a ORRS r2,r2,r3
;;;220
;;;221 ucByteCount = pucFrame[MB_PDU_FUNC_WRITE_MUL_BYTECNT_OFF];
000022 7946 LDRB r6,[r0,#5]
;;;222
;;;223 /* Compute the number of expected bytes in the request. */
;;;224 if( ( usCoilCnt & 0x0007 ) != 0 )
000024 0753 LSLS r3,r2,#29
000026 d004 BEQ |L3.50|
;;;225 {
;;;226 ucByteCountVerify = ( UCHAR )( usCoilCnt / 8 + 1 );
000028 2301 MOVS r3,#1
00002a eb0303d2 ADD r3,r3,r2,LSR #3
00002e b2db UXTB r3,r3
000030 e001 B |L3.54|
|L3.50|
;;;227 }
;;;228 else
;;;229 {
;;;230 ucByteCountVerify = ( UCHAR )( usCoilCnt / 8 );
000032 f3c203c7 UBFX r3,r2,#3,#8
|L3.54|
;;;231 }
;;;232
;;;233 if( ( usCoilCnt >= 1 ) &&
000036 1e57 SUBS r7,r2,#1
000038 f5b76ff6 CMP r7,#0x7b0
00003c d20d BCS |L3.90|
;;;234 ( usCoilCnt <= MB_PDU_FUNC_WRITE_MUL_COILCNT_MAX ) &&
;;;235 ( ucByteCountVerify == ucByteCount ) )
00003e 42b3 CMP r3,r6
000040 d10b BNE |L3.90|
;;;236 {
;;;237 eRegStatus =
000042 2301 MOVS r3,#1
000044 1d80 ADDS r0,r0,#6
000046 f7fffffe BL eMBRegCoilsCB
;;;238 eMBRegCoilsCB( &pucFrame[MB_PDU_FUNC_WRITE_MUL_VALUES_OFF],
;;;239 usRegAddress, usCoilCnt, MB_REG_WRITE );
;;;240
;;;241 /* If an error occured convert it into a Modbus exception. */
;;;242 if( eRegStatus != MB_ENOERR )
00004a b118 CBZ r0,|L3.84|
;;;243 {
;;;244 eStatus = prveMBError2Exception( eRegStatus );
00004c f7fffffe BL prveMBError2Exception
000050 4604 MOV r4,r0
000052 e005 B |L3.96|
|L3.84|
;;;245 }
;;;246 else
;;;247 {
;;;248 /* The response contains the function code, the starting address
;;;249 * and the quantity of registers. We reuse the old values in the
;;;250 * buffer because they are still valid. */
;;;251 *usLen = MB_PDU_FUNC_WRITE_MUL_BYTECNT_OFF;
000054 2005 MOVS r0,#5
000056 8028 STRH r0,[r5,#0]
000058 e002 B |L3.96|
|L3.90|
;;;252 }
;;;253 }
;;;254 else
;;;255 {
;;;256 eStatus = MB_EX_ILLEGAL_DATA_VALUE;
00005a 2403 MOVS r4,#3
00005c e000 B |L3.96|
|L3.94|
;;;257 }
;;;258 }
;;;259 else
;;;260 {
;;;261 /* Can't be a valid write coil register request because the length
;;;262 * is incorrect. */
;;;263 eStatus = MB_EX_ILLEGAL_DATA_VALUE;
00005e 2403 MOVS r4,#3
|L3.96|
;;;264 }
;;;265 return eStatus;
000060 4620 MOV r0,r4
;;;266 }
000062 e8bd81f0 POP {r4-r8,pc}
;;;267
ENDP
;*** Start embedded assembler ***
#line 1 "..\\..\\MODBUS\\modbus\\functions\\mbfunccoils.c"
AREA ||.rev16_text||, CODE
THUMB
EXPORT |__asm___13_mbfunccoils_c_e12d674a____REV16|
#line 129 "..\\..\\Libraries\\CMSIS\\Include\\core_cmInstr.h"
|__asm___13_mbfunccoils_c_e12d674a____REV16| PROC
#line 130
rev16 r0, r0
bx lr
ENDP
AREA ||.revsh_text||, CODE
THUMB
EXPORT |__asm___13_mbfunccoils_c_e12d674a____REVSH|
#line 144
|__asm___13_mbfunccoils_c_e12d674a____REVSH| PROC
#line 145
revsh r0, r0
bx lr
ENDP
AREA ||.rrx_text||, CODE
THUMB
EXPORT |__asm___13_mbfunccoils_c_e12d674a____RRX|
#line 300
|__asm___13_mbfunccoils_c_e12d674a____RRX| PROC
#line 301
rrx r0, r0
bx lr
ENDP
;*** End embedded assembler ***