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

📄 stm32f10x_spi.lst

📁 编译环境是 iar EWARM ,STM32 下的UCOSII
💻 LST
📖 第 1 页 / 共 5 页
字号:
    553          
    554          /*******************************************************************************
    555          * Function Name  : SPI_DataSizeConfig
    556          * Description    : Configures the data size for the selected SPI.
    557          * Input          : - SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
    558          *                  - SPI_DataSize: specifies the SPI data size.
    559          *                    This parameter can be one of the following values:
    560          *                       - SPI_DataSize_16b: Set data frame format to 16bit
    561          *                       - SPI_DataSize_8b: Set data frame format to 8bit
    562          * Output         : None
    563          * Return         : None
    564          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    565          void SPI_DataSizeConfig(SPI_TypeDef* SPIx, u16 SPI_DataSize)
    566          {
    567            /* Check the parameters */
    568            assert_param(IS_SPI_ALL_PERIPH(SPIx));
    569            assert_param(IS_SPI_DATASIZE(SPI_DataSize));
    570          
    571            /* Clear DFF bit */
    572            SPIx->CR1 &= (u16)~SPI_DataSize_16b;
   \                     SPI_DataSizeConfig:
   \   00000000   0288               LDRH     R2,[R0, #+0]
   \   00000002   ....               LDR.N    R3,??DataTable1  ;; 0xf7ff
   \   00000004   1340               ANDS     R3,R3,R2
   \   00000006   0380               STRH     R3,[R0, #+0]
    573            /* Set new DFF bit value */
    574            SPIx->CR1 |= SPI_DataSize;
   \   00000008   0288               LDRH     R2,[R0, #+0]
   \   0000000A   1143               ORRS     R1,R1,R2
   \   0000000C   0180               STRH     R1,[R0, #+0]
    575          }
   \   0000000E   7047               BX       LR               ;; return
    576          
    577          /*******************************************************************************
    578          * Function Name  : SPI_TransmitCRC
    579          * Description    : Transmit the SPIx CRC value.
    580          * Input          : - SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
    581          * Output         : None
    582          * Return         : None
    583          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    584          void SPI_TransmitCRC(SPI_TypeDef* SPIx)
    585          {
    586            /* Check the parameters */
    587            assert_param(IS_SPI_ALL_PERIPH(SPIx));
    588            
    589            /* Enable the selected SPI CRC transmission */
    590            SPIx->CR1 |= CR1_CRCNext_Set;
   \                     SPI_TransmitCRC:
   \   00000000   0188               LDRH     R1,[R0, #+0]
   \   00000002   51F48051           ORRS     R1,R1,#0x1000
   \   00000006   0180               STRH     R1,[R0, #+0]
    591          }
   \   00000008   7047               BX       LR               ;; return
    592          
    593          /*******************************************************************************
    594          * Function Name  : SPI_CalculateCRC
    595          * Description    : Enables or disables the CRC value calculation of the
    596          *                  transfered bytes.
    597          * Input          : - SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
    598          *                  - NewState: new state of the SPIx CRC value calculation.
    599          *                    This parameter can be: ENABLE or DISABLE.
    600          * Output         : None
    601          * Return         : None
    602          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    603          void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState)
    604          {
    605            /* Check the parameters */
    606            assert_param(IS_SPI_ALL_PERIPH(SPIx));
    607            assert_param(IS_FUNCTIONAL_STATE(NewState));
    608          
    609            if (NewState != DISABLE)
   \                     SPI_CalculateCRC:
   \   00000000   0029               CMP      R1,#+0
   \   00000002   0188               LDRH     R1,[R0, #+0]
   \   00000004   03D0               BEQ.N    ??SPI_CalculateCRC_0
    610            {
    611              /* Enable the selected SPI CRC calculation */
    612              SPIx->CR1 |= CR1_CRCEN_Set;
   \   00000006   51F40051           ORRS     R1,R1,#0x2000
   \   0000000A   0180               STRH     R1,[R0, #+0]
   \   0000000C   7047               BX       LR
    613            }
    614            else
    615            {
    616              /* Disable the selected SPI CRC calculation */
    617              SPIx->CR1 &= CR1_CRCEN_Reset;
   \                     ??SPI_CalculateCRC_0:
   \   0000000E   024A               LDR.N    R2,??SPI_CalculateCRC_1  ;; 0xdfff
   \   00000010   0A40               ANDS     R2,R2,R1
   \   00000012   0280               STRH     R2,[R0, #+0]
    618            }
    619          }
   \   00000014   7047               BX       LR               ;; return
   \   00000016   00BF               Nop      
   \                     ??SPI_CalculateCRC_1:
   \   00000018   FFDF0000           DC32     0xdfff
    620          
    621          /*******************************************************************************
    622          * Function Name  : SPI_GetCRC
    623          * Description    : Returns the transmit or the receive CRC register value for
    624          *                  the specified SPI.
    625          * Input          : - SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
    626          *                  - SPI_CRC: specifies the CRC register to be read.
    627          *                    This parameter can be one of the following values:
    628          *                       - SPI_CRC_Tx: Selects Tx CRC register
    629          *                       - SPI_CRC_Rx: Selects Rx CRC register
    630          * Output         : None
    631          * Return         : The selected CRC register value..
    632          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    633          u16 SPI_GetCRC(SPI_TypeDef* SPIx, u8 SPI_CRC)
    634          {
    635            u16 crcreg = 0;
    636          
    637            /* Check the parameters */
    638            assert_param(IS_SPI_ALL_PERIPH(SPIx));
    639            assert_param(IS_SPI_CRC(SPI_CRC));
    640          
    641            if (SPI_CRC != SPI_CRC_Rx)
   \                     SPI_GetCRC:
   \   00000000   0129               CMP      R1,#+1
   \   00000002   01D0               BEQ.N    ??SPI_GetCRC_0
    642            {
    643              /* Get the Tx CRC register */
    644              crcreg = SPIx->TXCRCR;
   \   00000004   008B               LDRH     R0,[R0, #+24]
   \   00000006   7047               BX       LR
    645            }
    646            else
    647            {
    648              /* Get the Rx CRC register */
    649              crcreg = SPIx->RXCRCR;
   \                     ??SPI_GetCRC_0:
   \   00000008   808A               LDRH     R0,[R0, #+20]
    650            }
    651          
    652            /* Return the selected CRC register */
    653            return crcreg;
   \   0000000A   7047               BX       LR               ;; return
    654          }
    655          
    656          /*******************************************************************************
    657          * Function Name  : SPI_GetCRCPolynomial
    658          * Description    : Returns the CRC Polynomial register value for the specified SPI.
    659          * Input          : - SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
    660          * Output         : None
    661          * Return         : The CRC Polynomial register value.
    662          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    663          u16 SPI_GetCRCPolynomial(SPI_TypeDef* SPIx)
    664          {
    665            /* Check the parameters */
    666            assert_param(IS_SPI_ALL_PERIPH(SPIx));
    667            
    668            /* Return the CRC polynomial register */
    669            return SPIx->CRCPR;
   \                     SPI_GetCRCPolynomial:
   \   00000000   008A               LDRH     R0,[R0, #+16]
   \   00000002   7047               BX       LR               ;; return
    670          }
    671          
    672          /*******************************************************************************
    673          * Function Name  : SPI_BiDirectionalLineConfig
    674          * Description    : Selects the data transfer direction in bi-directional mode
    675          *                  for the specified SPI.
    676          * Input          : - SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
    677          *                  - SPI_Direction: specifies the data transfer direction in
    678          *                    bi-directional mode. 
    679          *                    This parameter can be one of the following values:
    680          *                       - SPI_Direction_Tx: Selects Tx transmission direction
    681          *                       - SPI_Direction_Rx: Selects Rx receive direction
    682          * Output         : None
    683          * Return         : None
    684          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    685          void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, u16 SPI_Direction)
    686          {
    687            /* Check the parameters */
    688            assert_param(IS_SPI_ALL_PERIPH(SPIx));
    689            assert_param(IS_SPI_DIRECTION(SPI_Direction));
    690          
    691            if (SPI_Direction == SPI_Direction_Tx)
   \                     SPI_BiDirectionalLineConfig:
   \   00000000   5FF48042           MOVS     R2,#+16384
   \   00000004   9142               CMP      R1,R2
   \   00000006   0188               LDRH     R1,[R0, #+0]
   \   00000008   03D1               BNE.N    ??SPI_BiDirectionalLineConfig_0
    692            {
    693              /* Set the Tx only mode */
    694              SPIx->CR1 |= SPI_Direction_Tx;
   \   0000000A   51F48041           ORRS     R1,R1,#0x4000
   \   0000000E   0180               STRH     R1,[R0, #+0]
   \   00000010   7047               BX       LR
    695            }
    696            else
    697            {
    698              /* Set the Rx only mode */
    699              SPIx->CR1 &= SPI_Direction_Rx;
   \                     ??SPI_BiDirectionalLineConfig_0:
   \   00000012   024A               LDR.N    R2,??SPI_BiDirectionalLineConfig_1  ;; 0xbfff
   \   00000014   0A40               ANDS     R2,R2,R1
   \   00000016   0280               STRH     R2,[R0, #+0]
    700            }
    701          }
   \   00000018   7047               BX       LR               ;; return
   \   0000001A   00BF               Nop      
   \                     ??SPI_BiDirectionalLineConfig_1:
   \   0000001C   FFBF0000           DC32     0xbfff
    702          
    703          /*******************************************************************************
    704          * Function Name  : SPI_I2S_GetFlagStatus
    705          * Description    : Checks whether the specified SPI/I2S flag is set or not.
    706          * Input          : - SPIx: where x can be :
    707          *                         - 1, 2 or 3 in SPI mode 
    708          *                         - 2 or 3 in I2S mode
    709          *                  - SPI_I2S_FLAG: specifies the SPI/I2S flag to check. 
    710          *                    Thi

⌨️ 快捷键说明

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