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

📄 at24c.h

📁 this document is source code for arm9 of atmel
💻 H
字号:
/*-----------------------------------------------------------------------------
*         ATMEL Microcontroller Software Support  -  ROUSSET  -
*------------------------------------------------------------------------------
* The software is delivered "AS IS" without warranty or condition of any
* kind, either express, implied or statutory. This includes without
* limitation any warranty or condition with respect to merchantability or
* fitness for any particular purpose, or against the infringements of
* intellectual property rights of others.
*------------------------------------------------------------------------------
* File Name         : at24c.h
* Object            : ATMEL AT24C Two-wire Serial EEPROM header file definition
*
* Version | mm | dd | yy | author :
*  1.0      12   14   06    PFi   : Creation
*
*----------------------------------------------------------------------------*/

#ifndef at24c_h
#define at24c_h

#include "project.h"
/*---------------------------  Constants definition -------------------------*/
/* Slave address format:

  - AT24C128 to C512; 5 fixed internal address bit + 2 external user's define
    bits. Int. addr:"10100" + A1 + A0

  - AT24C1024 : 5 fixed internal address bit + 1 external user's define
    bits A1 and one page address bit. Int. addr:"10100" + A1 + P0
    This memory page address bit, P0, is the most significant bit of the data
    word address that follows. The eighth bit of the device address is the
    read/write operation select bit. A read operation is initiated if this bit
    is high and a write operation is initiated if this bit is low.

    Address used in this example with a AT24C1024 wit A1 = 1 (+VDD) */

#define AT24C_I2C_ADDRESS   (0x52<<16)

/* Eeprom Name */
#define AT24C128 128
#define AT24C256 256
#define AT24C512 512
#define AT24C1024 1024

#define ANY_SLAVE_ADDRESS 0xFF    /* Any Slave address for bus recovery */

/*---------------------------  Structure definition -------------------------*/

struct at24c{
   unsigned int PageSize;   /* See below for definition */
   unsigned int NumOfPage;  /* See below for definition */
   unsigned int EepromSize;
   unsigned int SlaveAddress;
   unsigned int EepromName;
};

/* Page size and number of page for the C128, C256, C512 and C1024 EEPROM */
/* AT24C1024 = 512 pages of 256 bytes each */
/* AT24C512  = 512 pages of 128-bytes each */
/* AT24C256  = 512 pages of 64-bytes each  */
/* AT24C128  = 256 pages of 64-bytes each  */


/*---------------------------  Function Prototyping -------------------------*/
/* AT24C Write Functions */
extern void AT91F_AT24C_WriteByte (struct at24c *ptAt24c,
                                   char Data2Write,
                                   unsigned int Address);

extern void AT91F_AT24C_WritePage (struct at24c *ptAt24c,
                                   char *Buffer,
                                   unsigned int NumOfBytes,
                                   unsigned int PageNumber,
                                   unsigned int AddressOffSet);

/* AT24C Read Functions */
extern char AT91F_AT24C_ReadByte (struct at24c *ptAt24c,
                                  unsigned int Address);

extern void AT91F_AT24C_ReadPage (struct at24c *ptAt24c,
                                  char *Buffer,
                                  unsigned int NumOfBytes,
                                  unsigned int PageNumber,
                                  unsigned int AddressOffSet) ;

extern void AT91F_AT24C_SequentialRead (struct at24c *ptAt24c,
                                 char *Buffer,
                                 unsigned int NumOfBytes,
                                 unsigned int Address);

/* AT24C Facilities Functions */
extern void AT91F_AT24C_MemoryReset (const AT91PS_PIO pPio,
                            int PioID,
                            int Twck,
                            int Twd);

extern void AT91F_AT24C_WaitMicroSecond (unsigned int MicroSecond);
extern void AT91F_AT24C_WaitMiliSecond (unsigned int MiliSeconds) ;

#endif /* at24c_h */

⌨️ 快捷键说明

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