📄 sddriver.lst
字号:
##############################################################################
# #
# IAR ARM ANSI C/C++ Compiler V4.30A/W32 KICKSTART 04/Aug/2006 19:16:18 #
# Copyright 1999-2005 IAR Systems. All rights reserved. #
# #
# Cpu mode = interwork #
# Endian = little #
# Stack alignment = 4 #
# Source file = C:\Documents and Settings\yc\桌面\AT91SAM7A3(SPI_SD_ #
# RW)\SD_SPI-SAM7A3\src\sddriver.c #
# Command line = "C:\Documents and Settings\yc\桌面\AT91SAM7A3(SPI_SD #
# _RW)\SD_SPI-SAM7A3\src\sddriver.c" -lC #
# "C:\Documents and Settings\yc\桌面\AT91SAM7A3(SPI_SD #
# _RW)\SD_SPI-SAM7A3\compil\RAM_Debug\List\" #
# --remarks -o "C:\Documents and #
# Settings\yc\桌面\AT91SAM7A3(SPI_SD_RW)\SD_SPI-SAM7A3 #
# \compil\RAM_Debug\Obj\" -z2 --no_cse --no_unroll #
# --no_inline --no_code_motion --no_tbaa #
# --no_clustering --no_scheduling --debug --cpu_mode #
# thumb --endian little --cpu ARM7TDMI --stack_align #
# 4 --interwork -e --fpu None --dlib_config "D:\IAR #
# Systems\Embedded Workbench 4.0 #
# Kickstart\arm\LIB\dl4tptinl8f.h" -I "C:\Documents #
# and Settings\yc\桌面\AT91SAM7A3(SPI_SD_RW)\SD_SPI-SA #
# M7A3\compil\srcIAR\" -I "C:\Documents and #
# Settings\yc\桌面\AT91SAM7A3(SPI_SD_RW)\SD_SPI-SAM7A3 #
# \compil\..\src\" -I "C:\Documents and #
# Settings\yc\桌面\AT91SAM7A3(SPI_SD_RW)\SD_SPI-SAM7A3 #
# \compil\..\..\" -I "D:\IAR Systems\Embedded #
# Workbench 4.0 Kickstart\arm\INC\" #
# List file = C:\Documents and Settings\yc\桌面\AT91SAM7A3(SPI_SD_ #
# RW)\SD_SPI-SAM7A3\compil\RAM_Debug\List\sddriver.lst #
# Object file = C:\Documents and Settings\yc\桌面\AT91SAM7A3(SPI_SD_ #
# RW)\SD_SPI-SAM7A3\compil\RAM_Debug\Obj\sddriver.r79 #
# #
# #
##############################################################################
C:\Documents and Settings\yc\桌面\AT91SAM7A3(SPI_SD_RW)\SD_SPI-SAM7A3\src\sddriver.c
1 /****************************************Copyright (c)**************************************************
2 ** Guangzhou ZLG-MCU Development Co.,LTD.
3 ** graduate school
4 ** http://www.zlgmcu.com
5 **
6 **--------------File Info-------------------------------------------------------------------------------
7 ** File name: sddriver.c
8 ** Last modified Date: 2005-3-10
9 ** Last Version: V2.0
10 ** Descriptions: SD/MMC卡读写模块: 物理层 用户API函数
11 ** Soft Packet of SD Card: user API funciton
12 **
13 **------------------------------------------------------------------------------------------------------
14 ** Created by: Ming Yuan Zheng
15 ** Created date: 2005-1-6
16 ** Version: V1.0
17 ** Descriptions: The original version
18 **
19 **------------------------------------------------------------------------------------------------------
20 ** Modified by: Ming Yuan Zheng
21 ** Modified date: 2005-3-10
22 ** Version: V2.0
23 ** Descriptions: 增加了对MMC卡的支持,增加了对UCOS-II的支持,使该模块不仅能运行于前后台系统,还可运行
24 ** 于UCOS-II上
25 **------------------------------------------------------------------------------------------------------
26 ** Modified by:
27 ** Modified date:
28 ** Version:
29 ** Descriptions:
30 **
31 ********************************************************************************************************/
32
33 #include "config.h"
34 #include "sdhal.h"
35 #include "SDCmd.h"
36
37 /* SD卡信息结构体变量 the information structure variable of SD Card */
\ In segment DATA_Z, align 4, align-sorted
38 sd_struct sds;
\ sds:
\ 00000000 DS8 28
39
40 /* 超时时间单位表(单位:0.000000001ns) timeout unit table */
\ In segment DATA_C, align 4, align-sorted
41 const INT32U time_unit[8] = {1000000000,100000000,10000000,
\ time_unit:
\ 00000000 00CA9A3B00E1 DC32 1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100
\ F50580969800
\ 40420F00A086
\ 010010270000
\ E80300006400
\ 0000
42 1000000,100000,10000,1000,100};
43
44 /* 超时时间表 timeout value table */
\ In segment DATA_C, align 4, align-sorted
45 const INT8U time_value[16] = {0,10,12,13,15,20,25,30,
\ time_value:
\ 00000000 000A0C0D0F14 DC8 0, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80
\ 191E23282D32
\ 373C4650
46 35,40,45,50,55,60,70,80};
47
48 /* 超时时间因数表 timeout factor table */
\ In segment DATA_C, align 4, align-sorted
49 const INT8U r2w_fator[8] = {1,2,4,8,16,32,64,128};
\ r2w_fator:
\ 00000000 010204081020 DC8 1, 2, 4, 8, 16, 32, 64, 128
\ 4080
50
51 /*
52 ***************************************************************************************************
53
54 用户API函数: 初始化,读,写,擦 SD卡 User API Function: Initialize,read,write,erase SD Card
55
56 ***************************************************************************************************
57 */
58
59 /*******************************************************************************************************************
60 ** 函数名称: INT8U SD_Initialize() Name: INT8U SD_Initialize()
61 ** 功能描述: 初始化SD/MMC卡 Function: initialize SD/MMC card
62 ** 输 入: 无 Input: NULL
63 ** 输 出: 0: 成功 >0: 错误码 Output: 0: right >0: error code
64 ********************************************************************************************************************/
\ In segment CODE, align 4, keep-with-next
65 INT8U SD_Initialize(void)
66 {
\ SD_Initialize:
\ 00000000 10B5 PUSH {R4,LR}
\ 00000002 81B0 SUB SP,#+0x4
67 INT8U recbuf[4],ret;
68 SD_StartSD(); // on ucos_II
\ 00000004 ........ BL SD_StartSD
69 SD_HardWareInit(); /* 初始化读写SD卡的硬件条件 Initialize the hardware that access SD Card */
\ 00000008 ........ _BLF SD_HardWareInit,SD_HardWareInit??rT
70
71 if (SD_ChkCard() != 1) /* 检查卡是否插入 check weather card is inserted */
\ 0000000C ........ _BLF SD_ChkCard,SD_ChkCard??rT
\ 00000010 0128 CMP R0,#+0x1
\ 00000012 02D0 BEQ ??SD_Initialize_0
72 {
73 ret = SD_ERR_NO_CARD;
\ 00000014 0120 MOV R0,#+0x1
\ 00000016 041C MOV R4,R0
74 goto SD_ERR;
\ 00000018 35E0 B ??SD_Initialize_1
75 }
76
77 SPI_CS_Assert(); /* 1. 置CS为低 assert CS */
\ ??SD_Initialize_0:
\ 0000001A ........ _BLF SPI_CS_Assert,SPI_CS_Assert??rT
78 SD_SPIDelay(25); /* 2. 至少延时 74 clock delay more than 74 clock */
\ 0000001E 1920 MOV R0,#+0x19
\ 00000020 ........ _BLF SD_SPIDelay,SD_SPIDelay??rT
79 SPI_CS_Deassert(); /* 3. 置CS为高 dessert CS */
\ 00000024 ........ _BLF SPI_CS_Deassert,SPI_CS_Deassert??rT
80 SD_SPIDelay(2); /* 4. 延时2(8 clock) delay 2(8 clock) */
\ 00000028 0220 MOV R0,#+0x2
\ 0000002A ........ _BLF SD_SPIDelay,SD_SPIDelay??rT
81
82 ret = SD_ResetSD(); /* 5. 发出CMDO命令复位SD卡 send CMD0 command to reset sd card */
\ 0000002E ........ _BLF SD_ResetSD,SD_ResetSD??rT
\ 00000032 041C MOV R4,R0
83 if (ret != SD_NO_ERR)
\ 00000034 002C CMP R4,#+0
\ 00000036 26D1 BNE ??SD_Initialize_1
84 goto SD_ERR;
85
86 ret = SD_ActiveInit(); /* 6. 激活卡进入初始化过程. active card initialize process */
\ 00000038 ........ BL SD_ActiveInit
\ 0000003C 041C MOV R4,R0
87 if (ret != SD_NO_ERR)
\ 0000003E 002C CMP R4,#+0
\ 00000040 21D1 BNE ??SD_Initialize_1
88 goto SD_ERR;
89
90 ret = SD_ReadOCR(4, recbuf); /* 7. 读OCR寄存器,查询卡支持的电压值 read OCR register,get the supported voltage */
\ 00000042 6946 MOV R1,SP
\ 00000044 0420 MOV R0,#+0x4
\ 00000046 ........ _BLF SD_ReadOCR,SD_ReadOCR??rT
\ 0000004A 041C MOV R4,R0
91 if (ret != SD_NO_ERR)
\ 0000004C 002C CMP R4,#+0
\ 0000004E 1AD1 BNE ??SD_Initialize_1
92 goto SD_ERR;
93
94 if ((recbuf[1] & MSK_OCR_33) != MSK_OCR_33)
\ 00000050 6846 MOV R0,SP
\ 00000052 4078 LDRB R0,[R0, #+0x1]
\ 00000054 C021 MOV R1,#+0xC0
\ 00000056 0140 AND R1,R0
\ 00000058 C029 CMP R1,#+0xC0
\ 0000005A 02D0 BEQ ??SD_Initialize_2
95 {
96 ret = SD_ERR_VOL_NOTSUSP; /* 不支持3.3V,返回错误码 not support 3.3V,return error code */
\ 0000005C 0420 MOV R0,#+0x4
\ 0000005E 041C MOV R4,R0
97 goto SD_ERR;
\ 00000060 11E0 B ??SD_Initialize_1
98 }
99
100 SPI_ClkToMax(); /* 8. 设置SPI时钟到最大值 set SPI clock to maximum */
\ ??SD_Initialize_2:
\ 00000062 ........ _BLF SPI_ClkToMax,SPI_ClkToMax??rT
101
102 #if SD_CRC_EN
103 ret = SD_EnableCRC(1); /* 使能CRC校验 enable CRC check */
104 if (ret != SD_NO_ERR)
105 goto SD_ERR;
106 #endif
107
108 ret = SD_SetBlockLen(SD_BLOCKSIZE); /* 9. 设置块的长度: 512Bytes Set the block length: 512Bytes */
\ 00000066 8020 MOV R0,#+0x80
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -