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

📄 stm32f10x_flash.lst

📁 完成数据的采集
💻 LST
📖 第 1 页 / 共 4 页
字号:
###############################################################################
#                                                                             #
#                                                       30/Jul/2008  11:02:19 #
# IAR ARM ANSI C/C++ Compiler V5.11.0.20622/W32 EVALUATION                    #
# Copyright 1999-2007 IAR Systems. All rights reserved.                       #
#                                                                             #
#    Cpu mode     =  thumb                                                    #
#    Endian       =  little                                                   #
#    Source file  =  E:\library\src\stm32f10x_flash.c                         #
#    Command line =  E:\library\src\stm32f10x_flash.c -D EMB_FLASH -lcN       #
#                    E:\ELE\yten\pro\Release\List\ -o                         #
#                    E:\ELE\yten\pro\Release\Obj\ --no_cse --no_unroll        #
#                    --no_inline --no_code_motion --no_tbaa --no_clustering   #
#                    --no_scheduling --debug --endian little --cpu Cortex-M3  #
#                    -e --fpu None --dlib_config "C:\Program Files\IAR        #
#                    Systems\Embedded Workbench 5.0                           #
#                    Evaluation\ARM\INC\DLib_Config_Normal.h" -I              #
#                    E:\ELE\yten\pro\ -I E:\ELE\yten\pro\..\LIBRARY\INC\ -I   #
#                    "C:\Program Files\IAR Systems\Embedded Workbench 5.0     #
#                    Evaluation\ARM\INC\" -On                                 #
#    List file    =  E:\ELE\yten\pro\Release\List\stm32f10x_flash.lst         #
#    Object file  =  E:\ELE\yten\pro\Release\Obj\stm32f10x_flash.o            #
#                                                                             #
#                                                                             #
###############################################################################

E:\library\src\stm32f10x_flash.c
      1          /******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
      2          * File Name          : stm32f10x_flash.c
      3          * Author             : MCD Application Team
      4          * Version            : V1.0
      5          * Date               : 10/08/2007
      6          * Description        : This file provides all the FLASH firmware functions.
      7          ********************************************************************************
      8          * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
      9          * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
     10          * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
     11          * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
     12          * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
     13          * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
     14          *******************************************************************************/
     15          
     16          /* Includes ------------------------------------------------------------------*/
     17          #include "stm32f10x_flash.h"
     18          
     19          /* Private typedef -----------------------------------------------------------*/
     20          /* Private define ------------------------------------------------------------*/
     21          /* Flash Access Control Register bits */
     22          #define ACR_LATENCY_Mask         ((u32)0x00000038)
     23          #define ACR_HLFCYA_Mask          ((u32)0xFFFFFFF7)
     24          #define ACR_PRFTBE_Mask          ((u32)0xFFFFFFEF)
     25          
     26          #ifdef _FLASH_PROG
     27          /* Flash Access Control Register bits */
     28          #define ACR_PRFTBS_Mask          ((u32)0x00000020) 
     29          
     30          /* Flash Control Register bits */
     31          #define CR_PG_Set                ((u32)0x00000001)
     32          #define CR_PG_Reset              ((u32)0x00001FFE) 
     33          
     34          #define CR_PER_Set               ((u32)0x00000002)
     35          #define CR_PER_Reset             ((u32)0x00001FFD)
     36          
     37          #define CR_MER_Set               ((u32)0x00000004)
     38          #define CR_MER_Reset             ((u32)0x00001FFB)
     39          
     40          #define CR_OPTPG_Set             ((u32)0x00000010)
     41          #define CR_OPTPG_Reset           ((u32)0x00001FEF)
     42          
     43          #define CR_OPTER_Set             ((u32)0x00000020)
     44          #define CR_OPTER_Reset           ((u32)0x00001FDF)
     45          
     46          #define CR_STRT_Set              ((u32)0x00000040)
     47          							 
     48          #define CR_LOCK_Set              ((u32)0x00000080)
     49          
     50          /* FLASH Mask */
     51          #define RDPRT_Mask               ((u32)0x00000002)
     52          #define WRP0_Mask                ((u32)0x000000FF)
     53          #define WRP1_Mask                ((u32)0x0000FF00)
     54          #define WRP2_Mask                ((u32)0x00FF0000)
     55          #define WRP3_Mask                ((u32)0xFF000000)
     56          
     57          /* FLASH Keys */
     58          #define RDP_Key                  ((u16)0x00A5)
     59          #define FLASH_KEY1               ((u32)0x45670123)
     60          #define FLASH_KEY2               ((u32)0xCDEF89AB)
     61          
     62          /* Delay definition */   
     63          #define EraseTimeout             ((u32)0x00000FFF)
     64          #define ProgramTimeout           ((u32)0x0000000F)
     65          #endif
     66          
     67          /* Private macro -------------------------------------------------------------*/
     68          /* Private variables ---------------------------------------------------------*/
     69          /* Private function prototypes -----------------------------------------------*/
     70          #ifdef _FLASH_PROG
     71          static void delay(void);
     72          #endif
     73          
     74          /* Private functions ---------------------------------------------------------*/
     75          /*******************************************************************************
     76          * Function Name  : FLASH_SetLatency
     77          * Description    : Sets the code latency value.
     78          * Input          : - FLASH_Latency: specifies the FLASH Latency value.
     79          *                    This parameter can be one of the following values:
     80          *                       - FLASH_Latency_0: FLASH Zero Latency cycle
     81          *                       - FLASH_Latency_1: FLASH One Latency cycle
     82          *                       - FLASH_Latency_2: FLASH Two Latency cycles
     83          * Output         : None
     84          * Return         : None
     85          *******************************************************************************/
     86          void FLASH_SetLatency(u32 FLASH_Latency)
     87          {
     88            /* Check the parameters */
     89            assert_param(IS_FLASH_LATENCY(FLASH_Latency));
     90            
     91            /* Sets the Latency value */
     92            FLASH->ACR &= ACR_LATENCY_Mask;
     93            FLASH->ACR |= FLASH_Latency;
     94          }
     95          
     96          /*******************************************************************************
     97          * Function Name  : FLASH_HalfCycleAccessCmd
     98          * Description    : Enables or disables the Half cycle flash access.
     99          * Input          : - FLASH_HalfCycle: specifies the FLASH Half cycle Access mode.
    100          *                    This parameter can be one of the following values:
    101          *                       - FLASH_HalfCycleAccess_Enable: FLASH Half Cycle Enable
    102          *                       - FLASH_HalfCycleAccess_Disable: FLASH Half Cycle Disable
    103          * Output         : None
    104          * Return         : None
    105          *******************************************************************************/
    106          void FLASH_HalfCycleAccessCmd(u32 FLASH_HalfCycleAccess)
    107          {
    108            /* Check the parameters */
    109            assert_param(IS_FLASH_HALFCYCLEACCESS_STATE(FLASH_HalfCycleAccess));
    110            
    111            /* Enable or disable the Half cycle access */
    112            FLASH->ACR &= ACR_HLFCYA_Mask;
    113            FLASH->ACR |= FLASH_HalfCycleAccess;
    114          }
    115          
    116          /*******************************************************************************
    117          * Function Name  : FLASH_PrefetchBufferCmd
    118          * Description    : Enables or disables the Prefetch Buffer.
    119          * Input          : - FLASH_PrefetchBuffer: specifies the Prefetch buffer status.
    120          *                    This parameter can be one of the following values:
    121          *                       - FLASH_PrefetchBuffer_Enable: FLASH Prefetch Buffer Enable
    122          *                       - FLASH_PrefetchBuffer_Disable: FLASH Prefetch Buffer Disable
    123          * Output         : None
    124          * Return         : None
    125          *******************************************************************************/
    126          void FLASH_PrefetchBufferCmd(u32 FLASH_PrefetchBuffer)
    127          {
    128            /* Check the parameters */
    129            assert_param(IS_FLASH_PREFETCHBUFFER_STATE(FLASH_PrefetchBuffer));
    130            
    131            /* Enable or disable the Prefetch Buffer */
    132            FLASH->ACR &= ACR_PRFTBE_Mask;
    133            FLASH->ACR |= FLASH_PrefetchBuffer;
    134          }
    135          
    136          #ifdef _FLASH_PROG
    137          /*******************************************************************************
    138          * Function Name  : FLASH_Unlock
    139          * Description    : Unlocks the FLASH Program Erase Controller.
    140          * Input          : None
    141          * Output         : None
    142          * Return         : None
    143          *******************************************************************************/
    144          void FLASH_Unlock(void)
    145          {
    146            /* Authorize the FPEC Access */
    147            FLASH->KEYR = FLASH_KEY1;
    148            FLASH->KEYR = FLASH_KEY2;
    149          }
    150          
    151          /*******************************************************************************
    152          * Function Name  : FLASH_Lock
    153          * Description    : Locks the FLASH Program Erase Controller.
    154          * Input          : None
    155          * Output         : None
    156          * Return         : None
    157          *******************************************************************************/
    158          void FLASH_Lock(void)
    159          {
    160            /* Set the Lock Bit to lock the FPEC and the FCR */
    161            FLASH->CR |= CR_LOCK_Set;
    162          }
    163          
    164          /*******************************************************************************
    165          * Function Name  : FLASH_ErasePage
    166          * Description    : Erases a specified FLASH page.
    167          * Input          : - Page_Address: The page address to be erased.
    168          * Output         : None
    169          * Return         : FLASH Status: The returned value can be: FLASH_BUSY, 
    170          *                  FLASH_ERROR_PG or FLASH_ERROR_WRP or FLASH_COMPLETE or 
    171          *                  FLASH_TIMEOUT.
    172          *******************************************************************************/
    173          FLASH_Status FLASH_ErasePage(u32 Page_Address)
    174          {
    175            FLASH_Status status = FLASH_COMPLETE;
    176          
    177            /* Check the parameters */
    178            assert_param(IS_FLASH_ADDRESS(Page_Address));
    179          
    180            /* Wait for last operation to be completed */
    181            status = FLASH_WaitForLastOperation(EraseTimeout);
    182            
    183            if(status == FLASH_COMPLETE)
    184            { 
    185              /* if the previous operation is completed, proceed to erase the page */
    186              FLASH->CR|= CR_PER_Set;
    187              FLASH->AR = Page_Address; 
    188              FLASH->CR|= CR_STRT_Set;
    189              
    190              /* Wait for last operation to be completed */
    191              status = FLASH_WaitForLastOperation(EraseTimeout);
    192          
    193              if(status != FLASH_BUSY)
    194              {
    195                /* if the erase operation is completed, disable the PER Bit */
    196                FLASH->CR &= CR_PER_Reset;
    197              }
    198            }
    199            /* Return the Erase Status */
    200            return status;
    201          }
    202          
    203          /*******************************************************************************
    204          * Function Name  : FLASH_EraseAllPages
    205          * Description    : Erases all FLASH pages.
    206          * Input          : None
    207          * Output         : None
    208          * Return         : FLASH Status: The returned value can be: FLASH_BUSY, 
    209          *                  FLASH_ERROR_PG or FLASH_ERROR_WRP or FLASH_COMPLETE or 
    210          *                  FLASH_TIMEOUT.
    211          *******************************************************************************/
    212          FLASH_Status FLASH_EraseAllPages(void)
    213          {
    214            FLASH_Status status = FLASH_COMPLETE;

⌨️ 快捷键说明

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