bsp_spi.txt
13.3 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
; 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\bsp_spi.o --asm_dir=.\Flash\List\ --list_dir=.\Flash\List\ --depend=.\flash\obj\bsp_spi.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\bsp_spi.crf ..\..\User\bsp\BSP\bsp_spi.c]
THUMB
AREA ||i.SpiInit||, CODE, READONLY, ALIGN=2
SpiInit PROC
;;;81
;;;82 void SpiInit()
000000 b510 PUSH {r4,lr}
;;;83 {
;;;84 reset_break_gpio_init(); // 复位与中断管脚初始化
000002 f7fffffe BL reset_break_gpio_init
;;;85
;;;86 spi_gpio_init(); // SPI管脚初始化
000006 f7fffffe BL spi_gpio_init
;;;87
;;;88 spiinitailize(); // SPI配置初始化
00000a f7fffffe BL spiinitailize
;;;89 //printf("111111111111111111111111\r\n");
;;;90 reg_wizchip_spi_cbfunc(spi_read_byte,spi_send_byte); // SPI读写数据函数映射
00000e 4905 LDR r1,|L1.36|
000010 4805 LDR r0,|L1.40|
000012 f7fffffe BL reg_wizchip_spi_cbfunc
;;;91 reg_wizchip_cs_cbfunc(cs_low,cs_high); // SPI片选控制函数映射
000016 e8bd4010 POP {r4,lr}
00001a 4904 LDR r1,|L1.44|
00001c 4804 LDR r0,|L1.48|
00001e f7ffbffe B.W reg_wizchip_cs_cbfunc
;;;92 }
;;;93
ENDP
000022 0000 DCW 0x0000
|L1.36|
DCD spi_send_byte
|L1.40|
DCD spi_read_byte
|L1.44|
DCD cs_high
|L1.48|
DCD cs_low
AREA ||i.cs_high||, CODE, READONLY, ALIGN=2
cs_high PROC
;;;53
;;;54 void cs_high(void) // A4---CS
000000 2110 MOVS r1,#0x10
;;;55 {
;;;56 GPIO_SetBits(GPIOA,GPIO_Pin_4);
000002 4801 LDR r0,|L2.8|
000004 f7ffbffe B.W GPIO_SetBits
;;;57 }
;;;58
ENDP
|L2.8|
DCD 0x40020000
AREA ||i.cs_low||, CODE, READONLY, ALIGN=2
cs_low PROC
;;;58
;;;59 void cs_low(void)
000000 2110 MOVS r1,#0x10
;;;60 {
;;;61 GPIO_ResetBits(GPIOA,GPIO_Pin_4);
000002 4801 LDR r0,|L3.8|
000004 f7ffbffe B.W GPIO_ResetBits
;;;62 }
;;;63
ENDP
|L3.8|
DCD 0x40020000
AREA ||i.spi_gpio_init||, CODE, READONLY, ALIGN=2
spi_gpio_init PROC
;;;8
;;;9 void spi_gpio_init(void)
000000 b57c PUSH {r2-r6,lr}
;;;10 {
;;;11 GPIO_InitTypeDef GPIO_InitStructure;
;;;12 // RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOD, ENABLE);
;;;13 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA,ENABLE);
000002 2101 MOVS r1,#1
000004 4608 MOV r0,r1
000006 f7fffffe BL RCC_AHB1PeriphClockCmd
;;;14
;;;15 GPIO_PinAFConfig(GPIOA, GPIO_PinSource5, GPIO_AF_SPI1); // 2020-2-12 add
00000a 4d15 LDR r5,|L4.96|
00000c 2205 MOVS r2,#5
00000e 4611 MOV r1,r2
000010 4628 MOV r0,r5
000012 f7fffffe BL GPIO_PinAFConfig
;;;16 GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_SPI1);
000016 2205 MOVS r2,#5
000018 2106 MOVS r1,#6
00001a 4628 MOV r0,r5
00001c f7fffffe BL GPIO_PinAFConfig
;;;17 GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_SPI1);
000020 2205 MOVS r2,#5
000022 2107 MOVS r1,#7
000024 4628 MOV r0,r5
000026 f7fffffe BL GPIO_PinAFConfig
;;;18
;;;19 /* PC-10 -> SCL | PC-11 -> MISO | PC-12 -> MOSI */
;;;20 // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
;;;21 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
00002a 2102 MOVS r1,#2
00002c f88d1004 STRB r1,[sp,#4]
;;;22 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
000030 2400 MOVS r4,#0
000032 f88d4006 STRB r4,[sp,#6]
;;;23 // GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; // ADD 2020-2-6
;;;24 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
000036 21e0 MOVS r1,#0xe0
000038 9100 STR r1,[sp,#0]
;;;25 GPIO_Init(GPIOA, &GPIO_InitStructure);
00003a 4669 MOV r1,sp
00003c 4628 MOV r0,r5
00003e f7fffffe BL GPIO_Init
;;;26 /* PA-04 -> CS */
;;;27 // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
;;;28 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
000042 2101 MOVS r1,#1
000044 f88d1004 STRB r1,[sp,#4]
;;;29 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
000048 f88d4006 STRB r4,[sp,#6]
;;;30 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; // ADD 2020-2-6
00004c f88d4007 STRB r4,[sp,#7]
;;;31 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
000050 2010 MOVS r0,#0x10
000052 9000 STR r0,[sp,#0]
;;;32 GPIO_Init(GPIOA, &GPIO_InitStructure);
000054 4669 MOV r1,sp
000056 4628 MOV r0,r5
000058 f7fffffe BL GPIO_Init
;;;33 }
00005c bd7c POP {r2-r6,pc}
;;;34
ENDP
00005e 0000 DCW 0x0000
|L4.96|
DCD 0x40020000
AREA ||i.spi_read_byte||, CODE, READONLY, ALIGN=2
spi_read_byte PROC
;;;71
;;;72 u8 spi_read_byte(void)
000000 b510 PUSH {r4,lr}
;;;73 {
;;;74 while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);
000002 4c0b LDR r4,|L5.48|
|L5.4|
000004 2102 MOVS r1,#2
000006 4620 MOV r0,r4
000008 f7fffffe BL SPI_I2S_GetFlagStatus
00000c 2800 CMP r0,#0
00000e d0f9 BEQ |L5.4|
;;;75 SPI_I2S_SendData(SPI1, 0);
000010 2100 MOVS r1,#0
000012 4620 MOV r0,r4
000014 f7fffffe BL SPI_I2S_SendData
|L5.24|
;;;76 while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
000018 2101 MOVS r1,#1
00001a 4620 MOV r0,r4
00001c f7fffffe BL SPI_I2S_GetFlagStatus
000020 2800 CMP r0,#0
000022 d0f9 BEQ |L5.24|
;;;77 return SPI_I2S_ReceiveData(SPI1);
000024 4620 MOV r0,r4
000026 f7fffffe BL SPI_I2S_ReceiveData
00002a b2c0 UXTB r0,r0
;;;78 }
00002c bd10 POP {r4,pc}
;;;79
ENDP
00002e 0000 DCW 0x0000
|L5.48|
DCD 0x40013000
AREA ||i.spi_send_byte||, CODE, READONLY, ALIGN=2
spi_send_byte PROC
;;;63
;;;64 void spi_send_byte(u8 byte)
000000 b570 PUSH {r4-r6,lr}
;;;65 {
000002 4605 MOV r5,r0
;;;66 while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET); // SPI_I2S_FLAG_TXE--发送缓冲区空
000004 4c0a LDR r4,|L6.48|
|L6.6|
000006 2102 MOVS r1,#2
000008 4620 MOV r0,r4
00000a f7fffffe BL SPI_I2S_GetFlagStatus
00000e 2800 CMP r0,#0
000010 d0f9 BEQ |L6.6|
;;;67 SPI_I2S_SendData(SPI1, byte);
000012 4629 MOV r1,r5
000014 4620 MOV r0,r4
000016 f7fffffe BL SPI_I2S_SendData
|L6.26|
;;;68 while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
00001a 2101 MOVS r1,#1
00001c 4620 MOV r0,r4
00001e f7fffffe BL SPI_I2S_GetFlagStatus
000022 2800 CMP r0,#0
000024 d0f9 BEQ |L6.26|
;;;69 SPI_I2S_ReceiveData(SPI1);
000026 4620 MOV r0,r4
000028 e8bd4070 POP {r4-r6,lr}
00002c f7ffbffe B.W SPI_I2S_ReceiveData
;;;70 }
;;;71
ENDP
|L6.48|
DCD 0x40013000
AREA ||i.spiinitailize||, CODE, READONLY, ALIGN=2
spiinitailize PROC
;;;34
;;;35 void spiinitailize(void)
000000 b510 PUSH {r4,lr}
;;;36 {
000002 b086 SUB sp,sp,#0x18
;;;37 SPI_InitTypeDef SPI_InitStructure;
;;;38 RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); // PA5 A6 A7---SPI1
000004 2101 MOVS r1,#1
000006 0308 LSLS r0,r1,#12
000008 f7fffffe BL RCC_APB2PeriphClockCmd
;;;39
;;;40 SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
00000c 2000 MOVS r0,#0
00000e f8ad0004 STRH r0,[sp,#4]
;;;41 SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
000012 f8ad0008 STRH r0,[sp,#8]
;;;42 SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
000016 2102 MOVS r1,#2
000018 f8ad100a STRH r1,[sp,#0xa]
;;;43 SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
00001c 2101 MOVS r1,#1
00001e f8ad100c STRH r1,[sp,#0xc]
;;;44 SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
000022 0249 LSLS r1,r1,#9
000024 f8ad100e STRH r1,[sp,#0xe]
;;;45 SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;
000028 2108 MOVS r1,#8
00002a f8ad1010 STRH r1,[sp,#0x10]
;;;46 SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
00002e f8ad0012 STRH r0,[sp,#0x12]
;;;47 SPI_InitStructure.SPI_CRCPolynomial = 7;
000032 2007 MOVS r0,#7
000034 f8ad0014 STRH r0,[sp,#0x14]
;;;48 SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
000038 f44f7082 MOV r0,#0x104
00003c f8ad0006 STRH r0,[sp,#6]
;;;49 SPI_Init(SPI1, &SPI_InitStructure);
000040 4c05 LDR r4,|L7.88|
000042 a901 ADD r1,sp,#4
000044 4620 MOV r0,r4
000046 f7fffffe BL SPI_Init
;;;50
;;;51 SPI_Cmd(SPI1,ENABLE);
00004a 2101 MOVS r1,#1
00004c 4620 MOV r0,r4
00004e f7fffffe BL SPI_Cmd
;;;52 }
000052 b006 ADD sp,sp,#0x18
000054 bd10 POP {r4,pc}
;;;53
ENDP
000056 0000 DCW 0x0000
|L7.88|
DCD 0x40013000
;*** Start embedded assembler ***
#line 1 "..\\..\\User\\bsp\\BSP\\bsp_spi.c"
AREA ||.rev16_text||, CODE
THUMB
EXPORT |__asm___9_bsp_spi_c_612b0872____REV16|
#line 129 "..\\..\\Libraries\\CMSIS\\Include\\core_cmInstr.h"
|__asm___9_bsp_spi_c_612b0872____REV16| PROC
#line 130
rev16 r0, r0
bx lr
ENDP
AREA ||.revsh_text||, CODE
THUMB
EXPORT |__asm___9_bsp_spi_c_612b0872____REVSH|
#line 144
|__asm___9_bsp_spi_c_612b0872____REVSH| PROC
#line 145
revsh r0, r0
bx lr
ENDP
AREA ||.rrx_text||, CODE
THUMB
EXPORT |__asm___9_bsp_spi_c_612b0872____RRX|
#line 300
|__asm___9_bsp_spi_c_612b0872____RRX| PROC
#line 301
rrx r0, r0
bx lr
ENDP
;*** End embedded assembler ***