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

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

?? flash.c

?? STM32+Grlib
?? C
?? 第 1 頁 / 共 2 頁
字號:
//*****************************************************************************
//
// flash.c - Driver for programming the on-chip flash.
//
// Copyright (c) 2005-2010 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
// 
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
// 
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
// 
// This is part of revision 5821 of the Stellaris Peripheral Driver Library.
//
//*****************************************************************************

//*****************************************************************************
//
//! \addtogroup flash_api
//! @{
//
//*****************************************************************************

#include "inc/hw_flash.h"
#include "inc/hw_ints.h"
#include "inc/hw_sysctl.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/flash.h"
#include "driverlib/interrupt.h"

//*****************************************************************************
//
// An array that maps the specified memory bank to the appropriate Flash
// Memory Protection Program Enable (FMPPE) register.
//
//*****************************************************************************
static const unsigned long g_pulFMPPERegs[] =
{
    FLASH_FMPPE,
    FLASH_FMPPE1,
    FLASH_FMPPE2,
    FLASH_FMPPE3
};

//*****************************************************************************
//
// An array that maps the specified memory bank to the appropriate Flash
// Memory Protection Read Enable (FMPRE) register.
//
//*****************************************************************************
static const unsigned long g_pulFMPRERegs[] =
{
    FLASH_FMPRE,
    FLASH_FMPRE1,
    FLASH_FMPRE2,
    FLASH_FMPRE3
};

//*****************************************************************************
//
//! Gets the number of processor clocks per micro-second.
//!
//! This function returns the number of clocks per micro-second, as presently
//! known by the flash controller.
//!
//! \return Returns the number of processor clocks per micro-second.
//
//*****************************************************************************
unsigned long
FlashUsecGet(void)
{
    //
    // Return the number of clocks per micro-second.
    //
    return(HWREG(FLASH_USECRL) + 1);
}

//*****************************************************************************
//
//! Sets the number of processor clocks per micro-second.
//!
//! \param ulClocks is the number of processor clocks per micro-second.
//!
//! This function is used to tell the flash controller the number of processor
//! clocks per micro-second.  This value must be programmed correctly or the
//! flash most likely will not program correctly; it has no affect on reading
//! flash.
//!
//! \return None.
//
//*****************************************************************************
void
FlashUsecSet(unsigned long ulClocks)
{
    //
    // Set the number of clocks per micro-second.
    //
    HWREG(FLASH_USECRL) = ulClocks - 1;
}

//*****************************************************************************
//
//! Erases a block of flash.
//!
//! \param ulAddress is the start address of the flash block to be erased.
//!
//! This function will erase a 1 kB block of the on-chip flash.  After erasing,
//! the block will be filled with 0xFF bytes.  Read-only and execute-only
//! blocks cannot be erased.
//!
//! This function will not return until the block has been erased.
//!
//! \return Returns 0 on success, or -1 if an invalid block address was
//! specified or the block is write-protected.
//
//*****************************************************************************
long
FlashErase(unsigned long ulAddress)
{
    //
    // Check the arguments.
    //
    ASSERT(!(ulAddress & (FLASH_ERASE_SIZE - 1)));

    //
    // Clear the flash access interrupt.
    //
    HWREG(FLASH_FCMISC) = FLASH_FCMISC_AMISC;

    //
    // Erase the block.
    //
    HWREG(FLASH_FMA) = ulAddress;
    HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_ERASE;

    //
    // Wait until the block has been erased.
    //
    while(HWREG(FLASH_FMC) & FLASH_FMC_ERASE)
    {
    }

    //
    // Return an error if an access violation occurred.
    //
    if(HWREG(FLASH_FCRIS) & FLASH_FCRIS_ARIS)
    {
        return(-1);
    }

    //
    // Success.
    //
    return(0);
}

//*****************************************************************************
//
//! Programs flash.
//!
//! \param pulData is a pointer to the data to be programmed.
//! \param ulAddress is the starting address in flash to be programmed.  Must
//! be a multiple of four.
//! \param ulCount is the number of bytes to be programmed.  Must be a multiple
//! of four.
//!
//! This function will program a sequence of words into the on-chip flash.
//! Programming each location consists of the result of an AND operation
//! of the new data and the existing data; in other words bits that contain
//! 1 can remain 1 or be changed to 0, but bits that are 0 cannot be changed
//! to 1.  Therefore, a word can be programmed multiple times as long as these
//! rules are followed; if a program operation attempts to change a 0 bit to
//! a 1 bit, that bit will not have its value changed.
//!
//! Since the flash is programmed one word at a time, the starting address and
//! byte count must both be multiples of four.  It is up to the caller to
//! verify the programmed contents, if such verification is required.
//!
//! This function will not return until the data has been programmed.
//!
//! \return Returns 0 on success, or -1 if a programming error is encountered.
//
//*****************************************************************************
long
FlashProgram(unsigned long *pulData, unsigned long ulAddress,
             unsigned long ulCount)
{
    //
    // Check the arguments.
    //
    ASSERT(!(ulAddress & 3));
    ASSERT(!(ulCount & 3));

    //
    // Clear the flash access interrupt.
    //
    HWREG(FLASH_FCMISC) = FLASH_FCMISC_AMISC;

    //
    // See if this device has a write buffer.
    //
    if(HWREG(SYSCTL_NVMSTAT) & SYSCTL_NVMSTAT_FWB)
    {
        //
        // Loop over the words to be programmed.
        //
        while(ulCount)
        {
            //
            // Set the address of this block of words.
            //
            HWREG(FLASH_FMA) = ulAddress & ~(0x7f);

            //
            // Loop over the words in this 32-word block.
            //
            while(((ulAddress & 0x7c) || (HWREG(FLASH_FWBVAL) == 0)) &&
                  (ulCount != 0))
            {
                //
                // Write this word into the write buffer.
                //
                HWREG(FLASH_FWBN + (ulAddress & 0x7c)) = *pulData++;
                ulAddress += 4;
                ulCount -= 4;
            }

            //
            // Program the contents of the write buffer into flash.
            //
            HWREG(FLASH_FMC2) = FLASH_FMC2_WRKEY | FLASH_FMC2_WRBUF;

            //
            // Wait until the write buffer has been programmed.
            //
            while(HWREG(FLASH_FMC2) & FLASH_FMC2_WRBUF)
            {
            }
        }
    }
    else
    {
        //
        // Loop over the words to be programmed.
        //
        while(ulCount)
        {
            //
            // Program the next word.
            //
            HWREG(FLASH_FMA) = ulAddress;
            HWREG(FLASH_FMD) = *pulData;
            HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_WRITE;

            //
            // Wait until the word has been programmed.
            //
            while(HWREG(FLASH_FMC) & FLASH_FMC_WRITE)
            {
            }

            //
            // Increment to the next word.
            //
            pulData++;
            ulAddress += 4;
            ulCount -= 4;
        }
    }

    //
    // Return an error if an access violation occurred.
    //
    if(HWREG(FLASH_FCRIS) & FLASH_FCRIS_ARIS)
    {
        return(-1);
    }

    //
    // Success.
    //
    return(0);
}

//*****************************************************************************
//
//! Gets the protection setting for a block of flash.
//!
//! \param ulAddress is the start address of the flash block to be queried.
//!
//! This function will get the current protection for the specified 2 kB block
//! of flash.  Each block can be read/write, read-only, or execute-only.
//! Read/write blocks can be read, executed, erased, and programmed.  Read-only
//! blocks can be read and executed.  Execute-only blocks can only be executed;
//! processor and debugger data reads are not allowed.
//!
//! \return Returns the protection setting for this block.  See
//! FlashProtectSet() for possible values.
//
//*****************************************************************************
tFlashProtection
FlashProtectGet(unsigned long ulAddress)
{
    unsigned long ulFMPRE, ulFMPPE;
    unsigned long ulBank;

    //
    // Check the argument.
    //
    ASSERT(!(ulAddress & (FLASH_PROTECT_SIZE - 1)));

    //
    // Calculate the Flash Bank from Base Address, and mask off the Bank
    // from ulAddress for subsequent reference.
    //
    ulBank = (((ulAddress / FLASH_PROTECT_SIZE) / 32) % 4);
    ulAddress &= ((FLASH_PROTECT_SIZE * 32) - 1);

    //
    // Read the appropriate flash protection registers for the specified
    // flash bank.
    //
    ulFMPRE = HWREG(g_pulFMPRERegs[ulBank]);
    ulFMPPE = HWREG(g_pulFMPPERegs[ulBank]);

    //
    // For Stellaris Sandstorm-class devices, revision C1 and C2, the upper
    // bits of the FMPPE register are used for JTAG protect options, and are
    // not available for the FLASH protection scheme.  When Querying Block
    // Protection, assume these bits are 1.
    //
    if(CLASS_IS_SANDSTORM && (REVISION_IS_C1 || REVISION_IS_C2))
    {
        ulFMPRE |= (FLASH_FMP_BLOCK_31 | FLASH_FMP_BLOCK_30);
    }

    //
    // Check the appropriate protection bits for the block of memory that
    // is specified by the address.
    //
    switch((((ulFMPRE >> (ulAddress / FLASH_PROTECT_SIZE)) &
             FLASH_FMP_BLOCK_0) << 1) |
           ((ulFMPPE >> (ulAddress / FLASH_PROTECT_SIZE)) & FLASH_FMP_BLOCK_0))
    {
        //
        // This block is marked as execute only (that is, it can not be erased
        // or programmed, and the only reads allowed are via the instruction
        // fetch interface).
        //
        case 0:
        case 1:
        {
            return(FlashExecuteOnly);
        }

        //
        // This block is marked as read only (that is, it can not be erased or
        // programmed).
        //
        case 2:
        {
            return(FlashReadOnly);
        }

        //
        // This block is read/write; it can be read, erased, and programmed.
        //
        case 3:
        default:
        {
            return(FlashReadWrite);
        }
    }
}

//*****************************************************************************
//
//! Sets the protection setting for a block of flash.
//!
//! \param ulAddress is the start address of the flash block to be protected.
//! \param eProtect is the protection to be applied to the block.  Can be one
//! of \b FlashReadWrite, \b FlashReadOnly, or \b FlashExecuteOnly.
//!
//! This function will set the protection for the specified 2 kB block of
//! flash.  Blocks which are read/write can be made read-only or execute-only.
//! Blocks which are read-only can be made execute-only.  Blocks which are
//! execute-only cannot have their protection modified.  Attempts to make the
//! block protection less stringent (that is, read-only to read/write) will
//! result in a failure (and be prevented by the hardware).
//!
//! Changes to the flash protection are maintained only until the next reset.
//! This allows the application to be executed in the desired flash protection
//! environment to check for inappropriate flash access (via the flash
//! interrupt).  To make the flash protection permanent, use the
//! FlashProtectSave() function.
//!
//! \return Returns 0 on success, or -1 if an invalid address or an invalid
//! protection was specified.
//
//*****************************************************************************
long
FlashProtectSet(unsigned long ulAddress, tFlashProtection eProtect)
{
    unsigned long ulProtectRE, ulProtectPE;
    unsigned long ulBank;

    //
    // Check the argument.
    //
    ASSERT(!(ulAddress & (FLASH_PROTECT_SIZE - 1)));
    ASSERT((eProtect == FlashReadWrite) || (eProtect == FlashReadOnly) ||
           (eProtect == FlashExecuteOnly));

    //
    // Convert the address into a block number.
    //
    ulAddress /= FLASH_PROTECT_SIZE;

    //
    // ulAddress contains a "raw" block number.  Derive the Flash Bank from
    // the "raw" block number, and convert ulAddress to a "relative"
    // block number.
    //
    ulBank = ((ulAddress / 32) % 4);
    ulAddress %= 32;

    //
    // Get the current protection for the specified flash bank.
    //
    ulProtectRE = HWREG(g_pulFMPRERegs[ulBank]);
    ulProtectPE = HWREG(g_pulFMPPERegs[ulBank]);

    //
    // For Stellaris Sandstorm-class devices, revision C1 and C2, the upper
    // bits of the FMPPE register are used for JTAG protect options, and are
    // not available for the FLASH protection scheme.  When setting protection,
    // check to see if block 30 or 31 and protection is FlashExecuteOnly.  If
    // so, return an error condition.
    //
    if(CLASS_IS_SANDSTORM && (REVISION_IS_C1 || REVISION_IS_C2))
    {
        if((ulAddress >= 30) && (eProtect == FlashExecuteOnly))
        {
            return(-1);
        }
    }

    //

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲美女屁股眼交3| 亚洲激情六月丁香| 欧美日韩免费高清一区色橹橹 | 日本一区免费视频| 色婷婷av一区二区三区软件| 精品亚洲aⅴ乱码一区二区三区| 亚洲欧美另类综合偷拍| 久久―日本道色综合久久| 欧美亚洲一区三区| 99久久精品久久久久久清纯| 免费人成在线不卡| 午夜久久福利影院| 国产精品情趣视频| 日韩欧美亚洲国产精品字幕久久久| 色网站国产精品| 国产sm精品调教视频网站| 美女一区二区三区| 亚洲综合在线第一页| 国产精品另类一区| 久久久久国色av免费看影院| 日韩精品中文字幕在线不卡尤物| 在线观看精品一区| 91蜜桃视频在线| jvid福利写真一区二区三区| 成人丝袜高跟foot| 国产精品资源网| 国产乱码字幕精品高清av| 久久99久久99精品免视看婷婷| 婷婷中文字幕综合| 亚洲成人av中文| 午夜精品久久久久久久99樱桃| 亚洲午夜av在线| 亚洲超丰满肉感bbw| 亚洲国产精品久久人人爱| 亚洲韩国精品一区| 亚洲h精品动漫在线观看| 亚洲一二三四久久| 亚洲国产视频在线| 午夜精品aaa| 午夜国产精品影院在线观看| 亚洲v日本v欧美v久久精品| 亚洲一区二区三区四区在线观看| 亚洲激情男女视频| 午夜激情一区二区三区| 日韩成人一区二区| 美女视频免费一区| 国内精品伊人久久久久av一坑 | 欧美日韩国产综合久久| 欧美日韩国产电影| 日韩精品专区在线影院观看| 精品播放一区二区| 国产欧美一区二区精品忘忧草 | 日韩欧美在线观看一区二区三区| 正在播放一区二区| 精品国产91乱码一区二区三区 | 日韩欧美中文一区二区| 精品久久久久久最新网址| 久久久久亚洲蜜桃| 亚洲欧洲在线观看av| 亚洲国产乱码最新视频| 日韩国产在线观看一区| 精品在线一区二区三区| 国产福利一区在线| 91偷拍与自偷拍精品| 欧美日韩国产综合一区二区| 精品国产一区二区在线观看| 亚洲国产精品精华液2区45| 亚洲激情五月婷婷| 久久精品国产澳门| 不卡在线观看av| 欧美日韩久久不卡| 国产欧美一区二区精品忘忧草| 亚洲欧美日韩在线不卡| 麻豆久久久久久久| 不卡高清视频专区| 欧美精品久久久久久久多人混战| 久久亚洲免费视频| 一区二区三区欧美| 免费日本视频一区| 97se狠狠狠综合亚洲狠狠| 欧美一区二区三区四区视频| 亚洲国产精华液网站w| 日韩精品电影在线| 成人一区二区在线观看| 8v天堂国产在线一区二区| 国产欧美日韩卡一| 奇米精品一区二区三区四区| 99久久综合精品| 欧美mv日韩mv| 午夜精品一区二区三区三上悠亚| 国产精品自在欧美一区| 欧美挠脚心视频网站| 国产精品美女久久久久av爽李琼 | 久久99精品视频| 91网站在线观看视频| 久久综合成人精品亚洲另类欧美 | 亚洲精品成人精品456| 久久99久国产精品黄毛片色诱| 91久久精品日日躁夜夜躁欧美| 精品捆绑美女sm三区| 亚洲一区电影777| av电影在线观看不卡| www一区二区| 日韩中文字幕区一区有砖一区| aaa亚洲精品| 久久久99免费| 麻豆精品久久精品色综合| 在线视频欧美精品| 中文字幕日韩一区| 国产主播一区二区| 欧美成人在线直播| 丝袜亚洲精品中文字幕一区| 欧美在线观看一二区| 国产精品久久久久久久久快鸭 | 成人激情视频网站| 欧美电影精品一区二区| 日本视频中文字幕一区二区三区| 日本福利一区二区| 国产精品成人免费在线| 懂色av一区二区三区免费看| 精品99999| 精品中文字幕一区二区| 日韩欧美激情四射| 天堂蜜桃91精品| 欧美日本一道本| 亚洲高清免费视频| 欧美视频一区在线| 亚洲成人免费视频| 欧美福利电影网| 午夜精品久久久久久久99樱桃| 欧美日韩综合一区| 亚欧色一区w666天堂| 欧美性色欧美a在线播放| 亚洲综合一区二区精品导航| 色综合天天综合网国产成人综合天 | 亚瑟在线精品视频| 欧美日韩和欧美的一区二区| 天天色图综合网| 日韩一区国产二区欧美三区| 麻豆一区二区三| 久久综合久久鬼色| 国产99久久久国产精品潘金| 国产精品国产三级国产aⅴ中文| 91在线视频播放| 亚洲美女区一区| 欧美精品一二三| 日韩国产精品久久| 欧美成人一区二区三区片免费| 久久国内精品视频| 中文字幕av一区二区三区高| 91玉足脚交白嫩脚丫在线播放| 亚洲日本在线观看| 欧美三级电影一区| 极品尤物av久久免费看| 国产欧美日本一区二区三区| 波多野结衣91| 亚洲午夜激情网站| 欧美电影免费观看完整版| 国产成人精品三级| 亚洲女与黑人做爰| 欧美一区二区视频观看视频| 黄网站免费久久| 中文字幕一区日韩精品欧美| 欧美视频一区在线观看| 精品在线免费视频| 国产精品久久午夜| 欧美美女bb生活片| 国产剧情一区在线| 制服丝袜激情欧洲亚洲| 天天av天天翘天天综合网色鬼国产| 欧美日韩一区二区在线视频| 久热成人在线视频| 国产日韩欧美精品电影三级在线| 99精品欧美一区二区三区综合在线| 亚洲午夜激情av| 久久久久国产精品厨房| 在线观看免费成人| 国产乱对白刺激视频不卡| 亚洲一区欧美一区| 精品国产精品网麻豆系列| 一本大道av伊人久久综合| 美女视频一区二区三区| 亚洲欧洲日韩一区二区三区| 欧美一级片在线| 成人黄色av电影| 日韩**一区毛片| 最新热久久免费视频| 日韩精品中文字幕在线不卡尤物 | 国产精品久久久久一区二区三区| 色婷婷亚洲综合| 国内成人自拍视频| 亚洲第一久久影院| 国产精品久久久久久亚洲伦| 日韩三级伦理片妻子的秘密按摩| 色哟哟国产精品| 国产91精品精华液一区二区三区| 视频一区二区中文字幕| 亚洲乱码一区二区三区在线观看| 久久综合成人精品亚洲另类欧美 | 欧美成人vr18sexvr|