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

📄 eeprom.h

📁 TDK 6521 SOC 芯片 DEMO程序
💻 H
字号:
/***************************************************************************
 * This code and information is provided "as is" without warranty of any   *
 * kind, either expressed or implied, including but not limited to the     *
 * implied warranties of merchantability and/or fitness for a particular   *
 * purpose.                                                                *
 *                                                                         *
 * Copyright (C) 2005 Teridian Semiconductor Corp. All Rights Reserved.    *
 ***************************************************************************/
//**************************************************************************
//    
//  DESCRIPTION: 71M65xx POWER METER - EEPROM Prototypes and Definitions.
//  This defines a concrete interface to an eeprom device,
//  and an abstract interface to a "nonvolatile" storage device.
// 
//  AUTHOR:  MTF/RGV
//
//  HISTORY: 2003 OCTOBER 30; First Version. 
//
//**************************************************************************
//               
// File:    EEPROM.H
//               
#ifndef EEPROM_H
#define EEPROM_H 1

// AT24C1024, eeprom.c, eepromp.c, needs I2C i/f,
// Standard for TSC meter demo PCBs
#if defined AT24C1024
#define PAGE_SIZE 256
#define WRITE_TIME 20  // 10 ms; but the least is two clock ticks...
#define EEPROM_SIZE   0x20000     // Size of AT24C1024 in bytes.   

// Microchip 93C76C, eepromp3.c, needs 3-wire i/f, very inexpensive
// Standard for TSC meter eval. PCBs with a 3-wire i/f
#elif defined M93C76C
#define PAGE_SIZE 1
#define WRITE_TIME 20  // 2 ms; but the least is two clock ticks...
#define EEPROM_SIZE   0x0400     // Size in bytes.   

// AT24C08, eep24c08.c, needs I2C i/f, very inexpensive
#elif defined AT24C08
#define PAGE_SIZE 16
#define WRITE_TIME 10  // 10 ms; but the least is two clock ticks...
#define EEPROM_SIZE   0x0400     // Size of AT24C08 in bytes.

// ST Micro 24512, eep24512.c, needs I2C i/f
#elif defined ST24512
#define PAGE_SIZE 128
#define WRITE_TIME 20  // 10 ms; but the least is two clock ticks...
#define EEPROM_SIZE   0x10000     // Size in bytes.   

#else
#if EEPROM
#error unhandled EEPROM device
#endif
#endif

enum EEPROM_RC { _OK, _PENDING, _ERR_OVERRUN, _ERR_NACK, _ERR_PENDING };

struct EEPROM_t
{                                    // Buffer to read-to or write-from. 
    uint32_t   addr;             // 4-byte address.
    uint8x_t  *buffer;          // Buffer to read-to or write-from.
    uint16_t   len;              // 2-byte len.
    enum EEPROM_RC data *status;
};

//**************************************************************************
//  EEProm_Config 
//**************************************************************************
//
//  Purpose: Connect/Disconnect DIO6/7 for I2C interface to serial EEProm.
//
//  Inputs:  Bbool access
//           uint16_t   page size of serial eeprom. 
//			 U08   page write time of serial eeprom.	
//  Outputs: None
//
//  Synopsis:

void EEProm_Config (uint8_t access, uint16_t page_size, uint8_t write_time) small reentrant;
#define eeprom_enable() EEProm_Config(1, PAGE_SIZE, WRITE_TIME)
#define eeprom_disable() EEProm_Config(0, PAGE_SIZE, WRITE_TIME)
//**************************************************************************

//**************************************************************************
//  memcpy_prx
//**************************************************************************
//
//  Purpose: Copy data to serial EEProm.
//
//  Inputs:  uint32_t    dst;                // 4-byte destination address in serial EEProm.  
//           uint8x_t  *src;                // Buffer to copy from.
//           uint16_t    len;                // 2-byte length.
//           
//  Outputs: enum EEPROM_RC *status;  
//
//  Synopsis:

enum EEPROM_RC data *memcpy_prx (uint32_t dst, uint8x_t *src, int16_t len) small reentrant;
enum EEPROM_RC data *memset_pr  (uint32_t dst, int32_t src);
//**************************************************************************

//**************************************************************************
//  memclr_pr
//**************************************************************************
//
//  Purpose: clear the EEPROM; performs a native erase if possible,
//  otherwise sets the EEPROM's memory to 0xFF
//
//  Inputs:  none
//           
enum EEPROM_RC data *memclr_pr (void);
//**************************************************************************

//**************************************************************************
//  memcpy_xpr
//**************************************************************************
//
//  Purpose: Copy data from serial EEProm.
//                                      
//  Inputs:  uint8x_t  *dst;                // Buffer to copy to.
//           uint32_t    src;                // 4-byte source address in serial EEProm.     
//           uint16_t    len;                // 2-byte length.
//           
//  Outputs: enum EEPROM_RC *status;    
//
//  Synopsis:

enum EEPROM_RC data *memcpy_xpr (uint8x_t *dst, uint32_t src, int16_t len) small reentrant;
enum EEPROM_RC data *memget_pr  (int32x_t *dst, uint32_t src) small reentrant;

// waits, returns 1 when it worked, 0 if it timed out or failed
bool eeprom_ok (enum EEPROM_RC data *pstatus) small reentrant;

/***************************************************************************
 * $Log: eeprom.h,v $
 * Revision 1.20  2006/09/09 01:09:18  gmikef
 * *** empty log message ***
 *
 * Revision 1.19  2006/08/08 00:43:38  tvander
 * Added debugged ST24512 EEPROM driver.
 *
 * Revision 1.18  2006/06/15 16:36:55  tvander
 * Fixed reentrancy on iiceep.c and eepromp.c
 * Made parallel code changes to microwire eeprom drivers.
 *
 * Revision 1.17  2006/05/25 03:24:11  tvander
 * Added timeouts to EEPROMs.  Tested all three.
 * Newly ported calibration loader, compiles without error.
 * RTC setting uses a software timer (less code, also frees tmr1)
 *
 * Revision 1.16  2006/05/18 23:18:44  tvander
 * 16K and 32K
 * First cut at new requirements.
 * 32K 6521 is grossly tested.
 * All others have a clean compile with C51 8.02
 *
 * Revision 1.15  2006/04/06 21:00:03  tvander
 * Maintained so microwire EEPROM driver still builds.
 *
 * Revision 1.14  2006/03/08 00:00:56  tvander
 * Revised IO so that multiplexed interrupts are centralized in io65xx.c
 * Added default interrupts to io65xx.c
 * Clean build.
 * Tested CE, serial.
 * interrupting EEPROM driver fails.
 *
 * Revision 1.13  2006/03/06 03:30:48  Michael T. Fischer
 * More 6530 prep.
 *
 * Revision 1.12  2006/02/08 22:36:53  gmikef
 * *** empty log message ***
 *
 * Revision 1.11  2006/02/08 03:43:18  tvander
 * Made "import" the default power measurement mode, rather than net-metering
 *
 * Revision 1.10  2006/01/10 03:57:03  gmikef
 * Added PDATA support for CE Outputs.
 *
 * Revision 1.8  2005/11/05 01:56:25  tvander
 * Added EEPROM erase; Note uwreep.c is not working; don't know why.
 *
 * Revision 1.7  2005/10/20 18:39:40  tvander
 * Ported 2-wire EEPROM code from 6511/6513, including interrupting version, polling version for DIO, and polling version using the 2-wire logic.
 *
 * Revision 1.6  2005/09/22 23:45:04  tvander
 * Clean build all models and unit tests, updated copyright to be fore Teridian
 *
 * Revision 1.5  2005/09/02 20:39:31  gmikef
 * Modified to fit CeCode of 1.5Kbytes and support new "ce_merge".
 *
 * Revision 1.4  2005/08/28 02:13:17  gmikef
 * *** empty log message ***
 *
 * Revision 1.3  2005/08/12 21:50:42  tvander
 * Added a synchronization and test function.
 *
 * Revision 1.2  2005/08/10 01:57:35  gmikef
 * *** empty log message ***
 *
 * Revision 1.1  2005/05/13 00:34:42  tvander
 * 6511/32k works
 * Integrated and debugged self-calibration.
 * The build has one unused segment, and no other errors or warnings.
 * default LCD and pulse displays appear OK.
 * EEPROM, software timers and hardware timers are all integrated.
 *
 * Copyright (C) 2005 Teridian Semiconductor Corp. All Rights Reserved.    *
 * this program is fully protected by the United States copyright          *
 * laws and is the property of Teridian Semiconductor Corporation.         *
 ***************************************************************************/
#endif /* eeprom.h */

⌨️ 快捷键说明

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