⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mem_handler.h

📁 飞思卡尔车身控制技术研讨会资料范例 基于LIN的收发通信
💻 H
字号:
/*******************************************************************************/
/**
Copyright (c) 2008 Freescale Semiconductor
Freescale Confidential Proprietary
\file       Mem_handler.h
\brief      Memory management functions and data types.
\author     Freescale Semiconductor
\author     B05114
\version    0.1
\date       January/ 2008
*/
/*******************************************************************************/

#ifndef MEM_HANDLER_H        /*prevent duplicated includes*/
#define MEM_HANDLER_H

/*-- Includes ----------------------------------------------------------------*/
#define MEM_MAX_KEYFOBS 0x06

/*-- Types Definitions -------------------------------------------------------*/
/* Parameters and Calibrations Data type*/
typedef struct tCalibrations
{
    UINT32  u32Cal_EEPROM_Restore; /* Flag to signal need to restore EEPROM values from Flash memory */
    UINT8   VkspRx_Counter[MEM_MAX_KEYFOBS][4];
    UINT8   VkspRx_LearnCodes[MEM_MAX_KEYFOBS][20];
    UINT8   VkspRx_Idx;
    UINT8   dummy1;
    UINT8   dummy2;
    UINT8   dummy3; 
};
/* BCM Memory Status Data type */
                           
typedef struct tMemoryStatus
{
    UINT8   bfShadowEEPROM_Initialized:1;           /* Shadow EEPROM Inialization flag */
    UINT8   bfShadowRAM_Initialized:1;              /* Shadow RAM Inialization flag */
    UINT8   bfShadowEEPROM_Update:2;                /* Shadow EEPROM Update status variable */
    UINT8   bfDirtyMemory:1;                        /* Shadow EEPROM is not UP TO DATE*/
    UINT8   bfBackupShadowRAM:3;                    /* Status flags for Shadow RAM Backup*/
};

/*-- Defines -----------------------------------------------------------------*/
/* Definitions for bfShadowEEPROM_Update bitfield */
#define NO_REQUEST              0
#define REQUEST                 1
#define PENDING_COMPLETION      2
#define END_EEPROM_INIT         3

/* Definitions for bfBackupShadowRAM bitfield */
#define NO_BACKUP_REQUEST       0
#define START                   1
#define ERASE                   2
#define PROGRAM                 3
#define END                     4

#define MEM_FILL_LEARNCODE1 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
#define MEM_FILL_LEARNCODE2 MEM_FILL_LEARNCODE1,MEM_FILL_LEARNCODE1
#define MEM_FILL_LEARNCODE3 MEM_FILL_LEARNCODE2,MEM_FILL_LEARNCODE1
#define MEM_FILL_LEARNCODE4 MEM_FILL_LEARNCODE3,MEM_FILL_LEARNCODE1
#define MEM_FILL_LEARNCODE5 MEM_FILL_LEARNCODE4,MEM_FILL_LEARNCODE1
#define MEM_FILL_LEARNCODE6 MEM_FILL_LEARNCODE5,MEM_FILL_LEARNCODE1
#define MEM_FILL_LEARNCODE7 MEM_FILL_LEARNCODE6,MEM_FILL_LEARNCODE1
#define MEM_FILL_LEARNCODE8 MEM_FILL_LEARNCODE7,MEM_FILL_LEARNCODE1

/*-- Macros ------------------------------------------------------------------*/
#if(MEM_MAX_KEYFOBS == 0x01)
#define MEM_FILL_LEARNCODE MEM_FILL_LEARNCODE1
#define MEM_FILL_COUNTERS 0x00
#endif

#if(MEM_MAX_KEYFOBS == 0x02)
#define MEM_FILL_LEARNCODE MEM_FILL_LEARNCODE2
#define MEM_FILL_COUNTERS 0x00
#endif

#if(MEM_MAX_KEYFOBS == 0x03)
#define MEM_FILL_LEARNCODE MEM_FILL_LEARNCODE3
#define MEM_FILL_COUNTERS 0x00
#endif

#if(MEM_MAX_KEYFOBS == 0x04)
#define MEM_FILL_LEARNCODE MEM_FILL_LEARNCODE4
#define MEM_FILL_COUNTERS 0x00
#endif

#if(MEM_MAX_KEYFOBS == 0x05)
#define MEM_FILL_LEARNCODE MEM_FILL_LEARNCODE5
#define MEM_FILL_COUNTERS 0x00
#endif

#if(MEM_MAX_KEYFOBS == 0x06)
#define MEM_FILL_LEARNCODE MEM_FILL_LEARNCODE6
#define MEM_FILL_COUNTERS 0x00
#endif

#if(MEM_MAX_KEYFOBS == 0x07)
#define MEM_FILL_LEARNCODE MEM_FILL_LEARNCODE7
#define MEM_FILL_COUNTERS 0x00
#endif

#if(MEM_MAX_KEYFOBS == 0x08)
#define MEM_FILL_LEARNCODE MEM_FILL_LEARNCODE8
#define MEM_FILL_COUNTERS 0x00
#endif


/*-- Macros ------------------------------------------------------------------*/

/*-- Function Prototypes -----------------------------------------------------*/
/* BCM Memory Initialization */
void vfnMemory_Init(void);
/* Validate Shadow EEPROM initialization */
void vfnShadowEEPROM_Init(void);
/* Validate Shadow RAM initialization */
void vfnShadowRAM_Init(void);
/* Perform ShadowRAM Backup into EEPROM*/
void vfnBackUpShadowRAM(void);
/* Write to ShadowRAM and update checksum:*/
void vfnShadowRAMWriteByte(UINT8  *dest, UINT8 Value);

void vfnShadowRAMWriteWord(UINT16 *dest, UINT16 Value);
void vfnShadowRAMWriteLong(UINT32 *dest, UINT32 Value);
/* Test if EEPROM is out of date*/
void vfnTestMemoryDirty(void);

#endif /* MEM_HANDLER_H */

/*******************************************************************************/
/*                                                                             */
/* All software, source code, included documentation, and any implied know-how */
/* are property of Freescale Semiconductor and therefore considered            */ 
/* CONFIDENTIAL INFORMATION.                                                   */
/*                                                                             */
/* This confidential information is disclosed FOR DEMONSTRATION PURPOSES ONLY. */
/*                                                                             */
/* All Confidential Information remains the property of Freescale Semiconductor*/
/* and will not be copied or reproduced without the express written permission */
/* of the Discloser, except for copies that are absolutely necessary in order  */
/* to fulfill the Purpose.                                                     */
/*                                                                             */
/* Services performed by FREESCALE in this matter are performed AS IS and      */
/* without any warranty. CUSTOMER retains the final decision relative to the   */
/* total design and functionality of the end product.                          */
/*                                                                             */
/* FREESCALE neither guarantees nor will be held liable by CUSTOMER for the    */
/* success of this project.                                                    */
/*                                                                             */
/* FREESCALE disclaims all warranties, express, implied or statutory including,*/
/* but not limited to, implied warranty of merchantability or fitness for a    */
/* particular purpose on any hardware, software ore advise supplied to the     */
/* project by FREESCALE, and or any product resulting from FREESCALE services. */
/*                                                                             */
/* In no event shall FREESCALE be liable for incidental or consequential       */
/* damages arising out of this agreement. CUSTOMER agrees to hold FREESCALE    */
/* harmless against any and all claims demands or actions by anyone on account */
/* of any damage,or injury, whether commercial, contractual, or tortuous,      */
/* rising directly or indirectly as a result of the advise or assistance       */
/* supplied CUSTOMER in connectionwith product, services or goods supplied     */
/* under this Agreement.                                                       */
/*                                                                             */
/*******************************************************************************/


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -