📄 main.lss
字号:
char mmcSetBlockLength (const unsigned long blocklength)
{
//char rValue = MMC_TIMEOUT_ERROR;
//char i = 0;
// SS = LOW (on)
//CS_LOW ();
// Set the block length to read
//MMC_SET_BLOCKLEN =CMD16
mmcSendCmd(16, blocklength, 0xFF);
// get response from MMC - make sure that its 0x00 (R1 ok response format)
if(mmcGetResponse()!=0x00);
//CS_HIGH ();
// Send 8 Clock pulses of delay.
spiSendByte(0xff);
return MMC_SUCCESS;
}
unsigned char spiSendByte(const unsigned char data)
{
/*
unsigned char spib;
//while(SSIOST_bit.BUSY != 0); // Wait until the character can be sent
SSIOINT_bit.TXCMP = 1; //clear interrupt register
SSIOBUF = data; // Send the data
while((SSIOINT & 0x02) != 0x02); // Wait for the transfer to complete
spib = SSIOBUF; // Get the data received
SSIOINT_bit.RXCMP = 1; //clear interrupt register
return spib; //return transmited character
*/
/*
//NOTE!!! This function send character to SPI bus when mode is MASTER
//NOTE!!! This function receive character from SPI when mode is SLAVE
unsigned int spib;
//while(SSPSR_bit.BSY); // Wait until the character can be sent
while(SSPSR_bit.TNF == 0);
SSPDR = data; // Send the data
//while(!SPSR0_bit.SPIF); // Wait for the transfer to complete
while(SSPSR_bit.RNE == 0); // Wait until the character can be sent
spib = SSPDR; // Get the data received
return spib;
//return 0;
*/
/*
unsigned int spib;
while((s_pSpi->SPI_SR & AT91C_SPI_RDRF) == 1); // Wait until the character can be sent
s_pSpi->SPI_RDR = data; // Send the data
while((s_pSpi->SPI_SR & AT91C_SPI_TDRE) == 1); // Wait for the transfer to complete
spib = s_pSpi->SPI_TDR; // Get the data received
return spib;
*/
unsigned int spib;
//while((s_pSpi->SPI_SR & AT91C_SPI_TDRE) == 0); // Wait for the transfer to complete
while((s_pSpi->SPI_SR & AT91C_SPI_TXEMPTY) == 0);
10058c: 4b07 ldr r3, [pc, #28] (1005ac <.text+0x5ac>) 10058e: 0600 lsl r0, r0, #24 100590: 681a ldr r2, [r3, #0] 100592: 0e00 lsr r0, r0, #24 100594: 6913 ldr r3, [r2, #16] 100596: 0599 lsl r1, r3, #22 100598: d5fc bpl 100594 <spiSendByte+0x8> s_pSpi->SPI_TDR = (data & 0xFFFF); // Send the data
10059a: 60d0 str r0, [r2, #12]
while((s_pSpi->SPI_SR & AT91C_SPI_RDRF) == 0); // Wait until the character can be sent
10059c: 6913 ldr r3, [r2, #16] 10059e: 07d9 lsl r1, r3, #31 1005a0: d5fc bpl 10059c <spiSendByte+0x10> spib = ((s_pSpi->SPI_RDR) & 0xFFFF); // Get the data received
1005a2: 6890 ldr r0, [r2, #8] 1005a4: 0600 lsl r0, r0, #24 1005a6: 0e00 lsr r0, r0, #24 return spib;
}
1005a8: 4770 bx lr 1005aa: 0000 lsl r0, r0, #0 1005ac: 003c lsl r4, r7, #0 1005ae: 0020 lsl r0, r4, #0001005b0 <mmcSendCmd>: 1005b0: b510 push {r4, lr} 1005b2: 0600 lsl r0, r0, #24 1005b4: b082 sub sp, #8 1005b6: 2340 mov r3, #64 1005b8: 0e00 lsr r0, r0, #24 1005ba: 4318 orr r0, r3 1005bc: 466b mov r3, sp 1005be: 0612 lsl r2, r2, #24 1005c0: 3302 add r3, #2 1005c2: 466c mov r4, sp 1005c4: 7018 strb r0, [r3, #0] 1005c6: 0e12 lsr r2, r2, #24 1005c8: 2018 mov r0, #24 1005ca: 3403 add r4, #3 1005cc: 1c0b mov r3, r1 (add r3, r1, #0) 1005ce: 40c3 lsr r3, r0 1005d0: 3808 sub r0, #8 1005d2: 7023 strb r3, [r4, #0] 1005d4: 1c03 mov r3, r0 (add r3, r0, #0) 1005d6: 3401 add r4, #1 1005d8: 3308 add r3, #8 1005da: d1f7 bne 1005cc <mmcSendCmd+0x1c> 1005dc: 466b mov r3, sp 1005de: 3302 add r3, #2 1005e0: 715a strb r2, [r3, #5] 1005e2: 1c1c mov r4, r3 (add r4, r3, #0) 1005e4: 7820 ldrb r0, [r4, #0] 1005e6: ffd1f7ff bl 10058c <spiSendByte> 1005ea: 3401 add r4, #1 1005ec: ab02 add r3, sp, #8 1005ee: 429c cmp r4, r3 1005f0: d1f8 bne 1005e4 <mmcSendCmd+0x34> 1005f2: b002 add sp, #8 1005f4: bc10 pop {r4} 1005f6: bc01 pop {r0} 1005f8: 4700 bx r0 ...001005fc <mmcGetResponse>: 1005fc: b510 push {r4, lr} 1005fe: 2441 mov r4, #65 100600: 20ff mov r0, #255 100602: ffc3f7ff bl 10058c <spiSendByte> 100606: 2800 cmp r0, #0 100608: d004 beq 100614 <mmcGetResponse+0x18> 10060a: 2801 cmp r0, #1 10060c: d002 beq 100614 <mmcGetResponse+0x18> 10060e: 3c01 sub r4, #1 100610: 2c00 cmp r4, #0 100612: d1f5 bne 100600 <mmcGetResponse+0x4> 100614: bc10 pop {r4} 100616: bc02 pop {r1} 100618: 4708 bx r1 ...0010061c <initMMC>: 10061c: b510 push {r4, lr} 10061e: ff89f7ff bl 100534 <initSPI> 100622: 240a mov r4, #10 100624: 20ff mov r0, #255 100626: 3c01 sub r4, #1 100628: ffb0f7ff bl 10058c <spiSendByte> 10062c: 2c00 cmp r4, #0 10062e: d1f9 bne 100624 <initMMC+0x8> 100630: 2000 mov r0, #0 100632: 2100 mov r1, #0 100634: 2295 mov r2, #149 100636: ffbbf7ff bl 1005b0 <mmcSendCmd> 10063a: ffdff7ff bl 1005fc <mmcGetResponse> 10063e: 20ff mov r0, #255 100640: ffa4f7ff bl 10058c <spiSendByte> 100644: 2001 mov r0, #1 100646: 2100 mov r1, #0 100648: 22ff mov r2, #255 10064a: ffb1f7ff bl 1005b0 <mmcSendCmd> 10064e: ffd5f7ff bl 1005fc <mmcGetResponse> 100652: 2801 cmp r0, #1 100654: d0f3 beq 10063e <initMMC+0x22> 100656: 20ff mov r0, #255 100658: ff98f7ff bl 10058c <spiSendByte> 10065c: 2000 mov r0, #0 10065e: bc10 pop {r4} 100660: bc02 pop {r1} 100662: 4708 bx r100100664 <mmcGetXXResponse>: 100664: b530 push {r4, r5, lr} 100666: 0600 lsl r0, r0, #24 100668: 4c06 ldr r4, [pc, #24] (100684 <.text+0x684>) 10066a: 0e05 lsr r5, r0, #24 10066c: 20ff mov r0, #255 10066e: ff8df7ff bl 10058c <spiSendByte> 100672: 42a8 cmp r0, r5 100674: d002 beq 10067c <mmcGetXXResponse+0x18> 100676: 3c01 sub r4, #1 100678: 2c00 cmp r4, #0 10067a: d1f7 bne 10066c <mmcGetXXResponse+0x8> 10067c: bc30 pop {r4, r5} 10067e: bc02 pop {r1} 100680: 4708 bx r1 100682: 0000 lsl r0, r0, #0 100684: 01f5 lsl r5, r6, #7 ...00100688 <mmcCheckBusy>: 100688: b510 push {r4, lr} 10068a: 2400 mov r4, #0 10068c: 20ff mov r0, #255 10068e: ff7df7ff bl 10058c <spiSendByte> 100692: 231f mov r3, #31 100694: 4018 and r0, r3 100696: 280b cmp r0, #11 100698: d004 beq 1006a4 <mmcCheckBusy+0x1c> 10069a: 280d cmp r0, #13 10069c: d004 beq 1006a8 <mmcCheckBusy+0x20> 10069e: 2805 cmp r0, #5 1006a0: d10a bne 1006b8 <mmcCheckBusy+0x30> 1006a2: e003 b 1006ac <mmcCheckBusy+0x24> 1006a4: 2010 mov r0, #16 1006a6: e00b b 1006c0 <mmcCheckBusy+0x38> 1006a8: 2011 mov r0, #17 1006aa: e009 b 1006c0 <mmcCheckBusy+0x38> 1006ac: 20ff mov r0, #255 1006ae: ff6df7ff bl 10058c <spiSendByte> 1006b2: 2800 cmp r0, #0 1006b4: d0fa beq 1006ac <mmcCheckBusy+0x24> 1006b6: e003 b 1006c0 <mmcCheckBusy+0x38> 1006b8: 3401 add r4, #1 1006ba: 2c41 cmp r4, #65 1006bc: d0f6 beq 1006ac <mmcCheckBusy+0x24> 1006be: e7e5 b 10068c <mmcCheckBusy+0x4> 1006c0: bc10 pop {r4} 1006c2: bc02 pop {r1} 1006c4: 4708 bx r1 ...001006c8 <mmcSetBlockLength>: 1006c8: b500 push {lr} 1006ca: 1c01 mov r1, r0 (add r1, r0, #0) 1006cc: 22ff mov r2, #255 1006ce: 2010 mov r0, #16 1006d0: ff6ef7ff bl 1005b0 <mmcSendCmd> 1006d4: ff92f7ff bl 1005fc <mmcGetResponse> 1006d8: 20ff mov r0, #255 1006da: ff57f7ff bl 10058c <spiSendByte> 1006de: 2000 mov r0, #0 1006e0: bc02 pop {r1} 1006e2: 4708 bx r1001006e4 <mmcReadBlock>: 1006e4: b510 push {r4, lr} 1006e6: 1c04 mov r4, r0 (add r4, r0, #0) 1006e8: 1c08 mov r0, r1 (add r0, r1, #0) 1006ea: ffedf7ff bl 1006c8 <mmcSetBlockLength> 1006ee: 2800 cmp r0, #0 1006f0: d001 beq 1006f6 <mmcReadBlock+0x12> 1006f2: 2401 mov r4, #1 1006f4: e021 b 10073a <mmcReadBlock+0x56> 1006f6: 2011 mov r0, #17 1006f8: 1c21 mov r1, r4 (add r1, r4, #0) 1006fa: 22ff mov r2, #255 1006fc: ff58f7ff bl 1005b0 <mmcSendCmd> 100700: ff7cf7ff bl 1005fc <mmcGetResponse> 100704: 2800 cmp r0, #0 100706: d001 beq 10070c <mmcReadBlock+0x28> 100708: 2402 mov r4, #2 10070a: e016 b 10073a <mmcReadBlock+0x56> 10070c: 20fe mov r0, #254 10070e: ffa9f7ff bl 100664 <mmcGetXXResponse> 100712: 28fe cmp r0, #254 100714: d001 beq 10071a <mmcReadBlock+0x36> 100716: 2403 mov r4, #3 100718: e00f b 10073a <mmcReadBlock+0x56> 10071a: 4c0b ldr r4, [pc, #44] (100748 <.text+0x748>) 10071c: 20ff mov r0, #255 10071e: ff35f7ff bl 10058c <spiSendByte> 100722: 4b0a ldr r3, [pc, #40] (10074c <.text+0x74c>) 100724: 7020 strb r0, [r4, #0] 100726: 3401 add r4, #1 100728: 429c cmp r4, r3 10072a: d1f7 bne 10071c <mmcReadBlock+0x38> 10072c: 20ff mov r0, #255 10072e: ff2df7ff bl 10058c <spiSendByte> 100732: 20ff mov r0, #255 100734: ff2af7ff bl 10058c <spiSendByte> 100738: 2400 mov r4, #0 10073a: 20ff mov r0, #255 10073c: ff26f7ff bl 10058c <spiSendByte> 100740: 1c20 mov r0, r4 (add r0, r4, #0) 100742: bc10 pop {r4} 100744: bc02 pop {r1} 100746: 4708 bx r1 100748: 0066 lsl r6, r4, #1 10074a: 0020 lsl r0, r4, #0 10074c: 0266 lsl r6, r4, #9 10074e: 0020 lsl r0, r4, #000100750 <mmcWriteBlock>: 100750: b510 push {r4, lr} 100752: 1c04 mov r4, r0 (add r4, r0, #0) 100754: 2080 mov r0, #128 100756: 0080 lsl r0, r0, #2 100758: ffb6f7ff bl 1006c8 <mmcSetBlockLength> 10075c: 2800 cmp r0, #0 10075e: d001 beq 100764 <mmcWriteBlock+0x14> 100760: 2401 mov r4, #1 100762: e020 b 1007a6 <mmcWriteBlock+0x56> 100764: 2018 mov r0, #24 100766: 1c21 mov r1, r4 (add r1, r4, #0) 100768: 22ff mov r2, #255 10076a: ff21f7ff bl 1005b0 <mmcSendCmd> 10076e: 2000 mov r0, #0 100770: ff78f7ff bl 100664 <mmcGetXXResponse> 100774: 2800 cmp r0, #0 100776: d115 bne 1007a4 <mmcWriteBlock+0x54> 100778: 20ff mov r0, #255 10077a: ff07f7ff bl 10058c <spiSendByte> 10077e: 20fe mov r0, #254 100780: ff04f7ff bl 10058c <spiSendByte> 100784: 4c0b ldr r4, [pc, #44] (1007b4 <.text+0x7b4>) 100786: 7820 ldrb r0, [r4, #0] 100788: ff00f7ff bl 10058c <spiSendByte> 10078c: 4b0a ldr r3, [pc, #40] (1007b8 <.text+0x7b8>) 10078e: 3401 add r4, #1 100790: 429c cmp r4, r3 100792: d1f8 bne 100786 <mmcWriteBlock+0x36> 100794: 20ff mov r0, #255 100796: fef9f7ff bl 10058c <spiSendByte> 10079a: 20ff mov r0, #255 10079c: fef6f7ff bl 10058c <spiSendByte> 1007a0: ff72f7ff bl 100688 <mmcCheckBusy> 1007a4: 2402 mov r4, #2 1007a6: 20ff mov r0, #255 1007a8: fef0f7ff bl 10058c <spiSendByte> 1007ac: 1c20 mov r0, r4 (add r0, r4, #0) 1007ae: bc10 pop {r4} 1007b0: bc02 pop {r1} 1007b2: 4708 bx r1 1007b4: 0066 lsl r6, r4, #1 1007b6: 0020 lsl r0, r4, #0 1007b8: 0266 lsl r6, r4, #9 1007ba: 0020 lsl r0, r4, #0001007bc <spiWriteByte>:
void spiWriteByte(const unsigned char data)
{
//while(SSIOST_bit.BUSY != 0); // Wait until the character can be sent
//SSIOINT_bit.TXCMP = 1; // clear interrupt register
//SSIOBUF = data;
//while((s_pSpi->SPI_SR & AT91C_SPI_RDRF) == 1); // Wait until the character can be sent
//s_pSpi->SPI_RDR = data; // Send the data
}
1007bc: 4770 bx lr ...001007c0 <spiReadByte>:
unsigned char spiReadByte()
{
//unsigned char spib;
//while(SSIOINT_bit.RXCMP == 0);
//spib = SSIOBUF; // Get the data received
//SSIOINT_bit.RXCMP = 1; //clear interrupt register
//return spib;
return 0;
}
1007c0: 2000 mov r0, #0 1007c2: 4770 bx lr001007c4 <mmcReadRegister>:
// Reading the contents of the CSD and CID registers in SPI mode is a simple
// read-block transaction.
char mmcReadRegister (const char cmd_register, const unsigned char length)
{
1007c4: b570 push {r4, r5, r6, lr} 1007c6: 0609 lsl r1, r1, #24 1007c8: 0600 lsl r0, r0, #24 1007ca: 0e0e lsr r6, r1, #24 1007cc: 0e04 lsr r4, r0, #24 char uc = 0;
char rvalue = MMC_TIMEOUT_ERROR;
// char i = 0;
if (mmcSetBlockLength (length) == MMC_SUCCESS)
1007ce: 1c30 mov r0, r6 (add r0, r6, #0) 1007d0: ff7af7ff bl 1006c8 <mmcSetBlockLength> 1007d4: 2800 cmp r0, #0 1007d6: d001 beq 1007dc <mmcReadRegister+0x18> 1007d8: 24ff mov r4, #255 1007da: e025 b 100828 <mmcReadRegister+0x64> {
//CS_LOW ();
// CRC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -