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

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

?? flash.c

?? AT91SAM7S64 / IAR EWARM 431A Examples
?? C
字號:
//*----------------------------------------------------------------------------
//*         ATMEL Microcontroller Software Support  -  ROUSSET  -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name           : Flash.c
//* Object              : Flash routine
//* Creation            : JPP   30/Jun/2004
//* Modif               : JPM   16/Nov/2004 Flash write status
//* 1.1   12/Sep/05 JPP : Change MC_FMR Setting
//*----------------------------------------------------------------------------

// Include Standard files
#include "Board.h"
#include "Flash.h"

extern  void AT91F_disable_interrupt(void);
extern  void AT91F_enable_interrupt(void);


//*----------------------------------------------------------------------------
//* \fn    AT91F_Flash_Init
//* \brief Flash init
//*----------------------------------------------------------------------------
void AT91F_Flash_Init (void)
{
    //* Set number of Flash Waite sate
    //  SAM7S64 features Single Cycle Access at Up to 30 MHz
    //  if MCK = 47923200, 72 Cycles for 1 祍econde ( field MC_FMR->FMCN)
        AT91C_BASE_MC->MC_FMR = ((AT91C_MC_FMCN)&(72 <<16)) | AT91C_MC_FWS_1FWS ;
}
//*----------------------------------------------------------------------------
//* \fn    AT91F_Flash_Init
//* \brief Flash init
//*----------------------------------------------------------------------------
void AT91F_NVM_Init (void)
{
    //* Set number of Flash Waite sate
    //  SAM7S64 features Single Cycle Access at Up to 30 MHz
    //  if MCK = 47923200, 48 Cycles for 1 祍econde ( field MC_FMR->FMCN)
        AT91C_BASE_MC->MC_FMR = ((AT91C_MC_FMCN)&(48 <<16)) | AT91C_MC_FWS_1FWS ;
}

//*----------------------------------------------------------------------------
//* \fn    AT91F_Flash_Ready
//* \brief Wait the flash ready
//*----------------------------------------------------------------------------
__ramfunc int AT91F_Flash_Ready (void)
{
    unsigned int status;
    status = 0;

    //* Wait the end of command
        while ((status & AT91C_MC_FRDY) != AT91C_MC_FRDY )
        {
          status = AT91C_BASE_MC->MC_FSR;
        }
        return status;
}

//*----------------------------------------------------------------------------
//* \fn    AT91F_Flash_Lock_Status
//* \brief Get the Lock bits field status
//*----------------------------------------------------------------------------
__ramfunc int AT91F_Flash_Lock_Status(void)
{
  return (AT91C_BASE_MC->MC_FSR & AT91C_MC_FSR_LOCK);
}
//*----------------------------------------------------------------------------
//* \fn    AT91F_Flash_Lock
//* \brief Write the lock bit and set at 0 FSR Bit = 1
//* \input page number (0-1023)
//* \output Region
//*----------------------------------------------------------------------------
__ramfunc int AT91F_Flash_Lock (unsigned int Flash_Lock_Page)
{
    //* set the Flash controller base address
        AT91PS_MC ptMC = AT91C_BASE_MC;

        AT91F_NVM_Init();
    //* write the flash
	//* Protect
		AT91F_disable_interrupt();
    //* Write the Set Lock Bit command
        ptMC->MC_FCR = AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_LOCK | (AT91C_MC_PAGEN & (Flash_Lock_Page << 8) ) ;

    //* Wait the end of command
         AT91F_Flash_Ready();
    //* Protect
		AT91F_enable_interrupt();


  return (AT91F_Flash_Lock_Status());
}
//*----------------------------------------------------------------------------
//* \fn    AT91F_Flash_Unlock
//* \brief Clear the lock bit and set at 1 FSR bit=0
//* \input page number (0-1023)
//* \output Region
//*----------------------------------------------------------------------------
__ramfunc int AT91F_Flash_Unlock(unsigned int Flash_Lock_Page)
{
	    AT91F_NVM_Init();

	//* Protect
		AT91F_disable_interrupt();
    //* Write the Clear Lock Bit command
        AT91C_BASE_MC->MC_FCR = AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_UNLOCK | (AT91C_MC_PAGEN & (Flash_Lock_Page << 8) ) ;

    //* Wait the end of command
        AT91F_Flash_Ready();
    //* Protect
		AT91F_enable_interrupt();

  return (AT91F_Flash_Lock_Status());
}


//*----------------------------------------------------------------------------
//* \fn    AT91F_Flash_Erase_All
//* \brief Send command erase all flash
//*----------------------------------------------------------------------------
__ramfunc int AT91F_Flash_Erase_All(void)
{
        AT91F_Flash_Init();
	//* Protect
		AT91F_disable_interrupt();
    //* set the Flash controller base address
        AT91PS_MC ptMC = AT91C_BASE_MC;
    //* Write the Erase All command
        ptMC->MC_FCR = AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_ERASE_ALL ;
    //* Wait the end of command
        AT91F_Flash_Ready();
   //* Protect
		AT91F_enable_interrupt();
    //* Check the result
        return ( (ptMC->MC_FSR & ( AT91C_MC_PROGE | AT91C_MC_LOCKE ))==0) ;
}

//*----------------------------------------------------------------------------
//* \fn    AT91F_Flash_Write
//* \brief Write in one Flash page located in AT91C_IFLASH,  size in 32 bits
//* \input Flash_Address: start at 0x0010 0000 size: in byte
//*----------------------------------------------------------------------------
__ramfunc int AT91F_Flash_Write( unsigned int Flash_Address ,int size ,unsigned int * buff)
{
    //* set the Flash controller base address
    AT91PS_MC ptMC = AT91C_BASE_MC;
    unsigned int i, page, status;
    unsigned int * Flash;
    //* init flash pointer
        Flash = (unsigned int *) Flash_Address;

        AT91F_Flash_Init();
   //* Get the Flash page number
        page = ((Flash_Address - (unsigned int)AT91C_IFLASH ) /FLASH_PAGE_SIZE_BYTE);
   //* copy the new value
	for (i=0; (i < FLASH_PAGE_SIZE_BYTE) & (size > 0) ;i++, Flash++,buff++,size-=4 ){
	//* copy the flash to the write buffer ensuring code generation
	    *Flash=*buff;
	}
	//* Protect
		AT91F_disable_interrupt();
    //* Write the write page command
        ptMC->MC_FCR = AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_START_PROG | (AT91C_MC_PAGEN & (page <<8)) ;
    //* Wait the end of command
        status = AT91F_Flash_Ready();
    //* Protect
		AT91F_enable_interrupt();

    //* Check the result
    if ( (status & ( AT91C_MC_PROGE | AT91C_MC_LOCKE ))!=0) return false;
  return true;
}


//*----------------------------------------------------------------------------
//* \fn    AT91F_NVM_Status
//* \brief Get the NVM field status
//*----------------------------------------------------------------------------
__ramfunc int AT91F_NVM_Status(void)
{
  return (AT91C_BASE_MC->MC_FSR & AT91C_MC_FSR_MVM);
}

//*----------------------------------------------------------------------------
//* \fn    AT91F_NVM_Set
//* \brief Write the Non Volatile Memory Bits and set at 0 FSR Bit = 1
//*----------------------------------------------------------------------------
__ramfunc int AT91F_NVM_Set (unsigned char NVM_Number)
{
        AT91F_NVM_Init();
    //* set the Flash controller base address
        AT91PS_MC ptMC = AT91C_BASE_MC;
	//* Protect
		AT91F_disable_interrupt();

	 //* write the flash
    //* Write the Set NVM Bit command
        ptMC->MC_FCR = AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_SET_GP_NVM | (AT91C_MC_PAGEN & (NVM_Number << 8) ) ;

    //* Wait the end of command
        AT91F_Flash_Ready();
    //* Protect
		AT91F_enable_interrupt();

  return (AT91F_NVM_Status());
}
//*----------------------------------------------------------------------------
//* \fn    AT91F_NVM_Clear
//* \brief Clear the Non Volatile Memory Bits and set at 1 FSR bit=0
//*----------------------------------------------------------------------------
__ramfunc int AT91F_NVM_Clear(unsigned char NVM_Number)
{
        AT91F_NVM_Init();
    //* set the Flash controller base address
        AT91PS_MC ptMC = AT91C_BASE_MC;

	//* Protect
		AT91F_disable_interrupt();
	 //* write the flash
    //* Write the Clear NVM Bit command
        ptMC->MC_FCR = AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_CLR_GP_NVM | (AT91C_MC_PAGEN & (NVM_Number << 8) ) ;

    //* Wait the end of command
       AT91F_Flash_Ready();
    //* Protect
		AT91F_enable_interrupt();


  return (AT91F_NVM_Status());
}

//*----------------------------------------------------------------------------
//* \fn    AT91F_SET_Security_Status
//* \brief Get Flash Security Bit Status
//*----------------------------------------------------------------------------
__ramfunc int AT91F_SET_Security_Status (void)
{
  return (AT91C_BASE_MC->MC_FSR & AT91C_MC_SECURITY);
}

//*----------------------------------------------------------------------------
//* \fn AT91F_SET_Security
//* \brief Set Flash Security Bit
//*----------------------------------------------------------------------------
__ramfunc int AT91F_SET_Security (void)
{
        AT91F_NVM_Init();
	//* Protect
		AT91F_disable_interrupt();
	 //* write the flash
    //* Write the Set Security Bit command
        AT91C_BASE_MC->MC_FCR = ( AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_SET_SECURITY ) ;

    //* Wait the end of command
       AT91F_Flash_Ready();
    //* Protect
		AT91F_enable_interrupt();

  return (AT91F_SET_Security_Status());
}
//*----------------------------------------------------------------------------
//* \fn    AT91F_Flash_Check_Erase
//* \brief Check the memory at 0xFF in 32 bits access
//*----------------------------------------------------------------------------
int AT91F_Flash_Check_Erase (unsigned int * start, unsigned int size)
{
	unsigned int i;
    //* Check if flash is erased
	for (i=0; i < (size/4) ; i++ )
	{
	    if ( start[i] != ERASE_VALUE ) return  false;
	}
	return true ;
}

//*----------------------------------------------------------------------------
//* \fn    AT91F_Flash_Write_all
//* \brief Write in one Flash page located in AT91C_IFLASH,  size in byte
//* \input Start address (base=AT91C_IFLASH) size (in byte ) and buff address
//*----------------------------------------------------------------------------
int AT91F_Flash_Write_all( unsigned int Flash_Address ,int size ,unsigned int * buff)
{

    int   next, status;
    unsigned int  dest;
    unsigned int * src;

    dest = Flash_Address;
    src = buff;
    status = true;

    while( (status == true) & (size > 0) )
	{
        //* Check the size
        if (size <= FLASH_PAGE_SIZE_BYTE) next = size;
        else next = FLASH_PAGE_SIZE_BYTE;

        //* Unlock current sector base address - current address by sector size
        AT91F_Flash_Unlock((dest - (unsigned int)AT91C_IFLASH ) /FLASH_PAGE_SIZE_BYTE);

        //* Write page and get status
        status = AT91F_Flash_Write( dest ,next ,src);
        // * get next page param
        size -= next;
        src += FLASH_PAGE_SIZE_BYTE/4;
        dest +=  FLASH_PAGE_SIZE_BYTE;
	}
    return status;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
懂色av一区二区三区蜜臀 | 国产乱妇无码大片在线观看| 成人一区二区视频| 欧美精品丝袜中出| 国产精品久久久久永久免费观看 | 欧美人与禽zozo性伦| 国产欧美久久久精品影院| 亚洲午夜精品在线| 成人一区二区三区在线观看| 欧美一级精品大片| 亚洲国产成人91porn| 91在线观看免费视频| 久久亚洲一级片| 日韩av网站在线观看| 91色视频在线| 国产精品国产自产拍高清av| 国产乱码精品一区二区三区av | 欧美男男青年gay1069videost| 久久精品视频免费观看| 一区二区三区成人| 99re成人在线| 国产精品视频在线看| 国产一区二区三区不卡在线观看 | 正在播放亚洲一区| 一二三四区精品视频| 99久久国产免费看| 国产精品久久久久久久蜜臀 | 日本欧美一区二区在线观看| 欧美中文字幕一二三区视频| 国产精品卡一卡二| 成人免费高清视频在线观看| 日本一区二区三区国色天香| 国产精品一级片在线观看| 久久婷婷成人综合色| 国产一区二区三区美女| 26uuu亚洲综合色| 久久99国产精品成人| 日韩一级成人av| 国产一区二区三区四区五区美女 | xnxx国产精品| 国产在线一区观看| 久久综合中文字幕| 国内不卡的二区三区中文字幕| 欧美变态口味重另类| 国产专区欧美精品| 中文字幕精品一区二区三区精品| 国产99久久精品| 亚洲视频一区二区在线| 日本高清不卡视频| 午夜视频一区二区三区| 日韩欧美国产一区二区在线播放| 日本伊人色综合网| 精品久久久久久综合日本欧美 | 看电影不卡的网站| 欧美二区三区的天堂| 极品美女销魂一区二区三区 | 午夜精品久久久久久久久| 欧美日韩精品欧美日韩精品 | 一区二区三区免费| 欧美色图免费看| 免费精品视频最新在线| 国产女主播一区| 91影院在线免费观看| 性做久久久久久免费观看| 欧美不卡激情三级在线观看| 国产不卡一区视频| 亚洲最色的网站| 精品日本一线二线三线不卡| 国产美女久久久久| 国产精品毛片大码女人| 欧美亚洲国产bt| 国产传媒一区在线| 亚洲国产精品久久一线不卡| 精品噜噜噜噜久久久久久久久试看| 成人久久久精品乱码一区二区三区 | 国产亚洲一区字幕| 欧美日韩精品专区| jlzzjlzz亚洲日本少妇| 日韩精品一卡二卡三卡四卡无卡| 欧美国产禁国产网站cc| 欧美一区二区三区视频免费 | 在线电影院国产精品| 成人午夜av影视| 亚洲va国产va欧美va观看| 精品国产3级a| 欧美人妖巨大在线| 色嗨嗨av一区二区三区| 国产一区91精品张津瑜| 亚洲欧美一区二区三区久本道91 | 久久99精品国产.久久久久 | 国产精品水嫩水嫩| 色域天天综合网| 日本女优在线视频一区二区| 337p粉嫩大胆色噜噜噜噜亚洲| 国产乱人伦精品一区二区在线观看 | 欧美网站一区二区| 秋霞电影网一区二区| 国产色产综合色产在线视频| 色哟哟欧美精品| 国产精品久久久一本精品| 久久久国产精品麻豆| 波多野结衣中文一区| 午夜不卡av在线| 国产精品蜜臀av| 欧美午夜精品久久久| 久久国产综合精品| 最新成人av在线| 91免费在线看| 免费成人在线观看| 亚洲久草在线视频| 久久免费午夜影院| 欧美视频一区二区在线观看| 国产盗摄女厕一区二区三区| 午夜精品aaa| 国产精品三级av| 精品成人一区二区三区| eeuss鲁片一区二区三区| 亚洲最大成人网4388xx| 日韩欧美亚洲一区二区| 91福利在线看| 成人做爰69片免费看网站| 久久69国产一区二区蜜臀| 亚洲国产日韩一区二区| 国产日本欧美一区二区| 欧美日韩国产区一| 国产乱码精品一区二区三区五月婷 | 国产精品午夜在线| 日韩一区二区三区视频在线| 不卡一区二区中文字幕| 九九在线精品视频| 视频一区视频二区中文字幕| 亚洲三级视频在线观看| 精品盗摄一区二区三区| 欧美精品在欧美一区二区少妇| 99久久久久久99| 日日摸夜夜添夜夜添国产精品| 久久精品国产99国产精品| 亚洲色图一区二区三区| 国产日韩精品一区| 久久久国产一区二区三区四区小说 | 精品一区二区三区日韩| 亚洲综合免费观看高清在线观看| 精品日产卡一卡二卡麻豆| 欧美一区二区三区播放老司机| 欧美性猛片xxxx免费看久爱| 欧美综合天天夜夜久久| 色综合天天综合在线视频| 国产福利一区二区三区| 美女国产一区二区| 亚洲韩国精品一区| 蜜桃视频免费观看一区| 美女视频黄免费的久久 | 久久综合网色—综合色88| 日韩一二在线观看| 日韩一区二区电影网| 日韩一级免费观看| 精品欧美黑人一区二区三区| 欧美性三三影院| 久久精品视频在线免费观看| 中文字幕不卡三区| 亚洲欧洲三级电影| 一区二区三区丝袜| 亚洲成av人片| 裸体一区二区三区| 国产不卡在线一区| 91香蕉视频污在线| 欧美成人a∨高清免费观看| 久久精品水蜜桃av综合天堂| 国产精品久久久久久久蜜臀 | 色av成人天堂桃色av| 日本道精品一区二区三区| 国产不卡高清在线观看视频| 国产精品一区二区免费不卡| 成人av在线电影| 欧美自拍偷拍午夜视频| 欧美一区二区三区色| 2017欧美狠狠色| 亚洲日本va午夜在线电影| 亚洲午夜久久久久久久久电影网 | 91精品国产综合久久久久久久| 日本高清不卡视频| 一本一道综合狠狠老| 成人av综合一区| 欧美午夜影院一区| www国产精品av| 一区二区在线观看视频| 亚洲最新视频在线播放| 日韩精品电影在线| 成人美女视频在线看| 在线不卡欧美精品一区二区三区| 国产日韩欧美亚洲| 中文字幕欧美国产| 国内精品伊人久久久久av一坑| 97国产精品videossex| 日韩精品专区在线影院观看 | 国产剧情一区二区| 91麻豆精东视频| 精品国产成人系列| 五月激情综合色| 久久99久久99小草精品免视看|