📄 dataper_api.c
字号:
/*
* File : DataPer_API.c
* Description: This file contains the data persistence APIs
* data persistance of different values.
* Author : Mahadev K C
* Created on : 3-FEB-2005
*
* Copyright 2004-2005 ZiLOG Inc. ALL RIGHTS RESERVED.
*
* This file contains unpublished confidential and proprietary information
* of ZiLOG, Inc.
* NO PART OF THIS WORK MAY BE DUPLICATED, STORED, PUBLISHED OR DISCLOSED
* IN ANY FORM WITHOUT THE PRIOR WRITTEN CONSENT OF ZiLOG, INC.
* This is not a license and no use of any kind of this work is authorized
* in the absence of a written license granted by ZiLOG, Inc. in ZiLOG's
* sole discretion
*/
/*
* standard header files
*/
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
//#include <defines.h>
/*
* system header files
*/
#include "DataPerStruct.h"
/*
* API prototypes:
*/
/*
* Function name: GetDataPersistence
* Description: This function reads the flash block area for Data
* persistence values
* Inputs: pDataPer - Data persistence structure
* Outputs: None
* Return values: 0 - Success, non-zero error
* Additional information:
*/
INT8 GetDataPersistence( PDATA_PER_t p_data_per )
#ifdef _IAR_CODE
@ "DATA_PER_RAM"
#endif
{
UINTRMASK intr_mask ;
if( NULL == p_data_per )
return -1 ;
/*
* disable the interrupts as we do not want any code to be executed
* from flash other than this function
*/
intr_mask = Per_DI() ;
/*
* Now initialize the flash block configured in the structure.
*/
g_data_per_cfg.pfn_dev_init( g_data_per_cfg.p_start_addr, g_data_per_cfg.ul_size ) ;
/*
* Now read the data from the flash block configured
*/
g_data_per_cfg.pfn_dev_read( g_data_per_cfg.p_start_addr, p_data_per, sizeof( DATA_PER_t ) ) ;
g_data_per_cfg.pfn_dev_close() ;
/*
* enable the interrupts
*/
Per_EI( intr_mask ) ;
return 0 ;
}
/*
* Function name: SetDataPersistence
* Description: This function erases the appropriate flash block and
* writes the data structure onto the flash
* Inputs: pDataPer - Data persistence structure
* Outputs: None
* Return values: 0 - Success, non-zero error
* Additional information:
*/
INT8 SetDataPersistence( PDATA_PER_t p_data_per )
#ifdef _IAR_CODE
@ "DATA_PER_RAM"
#endif
{
UINTRMASK intr_mask ;
if( NULL == p_data_per )
return -1 ;
/*
* disable the interrupts as we do not want any code to be executed
* from flash other than this function
*/
intr_mask = Per_DI() ;
/*
* Now erase the flash block configured in the structure.
*/
g_data_per_cfg.pfn_dev_init( g_data_per_cfg.p_start_addr, g_data_per_cfg.ul_size ) ;
g_data_per_cfg.pfn_dev_erase( g_data_per_cfg.p_start_addr, g_data_per_cfg.ul_size ) ;
/*
* Now write the data into the flash block configured
*/
g_data_per_cfg.pfn_dev_write( g_data_per_cfg.p_start_addr, p_data_per, sizeof( DATA_PER_t ) ) ;
g_data_per_cfg.pfn_dev_close() ;
/*
* enable the interrupts
*/
Per_EI( intr_mask ) ;
return 0 ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -