亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? stm32f10x_flash.c

?? STM32SDCardSourceCodeFATFS.rar
?? C
?? 第 1 頁 / 共 2 頁
字號:
/**
  ******************************************************************************
  * @file    stm32f10x_flash.c
  * @author  MCD Application Team
  * @version V3.1.2
  * @date    09/28/2009
  * @brief   This file provides all the FLASH firmware functions.
  ******************************************************************************
  * @copy
  *
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  *
  * <h2><center>&copy; COPYRIGHT 2009 STMicroelectronics</center></h2>
  */ 

/* Includes ------------------------------------------------------------------*/
#include "stm32f10x_flash.h"

/** @addtogroup STM32F10x_StdPeriph_Driver
  * @{
  */

/** @defgroup FLASH 
  * @brief FLASH driver modules
  * @{
  */ 

/** @defgroup FLASH_Private_TypesDefinitions
  * @{
  */

/**
  * @}
  */ 

/** @defgroup FLASH_Private_Defines
  * @{
  */ 

/* Flash Access Control Register bits */
#define ACR_LATENCY_Mask         ((uint32_t)0x00000038)
#define ACR_HLFCYA_Mask          ((uint32_t)0xFFFFFFF7)
#define ACR_PRFTBE_Mask          ((uint32_t)0xFFFFFFEF)

/* Flash Access Control Register bits */
#define ACR_PRFTBS_Mask          ((uint32_t)0x00000020) 

/* Flash Control Register bits */
#define CR_PG_Set                ((uint32_t)0x00000001)
#define CR_PG_Reset              ((uint32_t)0x00001FFE) 
#define CR_PER_Set               ((uint32_t)0x00000002)
#define CR_PER_Reset             ((uint32_t)0x00001FFD)
#define CR_MER_Set               ((uint32_t)0x00000004)
#define CR_MER_Reset             ((uint32_t)0x00001FFB)
#define CR_OPTPG_Set             ((uint32_t)0x00000010)
#define CR_OPTPG_Reset           ((uint32_t)0x00001FEF)
#define CR_OPTER_Set             ((uint32_t)0x00000020)
#define CR_OPTER_Reset           ((uint32_t)0x00001FDF)
#define CR_STRT_Set              ((uint32_t)0x00000040)
#define CR_LOCK_Set              ((uint32_t)0x00000080)

/* FLASH Mask */
#define RDPRT_Mask               ((uint32_t)0x00000002)
#define WRP0_Mask                ((uint32_t)0x000000FF)
#define WRP1_Mask                ((uint32_t)0x0000FF00)
#define WRP2_Mask                ((uint32_t)0x00FF0000)
#define WRP3_Mask                ((uint32_t)0xFF000000)

/* FLASH Keys */
#define RDP_Key                  ((uint16_t)0x00A5)
#define FLASH_KEY1               ((uint32_t)0x45670123)
#define FLASH_KEY2               ((uint32_t)0xCDEF89AB)

/* Delay definition */   
#define EraseTimeout             ((uint32_t)0x00000FFF)
#define ProgramTimeout           ((uint32_t)0x0000000F)

/**
  * @}
  */ 

/** @defgroup FLASH_Private_Macros
  * @{
  */

/**
  * @}
  */ 

/** @defgroup FLASH_Private_Variables
  * @{
  */

/**
  * @}
  */ 

/** @defgroup FLASH_Private_FunctionPrototypes
  * @{
  */

static void delay(void);
/**
  * @}
  */

/** @defgroup FLASH_Private_Functions
  * @{
  */

/**
  * @brief  Sets the code latency value.
  * @param  FLASH_Latency: specifies the FLASH Latency value.
  *   This parameter can be one of the following values:
  *     @arg FLASH_Latency_0: FLASH Zero Latency cycle
  *     @arg FLASH_Latency_1: FLASH One Latency cycle
  *     @arg FLASH_Latency_2: FLASH Two Latency cycles
  * @retval None
  */
void FLASH_SetLatency(uint32_t FLASH_Latency)
{
  uint32_t tmpreg = 0;
  
  /* Check the parameters */
  assert_param(IS_FLASH_LATENCY(FLASH_Latency));
  
  /* Read the ACR register */
  tmpreg = FLASH->ACR;  
  
  /* Sets the Latency value */
  tmpreg &= ACR_LATENCY_Mask;
  tmpreg |= FLASH_Latency;
  
  /* Write the ACR register */
  FLASH->ACR = tmpreg;
}

/**
  * @brief  Enables or disables the Half cycle flash access.
  * @param  FLASH_HalfCycleAccess: specifies the FLASH Half cycle Access mode.
  *   This parameter can be one of the following values:
  *     @arg FLASH_HalfCycleAccess_Enable: FLASH Half Cycle Enable
  *     @arg FLASH_HalfCycleAccess_Disable: FLASH Half Cycle Disable
  * @retval None
  */
void FLASH_HalfCycleAccessCmd(uint32_t FLASH_HalfCycleAccess)
{
  /* Check the parameters */
  assert_param(IS_FLASH_HALFCYCLEACCESS_STATE(FLASH_HalfCycleAccess));
  
  /* Enable or disable the Half cycle access */
  FLASH->ACR &= ACR_HLFCYA_Mask;
  FLASH->ACR |= FLASH_HalfCycleAccess;
}

/**
  * @brief  Enables or disables the Prefetch Buffer.
  * @param  FLASH_PrefetchBuffer: specifies the Prefetch buffer status.
  *   This parameter can be one of the following values:
  *     @arg FLASH_PrefetchBuffer_Enable: FLASH Prefetch Buffer Enable
  *     @arg FLASH_PrefetchBuffer_Disable: FLASH Prefetch Buffer Disable
  * @retval None
  */
void FLASH_PrefetchBufferCmd(uint32_t FLASH_PrefetchBuffer)
{
  /* Check the parameters */
  assert_param(IS_FLASH_PREFETCHBUFFER_STATE(FLASH_PrefetchBuffer));
  
  /* Enable or disable the Prefetch Buffer */
  FLASH->ACR &= ACR_PRFTBE_Mask;
  FLASH->ACR |= FLASH_PrefetchBuffer;
}

/**
  * @brief  Unlocks the FLASH Program Erase Controller.
  * @param  None
  * @retval None
  */
void FLASH_Unlock(void)
{
  /* Authorize the FPEC Access */
  FLASH->KEYR = FLASH_KEY1;
  FLASH->KEYR = FLASH_KEY2;
}

/**
  * @brief  Locks the FLASH Program Erase Controller.
  * @param  None
  * @retval None
  */
void FLASH_Lock(void)
{
  /* Set the Lock Bit to lock the FPEC and the FCR */
  FLASH->CR |= CR_LOCK_Set;
}

/**
  * @brief  Erases a specified FLASH page.
  * @param  Page_Address: The page address to be erased.
  * @retval FLASH Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PG,
  *   FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
  */
FLASH_Status FLASH_ErasePage(uint32_t Page_Address)
{
  FLASH_Status status = FLASH_COMPLETE;
  /* Check the parameters */
  assert_param(IS_FLASH_ADDRESS(Page_Address));
  /* Wait for last operation to be completed */
  status = FLASH_WaitForLastOperation(EraseTimeout);
  
  if(status == FLASH_COMPLETE)
  { 
    /* if the previous operation is completed, proceed to erase the page */
    FLASH->CR|= CR_PER_Set;
    FLASH->AR = Page_Address; 
    FLASH->CR|= CR_STRT_Set;
    
    /* Wait for last operation to be completed */
    status = FLASH_WaitForLastOperation(EraseTimeout);
    if(status != FLASH_TIMEOUT)
    {
      /* if the erase operation is completed, disable the PER Bit */
      FLASH->CR &= CR_PER_Reset;
    }
  }
  /* Return the Erase Status */
  return status;
}

/**
  * @brief  Erases all FLASH pages.
  * @param  None
  * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
  *   FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
  */
FLASH_Status FLASH_EraseAllPages(void)
{
  FLASH_Status status = FLASH_COMPLETE;
  /* Wait for last operation to be completed */
  status = FLASH_WaitForLastOperation(EraseTimeout);
  
  if(status == FLASH_COMPLETE)
  {
    /* if the previous operation is completed, proceed to erase all pages */
     FLASH->CR |= CR_MER_Set;
     FLASH->CR |= CR_STRT_Set;
    
    /* Wait for last operation to be completed */
    status = FLASH_WaitForLastOperation(EraseTimeout);
    if(status != FLASH_TIMEOUT)
    {
      /* if the erase operation is completed, disable the MER Bit */
      FLASH->CR &= CR_MER_Reset;
    }
  }	   
  /* Return the Erase Status */
  return status;
}

/**
  * @brief  Erases the FLASH option bytes.
  * @note   This functions erases all option bytes and then deactivates the Read
  *         protection. If the user needs to keep the Read protection activated,
  *         he has to enable it after this function call (using
  *         FLASH_ReadOutProtection function)
  * @param  None
  * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
  *   FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
  */
FLASH_Status FLASH_EraseOptionBytes(void)
{
  FLASH_Status status = FLASH_COMPLETE;
  
  /* Wait for last operation to be completed */
  status = FLASH_WaitForLastOperation(EraseTimeout);
  if(status == FLASH_COMPLETE)
  {
    /* Authorize the small information block programming */
    FLASH->OPTKEYR = FLASH_KEY1;
    FLASH->OPTKEYR = FLASH_KEY2;
    
    /* if the previous operation is completed, proceed to erase the option bytes */
    FLASH->CR |= CR_OPTER_Set;
    FLASH->CR |= CR_STRT_Set;
    /* Wait for last operation to be completed */
    status = FLASH_WaitForLastOperation(EraseTimeout);
    
    if(status == FLASH_COMPLETE)
    {
      /* if the erase operation is completed, disable the OPTER Bit */
      FLASH->CR &= CR_OPTER_Reset;
       
      /* Enable the Option Bytes Programming operation */
      FLASH->CR |= CR_OPTPG_Set;
      /* Disable the Read protection */
      OB->RDP= RDP_Key; 
      /* Wait for last operation to be completed */
      status = FLASH_WaitForLastOperation(ProgramTimeout);
 
      if(status != FLASH_TIMEOUT)
      {
        /* if the program operation is completed, disable the OPTPG Bit */
        FLASH->CR &= CR_OPTPG_Reset;
      }
    }
    else
    {
      if (status != FLASH_TIMEOUT)
      {
        /* Disable the OPTPG Bit */
        FLASH->CR &= CR_OPTPG_Reset;
      }
    }  
  }
  /* Return the erase status */
  return status;
}

/**
  * @brief  Programs a word at a specified address.
  * @param  Address: specifies the address to be programmed.
  * @param  Data: specifies the data to be programmed.
  * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
  *   FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. 
  */
FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data)
{
  FLASH_Status status = FLASH_COMPLETE;
  __IO uint32_t tmp = 0;

  /* Check the parameters */
  assert_param(IS_FLASH_ADDRESS(Address));
  /* Wait for last operation to be completed */
  status = FLASH_WaitForLastOperation(ProgramTimeout);
  
  if(status == FLASH_COMPLETE)
  {
    /* if the previous operation is completed, proceed to program the new first 
    half word */
    FLASH->CR |= CR_PG_Set;
  
    *(__IO uint16_t*)Address = (uint16_t)Data;
    /* Wait for last operation to be completed */
    status = FLASH_WaitForLastOperation(ProgramTimeout);
 
    if(status == FLASH_COMPLETE)
    {
      /* if the previous operation is completed, proceed to program the new second 
      half word */
      tmp = Address + 2;

      *(__IO uint16_t*) tmp = Data >> 16;
    
      /* Wait for last operation to be completed */
      status = FLASH_WaitForLastOperation(ProgramTimeout);
        
      if(status != FLASH_TIMEOUT)
      {
        /* Disable the PG Bit */
        FLASH->CR &= CR_PG_Reset;
      }
    }
    else
    {
      if (status != FLASH_TIMEOUT)
      {
        /* Disable the PG Bit */
        FLASH->CR &= CR_PG_Reset;
      }
     }
  }
  /* Return the Program Status */
  return status;
}

/**
  * @brief  Programs a half word at a specified address.
  * @param  Address: specifies the address to be programmed.
  * @param  Data: specifies the data to be programmed.
  * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
  *   FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. 
  */
FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data)
{
  FLASH_Status status = FLASH_COMPLETE;
  /* Check the parameters */
  assert_param(IS_FLASH_ADDRESS(Address));
  /* Wait for last operation to be completed */
  status = FLASH_WaitForLastOperation(ProgramTimeout);
  
  if(status == FLASH_COMPLETE)
  {
    /* if the previous operation is completed, proceed to program the new data */
    FLASH->CR |= CR_PG_Set;
  
    *(__IO uint16_t*)Address = Data;
    /* Wait for last operation to be completed */
    status = FLASH_WaitForLastOperation(ProgramTimeout);
    if(status != FLASH_TIMEOUT)
    {
      /* if the program operation is completed, disable the PG Bit */
      FLASH->CR &= CR_PG_Reset;
    }
  } 
  /* Return the Program Status */
  return status;
}

/**
  * @brief  Programs a half word at a specified Option Byte Data address.
  * @param  Address: specifies the address to be programmed.
  *   This parameter can be 0x1FFFF804 or 0x1FFFF806. 
  * @param  Data: specifies the data to be programmed.
  * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
  *   FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. 
  */
FLASH_Status FLASH_ProgramOptionByteData(uint32_t Address, uint8_t Data)
{
  FLASH_Status status = FLASH_COMPLETE;
  /* Check the parameters */
  assert_param(IS_OB_DATA_ADDRESS(Address));
  status = FLASH_WaitForLastOperation(ProgramTimeout);
  if(status == FLASH_COMPLETE)
  {
    /* Authorize the small information block programming */
    FLASH->OPTKEYR = FLASH_KEY1;
    FLASH->OPTKEYR = FLASH_KEY2;
    /* Enables the Option Bytes Programming operation */
    FLASH->CR |= CR_OPTPG_Set; 
    *(__IO uint16_t*)Address = Data;
    
    /* Wait for last operation to be completed */
    status = FLASH_WaitForLastOperation(ProgramTimeout);
    if(status != FLASH_TIMEOUT)
    {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成人动漫一区| 亚洲欧美日韩综合aⅴ视频| 18涩涩午夜精品.www| 日韩欧美一级二级三级| 日本高清视频一区二区| 白白色亚洲国产精品| 久久精品国产免费| 一区二区三区中文在线| 在线一区二区三区四区五区| 亚洲婷婷综合色高清在线| 国产区在线观看成人精品| 欧美精品一区二区三| 国产亚洲精品精华液| 中文字幕一区二区日韩精品绯色| 国产精品免费丝袜| 99久久精品情趣| 色综合久久中文字幕综合网| 成人av免费在线播放| caoporn国产精品| 91色.com| 欧美日韩国产小视频在线观看| 欧美日韩精品欧美日韩精品一| 日本不卡一区二区三区| 国产精品拍天天在线| 欧美亚洲日本国产| 欧美精品丝袜久久久中文字幕| 91精品午夜视频| 国产亚洲婷婷免费| 亚洲精品中文在线影院| 日韩精品欧美精品| 国产在线播放一区三区四| 99久久精品国产一区| 欧美日韩午夜在线| 久久色.com| 亚洲色大成网站www久久九九| 日日欢夜夜爽一区| 成熟亚洲日本毛茸茸凸凹| 欧美午夜电影网| 日韩欧美国产综合| 亚洲麻豆国产自偷在线| 久久99精品久久久久久久久久久久| 粉嫩一区二区三区在线看| 欧美日韩在线一区二区| 精品福利在线导航| 天天综合色天天| 成人午夜激情影院| 亚洲久本草在线中文字幕| 欧美精品一区视频| 亚洲一区二区在线视频| 国产精品白丝jk黑袜喷水| 欧美三级三级三级爽爽爽| 中文字幕欧美三区| 婷婷亚洲久悠悠色悠在线播放| 成人理论电影网| 精品国产精品网麻豆系列| 亚洲成人免费视频| 99精品久久只有精品| 国产欧美日韩麻豆91| 美女任你摸久久| 欧美日韩你懂的| 亚洲美女偷拍久久| 成人激情校园春色| 国产亚洲视频系列| 秋霞国产午夜精品免费视频| 日本高清不卡视频| 国产精品水嫩水嫩| 国产成人一区二区精品非洲| 久久亚洲影视婷婷| 九九九精品视频| 日韩欧美国产麻豆| 午夜久久久影院| 欧美日韩五月天| 视频在线观看一区| 欧美精品精品一区| 亚洲一区二区三区四区五区黄| 97久久人人超碰| 国产精品白丝在线| 日韩免费一区二区| 国产欧美日本一区二区三区| 欧美一三区三区四区免费在线看 | 色综合久久久久综合| 亚洲综合久久久| 国产美女在线观看一区| 亚洲一区中文在线| 亚洲成人av中文| 5566中文字幕一区二区电影| 日日摸夜夜添夜夜添亚洲女人| 欧美日韩国产一级片| 亚洲六月丁香色婷婷综合久久| 91久久精品一区二区三区| 欧美日韩卡一卡二| 人人爽香蕉精品| 久久久久久久久久久久电影 | 国产乱子伦视频一区二区三区 | 欧美嫩在线观看| 日韩电影在线免费看| 欧美日韩小视频| 久久se这里有精品| 国产精品国产自产拍在线| 91在线视频播放| 午夜精品福利一区二区三区av | 日韩片之四级片| 国产一区视频导航| 日韩理论在线观看| 欧美三级韩国三级日本三斤| 奇米色一区二区| 综合分类小说区另类春色亚洲小说欧美| 91在线国产观看| 捆绑紧缚一区二区三区视频| 日本一区二区三区dvd视频在线| 欧美性猛片xxxx免费看久爱| 精品一区二区成人精品| 一区在线播放视频| 日韩美女一区二区三区四区| 99这里只有久久精品视频| 日韩影院在线观看| 国产精品久久久99| 日韩视频一区在线观看| 91蜜桃在线免费视频| 激情久久久久久久久久久久久久久久| 欧美高清在线精品一区| 欧美久久一二三四区| av亚洲产国偷v产偷v自拍| 久久黄色级2电影| 伊人性伊人情综合网| 久久久久国色av免费看影院| 欧美酷刑日本凌虐凌虐| 在线一区二区观看| 成人免费黄色在线| 国精产品一区一区三区mba视频| 亚洲综合成人在线视频| 中文字幕一区二区不卡| 久久蜜桃香蕉精品一区二区三区| 欧美乱妇15p| 97精品国产露脸对白| 国产a久久麻豆| 国产综合成人久久大片91| 婷婷成人激情在线网| 亚洲综合一区二区精品导航| 最新成人av在线| 国产精品视频观看| 日本一区免费视频| 久久久.com| 久久免费电影网| 精品久久人人做人人爱| 欧美一级精品在线| 69堂精品视频| 911精品国产一区二区在线| 欧美性受xxxx| 美女视频黄a大片欧美| 中文字幕在线不卡国产视频| 欧美精品免费视频| 大白屁股一区二区视频| 天天av天天翘天天综合网色鬼国产| 日韩一区二区在线看片| 一本大道综合伊人精品热热| 免费人成在线不卡| 一区二区三区免费看视频| 国产欧美日韩另类视频免费观看| 欧美精品久久99久久在免费线 | 国产精品久久精品日日| 色婷婷av一区二区三区大白胸| 国产自产v一区二区三区c| 美脚の诱脚舐め脚责91| 婷婷久久综合九色综合伊人色| 夜夜爽夜夜爽精品视频| 欧美韩日一区二区三区| 久久久美女艺术照精彩视频福利播放| 男女男精品视频| 欧美国产一区二区| 久久伊人蜜桃av一区二区| 欧美精品久久久久久久久老牛影院| 制服丝袜亚洲色图| 国产成人在线视频网站| 亚洲蜜桃精久久久久久久| 56国语精品自产拍在线观看| 91免费国产在线观看| 色婷婷国产精品| 日韩欧美综合一区| 国产精品污污网站在线观看| 亚洲最色的网站| 美女一区二区在线观看| 日韩午夜在线观看视频| 亚洲色欲色欲www| 久久女同性恋中文字幕| 在线精品视频一区二区| 欧美一区二区播放| 久久精品一区二区三区不卡| 亚洲欧美日韩在线不卡| 免费观看在线综合| av激情综合网| 精品免费国产一区二区三区四区| 日韩精品一区二区三区视频在线观看| 欧美一区二区三区电影| 亚洲综合久久av| 高清不卡一二三区| 欧美成人乱码一区二区三区| 国产精品1024| 日本丰满少妇一区二区三区| 欧美一级日韩免费不卡|