⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdmmc_spi.lst

📁 Tried to make CAN logger on AT91sam7X-ek, but have no idea how to implement FATFs... -( I m just a
💻 LST
📖 第 1 页 / 共 5 页
字号:
    341          static unsigned char SD_SPI_R1(unsigned char *pResp)
    342          {
   \                     SD_SPI_R1:
   \   00000000   10402DE9           PUSH     {R4,LR}
   \   00000004   0040A0E1           MOV      R4,R0
    343              DecodeR1(*pResp);
   \   00000008   0000D4E5           LDRB     R0,[R4, #+0]
   \   0000000C   ........           BL       DecodeR1
    344          
    345              if((*pResp & 0x7E) !=0) {
   \   00000010   0000D4E5           LDRB     R0,[R4, #+0]
   \   00000014   ........           B        ?Subroutine3
    346                  // An error occured
    347                  return SD_ERROR_NORESPONSE;
    348              }
    349              else {
    350                  return 0;
    351              }
    352          }

   \                                 In section .text, align 4, keep-with-next
   \                     ?Subroutine3:
   \   00000000   7E0010E3           TST      R0,#0x7E
   \   00000004   0200A013           MOVNE    R0,#+2
   \   00000008   0000A003           MOVEQ    R0,#+0
   \   0000000C                      REQUIRE ??Subroutine5_0
   \   0000000C                      ;; // Fall through to label ??Subroutine5_0

   \                                 In section .text, align 4, keep-with-next
   \                     ??Subroutine5_0:
   \   00000000   1040BDE8           POP      {R4,LR}
   \   00000004   1EFF2FE1           BX       LR               ;; return
   \                     ??Subroutine5_1:
   \   00000008   ........           DC32     `?<Constant "-I- Card is busy\\n\\r">`
    353          
    354          //------------------------------------------------------------------------------
    355          /// Check SPI mode response 1b.
    356          /// Returns 0 if no error; Otherwise, returns error.
    357          /// \param pResp  Pointer to response token.
    358          //------------------------------------------------------------------------------

   \                                 In section .text, align 4, keep-with-next
    359          static unsigned char SD_SPI_R1b(unsigned char *pResp)
    360          {
   \                     SD_SPI_R1b:
   \   00000000   10402DE9           PUSH     {R4,LR}
   \   00000004   0040A0E1           MOV      R4,R0
    361              // A zero value indicates card is busy.
    362              // A non-zero value indicates the card is ready for the next command.
    363              if( (*pResp) == 0 ) {
   \   00000008   0000D4E5           LDRB     R0,[R4, #+0]
   \   0000000C   000050E3           CMP      R0,#+0
    364                  TRACE_INFO("Card is busy\n\r");
   \   00000010   ........           LDREQ    R0,??Subroutine5_1  ;; `?<Constant "-I- Card is busy\\n\\r">`
   \   00000014   ........           BLEQ     printf
    365              }
    366          
    367              DecodeR1(*(pResp+1));
   \   00000018   0100D4E5           LDRB     R0,[R4, #+1]
   \   0000001C   ........           BL       DecodeR1
    368              if(((*(pResp+1)) & 0x7E) !=0) {
   \   00000020   0100D4E5           LDRB     R0,[R4, #+1]
   \   00000024                      REQUIRE ?Subroutine3
   \   00000024                      ;; // Fall through to label ?Subroutine3
    369                  // An error occured
    370                  return SD_ERROR_NORESPONSE;
    371              }
    372              else {
    373                  return 0;
    374              }
    375          }
    376          
    377          //------------------------------------------------------------------------------
    378          /// Check SPI mode response 2.
    379          /// Returns 0 if no error; Otherwise, returns error.
    380          /// \param pResp  Pointer to response token.
    381          //------------------------------------------------------------------------------

   \                                 In section .text, align 4, keep-with-next
    382          static unsigned char SD_SPI_R2(unsigned char *pResp)
    383          {
   \                     SD_SPI_R2:
   \   00000000   10402DE9           PUSH     {R4,LR}
   \   00000004   0040A0E1           MOV      R4,R0
    384              DecodeR1(*pResp);
   \   00000008   0000D4E5           LDRB     R0,[R4, #+0]
   \   0000000C   ........           BL       DecodeR1
    385              DecodeR2(*(pResp+1));
   \   00000010   0100D4E5           LDRB     R0,[R4, #+1]
   \   00000014   ........           BL       DecodeR2
    386          
    387              if((( *pResp & 0x7e ) != 0) && (*(pResp+1) != 0)) {
   \   00000018   0000D4E5           LDRB     R0,[R4, #+0]
   \   0000001C   7E0010E3           TST      R0,#0x7E
   \   00000020   0400000A           BEQ      ??SD_SPI_R2_0
   \   00000024   0100D4E5           LDRB     R0,[R4, #+1]
   \   00000028   000050E3           CMP      R0,#+0
   \   0000002C   0200000A           BEQ      ??SD_SPI_R2_1
    388                  return SD_ERROR_NORESPONSE;
   \   00000030   0200A0E3           MOV      R0,#+2
   \   00000034   000000EA           B        ??SD_SPI_R2_1
    389              }
    390              else {
    391                  return 0;
   \                     ??SD_SPI_R2_0:
   \   00000038   0000A0E3           MOV      R0,#+0
   \                     ??SD_SPI_R2_1:
   \   0000003C   ........           B        ??Subroutine5_0
    392              }
    393          }
    394          
    395          //------------------------------------------------------------------------------
    396          /// Check SPI mode response 3.
    397          /// Returns 0 if no error; Otherwise, returns error.
    398          /// \param pResp  Pointer to response token.
    399          //------------------------------------------------------------------------------

   \                                 In section .text, align 4, keep-with-next
    400          static unsigned char SD_SPI_R3(unsigned char *pResp, unsigned int *ocr)
    401          {
    402              // *pResp: bit 32-39: R1
    403              if(( *pResp & 0x7e ) != 0) {
   \                     SD_SPI_R3:
   \   00000000   0020D0E5           LDRB     R2,[R0, #+0]
   \   00000004   7E0012E3           TST      R2,#0x7E
    404                  return SD_ERROR_NORESPONSE;
   \   00000008   0200A013           MOVNE    R0,#+2
   \   0000000C   0900001A           BNE      ??SD_SPI_R3_0
    405              }
    406              else {
    407                  // bit 0-31: OCR
    408                  *ocr = ((*(pResp+1) << 24) \
    409                         |(*(pResp+2) << 16) \
    410                         |(*(pResp+3) << 8)  \
    411                         | *(pResp+4));
   \   00000010   0120D0E5           LDRB     R2,[R0, #+1]
   \   00000014   0230D0E5           LDRB     R3,[R0, #+2]
   \   00000018   0338A0E1           LSL      R3,R3,#+16
   \   0000001C   022C83E1           ORR      R2,R3,R2, LSL #+24
   \   00000020   0330D0E5           LDRB     R3,[R0, #+3]
   \   00000024   032482E1           ORR      R2,R2,R3, LSL #+8
   \   00000028   0400D0E5           LDRB     R0,[R0, #+4]
   \   0000002C   020080E1           ORR      R0,R0,R2
   \   00000030   000081E5           STR      R0,[R1, #+0]
    412                  return 0;
   \   00000034   0000A0E3           MOV      R0,#+0
   \                     ??SD_SPI_R3_0:
   \   00000038   1EFF2FE1           BX       LR               ;; return
    413              }
    414          }
    415          
    416          //------------------------------------------------------------------------------
    417          /// Check SPI mode response 7.
    418          /// Returns 0 if no error; Otherwise, returns error.
    419          /// \param pResp  Pointer to response token.
    420          //------------------------------------------------------------------------------

   \                                 In section .text, align 4, keep-with-next
    421          static unsigned char SD_SPI_R7(unsigned char *pResp, unsigned char *isSdhc)
    422          {
    423              *isSdhc = 0;
   \                     SD_SPI_R7:
   \   00000000   0020A0E3           MOV      R2,#+0
   \   00000004   0020C1E5           STRB     R2,[R1, #+0]
    424          
    425              if(( *pResp & 0x7e ) != 0) {
   \   00000008   0020D0E5           LDRB     R2,[R0, #+0]
   \   0000000C   7E0012E3           TST      R2,#0x7E
    426                  return SD_ERROR_NORESPONSE;
   \   00000010   0200A013           MOVNE    R0,#+2
   \   00000014   0600001A           BNE      ??SD_SPI_R7_0
    427              }
    428              else {
    429                  // *(pResp+4): bit 0- 7: check pattern
    430                  // *(pResp+3): bit 8-11: voltage accepted:  0x01: 2.7-3.6V
    431                  if ((*(pResp+3) == 0x1) && (*(pResp+4) == 0xAA)) {
   \   00000018   0320D0E5           LDRB     R2,[R0, #+3]
   \   0000001C   010052E3           CMP      R2,#+1
   \   00000020   0400D005           LDRBEQ   R0,[R0, #+4]
   \   00000024   AA005003           CMPEQ    R0,#+170
    432                      *isSdhc = 1;
   \   00000028   0100A003           MOVEQ    R0,#+1
   \   0000002C   0000C105           STRBEQ   R0,[R1, #+0]
    433                  }
    434                  else {
    435                      *isSdhc = 0;
    436                  }
    437                  return 0;
   \   00000030   0000A0E3           MOV      R0,#+0
   \                     ??SD_SPI_R7_0:
   \   00000034   1EFF2FE1           BX       LR               ;; return
    438              }
    439          }
    440          
    441          //------------------------------------------------------------------------------
    442          /// Initialization delay: The maximum of 1 msec, 74 clock cycles and supply ramp
    443          /// up time.
    444          /// Returns the command transfer result (see SendCommand).
    445          /// \param pSd  Pointer to a SdCard driver instance.
    446          //------------------------------------------------------------------------------

   \                                 In section .text, align 4, keep-with-next
    447          static unsigned char Pon(SdCard *pSd)
    448          {
   \                     Pon:
   \   00000000   38402DE9           PUSH     {R3-R5,LR}
   \   00000004   0040A0E1           MOV      R4,R0
    449              SdCmd *pCommand = &(pSd->command);
   \   00000008   045084E2           ADD      R5,R4,#+4
    450              unsigned int response;
    451              unsigned char error;
    452          
    453              TRACE_DEBUG("Pon()\n\r");
    454              memset(pCommand, 0, sizeof(SdCmd));
   \   0000000C   2820A0E3           MOV      R2,#+40
   \   00000010   0010A0E3           MOV      R1,#+0
   \   00000014   0500A0E1           MOV      R0,R5
   \   00000018   ........           BL       memset
    455              // Fill command information
    456              pCommand->cmd = AT91C_POWER_ON_INIT;
   \   0000001C   0000A0E3           MOV      R0,#+0
   \   00000020   040085E5           STR      R0,[R5, #+4]
    457              pCommand->resType = 1;
   \   00000024   ........           B        ?Subroutine0
    458              pCommand->pResp = &response;
    459          
    460              // Set SD command state
    461              pSd->state = SD_STATE_STBY;
    462          
    463              // Send command
    464              error =  SendCommand(pSd);
    465              if( error == 0 ) {
    466                  error = SD_SPI_R1((unsigned char *)&response);
    467              }
    468              return error;
    469          }

   \                                 In section .text, align 4, keep-with-next
   \                     ?Subroutine0:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -