modbus.txt
11.7 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
; 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\modbus.o --asm_dir=.\Flash\List\ --list_dir=.\Flash\List\ --depend=.\flash\obj\modbus.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\modbus.crf ..\..\User\libapp\modbus.c]
THUMB
AREA ||i.eMBRegCoilsCB||, CODE, READONLY, ALIGN=1
eMBRegCoilsCB PROC
;;;107 eMBErrorCode
;;;108 eMBRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNCoils, eMBRegisterMode eMode )
000000 2000 MOVS r0,#0
;;;109 {
;;;110 eMBErrorCode eStatus = MB_ENOERR;
;;;111 // int iRegIndex;
;;;112
;;;113
;;;114 // if((usAddress >= REG_HOLDING_START)&&\
;;;115 // ((usAddress+usNCoils) <= (REG_HOLDING_START + REG_HOLDING_NREGS)))
;;;116 // {
;;;117 // iRegIndex = (int)(usAddress - usRegHoldingStart);
;;;118 // switch(eMode)
;;;119 // {
;;;120 // case MB_REG_READ://¶Á MB_REG_READ = 0
;;;121 // while(usNCoils > 0)
;;;122 // {
;;;123 // *pucRegBuffer++ = (u8)(usRegHoldingBuf[iRegIndex] >> 8);
;;;124 // *pucRegBuffer++ = (u8)(usRegHoldingBuf[iRegIndex] & 0xFF);
;;;125 // iRegIndex++;
;;;126 // usNCoils--;
;;;127 // }
;;;128 // break;
;;;129 // case MB_REG_WRITE://д MB_REG_WRITE = 1
;;;130 // while(usNCoils > 0)
;;;131 // {
;;;132 // usRegHoldingBuf[iRegIndex] = *pucRegBuffer++ << 8;
;;;133 // usRegHoldingBuf[iRegIndex] |= *pucRegBuffer++;
;;;134 // iRegIndex++;
;;;135 // usNCoils--;
;;;136 // }
;;;137 // }
;;;138 // }
;;;139 // else//´íÎó
;;;140 // {
;;;141 // eStatus = MB_ENOREG;
;;;142 // }
;;;143 //
;;;144 return eStatus;
;;;145 }
000002 4770 BX lr
;;;146 /****************************************************************************
ENDP
AREA ||i.eMBRegDiscreteCB||, CODE, READONLY, ALIGN=1
eMBRegDiscreteCB PROC
;;;155 eMBErrorCode
;;;156 eMBRegDiscreteCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNDiscrete )
000000 2001 MOVS r0,#1
;;;157 {
;;;158 // ( void )pucRegBuffer;
;;;159 // ( void )usAddress;
;;;160 // ( void )usNDiscrete;
;;;161 return MB_ENOREG;
;;;162 }
000002 4770 BX lr
ENDP
AREA ||i.eMBRegHoldingCB||, CODE, READONLY, ALIGN=2
eMBRegHoldingCB PROC
;;;52 eMBErrorCode
;;;53 eMBRegHoldingCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs, eMBRegisterMode eMode )
000000 e92d41f0 PUSH {r4-r8,lr}
;;;54 {
000004 4605 MOV r5,r0
000006 4614 MOV r4,r2
;;;55 eMBErrorCode eStatus = MB_ENOERR;
000008 2700 MOVS r7,#0
;;;56 int iRegIndex;
;;;57 u16 *PRT=(u16*)pucRegBuffer;
;;;58
;;;59 if((usAddress >= REG_HOLDING_START)&&
00000a 1908 ADDS r0,r1,r4
00000c f5b06f7a CMP r0,#0xfa0
000010 d822 BHI |L3.88|
;;;60 ((usAddress+usNRegs) <= (REG_HOLDING_START + REG_HOLDING_NREGS)))
;;;61 {
;;;62 iRegIndex = (int)(usAddress - usRegHoldingStart);
000012 4813 LDR r0,|L3.96|
000014 8840 LDRH r0,[r0,#2] ; usRegHoldingStart
000016 1a0e SUBS r6,r1,r0
;;;63 switch(eMode)
;;;64 {
;;;65 case MB_REG_READ://¶Á MB_REG_READ = 0
;;;66 while(usNRegs > 0)
;;;67 {
;;;68 *PRT++ = __REV16(usRegHoldingBuf[iRegIndex++]);
000018 f8df8048 LDR r8,|L3.100|
00001c b163 CBZ r3,|L3.56|
00001e 2b01 CMP r3,#1 ;63
000020 d11b BNE |L3.90|
000022 e016 B |L3.82|
|L3.36|
000024 4630 MOV r0,r6
000026 1c76 ADDS r6,r6,#1
000028 f8380010 LDRH r0,[r8,r0,LSL #1]
00002c f7fffffe BL __asm___8_modbus_c_38e931c6____REV16
000030 f8250b02 STRH r0,[r5],#2
;;;69 //*pucRegBuffer++ = (u8)(usRegHoldingBuf[iRegIndex] >> 8);
;;;70 //*pucRegBuffer++ = (u8)(usRegHoldingBuf[iRegIndex] & 0xFF);
;;;71 //iRegIndex++;
;;;72 usNRegs--;
000034 1e64 SUBS r4,r4,#1
000036 b2a4 UXTH r4,r4
|L3.56|
000038 2c00 CMP r4,#0 ;66
00003a d1f3 BNE |L3.36|
00003c e00d B |L3.90|
|L3.62|
;;;73 }
;;;74 break;
;;;75 case MB_REG_WRITE://д MB_REG_WRITE = 0
;;;76 while(usNRegs > 0)
;;;77 {
;;;78 usRegHoldingBuf[iRegIndex++] = __REV16(*PRT++);
00003e f8350b02 LDRH r0,[r5],#2
000042 f7fffffe BL __asm___8_modbus_c_38e931c6____REV16
000046 4631 MOV r1,r6
000048 1c76 ADDS r6,r6,#1
00004a f8280011 STRH r0,[r8,r1,LSL #1]
;;;79 //usRegHoldingBuf[iRegIndex] = *pucRegBuffer++ << 8;
;;;80 // usRegHoldingBuf[iRegIndex] |= *pucRegBuffer++;
;;;81 //iRegIndex++;
;;;82 usNRegs--;
00004e 1e64 SUBS r4,r4,#1
000050 b2a4 UXTH r4,r4
|L3.82|
000052 2c00 CMP r4,#0 ;76
000054 d1f3 BNE |L3.62|
000056 e000 B |L3.90|
|L3.88|
;;;83 }
;;;84 }
;;;85 }
;;;86 else//´íÎó
;;;87 {
;;;88 eStatus = MB_ENOREG;
000058 2701 MOVS r7,#1
|L3.90|
;;;89 }
;;;90
;;;91 return eStatus;
00005a 4638 MOV r0,r7
;;;92 }
00005c e8bd81f0 POP {r4-r8,pc}
;;;93
ENDP
|L3.96|
DCD ||.data||
|L3.100|
DCD ||area_number.7||
AREA ||i.eMBRegInputCB||, CODE, READONLY, ALIGN=2
eMBRegInputCB PROC
;;;11 eMBErrorCode
;;;12 eMBRegInputCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs )
000000 e92d41f0 PUSH {r4-r8,lr}
;;;13 {
000004 4605 MOV r5,r0
000006 4614 MOV r4,r2
;;;14 eMBErrorCode eStatus = MB_ENOERR;
000008 2700 MOVS r7,#0
;;;15 int iRegIndex;
;;;16 u16 *PRT=(u16*)pucRegBuffer;
;;;17
;;;18 if( ( usAddress >= REG_INPUT_START )
00000a 1908 ADDS r0,r1,r4
00000c 2832 CMP r0,#0x32
00000e d812 BHI |L4.54|
;;;19 && ( usAddress + usNRegs <= REG_INPUT_START + REG_INPUT_NREGS ) )
;;;20 {
;;;21 iRegIndex = ( int )( usAddress - usRegInputStart );
000010 480b LDR r0,|L4.64|
000012 8800 LDRH r0,[r0,#0] ; usRegInputStart
000014 1a0e SUBS r6,r1,r0
;;;22 while( usNRegs > 0 )
;;;23 {
;;;24 *PRT++ = __REV16(usRegHoldingBuf[iRegIndex++]);
000016 f8df802c LDR r8,|L4.68|
00001a e009 B |L4.48|
|L4.28|
00001c 4630 MOV r0,r6
00001e 1c76 ADDS r6,r6,#1
000020 f8380010 LDRH r0,[r8,r0,LSL #1]
000024 f7fffffe BL __asm___8_modbus_c_38e931c6____REV16
000028 f8250b02 STRH r0,[r5],#2
;;;25 // *pucRegBuffer++ = ( UCHAR )( usRegInputBuf[iRegIndex] >> 8 );
;;;26 // *pucRegBuffer++ = ( UCHAR )( usRegInputBuf[iRegIndex] & 0xFF );
;;;27 // iRegIndex++;
;;;28 usNRegs--;
00002c 1e64 SUBS r4,r4,#1
00002e b2a4 UXTH r4,r4
|L4.48|
000030 2c00 CMP r4,#0 ;22
000032 d1f3 BNE |L4.28|
000034 e000 B |L4.56|
|L4.54|
;;;29 }
;;;30 }
;;;31 else
;;;32 {
;;;33 eStatus = MB_ENOREG;
000036 2701 MOVS r7,#1
|L4.56|
;;;34 }
;;;35
;;;36 return eStatus;
000038 4638 MOV r0,r7
;;;37 }
00003a e8bd81f0 POP {r4-r8,pc}
;;;38
ENDP
00003e 0000 DCW 0x0000
|L4.64|
DCD ||.data||
|L4.68|
DCD ||area_number.7||
AREA ||.bss||, DATA, NOINIT, ALIGN=1
usRegInputBuf
% 100
AREA ||area_number.7||, DATA, NOINIT, ALIGN=1
EXPORTAS ||area_number.7||, ||.bss||
usRegHoldingBuf
% 8000
AREA ||.data||, DATA, ALIGN=1
usRegInputStart
000000 0000 DCW 0x0000
usRegHoldingStart
000002 0000 DCW 0x0000
;*** Start embedded assembler ***
#line 1 "..\\..\\User\\libapp\\modbus.c"
AREA ||.rev16_text||, CODE
THUMB
EXPORT |__asm___8_modbus_c_38e931c6____REV16|
#line 129 "..\\..\\Libraries\\CMSIS\\Include\\core_cmInstr.h"
|__asm___8_modbus_c_38e931c6____REV16| PROC
#line 130
rev16 r0, r0
bx lr
ENDP
AREA ||.revsh_text||, CODE
THUMB
EXPORT |__asm___8_modbus_c_38e931c6____REVSH|
#line 144
|__asm___8_modbus_c_38e931c6____REVSH| PROC
#line 145
revsh r0, r0
bx lr
ENDP
AREA ||.rrx_text||, CODE
THUMB
EXPORT |__asm___8_modbus_c_38e931c6____RRX|
#line 300
|__asm___8_modbus_c_38e931c6____RRX| PROC
#line 301
rrx r0, r0
bx lr
ENDP
;*** End embedded assembler ***