📄 sdcmd.lst
字号:
##############################################################################
# #
# IAR ARM ANSI C/C++ Compiler V4.30A/W32 KICKSTART 04/Aug/2006 19:16:02 #
# 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\sdcmd.c #
# Command line = "C:\Documents and Settings\yc\桌面\AT91SAM7A3(SPI_SD #
# _RW)\SD_SPI-SAM7A3\src\sdcmd.c" -lC "C:\Documents #
# and Settings\yc\桌面\AT91SAM7A3(SPI_SD_RW)\SD_SPI-SA #
# M7A3\compil\FLASH_Debug\List\" -o "C:\Documents and #
# Settings\yc\桌面\AT91SAM7A3(SPI_SD_RW)\SD_SPI-SAM7A3 #
# \compil\FLASH_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\FLASH_Debug\List\sdcmd.lst #
# Object file = C:\Documents and Settings\yc\桌面\AT91SAM7A3(SPI_SD_ #
# RW)\SD_SPI-SAM7A3\compil\FLASH_Debug\Obj\sdcmd.r79 #
# #
# #
##############################################################################
C:\Documents and Settings\yc\桌面\AT91SAM7A3(SPI_SD_RW)\SD_SPI-SAM7A3\src\sdcmd.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: sdcmd.c
8 ** Last modified Date: 2005-3-11
9 ** Last Version: V2.0
10 ** Descriptions: SD/MMC 读写模块: 物理层 ---- SD/MMC卡SPI模式支持的命令
11 ** Soft Packet of SD/MMC Card: commands that SD/MMC card supported in SPI mode
12 **
13 **------------------------------------------------------------------------------------------------------
14 ** Created by: Ming Yuan Zheng
15 ** Created date: 2005-1-6
16 ** Version: V1.0
17 ** Descriptions: SD/MMC 读写模块: 物理层 ---- SD卡SPI模式支持的命令
18 **
19 **------------------------------------------------------------------------------------------------------
20 ** Modified by: Ming Yuan Zheng
21 ** Modified date: 2005-3-11
22 ** Version: V2.0
23 ** Descriptions: 增加了对MMC卡的支持,并使用本模块既可以运行于前后台系统,也可运行于uCOS-II中.
24 **
25 **------------------------------------------------------------------------------------------------------
26 ** Modified by:
27 ** Modified date:
28 ** Version:
29 ** Descriptions:
30 **
31 ********************************************************************************************************/
32
33 #include "config.h"
34 #include "sdhal.h"
35 #include "sdcrc.h"
36 #include "sdcmd.h"
37
38
39 /********************************************************************************************************************
40 ** 函数名称: INT8U SD_SendCmd() Name: INT8U SD_SendCmd()
41 ** 功能描述: 向卡发送命令,并取得响应 Function: send command to the card,and get a response
42 ** 输 入: INT8U cmd : 命令字 Input: INT8U cmd : command byte
43 INT8U *param : 命令参数,长度为4字节 INT8U *param : command parameter,length is 4 bytes
44 INT8U resptype : 响应类型 INT8U resptype: response type
45 INT8U *resp : 响应,长度为1-5字节 INT8U *resp : response,length is 1-5 bytes
46 ** 输 出: 0: 正确 >0: 错误码 Output: 0: right >0: error code
47 ********************************************************************************************************************/
\ In segment CODE, align 4, keep-with-next
48 INT8U SD_SendCmd(INT8U cmd, INT8U *param, INT8U resptype, INT8U *resp)
49 {
\ SD_SendCmd:
\ 00000000 F7B5 PUSH {R0-R2,R4-R7,LR}
\ 00000002 1C1C MOV R4,R3
50 INT32 i,rlen;
51 INT8U tmp;
52
53 SPI_CS_Assert(); //CS 清 0
\ 00000004 ........ _BLF SPI_CS_Assert,SPI_CS_Assert??rT
54
55 SPI_SendByte((cmd & 0x3F) | 0x40); /* 发送命令头和命令字 send command header and word */
\ 00000008 6846 MOV R0,SP
\ 0000000A 0078 LDRB R0,[R0, #+0]
\ 0000000C 8106 LSL R1,R0,#+0x1A ;; ZeroExt R1,R0,#+0x1A,#+0x1A
\ 0000000E 890E LSR R1,R1,#+0x1A
\ 00000010 4020 MOV R0,#+0x40
\ 00000012 0843 ORR R0,R1
\ 00000014 0006 LSL R0,R0,#+0x18 ;; ZeroExt R0,R0,#+0x18,#+0x18
\ 00000016 000E LSR R0,R0,#+0x18
\ 00000018 ........ _BLF SPI_SendByte,SPI_SendByte??rT
56
57 for (i = 3; i >= 0; i--)
\ 0000001C 0320 MOV R0,#+0x3
\ 0000001E 051C MOV R5,R0
\ ??SD_SendCmd_0:
\ 00000020 002D CMP R5,#+0
\ 00000022 05D4 BMI ??SD_SendCmd_1
58 SPI_SendByte(param[i]); /* 发送参数 send parameters */
\ 00000024 0198 LDR R0,[SP, #+0x4]
\ 00000026 405D LDRB R0,[R0, R5]
\ 00000028 ........ _BLF SPI_SendByte,SPI_SendByte??rT
\ 0000002C 6D1E SUB R5,#+0x1
\ 0000002E F7E7 B ??SD_SendCmd_0
59
60 #if SD_CRC_EN
61 tmp = SD_GetCmdByte6((cmd & 0x3F) | 0x40, param);
62 SPI_SendByte(tmp);
63 #else
64 SPI_SendByte(0x95); /* CRC校验码,只用于第1个命令 CRC,only used for the first command */
\ ??SD_SendCmd_1:
\ 00000030 9520 MOV R0,#+0x95
\ 00000032 ........ _BLF SPI_SendByte,SPI_SendByte??rT
65 #endif
66
67 rlen = 0;
\ 00000036 0020 MOV R0,#+0
\ 00000038 061C MOV R6,R0
68 switch (resptype) /* 根据不同的命令,得到不同的响应长度 */
\ 0000003A 6846 MOV R0,SP
\ 0000003C 007A LDRB R0,[R0, #+0x8]
\ 0000003E 401E SUB R0,#+0x1
\ 00000040 0128 CMP R0,#+0x1
\ 00000042 04D9 BLS ??SD_SendCmd_2
\ 00000044 801E SUB R0,#+0x2
\ 00000046 05D0 BEQ ??SD_SendCmd_3
\ 00000048 401E SUB R0,#+0x1
\ 0000004A 06D0 BEQ ??SD_SendCmd_4
\ 0000004C 08E0 B ??SD_SendCmd_5
69 { /* according various command,get the various response length */
70 case R1:
71 case R1B: rlen = 1; break;
\ ??SD_SendCmd_2:
\ 0000004E 0120 MOV R0,#+0x1
\ 00000050 061C MOV R6,R0
\ 00000052 0CE0 B ??SD_SendCmd_6
72
73 case R2: rlen = 2; break;
\ ??SD_SendCmd_3:
\ 00000054 0220 MOV R0,#+0x2
\ 00000056 061C MOV R6,R0
\ 00000058 09E0 B ??SD_SendCmd_6
74
75 case R3: rlen = 5; break;
\ ??SD_SendCmd_4:
\ 0000005A 0520 MOV R0,#+0x5
\ 0000005C 061C MOV R6,R0
\ 0000005E 06E0 B ??SD_SendCmd_6
76
77 default: SPI_SendByte(0xFF);
\ ??SD_SendCmd_5:
\ 00000060 FF20 MOV R0,#+0xFF
\ 00000062 ........ _BLF SPI_SendByte,SPI_SendByte??rT
78 SPI_CS_Deassert();
\ 00000066 ........ _BLF SPI_CS_Deassert,SPI_CS_Deassert??rT
79 return SD_ERR_CMD_RESPTYPE; /* 返回命令响应类型错误 return error of command response type */
\ 0000006A 1020 MOV R0,#+0x10
\ 0000006C 1CE0 B ??SD_SendCmd_7
80 break;
^
Warning[Pe111]: statement is unreachable
81 }
82
83 i = 0;
\ ??SD_SendCmd_6:
\ 0000006E 0020 MOV R0,#+0
\ 00000070 051C MOV R5,R0
84 do /* 等待响应,响应的开始位为0 */
85 { /* Wait for a response,a response is a start bit(zero) */
86 tmp = SPI_RecByte();
\ ??SD_SendCmd_8:
\ 00000072 ........ _BLF SPI_RecByte,SPI_RecByte??rT
\ 00000076 071C MOV R7,R0
87 i++;
\ 00000078 6D1C ADD R5,#+0x1
88 }while (((tmp & 0x80) != 0) && (i < SD_CMD_TIMEOUT));
\ 0000007A 3806 LSL R0,R7,#+0x18
\ 0000007C 01D5 BPL ??SD_SendCmd_9
\ 0000007E 642D CMP R5,#+0x64
\ 00000080 F7DB BLT ??SD_SendCmd_8
89
90 if (i >= SD_CMD_TIMEOUT)
\ ??SD_SendCmd_9:
\ 00000082 642D CMP R5,#+0x64
\ 00000084 03DB BLT ??SD_SendCmd_10
91 {
92 SPI_CS_Deassert();
\ 00000086 ........ _BLF SPI_CS_Deassert,SPI_CS_Deassert??rT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -