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

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

?? flashmem.c

?? miceteck_MPC860_BSP源碼,基于VXWORK
?? C
字號:
/* flashMem.c - Flash memory device driver */

/*
DESCRIPTION
This library contains routines to manipulate flash memory.  Read and write
routines are included.

The macro values FLASH_ADRS, FLASH_SIZE, and FLASH_WIDTH must be defined to
indicate the address, size (in bytes), and the data-access width (in bytes) of
the flash memory.

If the flash memory needs to be overlaid, and the section of the memory that
needs to be overlaid is less than FLASH_SIZE, then, for efficiency, define
FLASH_SIZE_WRITABLE to the size (in bytes) of the overlay section.

The routine sysFlashDelay() creates a delay for a specified number of
microseconds.  The timing loop can be adjusted on a board-dependent basis by
defining the function sysFlashBoardDelay and values for the following macros,
.iP
SYS_FLASH_DELAY_SHIFT
.iP
SYS_FLASH_DELAY_ADJ
.iP
SYS_FLASH_DELAY_INCR
.LP
To use the routine sysFlashBoardDelay(), the macro SYS_FLASH_BOARD_DELAY
should be defined.

The macro FLASH_NO_OVERLAY should be defined when calls to sysFlashSet()
are expected to erase the flash and reprogram it with only the new data.

The macro SYS_FLASH_TYPE should be defined for flash devices that cannot be
auto-selected. This macro should be set to a flash device code defined in the
header files, <drv/mem/flash28.h> and <drv/mem/flash29.h>

To support flash devices that that need to turn on/off write protect features
(special programming voltages or other write-enable features), the macro
SYS_FLASH_WRITE, and the routines, sysFlashWriteEnable() and
sysFlashFlashWriteDisable() should be defined.

INTERNAL:
The FLASH_SIZE_WRITABLE concept doesn't work very well.  It just limits the
amount of flash that is writable, so why bother.  What it was really
intended to address was flash that is only block writable, i.e. you
can only write a complete block at a time.  To properly handle block
memory, you must copy the old block of memory to a buffer, update the
part of the buffer that is to be changed, and then write back the
complete buffer in a single write operation.

The accesses to non-volatile memory, and flash control registers needs
to be abstracted.  Macros should be used for all actual i/o operations.
*/
#include "flashMem.h"
#include "vxworks.h"
#include "string.h"

/* defines */

/* Establish default values for DELAY parameters */

#ifndef	SYS_FLASH_DELAY_SHIFT
#   define	SYS_FLASH_DELAY_SHIFT 0
#endif /*SYS_FLASH_DELAY_SHIFT*/

#ifndef	SYS_FLASH_DELAY_ADJ
#   define	SYS_FLASH_DELAY_ADJ 0
#endif	/* SYS_FLASH_DELAY_ADJ */

#ifndef	SYS_FLASH_DELAY_INCR
#   define	SYS_FLASH_DELAY_INCR 1
#endif	/* SYS_FLASH_DELAY_INCR */

/* Names of routines, or null values */


#ifdef	SYS_FLASH_BOARD_DELAY
#   define SYS_FLASH_BOARD_DELAY_RTN()	sysFlashBoardDelay ()
#else
#   define SYS_FLASH_BOARD_DELAY_RTN()
#endif	/* SYS_FLASH_BOARD_DELAY */


#ifdef FLASH_SIZE_WRITEABLE
#   define FLASH_MEM_SIZE		FLASH_SIZE_WRITEABLE
#else
#   define FLASH_MEM_SIZE		FLASH_SIZE
#endif	/* FLASH_SIZE_WRITEABLE */

/* Operation status bits for Flash 29Fxxx devices */

#define Q7(ix)		((ix & 0x80) >> 7)	/* DQ7 bit */
#define Q5(ix)		((ix & 0x20) >> 5)	/* DQ5 bit */

#ifndef FLASH_CAST 
#define FLASH_CAST (UINT8 *)
#endif

int	flashDelayShift	= SYS_FLASH_DELAY_SHIFT;
int	flashDelayAdj	= SYS_FLASH_DELAY_ADJ;
int	flashDelayIncr	= SYS_FLASH_DELAY_INCR;

/* forward declarations */

#ifdef	__STDC__

void	sysFlashDelay (int delayCount);
STATUS	sysFlashDataPoll (volatile UINT8 * pFA, UINT8 value,int pollSize);
STATUS	sysFlashErase (UINT8 eraseType,volatile UINT8* pFA,int sectorSize   );
STATUS	sysFlashWrite (UINT8 * pFB, int size, int offset);

#else	/* __STDC__ */

void	sysFlashDelay ();
STATUS	sysFlashDataPoll ();
STATUS	sysFlashErase ();
STATUS	sysFlashWrite ();

#endif	/* __STDC__ */

/******************************************************************************
*
* sysFlashGet - get the contents of flash memory
*
* This routine copies the contents of flash memory into a specified
* string.  The string is terminated with an EOS.
*
* RETURNS: OK, or ERROR if access is outside the flash memory range.
*
* SEE ALSO: sysFlashSet()
*
* INTERNAL
* If multiple tasks are calling sysFlashSet() and sysFlashGet(),
* they should use a semaphore to ensure mutually exclusive access.
*/

STATUS sysFlashGet
    (
    char *	string,		/* where to copy flash memory      */
    int		strLen,		/* maximum number of bytes to copy */
    int		offset		/* byte offset into flash memory   */
    )
    {
    if ((offset < 0) || (strLen < 0) || ((offset + strLen) > FLASH_SIZE))
        return (ERROR);

    bcopyBytes ((char *) (FLASH_ADRS + offset), string, strLen);
    string [strLen] = EOS;

    return (OK);
    }

/******************************************************************************
*
* sysFlashDelay - create a delay for a specified number of microseconds
*
* This routine implements a busy wait for a specified number of microseconds.
* The timing loop can be adjusted on a board-dependent basis by
* defining values for the following macros:
* .iP
*     SYS_FLASH_DELAY_SHIFT
* .iP
*     SYS_FLASH_DELAY_ADJ
* .iP
*     SYS_FLASH_DELAY_INCR
* .LP
* The values SYS_FLASH_DELAY_SHIFT and SYS_FLASH_DELAY_ADJ
* convert microseconds into a board-dependent tick-count.
* This routine can call a user-defined hook, sysFlashBoardDelay(),
* which creates a delay for a number of board-dependent ticks as
* specified by SYS_FLASH_DELAY_INCR.  To use sysFlashBoardDelay(), define
* SYS_FLASH_BOARD_DELAY in config.h.
*
* RETURNS: N/A
*
* SEE ALSO: sysFlashErase(), sysFlashWrite()
*/

void sysFlashDelay
    (
    int delayCount	/* number of uSec to delay */
    )
    {
    int ix;

    delayCount <<= flashDelayShift;	/* board-dependent shift */
    delayCount += flashDelayAdj;		/* board-dependent addition */

    for (ix = 0; ix < delayCount; ix += flashDelayIncr)
        SYS_FLASH_BOARD_DELAY_RTN ();
    }

/******************************************************************************
*
* sysFlashDataPoll - wait for a flash device operation to complete
*
* This routine polls a specified address on a 29LV flash device
* until the device operation at that location completes or times out.
*
* While a flash operation is in progress, a read on the device
* returns on Q7 (data bit 7) the complement of the previous value of Q7.  Once
* the flash operation has completed, the Q7 bit returns the true data
* of the last write. Subsequent reads return the correct data in Q0-7.
*
* The Q5 bit implements a timeout functionality.  When a currently
* executing flash operation exceeds specified limits, the Q5 bit is set (to 1).
*
* RETURNS: OK, or ERROR if the timeout (!Q5) occurs before the device operation
* completes.
*
* SEE ALSO: sysFlashErase(), sysFlashWrite()
*/

STATUS sysFlashDataPoll
    (
    volatile UINT8 * pFA,	/* programmed address to poll */
    UINT8 value,		/* data programmed to poll address */
    int pollSize                /* flash size(bytes) to be polled */ 
    )
    {
    STATUS retVal = OK;
    volatile UINT8 * pTest = (UINT8 *) pFA;
    int ix;			/* byte counter */
    int vBit;			/* programmed value of DQ7 */

    for (ix = (pollSize - 1); (ix >= 0 ) && (retVal == OK); ix--, pTest++)
        {
        vBit = Q7(value);

        while (Q7(*pTest) != vBit)
            if (Q5(*pTest) == 1)	/* timeout ? */
                break;

        if (Q7(*pTest) != vBit)		/* check Q7 & Q5 race */
            retVal = ERROR;
        }

    return (retVal);
    }

/******************************************************************************
*
* sysFlashErase - erase the contents of flash memory
*
* This routine clears the contents of flash memory.
*
* Flash 28F\f2xxx\f1 devices are erased by writing a flash erase command to
* the device and verifying that each flash location is set to a high value
* (0xFF).
*
* Flash 29F\f2xxx\f1 devices are erased by writing the six-byte erase code
* into specific address locations, which sets all byte locations to a high
* value (0xFF).
*
* RETURNS: OK, or ERROR if the contents of flash memory cannot be erased.
*/

STATUS sysFlashErase
    ( 	
   	UINT8 eraseType,   /* type of flash memory on-board */
   	volatile UINT8* pFA,   /* the begining address to be erased */
   	int sectorSize             /* sector size */
    )
    {
    STATUS retVal = OK;
   
    switch (eraseType)
      {
      case (CHIP_ERASE):
            *(FLASH_CAST FLASH29_REG_FIRST_CYCLE)  = FLASH29_CMD_FIRST;
            *(FLASH_CAST FLASH29_REG_SECOND_CYCLE) = FLASH29_CMD_SECOND;
            *(FLASH_CAST FLASH29_REG_FIRST_CYCLE)  = FLASH29_CMD_CHIP_ERASE;
            *(FLASH_CAST FLASH29_REG_FIRST_CYCLE)  = FLASH29_CMD_FOURTH;
            *(FLASH_CAST FLASH29_REG_SECOND_CYCLE) = FLASH29_CMD_FIFTH;
            *(FLASH_CAST FLASH29_REG_FIRST_CYCLE)  = FLASH29_CMD_SIXTH;
            
            do {
                retVal = sysFlashDataPoll (pFA, (UINT8) 0xffffffff,FLASH_SIZE);
                } while ((*pFA != (UINT8) 0xffffffff) && (retVal == OK));

            *(FLASH_CAST FLASH29_REG_FIRST_CYCLE)  = FLASH29_CMD_FIRST;
            *(FLASH_CAST FLASH29_REG_SECOND_CYCLE) = FLASH29_CMD_SECOND;
            *(FLASH_CAST FLASH29_REG_FIRST_CYCLE)  = FLASH29_CMD_READ_RESET;

	    break;
	
	case (SECTOR_ERASE):
	    *(FLASH_CAST FLASH29_REG_FIRST_CYCLE)  = FLASH29_CMD_FIRST;
            *(FLASH_CAST FLASH29_REG_SECOND_CYCLE) = FLASH29_CMD_SECOND;
            *(FLASH_CAST FLASH29_REG_FIRST_CYCLE)  = FLASH29_CMD_CHIP_ERASE;
            *(FLASH_CAST FLASH29_REG_FIRST_CYCLE)  = FLASH29_CMD_FOURTH;
            *(FLASH_CAST FLASH29_REG_SECOND_CYCLE) = FLASH29_CMD_FIFTH;
            *pFA  = FLASH29_CMD_SECTOR;

            do {
                retVal = sysFlashDataPoll (pFA, (UINT8) 0xffffffff,sectorSize);
                } while ((*pFA != (UINT8) 0xffffffff) && (retVal == OK));

            *(FLASH_CAST FLASH29_REG_FIRST_CYCLE)  = FLASH29_CMD_FIRST;
            *(FLASH_CAST FLASH29_REG_SECOND_CYCLE) = FLASH29_CMD_SECOND;
            *(FLASH_CAST FLASH29_REG_FIRST_CYCLE)  = FLASH29_CMD_READ_RESET;

	    break;   
	    
       default:
            retVal = ERROR;

      }

    return (retVal);
    }

/******************************************************************************
*
* sysFlashWrite - write data to flash memory
*
* This routine copies specified data of a specified length, <size>, into a
* specified offset, <offset>, in the flash memory.  Data is passed as a string,
* <pFB>, if not NULL.  If NULL, data is taken as a repeated sequence of
* <value>.
* The parameter <flashType> should be set to the flash device code.
* The parameter <offset> must be appropriately aligned for the width of
* the Flash devices in use.
*
* Flash 28F\f2xxx\f1 devices are programmed by a sequence of operations:
* .iP
* set up device to write
* .iP
* perform write
* .iP
* verify the write
* .LP
*
* Flash 29F\f2xxx\f1 devices are programmed by a sequence of operations:
* .iP
* set up device to write
* .iP
* perform write
* .iP
* wait for the write to complete
* .LP
*
* RETURNS: OK, or ERROR if the write operation fails.
*
* SEE ALSO: sysFlashSet()
*/

STATUS sysFlashWrite
    (
    UINT8 * pFB,		/* string to be copied; use <value> if NULL */
    int size,			/* size to program in bytes */
    int offset			/* byte offset into flash memory */
    )
    {
    UINT8 value;		/* value to program */
    volatile UINT8 * pFA;		/* flash address */
    STATUS retVal = OK;
    
        
        /* unlock bypass */
        *(FLASH_CAST FLASH29_REG_FIRST_CYCLE)  = FLASH29_CMD_FIRST;
        *(FLASH_CAST FLASH29_REG_SECOND_CYCLE) = FLASH29_CMD_SECOND;
        *(FLASH_CAST FLASH29_REG_FIRST_CYCLE)  = FLASH29_CMD_UNLOCK_BYPASS;
        
        for (pFA = FLASH_CAST (FLASH_ADRS + offset); pFA < FLASH_CAST
                (FLASH_ADRS + size + offset) && (retVal == OK); pFA++)
                {
                *(FLASH_CAST FLASH29_REG_FIRST_CYCLE)  = FLASH29_CMD_UNLOCK_BYPASS_PROG;
                if (pFB != NULL)
		    value = *pFB++;

                *pFA = value;                    	/* data to write */
                do {
                    retVal = sysFlashDataPoll (pFA, (UINT8) value,1);
                    } while ((*pFA != value) && (retVal == OK));
                }

        *(FLASH_CAST FLASH29_REG_FIRST_CYCLE)  = FLASH29_CMD_AUTOSELECT;
        *(FLASH_CAST FLASH29_REG_SECOND_CYCLE) = FLASH29_CMD_UNLOCK_BYPASS_RESET;
        /* *(FLASH_CAST FLASH29_REG_FIRST_CYCLE)  = FLASH29_CMD_READ_RESET; */


    return (retVal);
    }

#if false
/******************************************************************************
*
* sysFlashSet - write to flash memory
*
* This routine copies a specified string into flash memory after calling
* sysFlashErase() and clearing flash memory.
*
* If FLASH_NO_OVERLAY is defined, the parameter <offset> must be
* appropriately aligned for the Flash devices in use (device width,
* sector size etc.).
*
* If the specified string must be overlaid on the contents of flash memory,
* undefine FLASH_NO_OVERLAY.
*
* RETURNS: OK, or ERROR if the write fails or the input parameters are
* out of range.
*
* SEE ALSO: sysFlashErase(), sysFlashGet(), sysFlashTypeGet(), sysFlashWrite()
*
* INTERNAL
* If multiple tasks are calling sysFlashSet() and sysFlashGet(),
* they should use a semaphore to ensure mutually exclusive access to flash
* memory.
*/

STATUS sysFlashSet
    (
    char *string,     /* string to be copied into flash memory */
    int strLen,       /* maximum number of bytes to copy       */
    int offset        /* byte offset into flash memory         */
    )
    {
#ifndef	FLASH_NO_OVERLAY
    char *tempBuffer;
#endif	/* FLASH_NO_OVERLAY */


    if ((offset < 0) || (strLen < 0) || ((offset + strLen) > FLASH_MEM_SIZE))
        return (ERROR);

    /* see if contents are actually changing */

    if (bcmp ((char *) (FLASH_ADRS + offset), string, strLen) == 0)
	return (OK);


#ifndef	FLASH_NO_OVERLAY
    /* first read existing data */

    if (tempBuffer =(char*) malloc(FLASH_SIZE), tempBuffer == NULL)
	return (ERROR);

    bcopyBytes ((char *) FLASH_ADRS, tempBuffer, FLASH_MEM_SIZE);
    bcopyBytes (string, (tempBuffer + offset), strLen);
#endif	/* FLASH_NO_OVERLAY */

    if (sysFlashErase (CHIP_ERASE,(UINT8 *)FLASH_ADRS,0) == ERROR)	/* erase device */
		{
#ifndef	FLASH_NO_OVERLAY
		free (tempBuffer);
#endif


#ifndef	FLASH_NO_OVERLAY				/* program device */
    if (sysFlashWrite (FLASH_CAST (tempBuffer), FLASH_MEM_SIZE, 0)
	    == ERROR)
	free (tempBuffer);
#else	/* FLASH_NO_OVERLAY */
    if (sysFlashWrite (FLASH_CAST (string), strLen, offset,0) ==
	ERROR)
	{
#endif	/* FLASH_NO_OVERLAY */
	return (ERROR);
	}

#ifndef	FLASH_NO_OVERLAY
    free (tempBuffer);
#endif

    return (OK);
}

#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本亚洲免费观看| 国产一区二区三区四| 日本三级亚洲精品| 国产成人av电影在线观看| 精品美女在线播放| 亚洲丝袜另类动漫二区| 久久超级碰视频| 欧美日韩国产综合久久| 国产精品久久久久久亚洲毛片| 日韩av一级电影| 欧美天堂一区二区三区| 中文在线资源观看网站视频免费不卡| 肉色丝袜一区二区| 91香蕉视频在线| 欧美极品美女视频| 韩国成人精品a∨在线观看| 欧美三级韩国三级日本一级| 一区二区中文字幕在线| 国产一区在线不卡| 日韩美女视频一区二区在线观看| 亚洲午夜一区二区| 91视视频在线观看入口直接观看www| 久久一日本道色综合| 久久66热偷产精品| 日韩一区二区影院| 久久精品国产在热久久| 91精品国产aⅴ一区二区| 亚洲电影在线免费观看| 欧洲精品一区二区三区在线观看| 中文字幕一区不卡| 菠萝蜜视频在线观看一区| 国产欧美视频一区二区三区| 国内精品第一页| 婷婷综合久久一区二区三区| 一本一本大道香蕉久在线精品| 国产精品久久久久久久久久免费看| 国产麻豆成人传媒免费观看| 日韩精品最新网址| 国产一区 二区| 国产三级精品在线| kk眼镜猥琐国模调教系列一区二区 | 国产精品人成在线观看免费| 国产美女娇喘av呻吟久久| 欧美电影免费观看高清完整版在线观看 | 97超碰欧美中文字幕| 亚洲色图在线播放| 在线观看国产精品网站| 一级做a爱片久久| 91麻豆精品国产无毒不卡在线观看| 天天亚洲美女在线视频| 日韩视频免费直播| 国产成人综合在线播放| 久久久久亚洲蜜桃| 成人av在线一区二区三区| 亚洲女子a中天字幕| 欧美裸体bbwbbwbbw| 美女视频黄 久久| 日本一区二区免费在线观看视频| 成人精品电影在线观看| 亚洲a一区二区| 欧美va亚洲va在线观看蝴蝶网| 国产传媒久久文化传媒| 亚洲无线码一区二区三区| 日韩一区二区三| 播五月开心婷婷综合| 日韩av电影免费观看高清完整版在线观看 | 精品国产髙清在线看国产毛片| 国产精品一区免费视频| 亚洲一区在线观看视频| 亚洲精品一区二区三区影院| av成人免费在线| 青青草原综合久久大伊人精品优势| 欧美极品少妇xxxxⅹ高跟鞋| 欧美人牲a欧美精品| 国产成人精品综合在线观看| 亚洲综合999| 久久久久久9999| 7777精品伊人久久久大香线蕉最新版| 国产黑丝在线一区二区三区| 亚洲国产aⅴ成人精品无吗| 国产日韩在线不卡| 欧美色图一区二区三区| 国产精品羞羞答答xxdd| 午夜精品成人在线| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 色哟哟欧美精品| 激情久久五月天| 亚洲va天堂va国产va久| 国产精品久久久久久久久免费丝袜| 欧美精品v日韩精品v韩国精品v| 成人精品国产免费网站| 激情久久久久久久久久久久久久久久| 一卡二卡三卡日韩欧美| 国产精品三级电影| ww久久中文字幕| 欧美一区二区福利在线| 欧美影院一区二区| 91成人免费网站| 成人av在线影院| 成人美女视频在线看| 久久国产精品72免费观看| 天天免费综合色| 夜夜精品视频一区二区| **性色生活片久久毛片| 国产欧美日韩久久| 久久久久久亚洲综合影院红桃| 欧美一区午夜精品| 欧美一级二级三级蜜桃| 666欧美在线视频| 欧美区一区二区三区| 91国偷自产一区二区使用方法| 99久久国产免费看| www.亚洲激情.com| 99这里只有久久精品视频| 成人少妇影院yyyy| 成人免费av网站| 91蜜桃视频在线| 91国偷自产一区二区开放时间 | 91亚洲大成网污www| 色综合天天综合网天天狠天天| 不卡的看片网站| av在线不卡观看免费观看| caoporn国产一区二区| 99视频国产精品| 色哦色哦哦色天天综合| 色999日韩国产欧美一区二区| 色综合天天做天天爱| 欧美亚一区二区| 69堂亚洲精品首页| 日韩精品在线看片z| 久久亚洲捆绑美女| 日本一区二区免费在线观看视频 | 欧洲一区在线电影| 91精品国产欧美一区二区18| 日韩久久久久久| 国产精品久久久久久久久久免费看 | 日韩avvvv在线播放| 老司机精品视频导航| 粉嫩aⅴ一区二区三区四区| 成人av动漫网站| 欧美性做爰猛烈叫床潮| 精品欧美久久久| 国产精品久久久久久久久免费相片| 亚洲精选视频在线| 日韩精品色哟哟| 高清免费成人av| 欧美午夜精品久久久久久超碰| 欧美一区二区三区小说| 国产欧美1区2区3区| 亚洲小说欧美激情另类| 精品一区二区三区不卡| 成人h精品动漫一区二区三区| 欧洲精品在线观看| 国产性天天综合网| 亚洲主播在线观看| 国产一区二区三区久久久| 99精品视频在线观看免费| 日韩一区二区三区免费观看| 欧美国产日韩一二三区| 亚洲成av人片观看| 国产91综合一区在线观看| 欧美日韩视频一区二区| 久久久久久久久久久黄色| 亚洲一区二区成人在线观看| 国内偷窥港台综合视频在线播放| 色悠悠亚洲一区二区| 久久九九全国免费| 蜜臀av一区二区在线观看| 不卡的av电影在线观看| 欧美成人福利视频| 亚洲国产成人高清精品| 99精品黄色片免费大全| 欧美精品一区二区精品网| 亚洲一区二区三区国产| av在线免费不卡| 国产片一区二区| 久久精品免费看| 欧美三级视频在线观看| 综合激情网...| 东方aⅴ免费观看久久av| 日韩美女主播在线视频一区二区三区| 亚洲一区免费在线观看| av欧美精品.com| 久久精品一区蜜桃臀影院| 奇米影视一区二区三区| 欧美日韩国产美| 一区二区三区中文字幕| 99久久综合99久久综合网站| 久久久久国产免费免费| 国产一二三精品| 精品国产一区二区三区四区四 | 亚洲精品视频观看| aaa欧美色吧激情视频| 国产欧美视频在线观看| 国产美女娇喘av呻吟久久| 久久久久久久综合狠狠综合| 精品一区二区三区免费播放| 精品国产91乱码一区二区三区| 日韩综合在线视频| 69久久99精品久久久久婷婷|