亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
91丨九色丨国产丨porny| 亚洲男人的天堂在线aⅴ视频| 日本在线不卡视频一二三区| 欧美婷婷六月丁香综合色| 亚洲国产成人porn| 91精品国产色综合久久不卡电影| 青青草国产精品亚洲专区无| 欧美一区二区大片| 国产美女精品在线| 亚洲人成在线播放网站岛国| 色婷婷综合久久久久中文一区二区| 亚洲午夜在线观看视频在线| 7777精品久久久大香线蕉| 日韩高清在线观看| 亚洲小少妇裸体bbw| 欧美大肚乱孕交hd孕妇| 国产精品99久久久久久似苏梦涵 | 亚洲午夜久久久| 91精品国产91久久久久久最新毛片 | 久久久精品黄色| 91在线观看视频| 免费在线观看一区| 国产精品久久久久久久第一福利 | 亚洲国产成人av好男人在线观看| 欧美一区二区三区色| 国产**成人网毛片九色| 亚洲国产日韩a在线播放性色| 日韩一级免费一区| 91小视频在线免费看| 人人超碰91尤物精品国产| 国产精品国产三级国产a| 欧美日韩成人综合| 成人av先锋影音| 蜜臀av在线播放一区二区三区| 国产精品二区一区二区aⅴ污介绍| 欧美性一二三区| 国产成人亚洲综合色影视| 亚洲1区2区3区视频| 国产精品乱码人人做人人爱| 在线成人小视频| 一本久道久久综合中文字幕 | 男人的天堂亚洲一区| 亚洲天堂网中文字| 久久综合一区二区| 日韩一区二区视频| 欧美日韩亚洲综合| 成人免费看片app下载| 蜜桃av一区二区三区| 一区二区三区在线视频观看 | 色综合久久久久网| 丰满少妇在线播放bd日韩电影| 日本伊人午夜精品| 亚洲一区二区三区三| 国产精品日日摸夜夜摸av| 久久麻豆一区二区| 亚洲精品在线电影| 7777精品伊人久久久大香线蕉的| 91国偷自产一区二区三区成为亚洲经典| 国产高清一区日本| 韩日欧美一区二区三区| 日韩av电影免费观看高清完整版 | 国产综合久久久久久久久久久久| 亚洲午夜在线视频| 亚洲欧美日韩精品久久久久| 国产欧美日韩另类一区| ww久久中文字幕| 日韩一区二区在线看| 欧美一卡二卡三卡四卡| 欧美精品一卡二卡| 欧美另类变人与禽xxxxx| 欧美性视频一区二区三区| 欧美自拍丝袜亚洲| 欧美特级限制片免费在线观看| 色哟哟一区二区| 在线观看91精品国产入口| 一本大道av一区二区在线播放| 91污在线观看| av不卡在线播放| av影院午夜一区| 一本色道**综合亚洲精品蜜桃冫 | 欧美性色黄大片| 欧美性猛交一区二区三区精品| 欧美影视一区在线| 欧美欧美午夜aⅴ在线观看| 欧美久久一二三四区| 欧美精品精品一区| 欧美成人video| 国产亚洲短视频| 国产精品第13页| 亚洲成人tv网| 国内精品久久久久影院一蜜桃| 国产精品1区二区.| 成人国产精品免费| 欧美色国产精品| 欧美一区二区三区视频在线| 精品少妇一区二区三区在线播放 | 欧美在线观看18| 制服丝袜中文字幕一区| 日韩欧美激情四射| 中文字幕久久午夜不卡| 亚洲乱码国产乱码精品精98午夜| 亚洲一区二区视频在线观看| 天天做天天摸天天爽国产一区| 久久国产精品99精品国产| 国产传媒欧美日韩成人| 91国偷自产一区二区开放时间 | 国产又粗又猛又爽又黄91精品| 成人精品免费看| 欧美中文字幕一区二区三区| 日韩欧美中文一区二区| 国产精品日日摸夜夜摸av| 亚洲国产一区二区三区青草影视| 麻豆精品久久精品色综合| 国产99久久久久久免费看农村| 91麻豆swag| 欧美sm极限捆绑bd| 亚洲视频每日更新| 麻豆专区一区二区三区四区五区| 成人精品电影在线观看| 在线播放日韩导航| 国产精品久久福利| 日本欧美一区二区在线观看| 大白屁股一区二区视频| 91精品国产综合久久香蕉的特点 | 日本亚洲天堂网| 高清不卡在线观看| 欧美乱熟臀69xxxxxx| 国产精品免费免费| 日av在线不卡| 91福利国产精品| 欧美国产日本韩| 日韩国产欧美在线观看| 91网址在线看| 国产精品午夜免费| 六月婷婷色综合| 欧美三区在线观看| 国产精品久久久久久久蜜臀| 精品一区中文字幕| 在线成人av网站| 亚洲午夜精品久久久久久久久| 国产99久久精品| 精品黑人一区二区三区久久| 亚洲成人av在线电影| 91搞黄在线观看| 尤物视频一区二区| 成人av中文字幕| 日本一区二区三级电影在线观看 | 精品国一区二区三区| 日韩精品福利网| 欧美色网一区二区| 亚洲精品自拍动漫在线| 成人动漫av在线| 国产精品美女久久久久久| 国内成人免费视频| 26uuu成人网一区二区三区| 免费在线观看成人| 日韩视频一区在线观看| 日韩激情在线观看| 欧美日韩国产色站一区二区三区| 亚洲视频在线一区二区| 成人精品视频网站| 日韩美女久久久| www.亚洲精品| 日韩一区在线免费观看| 成人午夜精品一区二区三区| 久久久国产精华| 岛国一区二区三区| 中文字幕亚洲综合久久菠萝蜜| 成人免费福利片| 中文字幕亚洲一区二区av在线 | 99久久99久久综合| 中文字幕视频一区| 91美女片黄在线观看| 亚洲女与黑人做爰| 精品视频999| 免费观看一级特黄欧美大片| 日韩视频123| 国产精品综合二区| 亚洲欧美综合另类在线卡通| 99re8在线精品视频免费播放| 日韩一区欧美一区| 欧美伦理电影网| 国产一区二区三区四| 国产女人18毛片水真多成人如厕| 波多野结衣精品在线| 夜夜嗨av一区二区三区网页 | 欧美一区永久视频免费观看| 喷白浆一区二区| 久久久www成人免费毛片麻豆| 成人午夜在线免费| 亚洲最大成人网4388xx| 欧美日韩亚洲综合| 国产一区在线观看麻豆| 国产精品每日更新| 欧美挠脚心视频网站| 久久激五月天综合精品| 国产欧美日韩三区| 欧美日本韩国一区二区三区视频| 美腿丝袜亚洲一区| 国产精品久99|