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

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

?? flash.c

?? 一個開源的Modbus協議棧
?? C
字號:
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name          : flash.c
* Author             : MCD Application Team
* Date First Issued  : 07/28/2003
* Description        : This file provides all the Flash software functions
********************************************************************************
* History:
*  13/01/2006 : V3.1
*  24/05/2005 : V3.0
*  30/11/2004 : V2.0
*  14/07/2004 : V1.3
*  01/01/2004 : V1.2
*******************************************************************************
 THE PRESENT SOFTWARE 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 SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
 CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/

#include "flash.h"

/*******************************************************************************
* Function Name  : FLASH_Init
* Description    : Initialise the Flash registers to their default values.
* Input          : None.
* Return         : None.
*******************************************************************************/
void FLASH_Init(void)
{
/* Reset Flash Control Registers */
  FLASHR->CR0 = 0x00000000;
  FLASHR->CR1 = 0x00000000;
/* Reset Flash Data Registers */
  FLASHR->DR0 = 0xFFFFFFFF;
  FLASHR->DR1 = 0xFFFFFFFF;
/* Reset Flash Error Register */
  FLASHR->ER  = 0x00000000;
}

/*******************************************************************************
* Function Name  : FLASH_WordWrite
* Description    : Writes a Word in the Flash.
* Input 1        : Address of the Destination.
* Input 2        : Word to program at Address.
* Return         : None.
*******************************************************************************/
void FLASH_WordWrite(u32 XtargetAdd, u32 Xdata)
{
  /* Wait until another operation going on is completed */
  FLASH_WaitForLastTask();
  /* Set the Word Programming bit 'WPG' in the CR0 Reg */
  FLASHR->CR0 |= FLASH_WPG_Mask;
  /* Load the destination address in AR */
  FLASHR->AR   = XtargetAdd;
  /* Load DATA to be programmed in DR0 */
  FLASHR->DR0  = Xdata;
  /* Set the Write Mode Start bit 'WMS' in the CR0 Reg to Start Write Operation */
  FLASHR->CR0 |= FLASH_WMS_Mask;
  /* Wait until the write operation is completed */
  FLASH_WaitForLastTask();
}

/*******************************************************************************
* Function Name  : FLASH_DWordWrite
* Description    : Writes Double Word to the Flash.
* Input 1        : Address of the Destination.
* Input 2        : Word 1 to program.
* Input 3        : Word 2 to program.
* Return         : None.
*******************************************************************************/
void FLASH_DWordWrite(u32 XtargetAdd, u32 Xdata0, u32 Xdata1)
{
  /* Wait until another operation going on is completed */
  FLASH_WaitForLastTask();
  /* set the Double Word Programming bit 'DWPG' in the CR0 Reg */
  FLASHR->CR0 |= FLASH_DWPG_Mask;
  /* Load the destination address in AR */
  FLASHR->AR   = XtargetAdd;
  /* Load DATA0 in DR0 Reg */
  FLASHR->DR0  = Xdata0;
  /* Load DATA1 in DR1 Reg */
  FLASHR->DR1  = Xdata1;
  /* Set the Write Mode Start bit 'WMS' in the CR0 Reg to Start Write Operation */
  FLASHR->CR0 |= FLASH_WMS_Mask;
  /* Wait until the write operation is completed */
  FLASH_WaitForLastTask();
}

/*******************************************************************************
* Function Name  : FLASH_SectorErase
* Description    : Erases a Flash sector.
* Input 1        : Sectors to be Erased.
* Return         : None.
*******************************************************************************/
void FLASH_SectorErase(u32 Xsectors)
{
  /* Wait until another operation going on is completed */  
  FLASH_WaitForLastTask();
  /* Set the Sector Erase flag 'SER' in the CRO reg */
  FLASHR->CR0 |= FLASH_SER_Mask;
  /* Select in the CR1 register the Sectors to be erased  */
  FLASHR->CR1 |= Xsectors;
  /* Set the Write Mode Start bit 'WMS' in the CR0 Reg to Start Erase Operation */
  FLASHR->CR0 |= FLASH_WMS_Mask;
  /* Wait until the erase operation is completed */
  FLASH_WaitForLastTask();
}
/*******************************************************************************
* Function Name  : FLASH_Suspend
* Description    : Suspends the current program or erase operation.
* Input 1        : None.
* Return         : Flash CR0 register content.
*******************************************************************************/
u32 FLASH_Suspend(void)
{
  u32 temp;
  /* Save the CR0 Content */
  temp = FLASHR->CR0;
  /* Set The suspend Bit 'SUSP' in the CR0 register */
  FLASHR->CR0 |= FLASH_SUSP_Mask;
  /* Wait until the flash controller acknowledges the suspend of the current
     operation */
  FLASH_WaitForLastTask();
  return temp;
}

/*******************************************************************************
* Function Name  : FLASH_Resume
* Description    : Resume a Suspended program or erase operation.
* Input 1        : The operation to be resumed.
* Return         : None.
*******************************************************************************/
void FLASH_Resume(u32 FLASH_LastOperation)
{
  /* Clear The suspend Bit 'SUSP' in the FRC0 register */
  FLASHR->CR0 &= ~FLASH_SUSP_Mask;
  /* Resume last operation */
  FLASHR->CR0 = FLASH_LastOperation & 0x7FFFFFFF;
  /* Set write mode bit */
  FLASHR->CR0  |= FLASH_WMS_Mask;
}

/*******************************************************************************
* Function Name  : FLASH_WordRead
* Description    : Read a single word from the flash
* Input 1        : Source Address
* Return         : Word
*******************************************************************************/
u32 FLASH_WordRead(u32 FLASH_SourceAdd)
{
  FLASH_WaitForLastTask();
  /* Reads the data from the specified Address */
  return *(u32 *)(FLASH_SourceAdd + 0x40000000);
}

/*******************************************************************************
* Function Name  : FLASH_FlagStatus
* Description    : Returns the NewState of Flash flags
* Input          : Xflag(FLASH_BSYA0,  FLASH_BSYA1, FLASH_LOCK, FLASH_INTP
*                  FLASH_B0S, FLASH_B1S, FLASH_ERR, FLASH_ERER, FLASH_PGER, 
*                  FLASH_10ER, FLASH_SEQER, FLASH_RESER, FLASH_WPF)  
* Return         : FlagStatus (SET or RESET).
*******************************************************************************/
FlagStatus FLASH_FlagStatus(flashflags Xflag)
{
  FlagStatus TmpResult = RESET;
  u8 TmpReg;
  u8 TmpPos;
  /* Get the Register Index */
  TmpReg = (Xflag & FLASH_Reg_Mask) >> 5;
  /* Get the Flag Index */
  TmpPos = (Xflag & FLASH_Flag_Mask);

  switch(TmpReg)
  {
    case 0 : /* CR0 */
    {
      /* Returns the status of the CR0[TmpPos] flag */
      TmpResult = (FLASHR->CR0 & (1<<TmpPos))==0 ? RESET : SET;
      break;
    }
    case 1 : /* CR1 */
    {
      /* Returns the status of the CR1[TmpPos] flag */
      TmpResult = (FLASHR->CR1 & (1<<TmpPos))==0 ? RESET : SET;
      break;
    }
    case 5 : /* ER */
    {
      /* Returns the status of the ER[TmpPos] flag */
      TmpResult = (FLASHR->ER  & (1<<TmpPos))==0 ? RESET : SET;
      break;
    }
  }
  return(TmpResult);
}

/*******************************************************************************
* Function Name  : FLASH_FlagClear.
* Description    : Clears a flash flag.
* Input          : Xflag(FLASH_BSYA0,  FLASH_BSYA1, FLASH_LOCK, FLASH_INTP
*                  FLASH_B0S, FLASH_B1S, FLASH_ERR, FLASH_ERER, FLASH_PGER, 
*                  FLASH_10ER, FLASH_SEQER, FLASH_RESER, FLASH_WPF).  
* Return         : None.
*******************************************************************************/
void FLASH_FlagClear(flashflags Xflag)
{
  u8 TmpReg, TmpPos;
  TmpReg = (Xflag & FLASH_Reg_Mask) >> 5;
  TmpPos = (Xflag & FLASH_Flag_Mask);

  switch(TmpReg)
  {
    case 0 : /* CR0 */
    {
      /* Clears the status of the CR0[TmpPos] flag */
      FLASHR->CR0 &= ~(1<<TmpPos);
      break;
    }
    case 1 : /* CR1 */
    {
      /* Clears the status of the CR1[TmpPos] flag */
      FLASHR->CR1 &= ~(1<<TmpPos);
      break;
    }
    case 5 : /* ER */
    {
      /* Clears the status of the ER[TmpPos] flag */
      FLASHR->ER &= ~(1<<TmpPos);
      break;
    }
  }
}

/*******************************************************************************
* Function Name  : FLASH_WritePrConfig
* Description    : Enable Write protection or Disable temporarily Write 
*                  protection of a flash sector.
* Input 1        : Flash Sector.
* Input 2        : Enable or disable Flash sector Write Protection.
* Return         : None.
*******************************************************************************/
void FLASH_WritePrConfig(u32 Xsectors, FunctionalState NewState)
{
  /* Wait until another operation going on is completed */  
  FLASH_WaitForLastTask();  
  /* Enable Xsectors write protection */
  if (NewState == ENABLE)
  {
    /* Set the Set protection Bit */
    FLASHR->CR0 |= FLASH_SPR_Mask;
    /* Set the Register Address */
    FLASHR->AR  = 0x4010DFB0;
    /* Data to be programmed to the Protection Register */
    FLASHR->DR0  = ~Xsectors;
    /* Set the WMS bit to Start the Sequence */
    FLASHR->CR0 |= FLASH_WMS_Mask;
  }
  /* Unprotect temporarily Flash sector */ 
  else
  {
    /* Set the Set protection Bit */
    FLASHR->CR0 |= FLASH_SPR_Mask;
    /* Set the Register Address */
    FLASHR->AR  = 0x4010DFB0;
    /* Data to be programmed to the Protection Register */
    FLASHR->DR0  = FLASHPR->NVWPAR|Xsectors;
    /* Set the WMS bit to Start the Sequence */
    FLASHR->CR0 |= FLASH_WMS_Mask;
  }
}

/*******************************************************************************
* Function Name  : FLASH_PermanentDebugPrConfig
* Description    : Configures the Debug Protection Bits
* Input 1        : NewState: ENABLE or DISABLE.
* Return         : None.
*******************************************************************************/
void FLASH_PermanentDebugPrConfig(FunctionalState NewState)
{
  u16 ProtectionLevel = FLASH_ProtectionLevel();

  /* Enable permanent Debug protection */
  if (NewState == ENABLE)
  {
    /* If this is the first time that the debug protection is enabled:Reset 
       the DBGP bit in the NVAPR0 register */
    if(!ProtectionLevel) 
    {
      /* Set the Set protection Bit */
      FLASHR->CR0 |= FLASH_SPR_Mask;
      /* Set the Register Address */
      FLASHR->AR  = 0x4010DFB8;
      /* Data to be programmed to the Protection Register NVAPR0 */
      FLASHR->DR0 = ~2;
      /* Set the WMS bit to start the sequence */
      FLASHR->CR0 |= FLASH_WMS_Mask;
    }
    /* If this is not the first time that the debug protection is enabled: 
       use of NVAPR1 register */
    else 
    {
      /* Set the Set protection Bit */
      FLASHR->CR0 |= FLASH_SPR_Mask;
      /* Set the Register Address */
      FLASHR->AR  = 0x4010DFBC;
      /* Data to be programmed to the Protection Register NVAPR1(PEN bits) */
      FLASHR->DR0 =~(1<<(15+ProtectionLevel));
      /* Set the WMS bit to Start the Sequence */
      FLASHR->CR0 |= FLASH_WMS_Mask;
    }

  }
   /* Permanent debug unprotection: use of NVAPR1 register */ 
   else if(ProtectionLevel) 
   {
      /* Set the Set protection Bit */
      FLASHR->CR0 |= FLASH_SPR_Mask;
      /* Set the Register Address */
      FLASHR->AR  = 0x4010DFBC;
      /* Data to be programmed to the Protection Register NVAPR1(PDS bits)*/
      FLASHR->DR0 =~(1<<(ProtectionLevel-1));
      /* Set the WMS bit to Start the Sequence */
      FLASHR->CR0 |= FLASH_WMS_Mask;
  }

}

/*******************************************************************************
* Function Name  : FLASH_ProtectionLevel
* Description    : If the flash is Debug protected, up to 16 unprotection/
*                  protection cycles are possible using the NVAPR1 register.
*                  This routine returns the number of times of Debug unprotection. 
* Input          : None.
* Return         : Number of times of Debug Protection/Unprotection(0..15)
*                  Example: if 5 is returned, this means that the flash was debug 
*                  unprotected 5 times(using PDS bits)and debug protected 5 times 
*                  (1 time:using DBGP bit & 4 times: using PEN bits.   
*******************************************************************************/
u16 FLASH_ProtectionLevel(void)
{
  u16 TmpBitIndex =0;
  u16 ProtectionRegs;

  /* If DBGP = 1(Flash is Debug protected */
  if(FLASHPR->NVAPR0&2)
    TmpBitIndex=0;

  /*If DBGP = 0 (Flash is not Debug protected */
  else
    TmpBitIndex=1;
    ProtectionRegs=~(FLASHPR->NVAPR1>>16);

  while (((ProtectionRegs) != 0) && (TmpBitIndex < 16))
  {
    ProtectionRegs  = ProtectionRegs >>  1 ;
    TmpBitIndex++;
  }
  return TmpBitIndex;
}
/*******************************************************************************
* Function Name  : FLASH_WaitForLastTask
* Description    : Waits for the end of last task on a Flash Bank.
* Input 1        : None.
* Return         : None.
*******************************************************************************/
void FLASH_WaitForLastTask(void)
{
  while (FLASHR->CR0&0x16);
}

/*******************(C)COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美色一区| 亚洲国产综合人成综合网站| 亚洲色欲色欲www| 亚洲最大色网站| 日本不卡1234视频| 国产一区二区不卡| 色综合天天综合网国产成人综合天 | 久久99精品国产91久久来源| 国产成人鲁色资源国产91色综| 91视频免费播放| 欧美浪妇xxxx高跟鞋交| 26uuu色噜噜精品一区| 中文字幕视频一区二区三区久| 一区二区三区中文字幕电影| 日产欧产美韩系列久久99| 国产精品 欧美精品| 欧美午夜理伦三级在线观看| 精品国产凹凸成av人网站| 亚洲特级片在线| 青青国产91久久久久久| 成人av在线看| 日韩欧美中文字幕精品| 综合激情成人伊人| 麻豆国产欧美一区二区三区| 97国产一区二区| 日韩欧美国产一区二区三区| 亚洲欧美怡红院| 精品一区二区三区在线视频| 日本精品视频一区二区三区| 久久综合狠狠综合久久激情| 亚洲自拍欧美精品| 国产不卡视频在线观看| 日韩一区和二区| 亚洲精品国产a久久久久久| 成人精品亚洲人成在线| 欧美乱妇一区二区三区不卡视频| 欧美中文字幕一二三区视频| 91一区二区三区在线观看| 欧美一卡二卡在线| 亚洲免费观看视频| 国产精品一区二区免费不卡 | 欧美日韩亚洲综合在线| 亚洲国产精品黑人久久久| 亚洲成av人片在线观看无码| 成人18视频在线播放| www成人在线观看| 天天色天天爱天天射综合| 91视频国产观看| 国产欧美日韩精品一区| 九九在线精品视频| 欧美精品丝袜中出| 亚洲黄网站在线观看| 不卡av在线网| 国产日韩欧美在线一区| 久久精品国产免费| 欧美一二三区精品| 五月天网站亚洲| 欧美在线免费播放| 亚洲情趣在线观看| 92精品国产成人观看免费| 精品一区二区三区免费视频| 亚洲欧美色图小说| 国产iv一区二区三区| 久久久久久久免费视频了| 精品一区二区三区在线观看国产 | 久久奇米777| 欧美一卡二卡在线观看| 久久精品水蜜桃av综合天堂| 蜜桃视频一区二区三区在线观看 | 久久久精品影视| 另类小说色综合网站| 日韩视频一区二区在线观看| 亚洲6080在线| 欧美色综合久久| 一区二区三区日韩| 一本到三区不卡视频| 最新日韩在线视频| 99免费精品在线| 亚洲色欲色欲www在线观看| 99精品热视频| 亚洲欧洲综合另类在线| 色偷偷88欧美精品久久久| 亚洲天堂久久久久久久| 9人人澡人人爽人人精品| 中文字幕制服丝袜成人av| 白白色亚洲国产精品| 国产精品视频线看| 不卡免费追剧大全电视剧网站| 国产亚洲精品aa| 国产69精品久久99不卡| 亚洲国产精品精华液2区45| 波多野结衣亚洲一区| 亚洲码国产岛国毛片在线| 日本道精品一区二区三区| 亚洲午夜免费电影| 69堂国产成人免费视频| 开心九九激情九九欧美日韩精美视频电影 | 99久久精品99国产精品| 中文字幕在线观看不卡| 色综合一区二区三区| 亚洲日本中文字幕区| 99精品久久99久久久久| 亚洲h在线观看| 日韩欧美精品在线| 国产suv精品一区二区三区| 综合久久给合久久狠狠狠97色| 久久久综合九色合综国产精品| 国产欧美日韩卡一| 国产精品久久久久一区| 日韩黄色免费网站| 欧美大胆人体bbbb| 成人午夜精品一区二区三区| 亚洲精品第一国产综合野| 4438x亚洲最大成人网| 国产一区欧美一区| 亚洲欧洲三级电影| 69p69国产精品| 国产高清在线精品| 亚洲免费观看高清完整版在线| 欧美精品日韩综合在线| 国产精品一区在线观看乱码| 日韩理论片在线| 91精品午夜视频| 国产ts人妖一区二区| 性做久久久久久| 久久色中文字幕| 欧美三区免费完整视频在线观看| 国产在线精品视频| 一区二区三区在线影院| 欧美精品一区二区久久久| 91污片在线观看| 麻豆精品久久久| 亚洲天堂av一区| 久久香蕉国产线看观看99| 欧美中文一区二区三区| 韩国女主播一区| 一区二区三区鲁丝不卡| 久久久www成人免费毛片麻豆| 欧美三区在线视频| www.亚洲精品| 日韩av网站免费在线| 中文字幕在线不卡国产视频| 精品国产一区二区三区久久久蜜月| 色综合天天做天天爱| 国产精品一区二区x88av| 亚洲成人免费av| 中文字幕一区免费在线观看| 日韩欧美国产精品一区| 在线精品视频免费播放| 国产成人av电影在线| 免费成人在线观看视频| 亚洲午夜三级在线| 自拍偷在线精品自拍偷无码专区| 精品国产乱码久久久久久夜甘婷婷| 在线影视一区二区三区| 成人午夜视频在线观看| 久久se这里有精品| 午夜精品久久久久久久久 | 国产在线播放一区| 日韩精品色哟哟| 夜夜操天天操亚洲| 中文字幕一区二区三区不卡在线| 精品成a人在线观看| 欧美电影一区二区| 欧洲av一区二区嗯嗯嗯啊| 99久久免费视频.com| 处破女av一区二区| 久久精品国内一区二区三区| 午夜精品福利在线| 亚洲国产综合视频在线观看| 一区二区三区在线看| 亚洲欧洲中文日韩久久av乱码| 国产精品理伦片| 国产精品乱子久久久久| 国产无人区一区二区三区| 久久综合中文字幕| 欧美刺激午夜性久久久久久久| 欧美一区二区三区日韩视频| 一二三四区精品视频| 欧美日韩免费视频| 免费观看30秒视频久久| 亚洲男帅同性gay1069| 精品国产三级电影在线观看| 欧美视频一区二区在线观看| 国内精品在线播放| 中文字幕一区二区三区在线观看| 亚洲人xxxx| 国产精品女主播在线观看| 久久久精品中文字幕麻豆发布| 久久婷婷综合激情| 国产日韩欧美亚洲| 国产精品网友自拍| 国产日韩欧美亚洲| 午夜精品爽啪视频| 亚洲人123区| 一本一道综合狠狠老| 欧美日韩成人高清| 色呦呦一区二区三区| 在线视频国内自拍亚洲视频| 国产91丝袜在线18|