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

📄 stm32f10x_flash.lst

📁 ek-stm32f开发板测试程序,LCD+LED+按键
💻 LST
📖 第 1 页 / 共 4 页
字号:
    673            return (u32)(FLASH->WRPR);
    674          }
    675          
    676          /*******************************************************************************
    677          * Function Name  : FLASH_GetReadOutProtectionStatus
    678          * Description    : Checks whether the FLASH Read Out Protection Status is set 
    679          *                  or not.
    680          * Input          : None
    681          * Output         : None
    682          * Return         : FLASH ReadOut Protection Status(SET or RESET)
    683          *******************************************************************************/
    684          FlagStatus FLASH_GetReadOutProtectionStatus(void)
    685          {
    686            FlagStatus readoutstatus = RESET;
    687          
    688            if ((FLASH->OBR & RDPRT_Mask) != (u32)RESET)
    689            {
    690              readoutstatus = SET;
    691            }
    692            else
    693            {
    694              readoutstatus = RESET;
    695            }
    696            return readoutstatus;
    697          }
    698          
    699          /*******************************************************************************
    700          * Function Name  : FLASH_GetPrefetchBufferStatus
    701          * Description    : Checks whether the FLASH Prefetch Buffer status is set or not.
    702          * Input          : None
    703          * Output         : None
    704          * Return         : FLASH Prefetch Buffer Status (SET or RESET).
    705          *******************************************************************************/
    706          FlagStatus FLASH_GetPrefetchBufferStatus(void)
    707          {
    708            FlagStatus bitstatus = RESET;
    709            
    710            if ((FLASH->ACR & ACR_PRFTBS_Mask) != (u32)RESET)
    711            {
    712              bitstatus = SET;
    713            }
    714            else
    715            {
    716              bitstatus = RESET;
    717            }
    718            /* Return the new state of FLASH Prefetch Buffer Status (SET or RESET) */
    719            return bitstatus; 
    720          }
    721          
    722          /*******************************************************************************
    723          * Function Name  : FLASH_ITConfig
    724          * Description    : Enables or disables the specified FLASH interrupts.
    725          * Input          : - FLASH_IT: specifies the FLASH interrupt sources to be 
    726          *                    enabled or disabled.
    727          *                    This parameter can be any combination of the following values:
    728          *                       - FLASH_IT_ERROR: FLASH Error Interrupt
    729          *                       - FLASH_IT_EOP: FLASH end of operation Interrupt
    730          * Output         : None
    731          * Return         : None 
    732          *******************************************************************************/
    733          void FLASH_ITConfig(u16 FLASH_IT, FunctionalState NewState)
    734          {
    735            /* Check the parameters */
    736            assert(IS_FLASH_IT(FLASH_IT)); 
    737            assert(IS_FUNCTIONAL_STATE(NewState));
    738          
    739            if(NewState != DISABLE)
    740            {
    741              /* Enable the interrupt sources */
    742              FLASH->CR |= FLASH_IT;
    743            }
    744            else
    745            {
    746              /* Disable the interrupt sources */
    747              FLASH->CR &= ~(u32)FLASH_IT;
    748            }
    749          }
    750          
    751          /*******************************************************************************
    752          * Function Name  : FLASH_GetFlagStatus
    753          * Description    : Checks whether the specified FLASH flag is set or not.
    754          * Input          : - FLASH_FLAG: specifies the FLASH flag to check.
    755          *                     This parameter can be one of the following values:
    756          *                    - FLASH_FLAG_BSY: FLASH Busy flag           
    757          *                    - FLASH_FLAG_PGERR: FLASH Program error flag       
    758          *                    - FLASH_FLAG_WRPRTERR: FLASH Write protected error flag      
    759          *                    - FLASH_FLAG_EOP: FLASH End of Operation flag           
    760          *                    - FLASH_FLAG_OPTERR:  FLASH Option Byte error flag     
    761          * Output         : None
    762          * Return         : The new state of FLASH_FLAG (SET or RESET).
    763          *******************************************************************************/
    764          FlagStatus FLASH_GetFlagStatus(u16 FLASH_FLAG)
    765          {
    766            FlagStatus bitstatus = RESET;
    767          
    768            /* Check the parameters */
    769            assert(IS_FLASH_GET_FLAG(FLASH_FLAG)) ;
    770          
    771            if(FLASH_FLAG == FLASH_FLAG_OPTERR) 
    772            {
    773              if((FLASH->OBR & FLASH_FLAG_OPTERR) != (u32)RESET)
    774              {
    775                bitstatus = SET;
    776              }
    777              else
    778              {
    779                bitstatus = RESET;
    780              }
    781            }
    782            else
    783            {
    784             if((FLASH->SR & FLASH_FLAG) != (u32)RESET)
    785              {
    786                bitstatus = SET;
    787              }
    788              else
    789              {
    790                bitstatus = RESET;
    791              }
    792            }
    793            /* Return the new state of FLASH_FLAG (SET or RESET) */
    794            return bitstatus;
    795          }
    796          
    797          /*******************************************************************************
    798          * Function Name  : FLASH_ClearFlag
    799          * Description    : Clears the FLASH抯 pending flags.
    800          * Input          : - FLASH_FLAG: specifies the FLASH flags to clear.
    801          *                    This parameter can be any combination of the following values:
    802          *                    - FLASH_FLAG_BSY: FLASH Busy flag           
    803          *                    - FLASH_FLAG_PGERR: FLASH Program error flag       
    804          *                    - FLASH_FLAG_WRPRTERR: FLASH Write protected error flag      
    805          *                    - FLASH_FLAG_EOP: FLASH End of Operation flag           
    806          * Output         : None
    807          * Return         : None
    808          *******************************************************************************/
    809          void FLASH_ClearFlag(u16 FLASH_FLAG)
    810          {
    811            /* Check the parameters */
    812            assert(IS_FLASH_CLEAR_FLAG(FLASH_FLAG)) ;
    813            
    814            /* Clear the flags */
    815            FLASH->SR = FLASH_FLAG;
    816          }
    817          
    818          /*******************************************************************************
    819          * Function Name  : FLASH_GetStatus
    820          * Description    : Returns the FLASH Status.
    821          * Input          : None
    822          * Output         : None
    823          * Return         : FLASH Status: The returned value can be: FLASH_BUSY, 
    824          *                  FLASH_ERROR_PG or FLASH_ERROR_WRP or FLASH_COMPLETE
    825          *******************************************************************************/
    826          FLASH_Status FLASH_GetStatus(void)
    827          {
    828            FLASH_Status flashstatus = FLASH_COMPLETE;
    829            
    830            if((FLASH->SR & FLASH_FLAG_BSY) == FLASH_FLAG_BSY) 
    831            {
    832              flashstatus = FLASH_BUSY;
    833            }
    834            else 
    835            {  
    836              if(FLASH->SR & FLASH_FLAG_PGERR)
    837              { 
    838                flashstatus = FLASH_ERROR_PG;
    839              }
    840              else 
    841              {
    842                if(FLASH->SR & FLASH_FLAG_WRPRTERR)
    843                {
    844                  flashstatus = FLASH_ERROR_WRP;
    845                }
    846                else
    847                {
    848                  flashstatus = FLASH_COMPLETE;
    849                }
    850              }
    851            }
    852            /* Return the Flash Status */
    853            return flashstatus;
    854          }
    855          
    856          /*******************************************************************************
    857          * Function Name  : FLASH_WaitForLastOperation
    858          * Description    : Waits for a Flash operation to complete or a TIMEOUT to occur.
    859          * Input          : - Timeout: FLASH progamming Timeout
    860          * Output         : None
    861          * Return         : FLASH Status: The returned value can be: FLASH_BUSY, 
    862          *                  FLASH_ERROR_PG or FLASH_ERROR_WRP or FLASH_COMPLETE or 
    863          *                  FLASH_TIMEOUT.
    864          *******************************************************************************/
    865          FLASH_Status FLASH_WaitForLastOperation(u32 Timeout)
    866          { 
    867            FLASH_Status status = FLASH_COMPLETE;
    868             
    869            /* Check for the Flash Status */
    870            status = FLASH_GetStatus();
    871          
    872            /* Wait for a Flash operation to complete or a TIMEOUT to occur */
    873            while((status == FLASH_BUSY) && (Timeout != 0x00))
    874            {
    875              delay();
    876              status = FLASH_GetStatus();
    877              Timeout--;
    878            }
    879          
    880            if(Timeout == 0x00 )
    881            {
    882              status = FLASH_TIMEOUT;
    883            }
    884          
    885            /* Return the operation status */
    886            return status;
    887          }
    888          
    889          /*******************************************************************************
    890          * Function Name  : delay
    891          * Description    : Inserts a time delay.
    892          * Input          : None
    893          * Output         : None
    894          * Return         : None
    895          *******************************************************************************/
    896          static void delay(void)
    897          {
    898            vu32 i = 0;
    899          
    900            for(i = 0xFF; i != 0; i--)
    901            {
    902            }
    903          }
    904          #endif
    905          
    906          /******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/

Errors: 1
Warnings: none

⌨️ 快捷键说明

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