📄 mci_sd.lst
字号:
133 CMDR_param |= AT91C_MCI_OPDCMD ; /*****不可以读取的!!!!!!!!!!!!!*/
\ ??MCI_SendCommand_2:
\ 00000020 8020 MOV R0,#+0x80
\ 00000022 0001 LSL R0,R0,#+0x4 ;; #+0x800
\ 00000024 0843 ORR R0,R1
134 if(Responed_Type !=No_Respond)
\ 00000026 002C CMP R4,#+0
\ 00000028 02D0 BEQ ??MCI_SendCommand_4
135 CMDR_param |= (Responed_Type<<6) ; // MCI_CMDR不可读
\ 0000002A 011C MOV R1,R0
\ 0000002C A001 LSL R0,R4,#+0x6
\ 0000002E 0843 ORR R0,R1
136 CMDR_param |= AT91C_MCI_TRCMD_START ;
\ ??MCI_SendCommand_4:
\ 00000030 8021 MOV R1,#+0x80
\ 00000032 4902 LSL R1,R1,#+0x9 ;; #+0x10000
\ 00000034 0143 ORR R1,R0
\ 00000036 .... LDR R5,??DataTable9 ;; 0xfffac040
137 //while((AT91C_BASE_MCI->MCI_SR & AT91C_MCI_CMDRDY)==0) ; //等待发送数据
138 while((AT91C_BASE_MCI->MCI_SR & AT91C_MCI_TXRDY)==0);
\ ??MCI_SendCommand_5:
\ 00000038 2868 LDR R0,[R5, #+0]
\ 0000003A 4007 LSL R0,R0,#+0x1D
\ 0000003C FCD5 BPL ??MCI_SendCommand_5
139 AT91C_BASE_MCI->MCI_CMDR |=CMDR_param ; //开始发送 (是否只是发送数据块时用到???)
\ 0000003E .... LDR R0,??DataTable20 ;; 0xfffac014
\ 00000040 0268 LDR R2,[R0, #+0]
\ 00000042 1143 ORR R1,R2
\ 00000044 0160 STR R1,[R0, #+0]
140 delay() ;
\ 00000046 ........ BL delay
141 delay() ;
\ 0000004A ........ BL delay
142 delay() ;
\ 0000004E ........ BL delay
143 //while((AT91C_BASE_MCI->MCI_SR & AT91C_MCI_CMDRDY)==0); //等待CMDRDY
144 GetState=AT91C_BASE_MCI->MCI_SR ;
\ 00000052 2868 LDR R0,[R5, #+0]
145 //while ((GetState & AT91C_MCI_TXRDY)==0) //等待数据send完成 ****************************************************
146 // GetState=AT91C_BASE_MCI->MCI_SR ;
147 //******检测错误**************************
148 //if((GetState & 0x007F0000)!= 0) // 有错误,转错误处理
149 // return (-1) ;
150 if((GetState & AT91C_MCI_CMDRDY)==AT91C_MCI_CMDRDY) // 当有需要的时候,读取 响应寄存器
\ 00000054 C007 LSL R0,R0,#+0x1F
\ 00000056 0FD5 BPL ??MCI_SendCommand_6
151 {
152 ResponedType=Responed_Type ;
\ 00000058 .... LDR R0,??DataTable11 ;; ResponedType
\ 0000005A 0460 STR R4,[R0, #+0]
153 //return 0 ;
154
155
156 switch (Responed_Type)
\ 0000005C 002C CMP R4,#+0
\ 0000005E 04D0 BEQ ??MCI_SendCommand_7
\ 00000060 012C CMP R4,#+0x1
\ 00000062 04D0 BEQ ??MCI_SendCommand_8
\ 00000064 022C CMP R4,#+0x2
\ 00000066 04D0 BEQ ??MCI_SendCommand_9
\ 00000068 06E0 B ??MCI_SendCommand_6
157 {
158 case 0: // 无响应,不处理
159 {
160 Read_CMD_Respond(No_Respond) ;
\ ??MCI_SendCommand_7:
\ 0000006A 0020 MOV R0,#+0
\ 0000006C 02E0 B ??MCI_SendCommand_10
161 break ;
162
163 }
164 case 1: // 48 bit 响应
165 {
166 Read_CMD_Respond(Respond_Len_48) ; // 48 bit响应
\ ??MCI_SendCommand_8:
\ 0000006E 0120 MOV R0,#+0x1
\ 00000070 00E0 B ??MCI_SendCommand_10
167 break ;
168 }
169 case 2:
170 {
171 Read_CMD_Respond(Respond_Len_136) ; // 136 bit响应
\ ??MCI_SendCommand_9:
\ 00000072 0220 MOV R0,#+0x2
\ ??MCI_SendCommand_10:
\ 00000074 ........ BL Read_CMD_Respond
172 break ;
173 }
174 default : ;
175
176 }
177
178 }
179 return 0 ; //正确返回
\ ??MCI_SendCommand_6:
\ 00000078 0020 MOV R0,#+0
\ 0000007A 30BC POP {R4,R5}
\ 0000007C 02BC POP {R1}
\ 0000007E 0847 BX R1 ;; return
\ ??MCI_SendCommand_0:
\ 00000080 10C0FAFF DC32 0xfffac010
180 }
181 //******************************************************************************************************
182 //********读取 返回值 ,RCA=Respond[ 39:24]
\ In segment CODE, align 4, keep-with-next
183 void Get_SD_RCA( void )
184 {
\ Get_SD_RCA:
\ 00000000 00B5 PUSH {LR}
185 unsigned int ch ;
186 MCI_SendCommand(0x03 ,0,Respond_Len_48,0) ; //RCA =Respond[ 39:24]
\ 00000002 0023 MOV R3,#+0
\ 00000004 0122 MOV R2,#+0x1
\ 00000006 0021 MOV R1,#+0
\ 00000008 0320 MOV R0,#+0x3
\ 0000000A ........ BL MCI_SendCommand
187 //***得到 RCA 的值,如需要检测状态 ,可以读[23:8] 的状态
188 ch=Get_Respond_Buffer.data[4] ;
189 RCA_Addr=0x00000000 ;
190 RCA_Addr += (unsigned int)ch <<24 ;
191 ch=Get_Respond_Buffer.data[3] ;
192 RCA_Addr += (unsigned int)ch <<16 ;
\ 0000000E .... LDR R0,??Subroutine13_0 ;; Get_Respond_Buffer
\ 00000010 .... LDR R1,??DataTable21 ;; RCA_Addr
\ 00000012 0279 LDRB R2,[R0, #+0x4]
\ 00000014 1206 LSL R2,R2,#+0x18
\ 00000016 C078 LDRB R0,[R0, #+0x3]
\ 00000018 0004 LSL R0,R0,#+0x10
\ 0000001A 1018 ADD R0,R2,R0
\ 0000001C REQUIRE ?Subroutine13
\ 0000001C ;; // Fall through to label ?Subroutine13
193
194 }
195
196 /******************************************************************************************************
197 写卡的步骤为:1:选择要写的目标卡 (发送基本命令 CMD7 ,参数为RCA ,响应类型为R1b)
198 2: 设置写块的长度:SET_BLOCKLEN ,命令CMD16 ,参数32bit块长度,响应类型 R1 .
199 (SET_BLOCKLEN为每次要写入的数据长度)
200 3: 是否用PDC通道传送,设置传送方式和块长度
201 4:发写数据块命令 ,
202 5:等待标志 ,如果是通道发送的话,ENDTX = 0标志着数据发送结束,非通道,循环发送
203 本列采用通道和非通道两种发送方式:
204 ******************************************************************************************************/
205 //注意 ,在调用程序的时候 ,Block_Len =StrLen(SendData) ,即为发送数据的长度
\ In segment CODE, align 4, keep-with-next
206 int MCI_SendData (char *SendData ,unsigned long int WriteTo_Addr,unsigned int UsePDC)
207 {
\ MCI_SendData:
\ 00000000 F5B5 PUSH {R0,R2,R4-R7,LR}
\ 00000002 0C1C MOV R4,R1
208 int State ;
209 int TXcnt =0 ;
\ 00000004 0025 MOV R5,#+0
210 unsigned int Multiply_Block=0 ; //数据是写入单块还是多块 ,0:single ,1: Multiply
\ 00000006 0027 MOV R7,#+0
211 unsigned long int Block_Len ;
212 Block_Len=strlen(SendData) ; //得到写入数据的总长度
\ 00000008 2E1C MOV R6,R5
\ ??MCI_SendData_0:
\ 0000000A 815D LDRB R1,[R0, R6]
\ 0000000C 761C ADD R6,R6,#+0x1
\ 0000000E 0029 CMP R1,#+0
\ 00000010 FBD1 BNE ??MCI_SendData_0
\ 00000012 761E SUB R6,R6,#+0x1
\ 00000014 FF20 MOV R0,#+0xFF
\ 00000016 801C ADD R0,R0,#+0x2 ;; #+0x101
\ 00000018 8642 CMP R6,R0
\ 0000001A 00D3 BCC ??MCI_SendData_1
213 if( Block_Len > Max_BlockSize ) //数据大于块容量,多块写入 *****
214 Multiply_Block=0x1 ;
\ 0000001C 0127 MOV R7,#+0x1
215 State =MCI_SendCommand(0x07,0,Respond_Len_48,0) ; // Send command SEL_DESEL_CARD to select the card
\ ??MCI_SendData_1:
\ 0000001E 0023 MOV R3,#+0
\ 00000020 0122 MOV R2,#+0x1
\ 00000022 291C MOV R1,R5
\ 00000024 0720 MOV R0,#+0x7
\ 00000026 ........ BL MCI_SendCommand
216 while(State !=0)
\ 0000002A 0028 CMP R0,#+0
\ 0000002C 08D0 BEQ ??MCI_SendData_2
217 {
218 delay() ;
\ ??MCI_SendData_3:
\ 0000002E ........ BL delay
219 if(TXcnt++ >10)
\ 00000032 281C MOV R0,R5
\ 00000034 6D1C ADD R5,R5,#+0x1
\ 00000036 0B28 CMP R0,#+0xB
\ 00000038 F9DB BLT ??MCI_SendData_3
220 return -1;
\ ??MCI_SendData_4:
\ 0000003A 0020 MOV R0,#+0
\ 0000003C C043 MVN R0,R0 ;; #-1
\ 0000003E 83E0 B ??MCI_SendData_5
221 }
222
223 State =MCI_SendCommand(0x10,Block_Len,Respond_Len_48,0) ; // SET_BLOCKLEN
\ ??MCI_SendData_2:
\ 00000040 0023 MOV R3,#+0
\ 00000042 0122 MOV R2,#+0x1
\ 00000044 311C MOV R1,R6
\ 00000046 1020 MOV R0,#+0x10
\ 00000048 ........ BL MCI_SendCommand
224 while(State !=0)
\ 0000004C 0028 CMP R0,#+0
\ 0000004E 06D0 BEQ ??MCI_SendData_6
225 {
226 delay() ;
\ ??MCI_SendData_7:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -