/***********************************************************************
 * DISCLAIMER:                                                         *
 * The software supplied by Renesas Technology America Inc. is         *
 * intended and supplied for use on Renesas Technology products.       *
 * This software is owned by Renesas Technology America, Inc. or       *
 * Renesas Technology Corporation and is protected under applicable    *
 * copyright laws. All rights are reserved.                            *
 *                                                                     *
 * 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. RENESAS TECHNOLOGY AMERICA, INC. AND        *
 * AND RENESAS TECHNOLOGY CORPORATION RESERVE THE RIGHT, WITHOUT       *
 * NOTICE, TO MAKE CHANGES TO THIS SOFTWARE. NEITHER RENESAS           *
 * TECHNOLOGY AMERICA, INC. NOR RENESAS TECHNOLOGY CORPORATION SHALL,  *
 * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR         *
 * CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER ARISING OUT OF THE  *
 * USE OR APPLICATION OF THIS SOFTWARE.                                *
 ***********************************************************************/

/*****************************************************************************
*
*   File Name:   VirEE_variable.h
*
*   Content:     Header file for variable record length virtual EEPROM functions.
*
*   Copyright (c) 2004 Renesas Technology America , Inc.
*   All rights reserved
*=============================================================================
*   $Revision: 1.1 $ $Date: 2004-01-05 15:12:55-05 $
*===========================================================================*/
#define API_BLOCK_HI BLOCK_B    /* flash_api block number for data block */
#define ADDR_BLOCK_HI (02800h)  /* block address, note assembly format "xxxxh"...MUST BE GREATER THAN ADDR_BLOCK_LO */

#define API_BLOCK_LO BLOCK_A    /* flash_api block number for data block */
#define ADDR_BLOCK_LO (02000h)  /* block address, note assembly format "xxxxh"...MUST BE LESS THAN ADDR_BLOCK_HI */

#define BLOCK_SIZE (1024)       /* block size in words */

#if 1
#define NV_FAR                  /* if both flash blocks are "near", use this
                                   (<64k on M16C, or anywhere on M32C, R8C) */
#else
#define NV_FAR _far             /* if either flash block is "far", use this
                                   (>64k on M16C) */
#endif

#define MAX_RECORD_LABEL 16      /* improves transfer seek time (must be less than 0xFF) */

typedef struct
{
  unsigned char record_label;   /* arbitrary value 0x00 to 0xFE to distinguish between different record types */
  unsigned char data_size;      /* number of data WORDS (16-bit values) -1 associated with this record type. 0x00=1 Word size... 0xFF=256 Word size */
  unsigned int NV_FAR *pData;   /* pointer to data to be copied on write, pointer to located data on read */
} NV_type;

/*****************************************************************************
Name:       NV_Write
Parameters:   NV_type *pNV: structure indicating source information
Returns:      0=OK, 1=NG
Description:  Stores data structure in flash memory.
*****************************************************************************/
unsigned char NV_Write(NV_type *pNV);

/*****************************************************************************
Name:       NV_Read
Parameters:   NV_type *pNV: structure indicating record type
Returns:      0=OK, 1=record not found, 2=invalid state NG...pNV->pData data location if OK
Description:  locates data stored in NV
*****************************************************************************/
unsigned char NV_Read(NV_type *pNV);