📄 f34x_msd_mmc.src
字号:
MOV R4,#HIGH (current_command?144)
MOV R5,#00H
MOV R6,#00H
MOV R7,#06H
LCALL ?C?COPY
; // from code space;
; card_response.i = 0;
; SOURCE LINE # 344
CLR A
MOV R0,#LOW (card_response?149)
MOV @R0,A
INC R0
MOV @R0,A
; #ifdef __F326_VER__
; Write_Read_Spi_Byte(0xFF);
; SCS = 0;
; Write_Read_Spi_Byte(0xFF);
; Write_Read_Spi_Byte(current_command.command_byte | 0x40);
; #else
; #ifdef SEND__IN_FUNCTION
; Write_Read_Spi_Byte(0xFF);
; SOURCE LINE # 352
MOV R7,#0FFH
LCALL _Write_Read_Spi_Byte
; NSSMD0 = 0;
; SOURCE LINE # 353
CLR NSSMD0
; Write_Read_Spi_Byte(0xFF);
; SOURCE LINE # 354
MOV R7,#0FFH
LCALL _Write_Read_Spi_Byte
; Write_Read_Spi_Byte(current_command.command_byte | 0x40);
; SOURCE LINE # 355
MOV R0,#LOW (current_command?144)
MOV A,@R0
ORL A,#040H
MOV R7,A
LCALL _Write_Read_Spi_Byte
; #else
;
; SPI0DAT = 0xFF; // Send buffer SPI clocks to ensure no
; while(!SPIF){} // MMC operations are pending;
; SPIF = 0;
; NSSMD0 = 0; // Select MMC by pulling CS low;
; SPI0DAT = 0xFF; // Send another byte of SPI clocks;
; while(!SPIF){}
; SPIF = 0;
; // Issue command opcode;
; SPI0DAT = (current_command.command_byte | 0x40);
; #endif
; #endif
; long_arg.l = argument; // Make argument byte addressable;
; SOURCE LINE # 369
MOV DPTR,#argument?141
LCALL L?0147
MOV R0,#LOW (long_arg?145)
LCALL ?C?LSTIDATA
; // If current command changes block
; // length, update block length variable
; // to keep track;
; // Command byte = 16 means that a set
; // block length command is taking place
; // and block length variable must be
; // set;
; if(current_command.command_byte == 16) {
; SOURCE LINE # 377
MOV R0,#LOW (current_command?144)
MOV A,@R0
MOV R3,A
CJNE A,#010H,?C0002
; current_blklen = argument;
; SOURCE LINE # 378
MOV DPTR,#argument?141
LCALL L?0165
; }
; SOURCE LINE # 379
?C0002:
; // Command byte = 9 or 10 means that a
; // 16-byte register value is being read
; // from the card, block length must be
; // set to 16 bytes, and restored at the
; // end of the transfer;
; if((current_command.command_byte == 9)||
; SOURCE LINE # 385
MOV A,R3
XRL A,#09H
JZ ?C0004
MOV R0,#LOW (current_command?144)
MOV A,@R0
CJNE A,#0AH,?C0003
?C0004:
; (current_command.command_byte == 10)) {
; SOURCE LINE # 386
; old_blklen = current_blklen; // Command is a GET_CSD or GET_CID,
; SOURCE LINE # 387
MOV DPTR,#current_blklen?146
MOVX A,@DPTR
MOV R6,A
INC DPTR
MOVX A,@DPTR
MOV R7,A
CLR A
MOV R4,A
MOV R5,A
MOV DPTR,#old_blklen?147
LCALL ?C?LSTXDATA
; current_blklen = 16; // set block length to 16-bytes;
; SOURCE LINE # 388
MOV DPTR,#current_blklen?146
CLR A
MOVX @DPTR,A
INC DPTR
MOV A,#010H
MOVX @DPTR,A
; }
; SOURCE LINE # 389
?C0003:
;
; #ifndef __F326_VER__
; #ifdef SEND__IN_FUNCTION
; #else
; while(!SPIF){} // Wait for initial SPI transfer to end;
; SPIF = 0; // Clear SPI Interrupt flag;
; #endif
; #endif
;
; // If an argument is required, transmit
; // one, otherwise transmit 4 bytes of
; // 0x00;
; plast = &pchar[current_blklen];
; SOURCE LINE # 402
LCALL L?0150
MOV R6,A
INC DPTR
MOVX A,@DPTR
MOV R7,A
MOV A,R1
ADD A,R7
MOV R1,A
MOV A,R2
ADDC A,R6
MOV R2,A
MOV DPTR,#plast?152
MOV A,R3
LCALL L?0143
; if(current_command.arg_required == YES) {
; SOURCE LINE # 403
MOV R0,#LOW (current_command?144+01H)
MOV A,@R0
CJNE A,#01H,?C0005
; counter = 0;
; SOURCE LINE # 404
LCALL L?0161
?C0006:
; while(counter <= 3) {
; SOURCE LINE # 405
MOV R0,#LOW (counter?148)
MOV A,@R0
MOV R6,A
INC R0
MOV A,@R0
MOV R7,A
SETB C
SUBB A,#03H
MOV A,R6
SUBB A,#00H
JNC ?C0008
; #ifdef __F326_VER__
; Write_Read_Spi_Byte(long_arg.b[counter]);
; counter++;
; #else
; #ifdef SEND__IN_FUNCTION
; Write_Read_Spi_Byte(long_arg.b[counter]);
; SOURCE LINE # 411
MOV A,#LOW (long_arg?145)
ADD A,R7
MOV R0,A
MOV A,@R0
MOV R7,A
LCALL _Write_Read_Spi_Byte
; counter++;
; SOURCE LINE # 412
MOV R0,#LOW (counter?148+01H)
INC @R0
MOV A,@R0
DEC R0
JNZ ?C0006
INC @R0
?C0120:
; #else
; SPI0DAT = long_arg.b[counter];
; counter++;
; while(!SPIF){}
; SPIF = 0;
; #endif
; #endif
; }
; SOURCE LINE # 420
SJMP ?C0006
; } else {
; SOURCE LINE # 421
?C0005:
; counter = 0;
; SOURCE LINE # 422
LCALL L?0162
?C0009:
; while(counter <= 3) {
; SOURCE LINE # 423
; #ifdef __F326_VER__
; Write_Read_Spi_Byte(0x00);
; counter++;
; #else
; #ifdef SEND__IN_FUNCTION
; Write_Read_Spi_Byte(0x00);
; SOURCE LINE # 429
CLR A
MOV R7,A
LCALL _Write_Read_Spi_Byte
; counter++;
; SOURCE LINE # 430
MOV R0,#LOW (counter?148+01H)
INC @R0
MOV A,@R0
DEC R0
JNZ ?C0121
INC @R0
?C0121:
; #else
; SPI0DAT = 0x00;
; counter++;
; while(!SPIF){}
; SPIF = 0;
; #endif
; #endif
; }
; SOURCE LINE # 438
LCALL L?0173
JC ?C0009
; }
; SOURCE LINE # 439
?C0008:
; #ifdef __F326_VER__
; Write_Read_Spi_Byte(current_command.CRC);
; #else
; #ifdef SEND__IN_FUNCTION
; Write_Read_Spi_Byte(current_command.CRC);
; SOURCE LINE # 444
MOV R0,#LOW (current_command?144+02H)
MOV A,@R0
MOV R7,A
LCALL _Write_Read_Spi_Byte
; #else
; SPI0DAT = current_command.CRC; // Transmit CRC byte; In all cases
; while(!SPIF){} // except CMD0, this will be a dummy
; SPIF = 0; // character;
; #endif
; #endif
; // The command table entry will indicate
; // what type of response to expect for
; // a given command; The following
; // conditional handles the MMC response;
; if(current_command.response == R1) { // Read the R1 response from the card;
; SOURCE LINE # 455
MOV R0,#LOW (current_command?144+04H)
MOV A,@R0
JNZ ?C0011
; loopguard=0;
; SOURCE LINE # 456
MOV DPTR,#loopguard?143
MOVX @DPTR,A
?C0014:
; do {
; SOURCE LINE # 457
; #ifdef __F326_VER__
; card_response.b[0] = Write_Read_Spi_Byte(0xFF);
; #else
;
; #ifdef SEND__IN_FUNCTION
; card_response.b[0] = Write_Read_Spi_Byte(0xFF);
; SOURCE LINE # 463
; #else
; SPI0DAT = 0xFF; // Write dummy value to SPI so that
; while(!SPIF){} // the response byte will be shifted in;
; SPIF = 0;
; card_response.b[0] = SPI0DAT; // Save the response;
; #endif
; #endif
;
; if(!++loopguard) break;
; SOURCE LINE # 472
LCALL L?0144
JZ ?C0013
?C0015:
; if(card_response.b[0] & BUSY_BIT) {
; SOURCE LINE # 473
MOV R0,#LOW (card_response?149)
MOV A,@R0
JNB ACC.7,?C0012
; // printf("R1 response 0x%02bX\r\n",card_response.b[0]);
; Wait_ns(700);
; SOURCE LINE # 475
LCALL L?0170
; }
; SOURCE LINE # 476
; } while((card_response.b[0] & BUSY_BIT));
; SOURCE LINE # 477
?C0012:
MOV R0,#LOW (card_response?149)
MOV A,@R0
JB ACC.7,?C0014
?C0013:
; if(!loopguard) {
; SOURCE LINE # 478
MOV DPTR,#loopguard?143
MOVX A,@DPTR
JZ $ + 5H
LJMP ?C0019
; /*printf("R1 response 0x%02bX\r\n",card_response.b[0]);*/
; return card_response.b[0];}//{ return 0; }
; SOURCE LINE # 480
MOV R0,#LOW (card_response?149)
MOV A,@R0
MOV R7,A
MOV R6,#00H
RET
; } // Read the R1b response;
; SOURCE LINE # 481
?C0011:
; else if(current_command.response == R1b) {
; SOURCE LINE # 482
MOV R0,#LOW (current_command?144+04H)
MOV A,@R0
XRL A,#01H
JNZ ?C0020
; loopguard = 0;
; SOURCE LINE # 483
MOV DPTR,#loopguard?143
MOVX @DPTR,A
?C0023:
; do {
; SOURCE LINE # 484
; #ifdef __F326_VER__
; card_response.b[0] = Write_Read_Spi_Byte(0xFF);
; #else
; #ifdef SEND__IN_FUNCTION
; card_response.b[0] = Write_Read_Spi_Byte(0xFF);
; SOURCE LINE # 489
; #else
; SPI0DAT = 0xFF; // Start SPI transfer;
; while(!SPIF){}
; SPIF = 0;
; card_response.b[0] = SPI0DAT; // Save card response
; #endif
; #endif
; if(!++loopguard) break;
; SOURCE LINE # 497
LCALL L?0144
JZ ?C0025
; }
; SOURCE LINE # 498
?C0021:
; while((card_response.b[0] & BUSY_BIT));
; SOURCE LINE # 499
MOV R0,#LOW (card_response?149)
MOV A,@R0
JB ACC.7,?C0023
?C0025:
; #ifdef __F326_VER__
; while(Write_Read_Spi_Byte(0xff) == 0x00);
; #else
; #ifdef SEND__IN_FUNCTION
; while(Write_Read_Spi_Byte(0xff) == 0x00);
; SOURCE LINE # 504
LCALL L?0178
JZ $ + 5H
LJMP ?C0019
SJMP ?C0025
; #else
; loopguard = 0;
; do { // Wait for busy signal to end;
; SPI0DAT = 0xFF;
; while(!SPIF){}
; SPIF = 0;
; if(!++loopguard) break;
; } while(SPI0DAT == 0x00); // When byte from card is non-zero,
; if(!loopguard) {BACK_FROM_ERROR;}
; #endif
; #endif
; } // card is no longer busy;
; SOURCE LINE # 516
?C0020:
; // Read R2 response
; else if(current_command.response == R2) {
; SOURCE LINE # 518
MOV R0,#LOW (current_command?144+04H)
MOV A,@R0
XRL A,#02H
JNZ ?C0028
; loopguard=0;
; SOURCE LINE # 519
MOV DPTR,#loopguard?143
MOVX @DPTR,A
?C0031:
; do {
; SOURCE LINE # 520
; #ifdef __F326_VER__
; card_response.b[0] = Write_Read_Spi_Byte(0xFF);
; #else
; #ifdef SEND__IN_FUNCTION
; card_response.b[0] = Write_Read_Spi_Byte(0xFF);
; SOURCE LINE # 525
; #else
; SPI0DAT = 0xFF; // Start SPI transfer;
; while(!SPIF){}
; SPIF = 0;
; card_response.b[0] = SPI0DAT; // Read first byte of response;
; #endif
; #endif
; if(!++loopguard) break;
; SOURCE LINE # 533
LCALL L?0153
JZ ?C0030
; } while((card_response.b[0] & BUSY_BIT));
; SOURCE LINE # 534
?C0029:
MOV R0,#LOW (card_response?149)
MOV A,@R0
JB ACC.7,?C0031
?C0030:
;
; if(!loopguard) { BACK_FROM_ERROR; }
; SOURCE LINE # 536
MOV DPTR,#loopguard?143
MOVX A,@DPTR
JNZ ?C0033
MOV SPI0DAT,#0FFH
?C0034:
JNB SPIF,?C0034
?C0035:
LCALL L?0163
?C0036:
JNB SPIF,?C0036
?C0037:
LJMP ?C0138
?C0033:
; #ifdef __F326_VER__
; card_response.b[1] = Write_Read_Spi_Byte(0xFF);
; #else
; #ifdef SEND__IN_FUNCTION
; card_response.b[1] = Write_Read_Spi_Byte(0xFF);
; SOURCE LINE # 541
MOV R7,#0FFH
LCALL _Write_Read_Spi_Byte
MOV R0,#LOW (card_response?149+01H)
MOV A,R7
MOV @R0,A
; #else
; SPI0DAT = 0xFF;
; while(!SPIF){}
; SPIF = 0;
; card_response.b[1] = SPI0DAT; // Read second byte of response;
; #endif
; #endif
; } else { // Read R3 response;
; SOURCE LINE # 549
SJMP ?C0019
?C0028:
; loopguard=0;
; SOURCE LINE # 550
CLR A
MOV DPTR,#loopguard?143
MOVX @DPTR,A
?C0041:
; do {
; SOURCE LINE # 551
; #ifdef __F326_VER__
; card_response.b[0] = Write_Read_Spi_Byte(0xFF);
; #else
; #ifdef SEND__IN_FUNCTION
; card_response.b[0] = Write_Read_Spi_Byte(0xFF);
; SOURCE LINE # 556
; #else
; SPI0DAT = 0xFF; // Start SPI transfer;
; while(!SPIF){}
; SPIF = 0;
; card_response.b[0] = SPI0DAT; // Read first byte of response;
; #endif
; #endif
; if(!++loopguard) break;
; SOURCE LINE # 564
LCALL L?0153
JZ ?C0040
; } while((card_response.b[0] & BUSY_BIT));
; SOURCE LINE # 565
?C0039:
MOV R0,#LOW (card_response?149)
MOV A,@R0
JB ACC.7,?C0041
?C0040:
;
; if(!loopguard) { BACK_FROM_ERROR; }
; SOURCE LINE # 567
MOV DPTR,#loopguard?143
MOVX A,@DPTR
JNZ ?C0043
MOV SPI0DAT,#0FFH
?C0044:
JNB SPIF,?C0044
?C0045:
LCALL L?0163
?C0046:
JNB SPIF,?C0046
?C0047:
?C0136:
LJMP ?C0138
?C0043:
; counter = 0;
; SOURCE LINE # 568
LCALL L?0162
?C0048:
; while(counter <= 3) // Read next three bytes and store them
; SOURCE LINE # 569
LCALL L?0173
JNC ?C0019
; { // in local memory; These bytes make up
; SOURCE LINE # 570
; counter++; // the Operating Conditions Register
; SOURCE LINE # 571
INC R0
INC @R0
MOV A,@R0
DEC R0
JNZ ?C0122
INC @R0
?C0122:
; #ifdef __F326_VER__
; *pchar++ = Write_Read_Spi_Byte(0xFF);
; #else
; #ifdef SEND__IN_FUNCTION
; *pchar++ = Write_Read_Spi_Byte(0xFF);
; SOURCE LINE # 576
MOV R7,#0FFH
LCALL _Write_Read_Spi_Byte
MOV DPTR,#pchar?142
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -