📄 nvramtoflash.c
字号:
/* nvRamToFlash.c - non-volatile RAM to FLASH memory routine mapping */
/* Copyright 1994-1998 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
01d,03apr98,cdp copied to BSP with mods to use end of boot device as NVRAM.
01c,14nov96,wlf doc: cleanup.
01b,31jan96,dzb added NV_BOOT_OFFSET and NV_RAM_SIZE checking. Added EOS.
01a,08jan94,dzb created.
*/
/*
DESCRIPTION
This library contains non-volatile RAM manipulation routines for targets
lacking non-volatile RAM, but that do have FLASH memory. Read and write
wrappers are provided for the FLASH memory routines sysFlashGet() and
sysFlashSet().
*/
/* includes */
#include "drv/mem/memDev.h"
#include "drv/mem/flashDev.h"
/******************************************************************************
*
* sysNvRamGet - get the contents of non-volatile RAM
*
* This routine calls sysFlashGet() to copy the contents of flash memory
* into a specified string. The string is terminated with an EOS.
*
* RETURNS: The return value of sysFlashGet().
*
* SEE ALSO: sysNvRamSet(), sysFlashGet()
*/
STATUS sysNvRamGet
(
char *string, /* where to copy non-volatile RAM */
int strLen, /* maximum number of bytes to copy */
int offset /* byte offset into non-volatile RAM */
)
{
STATUS retVal;
if ((offset < 0) || (strLen < 0) || ((offset + strLen) > NV_RAM_SIZE))
return (ERROR);
retVal = sysFlashGet (string, strLen, offset + FLASH_NV_RAM_OFFSET);
string [strLen] = EOS;
return (retVal);
}
/*******************************************************************************
*
* sysNvRamSet - write to non-volatile RAM
*
* This routine calls sysFlashSet() to copy a specified string into
* flash memory.
*
* RETURNS: The return value of sysFlashSet().
*
* SEE ALSO: sysNvRamGet(), sysFlashSet()
*/
STATUS sysNvRamSet
(
char *string, /* string to be copied into non-volatile RAM */
int strLen, /* maximum number of bytes to copy */
int offset /* byte offset into non-volatile RAM */
)
{
if ((offset < 0) || (strLen < 0) || ((offset + strLen) > NV_RAM_SIZE))
return (ERROR);
return (sysFlashSet (string, strLen, offset + FLASH_NV_RAM_OFFSET));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -