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

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

?? flash.c

?? KEIL驅動 各方面各 你的看法女士的煩惱 方看到你
?? C
?? 第 1 頁 / 共 2 頁
字號:
//*****************************************************************************
//
// flash.c - Driver for programming the on-chip flash.
//
// Copyright (c) 2005-2008 Luminary Micro, Inc.  All rights reserved.
// 
// Software License Agreement
// 
// Luminary Micro, Inc. (LMI) is supplying this software for use solely and
// exclusively on LMI's microcontroller products.
// 
// The software is owned by LMI and/or its suppliers, and is protected under
// applicable copyright laws.  All rights are reserved.  You may not combine
// this software with "viral" open-source software in order to form a larger
// program.  Any use in violation of the foregoing restrictions may subject
// the user to criminal sanctions under applicable laws, as well as to civil
// liability for the breach of the terms and conditions of this license.
// 
// THIS SOFTWARE IS PROVIDED "AS IS".  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.
// LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
// CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
// 
// This is part of revision 3223 of the Stellaris Peripheral Driver Library.
//
//*****************************************************************************

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

#include "../hw_flash.h"
#include "../hw_ints.h"
#include "../hw_memmap.h"
#include "../hw_sysctl.h"
#include "../hw_types.h"
#include "debug.h"
#include "flash.h"
#include "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;

    //
    // 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
        // fecth 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);
        }
    }

    //
    // Set the protection based on the requested proection.
    //
    switch(eProtect)
    {
        //
        // Make this block execute only.
        //
        case FlashExecuteOnly:
        {
            //
            // Turn off the read and program bits for this block.
            //
            ulProtectRE &= ~(FLASH_FMP_BLOCK_0 << ulAddress);
            ulProtectPE &= ~(FLASH_FMP_BLOCK_0 << ulAddress);

            //
            // We're done handling this protection.
            //
            break;
        }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
a4yy欧美一区二区三区| 国产成人在线观看| 国产精品萝li| 欧美一级一区二区| 色婷婷久久99综合精品jk白丝| 美女视频免费一区| 亚洲线精品一区二区三区八戒| 久久品道一品道久久精品| 欧美日韩国产在线播放网站| 北条麻妃国产九九精品视频| 国产在线不卡一区| 奇米在线7777在线精品| 一区二区三区在线视频观看 | 色综合色狠狠天天综合色| 精品无码三级在线观看视频| 亚洲成人久久影院| 亚洲三级在线播放| 国产精品久久久久影院色老大| 精品久久久久久久久久久久包黑料 | 成人午夜视频在线观看| 国产在线视频不卡二| 日韩高清在线观看| 日韩专区中文字幕一区二区| 亚洲精品视频免费看| 国产精品色哟哟| 久久久久国产精品人| 精品国产一区二区三区久久久蜜月| 欧美日韩一级二级三级| 欧美三级在线视频| 欧美亚洲丝袜传媒另类| 欧美中文字幕亚洲一区二区va在线| 91在线你懂得| 色香蕉成人二区免费| 91免费小视频| 色综合视频一区二区三区高清| 91热门视频在线观看| av色综合久久天堂av综合| av一区二区三区在线| 99精品视频一区| 99精品欧美一区| 一本大道久久a久久综合| 色一情一伦一子一伦一区| 色老综合老女人久久久| 欧美自拍偷拍午夜视频| 欧美日本一区二区三区四区| 欧美日韩一二三| 日韩一级高清毛片| 久久综合久久综合九色| 久久精品亚洲一区二区三区浴池| 中文字幕乱码日本亚洲一区二区| 欧美激情一区二区三区蜜桃视频| 国产精品乱人伦中文| 亚洲精品成a人| 午夜精品福利一区二区蜜股av| 香蕉久久一区二区不卡无毒影院| 免费不卡在线观看| 国产伦精品一区二区三区视频青涩| 国产高清在线精品| 一本久久综合亚洲鲁鲁五月天 | 国产三级精品三级在线专区| av在线不卡观看免费观看| 国产真实精品久久二三区| 国产精品视频在线看| 欧美成人免费网站| 精品婷婷伊人一区三区三| 欧美三级电影在线看| 欧美日韩三级在线| 91首页免费视频| 图片区小说区区亚洲影院| 亚洲欧洲日韩av| 亚洲欧洲日本在线| 亚洲电影在线播放| 午夜久久久久久| 韩国av一区二区三区| 在线看不卡av| 国产iv一区二区三区| 婷婷开心久久网| 亚洲一区二区av电影| 亚洲亚洲人成综合网络| 天天影视网天天综合色在线播放| 亚洲电影视频在线| 国产视频一区不卡| 色诱视频网站一区| 国产一区二区精品在线观看| 国产精品丝袜91| 777色狠狠一区二区三区| 在线观看不卡一区| 久久综合色婷婷| 国产欧美一区二区精品忘忧草| 欧美激情在线看| 亚洲18女电影在线观看| 国产毛片精品视频| 欧美日韩免费一区二区三区视频| 欧美日韩成人综合天天影院| 国产精品女人毛片| 美国十次了思思久久精品导航| 极品美女销魂一区二区三区| 成人动漫视频在线| 欧美xxxx老人做受| 亚洲chinese男男1069| av不卡在线观看| 26uuu亚洲综合色| 亚洲va欧美va国产va天堂影院| 成人一区二区视频| 欧美变态tickling挠脚心| 亚洲成人精品在线观看| 91小视频免费看| 国产亚洲精品资源在线26u| 日日夜夜精品视频免费| 色综合欧美在线视频区| 国产精品欧美极品| 久久se这里有精品| 欧美日韩国产成人在线91| 亚洲色欲色欲www在线观看| 国产乱码精品一区二区三| 91麻豆精品国产无毒不卡在线观看| 亚洲免费观看高清在线观看| 成人午夜碰碰视频| 久久久久久久网| 精品一区二区免费视频| 欧美一区二区精美| 首页国产欧美久久| 欧美日韩一级大片网址| 亚洲电影在线免费观看| 欧美性极品少妇| 亚洲一区二区三区中文字幕| 91丝袜美腿高跟国产极品老师 | 色综合咪咪久久| 国产精品久久久久久久浪潮网站| 国产福利精品导航| 国产片一区二区| 国产成人丝袜美腿| 久久精品日产第一区二区三区高清版| 精品在线免费观看| 欧美不卡一区二区三区四区| 蜜桃传媒麻豆第一区在线观看| 欧美一区二区三区系列电影| 日本不卡一区二区三区高清视频| 欧美一区二区三区思思人| 午夜久久电影网| 91久久精品国产91性色tv| 一区二区欧美国产| 欧美午夜不卡在线观看免费| 日韩成人精品在线观看| 精品日韩在线一区| 国产成人午夜精品影院观看视频| 国产精品美女久久久久aⅴ国产馆| 国产不卡一区视频| 国产精品国产三级国产普通话蜜臀 | 亚洲第一福利一区| 日韩一区二区电影在线| 九色porny丨国产精品| 国产午夜精品久久久久久免费视 | 欧美精品精品一区| 男女男精品网站| 久久久精品国产免大香伊| www.欧美日韩| 亚洲国产欧美在线| 精品免费视频一区二区| 国产精品一二三四| 亚洲自拍偷拍九九九| 337p亚洲精品色噜噜狠狠| 韩国欧美国产1区| 中文字幕亚洲电影| 欧美日韩精品一区二区三区四区| 久久精品国产澳门| 中文字幕一区二区三| 欧美日韩国产综合久久 | 国产一区二区在线观看视频| 国产精品无遮挡| 欧美卡1卡2卡| 国产精品一品视频| 亚洲午夜久久久久久久久久久| 日韩欧美成人一区| 99天天综合性| 久久精品国产精品亚洲精品| 亚洲欧洲精品成人久久奇米网 | 亚洲人成在线播放网站岛国| 4hu四虎永久在线影院成人| 国产在线精品免费| 亚洲一区免费视频| 久久理论电影网| 欧美日韩精品高清| 高清不卡在线观看av| 午夜私人影院久久久久| 久久免费国产精品| 欧美精品乱码久久久久久按摩| 国产成人鲁色资源国产91色综| 亚洲福利一区二区| 中文字幕亚洲精品在线观看| 日韩一区二区三区av| 97久久精品人人做人人爽| 免费成人av资源网| 亚洲图片一区二区| 国产精品嫩草影院av蜜臀| 欧美一级在线视频| 在线视频你懂得一区二区三区| 国产乱码精品一品二品| 日韩精品成人一区二区三区| 国产精品福利一区二区|