Add 24LC16 support.
[bertos.git] / drv / eeprom.h
1 /*!
2  * \file
3  * <!--
4  * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
5  * All Rights Reserved.
6  * -->
7  *
8  * \version $Id$
9  *
10  * \author Stefano Fedrigo <aleph@develer.com>
11  * \author Bernardo Innocenti <bernie@develer.com>
12  *
13  * \brief Driver for the 24xx16 and 24xx256 I2C EEPROMS (interface)
14  */
15
16 /*
17  * $Log$
18  * Revision 1.2  2004/07/29 22:57:09  bernie
19  * Add 24LC16 support.
20  *
21  * Revision 1.1  2004/07/20 17:11:18  bernie
22  * Import into DevLib.
23  *
24  */
25 #ifndef DRV_EEPROM_H
26 #define DRV_EEPROM_H
27
28 #include <compiler.h>
29 #include <config.h>
30
31 /*!
32  * \name Values for CONFIG_EEPROM_TYPE
33  * \{
34  */
35 #define EEPROM_24XX16 1
36 #define EEPROM_24XX256 2
37 /*\}*/
38
39 #if CONFIG_EEPROM_TYPE == EEPROM_24XX16
40         #define EEPROM_BLKSIZE   0x10 //!< Eeprom block size (16byte)
41         #define EEPROM_SIZE     0x800 //!< Eeprom total size (2kB)
42 #elif CONFIG_EEPROM_TYPE == EEPROM_24XX256
43         #define EEPROM_BLKSIZE   0x40 //!< Eeprom block size (64byte)
44         #define EEPROM_SIZE    0x8000 //!< Eeprom total size (32kB)
45 #else
46         #error Unsupported EEPROM type.
47 #endif
48
49 //! Type for EEPROM addresses
50 typedef uint16_t e2addr_t;
51
52 bool eeprom_write(e2addr_t addr, const void *buf, size_t count);
53 bool eeprom_read(e2addr_t addr, void *buf, size_t count);
54 bool eeprom_write_char(e2addr_t addr, char c);
55 int eeprom_read_char(e2addr_t addr);
56 void eeprom_init(void);
57 void eeprom_test(void);
58
59 #endif /* DRV_EEPROM_H */