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

📄 s12_eets.h

📁 使用FREESCALE单片机内部的EEPROM的程序
💻 H
字号:
//=============================================================================
// File: S12_EETS.H - V1.00
// Rem.: The ACPRD Project Page on the Web -> http://hc12web.de/acprd
//=============================================================================

#ifndef __S12_EETS_H
#define __S12_EETS_H

//-- Includes -----------------------------------------------------------------

#include "s12_crg.h"	// contains S12_OSCCLK value

//-- EETS Bit Mask Definitions ------------------------------------------------

// Bits in ECLKDIV:

#define UINT16 unsigned int
#define INT8 char

#define BM_EDIVLD	0x80
#define BM_PRDIV8	0x40

// Bits in ECNFG:
#define BM_CBEIE	0x80
#define BM_CCIE		0x40

// Bits in EPROT:
#define BM_EPOPEN	0x80
#define BM_NV6		0x40
#define BM_NV5		0x20
#define BM_NV4		0x10
#define BM_EPDIS	0x08
#define BM_EP2		0x04
#define BM_EP1		0x02
#define BM_EP0		0x01

// Bits in ESTAT:
#define BM_CBEIF	0x80
#define BM_CCIF		0x40
#define BM_PVIOL	0x20
#define BM_ACCERR	0x10
//#define reserved	0x08
#define BM_BLANK	0x04
//#define reserved	0x02
//#define reserved	0x01

//-- Defines ------------------------------------------------------------------

#define EETS_START		0x2000		// 0x0000..0x03ff hidden by Register Block
#define EETS_LAST		0x27ef		// 0x0ff0..0x0fff reserved

#define EETS_MAX_SECTOR	(((EETS_LAST+1) - EETS_START) / 4)	

// This is a simplified equation, suitable for a large number of
// apps - please refer to EETS4K Block Guide for detailed information,
// especially if low clock/bus frequencies (below 4 Mhz) are used!
#if (S12_OSCCLK > 12800000)
#define EETS_ECLKDIV	(S12_OSCCLK/1600000 + BM_PRDIV8)
#else
#define EETS_ECLKDIV	(S12_OSCCLK/200000)
#endif

// EEPROM Commands:
#define EETS_CMD_EVERIFY	0x05
#define EETS_CMD_PROGRAM	0x20
#define EETS_CMD_SERASE		0x40
#define EETS_CMD_MERASE		0x41
#define EETS_CMD_SMODIFY	0x60

//-- Function Prototypes ------------------------------------------------------

void EEPROM_Init(void);
INT8 wrSectEETS(UINT16 *dest, UINT16 *src);
INT8 writeItemEETS(UINT16 item_no, void *item);
INT8 readItemEETS(UINT16 item_no, void *item);

#endif //__S12_EETS_H =========================================================

⌨️ 快捷键说明

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