📄 sdcard.txt
字号:
;;;2429 SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
;;;2430 SDIO_SendCommand(&SDIO_CmdInitStructure);
;;;2431
;;;2432 errorstatus = CmdResp1Error(SDIO_APP_CMD);
;;;2433
;;;2434 if (errorstatus != SD_OK)
;;;2435 {
;;;2436 return(errorstatus);
;;;2437 }
;;;2438
;;;2439 /* Send ACMD6 APP_CMD with argument as 2 for wide bus mode */
;;;2440 SDIO_CmdInitStructure.SDIO_Argument = 0x2;
;;;2441 SDIO_CmdInitStructure.SDIO_CmdIndex = SDIO_APP_SD_SET_BUSWIDTH;
;;;2442 SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;
;;;2443 SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
;;;2444 SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
;;;2445 SDIO_SendCommand(&SDIO_CmdInitStructure);
;;;2446
;;;2447 errorstatus = CmdResp1Error(SDIO_APP_SD_SET_BUSWIDTH);
;;;2448
;;;2449 if (errorstatus != SD_OK)
;;;2450 {
;;;2451 return(errorstatus);
;;;2452 }
;;;2453 return(errorstatus);
;;;2454 }
;;;2455 else
;;;2456 {
;;;2457 errorstatus = SD_REQUEST_NOT_APPLICABLE;
;;;2458 return(errorstatus);
;;;2459 }
;;;2460 } /* If wide bus operation to be disabled */
;;;2461 else
;;;2462 {
;;;2463 /* If requested card supports 1 bit mode operation */
;;;2464 if ((scr[1] & SD_SINGLE_BUS_SUPPORT) != SD_ALLZERO)
;;;2465 {
;;;2466 /* Send CMD55 APP_CMD with argument as card's RCA.*/
;;;2467 SDIO_CmdInitStructure.SDIO_Argument = (u32) RCA << 16;
;;;2468 SDIO_CmdInitStructure.SDIO_CmdIndex = SDIO_APP_CMD;
;;;2469 SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;
;;;2470 SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
;;;2471 SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
;;;2472 SDIO_SendCommand(&SDIO_CmdInitStructure);
;;;2473
;;;2474
;;;2475 errorstatus = CmdResp1Error(SDIO_APP_CMD);
;;;2476
;;;2477 if (errorstatus != SD_OK)
;;;2478 {
;;;2479 return(errorstatus);
;;;2480 }
;;;2481
;;;2482 /* Send ACMD6 APP_CMD with argument as 2 for wide bus mode */
;;;2483 SDIO_CmdInitStructure.SDIO_Argument = 0x00;
;;;2484 SDIO_CmdInitStructure.SDIO_CmdIndex = SDIO_APP_SD_SET_BUSWIDTH;
;;;2485 SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;
;;;2486 SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
;;;2487 SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
;;;2488 SDIO_SendCommand(&SDIO_CmdInitStructure);
;;;2489
;;;2490 errorstatus = CmdResp1Error(SDIO_APP_SD_SET_BUSWIDTH);
;;;2491
;;;2492 if (errorstatus != SD_OK)
;;;2493 {
;;;2494 return(errorstatus);
;;;2495 }
;;;2496
;;;2497 return(errorstatus);
;;;2498 }
;;;2499 else
;;;2500 {
;;;2501 errorstatus = SD_REQUEST_NOT_APPLICABLE;
;;;2502 return(errorstatus);
;;;2503 }
;;;2504 }
;;;2505 }
00001a e8bd87fc POP {r2-r10,pc}
|L8.30|
00001e 4c24 LDR r4,|L8.176|
000020 4669 MOV r1,sp ;2411
000022 68a0 LDR r0,[r4,#8] ;2411 ; RCA
000024 b280 UXTH r0,r0 ;2411
000026 f7fffffe BL FindSCR
00002a 282a CMP r0,#0x2a ;2413
00002c d1f5 BNE |L8.26|
00002e 2640 MOVS r6,#0x40 ;2427
000030 2037 MOVS r0,#0x37 ;2426
000032 4d20 LDR r5,|L8.180|
000034 0137 LSLS r7,r6,#4 ;2429
000036 9901 LDR r1,[sp,#4] ;2419
000038 f04f0a06 MOV r10,#6 ;2441
00003c f04f0800 MOV r8,#0 ;2404
000040 f1b90f01 CMP r9,#1 ;2419
000044 d113 BNE |L8.110|
000046 0349 LSLS r1,r1,#13 ;2422
000048 d52f BPL |L8.170|
00004a 68a1 LDR r1,[r4,#8] ;2425 ; RCA
00004c e9c58703 STRD r8,r7,[r5,#0xc] ;2430
000050 e9c50601 STRD r0,r6,[r5,#4] ;2430
000054 0409 LSLS r1,r1,#16 ;2425
000056 6029 STR r1,[r5,#0] ;2430 ; SDIO_CmdInitStructure
000058 4628 MOV r0,r5 ;2430
00005a f7fffffe BL SDIO_SendCommand
00005e 2037 MOVS r0,#0x37 ;2432
000060 f7fffffe BL CmdResp1Error
000064 282a CMP r0,#0x2a ;2434
000066 d1d8 BNE |L8.26|
000068 2002 MOVS r0,#2 ;2440
00006a 6028 STR r0,[r5,#0] ;2449 ; SDIO_CmdInitStructure
00006c e012 B |L8.148|
|L8.110|
00006e 03c9 LSLS r1,r1,#15 ;2464
000070 d51b BPL |L8.170|
000072 68a1 LDR r1,[r4,#8] ;2467 ; RCA
000074 e9c58703 STRD r8,r7,[r5,#0xc] ;2472
000078 e9c50601 STRD r0,r6,[r5,#4] ;2472
00007c 0409 LSLS r1,r1,#16 ;2467
00007e 6029 STR r1,[r5,#0] ;2472 ; SDIO_CmdInitStructure
000080 480c LDR r0,|L8.180|
000082 f7fffffe BL SDIO_SendCommand
000086 2037 MOVS r0,#0x37 ;2475
000088 f7fffffe BL CmdResp1Error
00008c 282a CMP r0,#0x2a ;2477
00008e d1c4 BNE |L8.26|
000090 f8c58000 STR r8,[r5,#0] ;2483 ; SDIO_CmdInitStructure
|L8.148|
000094 e9c5a601 STRD r10,r6,[r5,#4] ;2488
000098 e9c58703 STRD r8,r7,[r5,#0xc] ;2488
00009c 4805 LDR r0,|L8.180|
00009e f7fffffe BL SDIO_SendCommand
0000a2 2006 MOVS r0,#6 ;2490
0000a4 f7fffffe BL CmdResp1Error
0000a8 e7b7 B |L8.26|
|L8.170|
0000aa 2025 MOVS r0,#0x25 ;2501
0000ac e7b5 B |L8.26|
;;;2506
ENDP
0000ae 0000 DCW 0x0000
|L8.176|
DCD ||.data||
|L8.180|
DCD ||.bss||+0x38
AREA ||i.SD_EnableWideBusOperation||, CODE, READONLY, ALIGN=2
SD_EnableWideBusOperation PROC
;;;624 *******************************************************************************/
;;;625 SD_Error SD_EnableWideBusOperation(u32 WideMode)
000000 e92d41f0 PUSH {r4-r8,lr}
;;;626 {
000004 4601 MOV r1,r0
;;;627 SD_Error errorstatus = SD_OK;
;;;628
;;;629 /* MMC Card doesn't support this feature */
;;;630 if (SDIO_MULTIMEDIA_CARD == CardType)
000006 4819 LDR r0,|L9.108|
000008 242a MOVS r4,#0x2a ;627
00000a 6840 LDR r0,[r0,#4] ; CardType
00000c b130 CBZ r0,|L9.28|
;;;631 {
;;;632 errorstatus = SD_UNSUPPORTED_FEATURE;
;;;633 return(errorstatus);
;;;634 }
;;;635 else if ((SDIO_SECURE_DIGITAL_CARD == CardType) || (SDIO_HIGH_CAPACITY_SD_CARD == CardType))
00000e 2801 CMP r0,#1
000010 d001 BEQ |L9.22|
000012 2805 CMP r0,#5
000014 d127 BNE |L9.102|
|L9.22|
;;;636 {
;;;637 if (SDIO_BusWide_8b == WideMode)
000016 f5b15f80 CMP r1,#0x1000
00001a d102 BNE |L9.34|
|L9.28|
;;;638 {
;;;639 errorstatus = SD_UNSUPPORTED_FEATURE;
00001c 2027 MOVS r0,#0x27
|L9.30|
;;;640 return(errorstatus);
;;;641 }
;;;642 else if (SDIO_BusWide_4b == WideMode)
;;;643 {
;;;644 errorstatus = SDEnWideBus(ENABLE);
;;;645
;;;646 if (SD_OK == errorstatus)
;;;647 {
;;;648 /* Configure the SDIO peripheral */
;;;649 SDIO_InitStructure.SDIO_ClockDiv = SDIO_TRANSFER_CLK_DIV;
;;;650 SDIO_InitStructure.SDIO_ClockEdge = SDIO_ClockEdge_Rising;
;;;651 SDIO_InitStructure.SDIO_ClockBypass = SDIO_ClockBypass_Disable;
;;;652 SDIO_InitStructure.SDIO_ClockPowerSave = SDIO_ClockPowerSave_Disable;
;;;653 SDIO_InitStructure.SDIO_BusWide = SDIO_BusWide_4b;
;;;654 SDIO_InitStructure.SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable;
;;;655 SDIO_Init(&SDIO_InitStructure);
;;;656 }
;;;657 }
;;;658 else
;;;659 {
;;;660 errorstatus = SDEnWideBus(DISABLE);
;;;661
;;;662 if (SD_OK == errorstatus)
;;;663 {
;;;664 /* Configure the SDIO peripheral */
;;;665 SDIO_InitStructure.SDIO_ClockDiv = SDIO_TRANSFER_CLK_DIV;
;;;666 SDIO_InitStructure.SDIO_ClockEdge = SDIO_ClockEdge_Rising;
;;;667 SDIO_InitStructure.SDIO_ClockBypass = SDIO_ClockBypass_Disable;
;;;668 SDIO_InitStructure.SDIO_ClockPowerSave = SDIO_ClockPowerSave_Disable;
;;;669 SDIO_InitStructure.SDIO_BusWide = SDIO_BusWide_1b;
;;;670 SDIO_InitStructure.SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable;
;;;671 SDIO_Init(&SDIO_InitStructure);
;;;672 }
;;;673 }
;;;674 }
;;;675
;;;676 return(errorstatus);
;;;677 }
00001e e8bd81f0 POP {r4-r8,pc}
|L9.34|
000022 f44f6800 MOV r8,#0x800 ;642
000026 2600 MOVS r6,#0 ;630
000028 2701 MOVS r7,#1 ;630
00002a 4d11 LDR r5,|L9.112|
00002c 4541 CMP r1,r8 ;642
00002e d10b BNE |L9.72|
000030 2001 MOVS r0,#1 ;644
000032 f7fffffe BL SDEnWideBus
000036 4604 MOV r4,r0 ;644
000038 282a CMP r0,#0x2a ;646
00003a d114 BNE |L9.102|
00003c 702f STRB r7,[r5,#0] ;649
00003e 606e STR r6,[r5,#4] ;651 ; SDIO_InitStructure
000040 60ae STR r6,[r5,#8] ;652 ; SDIO_InitStructure
000042 e9c56803 STRD r6,r8,[r5,#0xc] ;655
000046 e00a B |L9.94|
|L9.72|
000048 2000 MOVS r0,#0 ;660
00004a f7fffffe BL SDEnWideBus
00004e 4604 MOV r4,r0 ;660
000050 282a CMP r0,#0x2a ;662
000052 d108 BNE |L9.102|
000054 702f STRB r7,[r5,#0] ;665
000056 606e STR r6,[r5,#4] ;667 ; SDIO_InitStructure
000058 60ae STR r6,[r5,#8] ;668 ; SDIO_InitStructure
00005a 60ee STR r6,[r5,#0xc] ;669 ; SDIO_InitStructure
00005c 612e STR r6,[r5,#0x10] ;669 ; SDIO_InitStructure
|L9.94|
00005e 4804 LDR r0,|L9.112|
000060 616e STR r6,[r5,#0x14] ;671 ; SDIO_InitStructure
000062 f7fffffe BL SDIO_Init
|L9.102|
000066 4620 MOV r0,r4 ;676
000068 e7d9 B |L9.30|
;;;678
ENDP
00006a 0000 DCW 0x0000
|L9.108|
DCD ||.data||
|L9.112|
DCD ||.bss||+0x20
AREA ||i.SD_Erase||, CODE, READONLY, ALIGN=2
SD_Erase PROC
;;;1646 *******************************************************************************/
;;;1647 SD_Error SD_Erase(u32 startaddr, u32 endaddr)
000000 e92d4ff8 PUSH {r3-r11,lr}
;;;1648 {
000004 4682 MOV r10,r0
;;;1649 SD_Error errorstatus = SD_OK;
;;;1650 u32 delay = 0;
000006 2400 MOVS r4,#0
;;;1651 vu32 maxdelay = 0;
;;;1652 u8 cardstate = 0;
;;;1653
;;;1654 /* Check if the card coomnd class supports erase command */
;;;1655 if (((CSD_Tab[1] >> 20) & SD_CCCC_ERASE) == 0)
000008 4832 LDR r0,|L10.212|
00000a 9400 STR r4,[sp,#0]
00000c 6840 LDR r0,[r0,#4] ; CSD_Tab
00000e 468b MOV r11,r1 ;1648
000010 ea4f5010 LSR r0,r0,#20
000014 4626 MOV r6,r4 ;1652
000016 0680 LSLS r0,r0,#26
000018 d402 BMI |L10.32|
;;;1656 {
;;;1657 errorstatus = SD_REQUEST_NOT_APPLICABLE;
00001a 2025 MOVS r0,#0x25
|L10.28|
;;;1658 return(errorstatus);
;;;1659 }
;;;1660
;;;1661 maxdelay = 72000 / ((SDIO->CLKCR & 0xFF) + 2);
;;;1662
;;;1663 if (SDIO_GetResponse(SDIO_RESP1) & SD_CARD_LOCKED)
;;;1664 {
;;;1665 errorstatus = SD_LOCK_UNLOCK_FAILED;
;;;1666 return(errorstatus);
;;;1667 }
;;;1668
;;;1669 /* According to sd-card spec 1.0 ERASE_GROUP_START (CMD32) and erase_group_end(CMD33) */
;;;1670 if ((SDIO_SECURE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -