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

📄 stm32f10x_spi.lst

📁 STM32利用正交编码器实现电机的控制
💻 LST
📖 第 1 页 / 共 3 页
字号:
    466          *                    bi-directional mode. 
    467          *                    This parameter can be one of the following values:
    468          *                       - SPI_Direction_Tx: Selects Tx transmission direction
    469          *                       - SPI_Direction_Rx: Selects Rx receive direction
    470          * Output         : None
    471          * Return         : None
    472          *******************************************************************************/
    473          void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, u16 SPI_Direction)
    474          {
    475            /* Check the parameters */
    476            assert(IS_SPI_DIRECTION(SPI_Direction));
    477          
    478            if (SPI_Direction == SPI_Direction_Tx)
    479            {
    480              /* Set the Tx only mode */
    481              SPIx->CR1 |= SPI_Direction_Tx;
    482            }
    483            else
    484            {
    485              /* Set the Rx only mode */
    486              SPIx->CR1 &= SPI_Direction_Rx;
    487            }
    488          }
    489          
    490          /*******************************************************************************
    491          * Function Name  : SPI_GetFlagStatus
    492          * Description    : Checks whether the specified SPI flag is set or not.
    493          * Input          : - SPIx: where x can be 1 or 2 to select the SPI peripheral.
    494          *                  - SPI_FLAG: specifies the flag to check. 
    495          *                    This parameter can be one of the following values:
    496          *                       - SPI_FLAG_BSY: Busy flag.
    497          *                       - SPI_FLAG_OVR: Overrun flag.
    498          *                       - SPI_FLAG_MODF: Mode Fault flag.
    499          *                       - SPI_FLAG_CRCERR: CRC Error flag.
    500          *                       - SPI_FLAG_TXE: Transmit buffer empty flag.
    501          *                       - SPI_FLAG_RXNE: Receive buffer not empty flag.
    502          * Output         : None
    503          * Return         : The new state of SPI_FLAG (SET or RESET).
    504          *******************************************************************************/
    505          FlagStatus SPI_GetFlagStatus(SPI_TypeDef* SPIx, u16 SPI_FLAG)
    506          {
    507            FlagStatus bitstatus = RESET;
    508          
    509            /* Check the parameters */
    510            assert(IS_SPI_GET_FLAG(SPI_FLAG));
    511          
    512            /* Check the status of the specified SPI flag */
    513            if ((SPIx->SR & SPI_FLAG) != (u16)RESET)
    514            {
    515              /* SPI_FLAG is set */
    516              bitstatus = SET;
    517            }
    518            else
    519            {
    520              /* SPI_FLAG is reset */
    521              bitstatus = RESET;
    522            }
    523            /* Return the SPI_FLAG status */
    524            return  bitstatus;
    525          }
    526          
    527          /*******************************************************************************
    528          * Function Name  : SPI_ClearFlag
    529          * Description    : Clears the SPIx's pending flags.
    530          * Input          : - SPIx: where x can be 1 or 2 to select the SPI peripheral.
    531          *                  - SPI_FLAG: specifies the flag to clear. 
    532          *                    This parameter can be any combination of the following values:
    533          *                       - SPI_FLAG_OVR: Overrun flag.
    534          *                       - SPI_FLAG_MODF: Mode Fault flag.
    535          *                       - SPI_FLAG_CRCERR: CRC Error flag.
    536          * Output         : None
    537          * Return         : None
    538          *******************************************************************************/
    539          void SPI_ClearFlag(SPI_TypeDef* SPIx, u16 SPI_FLAG)
    540          {
    541            /* Check the parameters */
    542            assert(IS_SPI_CLEAR_FLAG(SPI_FLAG));
    543              
    544            /* SPI_FLAG_MODF flag clear */
    545            if(SPI_FLAG == SPI_FLAG_MODF)
    546            {
    547              /* Read SR register */
    548              (void)SPIx->SR;
    549              /* Write on CR1 register */
    550              SPIx->CR1 |= CR1_SPE_Set; 
    551            }
    552            /* SPI_FLAG_OVR flag clear */
    553            else if(SPI_FLAG == SPI_FLAG_OVR)  
    554            {
    555              /* Read SR register */
    556              (void)SPIx->SR;
    557            }
    558            else /* SPI_FLAG_CRCERR flag clear */
    559            {
    560              /* Clear the selected SPI flag */
    561              SPIx->SR &= (u16)~SPI_FLAG;
    562            }
    563          }
    564          
    565          /*******************************************************************************
    566          * Function Name  : SPI_GetITStatus
    567          * Description    : Checks whether the specified SPI interrupt has occurred or not.
    568          * Input          : - SPIx: where x can be 1 or 2 to select the SPI peripheral.
    569          *                  - SPI_IT: specifies the SPI interrupt source to check. 
    570          *                    This parameter can be one of the following values:
    571          *                       - SPI_IT_OVR: Overrun interrupt.
    572          *                       - SPI_IT_MODF: Mode Fault interrupt.
    573          *                       - SPI_IT_CRCERR: CRC Error interrupt.
    574          *                       - SPI_IT_TXE: Transmit buffer empty interrupt.
    575          *                       - SPI_IT_RXNE: Receive buffer not empty interrupt.
    576          * Output         : None
    577          * Return         : The new state of SPI_IT (SET or RESET).
    578          *******************************************************************************/
    579          ITStatus SPI_GetITStatus(SPI_TypeDef* SPIx, u8 SPI_IT)
    580          {
    581            ITStatus bitstatus = RESET;
    582            u16 itpos = 0, itmask = 0, enablestatus = 0;
    583          
    584            /* Check the parameters */
    585            assert(IS_SPI_GET_IT(SPI_IT));
    586          
    587            /* Get the SPI IT index */
    588            itpos = (u16)((u16)0x01 << (SPI_IT & (u8)0x0F));
    589          
    590            /* Get the SPI IT index */
    591            itmask = SPI_IT >> 4;
    592            /* Set the IT mask */
    593            itmask = (u16)((u16)0x01 << itmask);
    594            /* Get the SPI_IT enable bit status */
    595            enablestatus = (SPIx->CR2 & itmask) ;
    596          
    597            /* Check the status of the specified SPI interrupt */
    598            if (((SPIx->SR & itpos) != (u16)RESET) && enablestatus)
    599            {
    600              /* SPI_IT is set */
    601              bitstatus = SET;
    602            }
    603            else
    604            {
    605              /* SPI_IT is reset */
    606              bitstatus = RESET;
    607            }
    608            /* Return the SPI_IT status */
    609            return bitstatus;
    610          }
    611          
    612          /*******************************************************************************
    613          * Function Name  : SPI_ClearITPendingBit
    614          * Description    : Clears the SPIx抯 interrupt pending bits.
    615          * Input          : - SPIx: where x can be 1 or 2 to select the SPI peripheral.
    616          *                  - SPI_IT: specifies the SPI interrupt pending bit to clear.
    617          *                    This parameter can be one of the following values:
    618          *                       - SPI_IT_OVR: Overrun interrupt.
    619          *                       - SPI_IT_MODF: Mode Fault interrupt.
    620          *                       - SPI_IT_CRCERR: CRC Error interrupt.
    621          * Output         : None
    622          * Return         : None
    623          *******************************************************************************/
    624          void SPI_ClearITPendingBit(SPI_TypeDef* SPIx, u8 SPI_IT)
    625          {
    626            u16 itpos = 0;
    627          
    628            /* Check the parameters */
    629            assert(IS_SPI_CLEAR_IT(SPI_IT));
    630          
    631            /* SPI_IT_MODF pending bit clear */
    632            if(SPI_IT == SPI_IT_MODF)
    633            {
    634              /* Read SR register */
    635              (void)SPIx->SR;
    636              /* Write on CR1 register */
    637              SPIx->CR1 |= CR1_SPE_Set; 
    638            }
    639            else if(SPI_IT == SPI_IT_OVR)   /* SPI_IT_OVR pending bit clear */ 
    640            {
    641              /* Read SR register */
    642              (void)(SPIx->SR);
    643            }
    644            else   /* SPI_IT_CRCERR pending bit clear */
    645            {
    646              /* Get the SPI IT index */
    647              itpos = (u16)((u16)0x01 << (SPI_IT & (u8)0x0F));
    648              /* Clear the selected SPI interrupt pending bits */
    649              SPIx->SR &= (u16)~itpos;
    650            }
    651          }
    652          
    653          /******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/

   Maximum stack usage in bytes:

     Function                      CSTACK
     --------                      ------
     SPI_BiDirectionalLineConfig      12
     SPI_CalculateCRC                 12
     SPI_ClearFlag                    12
     SPI_ClearITPendingBit            12
     SPI_Cmd                          12
     SPI_DMACmd                       16
     SPI_DataSizeConfig               12
     SPI_DeInit                        4
     SPI_GetCRC                       12
     SPI_GetCRCPolynomial              0
     SPI_GetFlagStatus                12
     SPI_GetITStatus                  12
     SPI_ITConfig                     16
     SPI_Init                         12
     SPI_NSSInternalSoftwareConfig    12
     SPI_ReceiveData                   0
     SPI_SSOutputCmd                  12
     SPI_SendData                      0
     SPI_StructInit                    0
     SPI_TransmitCRC                   0


   Segment part sizes:

     Function/Label                 Bytes
     --------------                 -----
     SPI_DeInit                       68
     SPI_Init                        302
     SPI_StructInit                   38
     SPI_Cmd                          52
     SPI_ITConfig                     84
     SPI_DMACmd                       68
     SPI_SendData                      4
     SPI_ReceiveData                   4
     SPI_NSSInternalSoftwareConfig    64
     SPI_SSOutputCmd                  56
     SPI_DataSizeConfig               52
     SPI_TransmitCRC                  10
     SPI_CalculateCRC                 56
     SPI_GetCRC                       38
     SPI_GetCRCPolynomial              4
     SPI_BiDirectionalLineConfig      64
     SPI_GetFlagStatus                56
     SPI_ClearFlag                    64
     SPI_GetITStatus                 104
     SPI_ClearITPendingBit            72
     ??DataTable18                     4
     ??DataTable23                     4
     ?<Constant "C:\\David JIANG\\ST MCU...">
                                      88
      Others                          24

 
 1 292 bytes in segment CODE
    88 bytes in segment DATA_C
 
 1 268 bytes of CODE  memory (+ 24 bytes shared)
    88 bytes of CONST memory

Errors: none
Warnings: none

⌨️ 快捷键说明

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