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

📄 spi.lst

📁 IAR5.2下 AT91SAM9260 ARM 对 MCP2515 控制源化码
💻 LST
📖 第 1 页 / 共 3 页
字号:
   \                     ??SPI_EnableIt_0:
   \   0000000C   1480FCFF           DC32     0xfffc8014
    132          
    133          //*----------------------------------------------------------------------------
    134          //* \fn    AT91F_SPI_DisableIt
    135          //* \brief Disable SPI interrupt
    136          //*----------------------------------------------------------------------------

   \                                 In section .text, align 4, keep-with-next
    137          void SPI_DisableIt (unsigned int flag) // IT to be disabled
    138          {
    139          	//* Write to the IDR register
    140          	AT91C_BASE_SPI0->SPI_IDR = flag;
   \                     SPI_DisableIt:
   \   00000000   ........           LDR      R1,??DataTable2  ;; 0xfffc8018
   \   00000004   000081E5           STR      R0,[R1, #+0]
    141          }
   \   00000008   1EFF2FE1           BX       LR               ;; return
    142          
    143          
    144          //------------------------------------------------------------------------------
    145          /// Sends data through a SPI peripheral. If the SPI is configured to use a fixed
    146          /// peripheral select, the npcs value is meaningless. Otherwise, it identifies
    147          /// the component which shall be addressed.
    148          /// \param spi  Pointer to an AT91S_SPI instance.
    149          /// \param npcs  Chip select of the component to address (0, 1, 2 or 3).
    150          /// \param data  Word of data to send.
    151          //------------------------------------------------------------------------------

   \                                 In section .text, align 4, keep-with-next
    152          void SPI_Write(AT91S_SPI *spi, unsigned int npcs, unsigned short data)
    153          {
   \                     SPI_Write:
   \   00000000   00502DE9           PUSH     {R12,LR}
    154              char NPCS[4] = {0x0E,0x0D,0xB0,0x07};
   \   00000004   0D30B0E1           MOVS     R3,SP
   \   00000008   3CC09FE5           LDR      R12,??SPI_Write_0  ;; `?<Constant {14, 13, 176, 7}>`
   \   0000000C   00E09CE5           LDR      LR,[R12, #0]
   \   00000010   00E083E5           STR      LR,[R3, #+0]
    155              // Discard contents of RDR register
    156              //volatile unsigned int discard = spi->SPI_RDR;
    157          
    158              // Send data
    159              while ((spi->SPI_SR & AT91C_SPI_TXEMPTY) == 0);
   \                     ??SPI_Write_1:
   \   00000014   103090E5           LDR      R3,[R0, #+16]
   \   00000018   800F13E3           TST      R3,#0x200
   \   0000001C   FCFFFF0A           BEQ      ??SPI_Write_1
    160              spi->SPI_TDR = data | (NPCS[npcs]<<16);
   \   00000020   0230B0E1           MOVS     R3,R2
   \   00000024   0338A0E1           MOV      R3,R3, LSL #+16
   \   00000028   2338B0E1           MOVS     R3,R3, LSR #+16
   \   0000002C   0DC0B0E1           MOVS     R12,SP
   \   00000030   0CC0D1E7           LDRB     R12,[R1, +R12]
   \   00000034   0C3893E1           ORRS     R3,R3,R12, LSL #+16
   \   00000038   0C3080E5           STR      R3,[R0, #+12]
    161              while ((spi->SPI_SR & AT91C_SPI_TDRE) == 0);
   \                     ??SPI_Write_2:
   \   0000003C   103090E5           LDR      R3,[R0, #+16]
   \   00000040   020013E3           TST      R3,#0x2
   \   00000044   FCFFFF0A           BEQ      ??SPI_Write_2
    162          }
   \   00000048   0180BDE8           POP      {R0,PC}          ;; return
   \                     ??SPI_Write_0:
   \   0000004C   ........           DC32     `?<Constant {14, 13, 176, 7}>`
    163          
    164          //------------------------------------------------------------------------------
    165          /// Sends the contents of buffer through a SPI peripheral, using the PDC to
    166          /// take care of the transfer.
    167          /// \param spi  Pointer to an AT91S_SPI instance.
    168          /// \param buffer  Data buffer to send.
    169          /// \param length  Length of the data buffer.
    170          //------------------------------------------------------------------------------

   \                                 In section .text, align 4, keep-with-next
    171          unsigned char SPI_WriteBuffer(AT91S_SPI *spi,
    172                                        void *buffer,
    173                                        unsigned int length)
    174          {
   \                     SPI_WriteBuffer:
   \   00000000   0030B0E1           MOVS     R3,R0
    175              // Check if first bank is free
    176              if (spi->SPI_TCR == 0) 
   \   00000004   0C0193E5           LDR      R0,[R3, #+268]
   \   00000008   000050E3           CMP      R0,#+0
   \   0000000C   0500001A           BNE      ??SPI_WriteBuffer_0
    177              {
    178                  spi->SPI_TPR = (unsigned int) buffer;
   \   00000010   081183E5           STR      R1,[R3, #+264]
    179                  spi->SPI_TCR = length;
   \   00000014   0C2183E5           STR      R2,[R3, #+268]
    180                  spi->SPI_PTCR = AT91C_PDC_TXTEN;
   \   00000018   400FA0E3           MOV      R0,#+256
   \   0000001C   200183E5           STR      R0,[R3, #+288]
    181                  return 1;
   \   00000020   0100A0E3           MOV      R0,#+1
   \   00000024   070000EA           B        ??SPI_WriteBuffer_1
    182              }
    183              // Check if second bank is free
    184              else if (spi->SPI_TNCR == 0) 
   \                     ??SPI_WriteBuffer_0:
   \   00000028   1C0193E5           LDR      R0,[R3, #+284]
   \   0000002C   000050E3           CMP      R0,#+0
   \   00000030   0300001A           BNE      ??SPI_WriteBuffer_2
    185              {
    186                  spi->SPI_TNPR = (unsigned int) buffer;
   \   00000034   181183E5           STR      R1,[R3, #+280]
    187                  spi->SPI_TNCR = length;
   \   00000038   1C2183E5           STR      R2,[R3, #+284]
    188                  return 1;
   \   0000003C   0100A0E3           MOV      R0,#+1
   \   00000040   000000EA           B        ??SPI_WriteBuffer_1
    189              }   
    190              // No free banks
    191              return 0;
   \                     ??SPI_WriteBuffer_2:
   \   00000044   0000A0E3           MOV      R0,#+0
   \                     ??SPI_WriteBuffer_1:
   \   00000048   1EFF2FE1           BX       LR               ;; return
    192          }
    193          
    194          //------------------------------------------------------------------------------
    195          /// Returns 1 if there is no pending write operation on the SPI; otherwise
    196          /// returns 0.
    197          /// \param pSpi  Pointer to an AT91S_SPI instance.
    198          //------------------------------------------------------------------------------

   \                                 In section .text, align 4, keep-with-next
    199          unsigned char SPI_IsFinished(AT91S_SPI *pSpi)
    200          {
    201              return ((pSpi->SPI_SR & AT91C_SPI_TXEMPTY) != 0);
   \                     SPI_IsFinished:
   \   00000000   100090E5           LDR      R0,[R0, #+16]
   \   00000004   800F10E3           TST      R0,#0x200
   \   00000008   0100000A           BEQ      ??SPI_IsFinished_0
   \   0000000C   0100A0E3           MOV      R0,#+1
   \   00000010   000000EA           B        ??SPI_IsFinished_1
   \                     ??SPI_IsFinished_0:
   \   00000014   0000A0E3           MOV      R0,#+0
   \                     ??SPI_IsFinished_1:
   \   00000018   FF0010E2           ANDS     R0,R0,#0xFF      ;; Zero extend
   \   0000001C   1EFF2FE1           BX       LR               ;; return
    202          }
    203          
    204          //------------------------------------------------------------------------------
    205          /// Reads and returns the last word of data received by a SPI peripheral. This
    206          /// method must be called after a successful SPI_Write call.
    207          /// \param spi  Pointer to an AT91S_SPI instance.
    208          //------------------------------------------------------------------------------

   \                                 In section .text, align 4, keep-with-next
    209          unsigned short SPI_Read(AT91S_SPI *spi)
    210          {
    211              while ((spi->SPI_SR & AT91C_SPI_RDRF) == 0);
   \                     SPI_Read:
   \                     ??SPI_Read_0:
   \   00000000   101090E5           LDR      R1,[R0, #+16]
   \   00000004   010011E3           TST      R1,#0x1
   \   00000008   FCFFFF0A           BEQ      ??SPI_Read_0
    212              return spi->SPI_RDR & 0xFFFF;
   \   0000000C   080090E5           LDR      R0,[R0, #+8]
   \   00000010   0008A0E1           MOV      R0,R0, LSL #+16
   \   00000014   2008B0E1           MOVS     R0,R0, LSR #+16
   \   00000018   1EFF2FE1           BX       LR               ;; return
    213          }
    214          
    215          //------------------------------------------------------------------------------
    216          /// Reads data from a SPI peripheral until the provided buffer is filled. This
    217          /// method does NOT need to be called after SPI_Write or SPI_WriteBuffer.
    218          /// \param spi  Pointer to an AT91S_SPI instance.
    219          /// \param buffer  Data buffer to store incoming bytes.
    220          /// \param length  Length in bytes of the data buffer.
    221          //------------------------------------------------------------------------------

   \                                 In section .text, align 4, keep-with-next
    222          unsigned char SPI_ReadBuffer(AT91S_SPI *spi,
    223                                       void *buffer,
    224                                       unsigned int length)
    225          {
   \                     SPI_ReadBuffer:
   \   00000000   0030B0E1           MOVS     R3,R0
    226              // Check if the first bank is free
    227              if (spi->SPI_RCR == 0) 
   \   00000004   040193E5           LDR      R0,[R3, #+260]
   \   00000008   000050E3           CMP      R0,#+0
   \   0000000C   0500001A           BNE      ??SPI_ReadBuffer_0
    228              {
    229                  spi->SPI_RPR = (unsigned int) buffer;
   \   00000010   001183E5           STR      R1,[R3, #+256]
    230                  spi->SPI_RCR = length;
   \   00000014   042183E5           STR      R2,[R3, #+260]
    231                  spi->SPI_PTCR = AT91C_PDC_RXTEN;
   \   00000018   0100A0E3           MOV      R0,#+1
   \   0000001C   200183E5           STR      R0,[R3, #+288]
    232                  return 1;
   \   00000020   0100A0E3           MOV      R0,#+1
   \   00000024   070000EA           B        ??SPI_ReadBuffer_1
    233              }
    234              // Check if second bank is free
    235              else if (spi->SPI_RNCR == 0) 
   \                     ??SPI_ReadBuffer_0:
   \   00000028   140193E5           LDR      R0,[R3, #+276]
   \   0000002C   000050E3           CMP      R0,#+0
   \   00000030   0300001A           BNE      ??SPI_ReadBuffer_2
    236              {
    237                  spi->SPI_RNPR = (unsigned int) buffer;
   \   00000034   101183E5           STR      R1,[R3, #+272]
    238                  spi->SPI_RNCR = length;
   \   00000038   142183E5           STR      R2,[R3, #+276]
    239                  return 1;
   \   0000003C   0100A0E3           MOV      R0,#+1
   \   00000040   000000EA           B        ??SPI_ReadBuffer_1
    240              }
    241              // No free bank
    242              return 0;
   \                     ??SPI_ReadBuffer_2:
   \   00000044   0000A0E3           MOV      R0,#+0
   \                     ??SPI_ReadBuffer_1:
   \   00000048   1EFF2FE1           BX       LR               ;; return
    243          }
    244          
    245          
    246          //*****************************************************************************
    247          //* 函数名称:AT91F_DataFlashHandler
    248          //* 函数功能:SPI0 中断处理程序
    249          //* 入口参数:status: SPI0 中断状态
    250          //* 返回值 :无
    251          //*****************************************************************************

   \                                 In section .text, align 4, keep-with-next
    252          void SPI0_Handler(unsigned int status)

⌨️ 快捷键说明

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