📄 spi_flash.txt
字号:
0000a0 b2e4 UXTB r4,r4 ;255
0000a2 d1f1 BNE |L8.136|
;;;260 }
;;;261
;;;262 if(NumOfSingle != 0)
0000a4 f1ba0f00 CMP r10,#0
0000a8 d006 BEQ |L8.184|
;;;263 {
;;;264 SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumOfSingle);
0000aa 4652 MOV r2,r10
0000ac 4641 MOV r1,r8
0000ae 4628 MOV r0,r5
|L8.176|
0000b0 e8bd47f0 POP {r4-r10,lr}
0000b4 f7ffbffe B.W SPI_FLASH_PageWrite
|L8.184|
;;;265 }
;;;266 }
;;;267 }
;;;268 }
0000b8 e8bd87f0 POP {r4-r10,pc}
;;;269
ENDP
AREA ||i.SPI_FLASH_BufferRead||, CODE, READONLY, ALIGN=2
SPI_FLASH_BufferRead PROC
;;;280 void SPI_FLASH_BufferRead(u8* pBuffer, u32 ReadAddr, u16 NumByteToRead)
;;;281 {
000000 e92d41f0 PUSH {r4-r8,lr}
;;;282 /* Select the FLASH: Chip Select low */
;;;283 SPI_FLASH_CS_LOW();
000004 4e13 LDR r6,|L9.84|
000006 4604 MOV r4,r0 ;281
000008 460f MOV r7,r1 ;281
00000a 4615 MOV r5,r2 ;281
00000c 2101 MOVS r1,#1
00000e 4630 MOV r0,r6
000010 f7fffffe BL GPIO_ResetBits
;;;284
;;;285 /* Send "Read from Memory " instruction */
;;;286 SPI_FLASH_SendByte(READ);
000014 2003 MOVS r0,#3
000016 f7fffffe BL SPI_FLASH_SendByte
;;;287
;;;288 /* Send ReadAddr high nibble address byte to read from */
;;;289 SPI_FLASH_SendByte((ReadAddr & 0xFF0000) >> 16);
00001a f3c74007 UBFX r0,r7,#16,#8
00001e f7fffffe BL SPI_FLASH_SendByte
;;;290 /* Send ReadAddr medium nibble address byte to read from */
;;;291 SPI_FLASH_SendByte((ReadAddr& 0xFF00) >> 8);
000022 f3c72007 UBFX r0,r7,#8,#8
000026 f7fffffe BL SPI_FLASH_SendByte
;;;292 /* Send ReadAddr low nibble address byte to read from */
;;;293 SPI_FLASH_SendByte(ReadAddr & 0xFF);
00002a b2f8 UXTB r0,r7
00002c f7fffffe BL SPI_FLASH_SendByte
;;;294
;;;295 while(NumByteToRead--) /* while there is data to be read */
000030 e004 B |L9.60|
|L9.50|
;;;296 {
;;;297 /* Read a byte from the FLASH */
;;;298 *pBuffer = SPI_FLASH_SendByte(Dummy_Byte);
000032 20a5 MOVS r0,#0xa5
000034 f7fffffe BL SPI_FLASH_SendByte
000038 f8040b01 STRB r0,[r4],#1
|L9.60|
00003c 0028 MOVS r0,r5 ;295
00003e f1a50501 SUB r5,r5,#1 ;295
000042 b2ad UXTH r5,r5 ;295
000044 d1f5 BNE |L9.50|
;;;299 /* Point to the next location where the byte read will be saved */
;;;300 pBuffer++;
;;;301 }
;;;302
;;;303 /* Deselect the FLASH: Chip Select high */
;;;304 SPI_FLASH_CS_HIGH();
000046 4630 MOV r0,r6
000048 e8bd41f0 POP {r4-r8,lr}
00004c 2101 MOVS r1,#1
00004e f7ffbffe B.W GPIO_SetBits
;;;305 }
;;;306
ENDP
000052 0000 DCW 0x0000
|L9.84|
000054 40010c00 DCD 0x40010c00
AREA ||i.SPI_FLASH_ReadID||, CODE, READONLY, ALIGN=2
SPI_FLASH_ReadID PROC
;;;314 u32 SPI_FLASH_ReadID(void)
;;;315 {
000000 e92d41f0 PUSH {r4-r8,lr}
;;;316 u32 Temp = 0, Temp0 = 0, Temp1 = 0, Temp2 = 0;
;;;317
;;;318 /* Select the FLASH: Chip Select low */
;;;319 SPI_FLASH_CS_LOW();
000004 4f0e LDR r7,|L10.64|
000006 2101 MOVS r1,#1
000008 4638 MOV r0,r7
00000a f7fffffe BL GPIO_ResetBits
;;;320
;;;321 /* Send "RDID " instruction */
;;;322 SPI_FLASH_SendByte(0x9F);
00000e 209f MOVS r0,#0x9f
000010 f7fffffe BL SPI_FLASH_SendByte
;;;323
;;;324 /* Read a byte from the FLASH */
;;;325 Temp0 = SPI_FLASH_SendByte(Dummy_Byte);
000014 20a5 MOVS r0,#0xa5
000016 f7fffffe BL SPI_FLASH_SendByte
00001a 4605 MOV r5,r0
;;;326
;;;327 /* Read a byte from the FLASH */
;;;328 Temp1 = SPI_FLASH_SendByte(Dummy_Byte);
00001c 20a5 MOVS r0,#0xa5
00001e f7fffffe BL SPI_FLASH_SendByte
000022 4604 MOV r4,r0
;;;329
;;;330 /* Read a byte from the FLASH */
;;;331 Temp2 = SPI_FLASH_SendByte(Dummy_Byte);
000024 20a5 MOVS r0,#0xa5
000026 f7fffffe BL SPI_FLASH_SendByte
00002a 4606 MOV r6,r0
;;;332
;;;333 /* Deselect the FLASH: Chip Select high */
;;;334 SPI_FLASH_CS_HIGH();
00002c 2101 MOVS r1,#1
00002e 4638 MOV r0,r7
000030 f7fffffe BL GPIO_SetBits
;;;335
;;;336 Temp = (Temp0 << 16) | (Temp1 << 8) | Temp2;
000034 0428 LSLS r0,r5,#16
000036 ea402004 ORR r0,r0,r4,LSL #8
00003a 4330 ORRS r0,r0,r6
;;;337
;;;338 return Temp;
;;;339 }
00003c e8bd81f0 POP {r4-r8,pc}
;;;340
ENDP
|L10.64|
000040 40010c00 DCD 0x40010c00
AREA ||i.SPI_FLASH_StartReadSequence||, CODE, READONLY, ALIGN=2
SPI_FLASH_StartReadSequence PROC
;;;353 void SPI_FLASH_StartReadSequence(u32 ReadAddr)
;;;354 {
000000 b510 PUSH {r4,lr}
000002 4604 MOV r4,r0
;;;355 /* Select the FLASH: Chip Select low */
;;;356 SPI_FLASH_CS_LOW();
000004 2101 MOVS r1,#1
000006 4809 LDR r0,|L11.44|
000008 f7fffffe BL GPIO_ResetBits
;;;357
;;;358 /* Send "Read from Memory " instruction */
;;;359 SPI_FLASH_SendByte(READ);
00000c 2003 MOVS r0,#3
00000e f7fffffe BL SPI_FLASH_SendByte
;;;360
;;;361 /* Send the 24-bit address of the address to read from -----------------------*/
;;;362 /* Send ReadAddr high nibble address byte */
;;;363 SPI_FLASH_SendByte((ReadAddr & 0xFF0000) >> 16);
000012 f3c44007 UBFX r0,r4,#16,#8
000016 f7fffffe BL SPI_FLASH_SendByte
;;;364 /* Send ReadAddr medium nibble address byte */
;;;365 SPI_FLASH_SendByte((ReadAddr& 0xFF00) >> 8);
00001a f3c42007 UBFX r0,r4,#8,#8
00001e f7fffffe BL SPI_FLASH_SendByte
;;;366 /* Send ReadAddr low nibble address byte */
;;;367 SPI_FLASH_SendByte(ReadAddr & 0xFF);
000022 b2e0 UXTB r0,r4
000024 e8bd4010 POP {r4,lr}
000028 f7ffbffe B.W SPI_FLASH_SendByte
;;;368 }
;;;369
ENDP
|L11.44|
00002c 40010c00 DCD 0x40010c00
AREA ||i.SPI_FLASH_ReadByte||, CODE, READONLY, ALIGN=1
SPI_FLASH_ReadByte PROC
;;;380 {
;;;381 return (SPI_FLASH_SendByte(Dummy_Byte));
000000 20a5 MOVS r0,#0xa5
000002 f7ffbffe B.W SPI_FLASH_SendByte
;;;382 }
;;;383
ENDP
AREA ||i.SPI_FLASH_SendHalfWord||, CODE, READONLY, ALIGN=2
SPI_FLASH_SendHalfWord PROC
;;;415 u16 SPI_FLASH_SendHalfWord(u16 HalfWord)
;;;416 {
000000 b570 PUSH {r4-r6,lr}
000002 4c0b LDR r4,|L13.48|
000004 4605 MOV r5,r0
|L13.6|
;;;417 /* Loop while DR register in not emplty */
;;;418 while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);
000006 2102 MOVS r1,#2
000008 4620 MOV r0,r4
00000a f7fffffe BL SPI_I2S_GetFlagStatus
00000e 2800 CMP r0,#0
000010 d0f9 BEQ |L13.6|
;;;419
;;;420 /* Send Half Word through the SPI1 peripheral */
;;;421 SPI_I2S_SendData(SPI1, HalfWord);
000012 4629 MOV r1,r5
000014 4620 MOV r0,r4
000016 f7fffffe BL SPI_I2S_SendData
|L13.26|
;;;422
;;;423 /* Wait to receive a Half Word */
;;;424 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 |L13.26|
;;;425
;;;426 /* Return the Half Word read from the SPI bus */
;;;427 return SPI_I2S_ReceiveData(SPI1);
000026 4620 MOV r0,r4
000028 e8bd4070 POP {r4-r6,lr}
00002c f7ffbffe B.W SPI_I2S_ReceiveData
;;;428 }
;;;429
ENDP
|L13.48|
000030 40013000 DCD 0x40013000
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -