Include top-level headers from cfg/ subdir.
[bertos.git] / drv / eeprom.h
1 /*!
2  * \file
3  * <!--
4  * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
5  * This file is part of DevLib - See devlib/README for information.
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.6  2005/04/11 19:10:27  bernie
19  *#* Include top-level headers from cfg/ subdir.
20  *#*
21  *#* Revision 1.5  2004/11/02 17:50:02  bernie
22  *#* CONFIG_EEPROM_VERIFY: New config option.
23  *#*
24  *#* Revision 1.4  2004/08/25 14:12:08  rasky
25  *#* Aggiornato il comment block dei log RCS
26  *#*
27  *#* Revision 1.3  2004/08/10 06:57:22  bernie
28  *#* eeprom_erase(): New function.
29  *#*
30  *#* Revision 1.2  2004/07/29 22:57:09  bernie
31  *#* Add 24LC16 support.
32  *#*
33  *#* Revision 1.1  2004/07/20 17:11:18  bernie
34  *#* Import into DevLib.
35  *#*
36  *#*/
37 #ifndef DRV_EEPROM_H
38 #define DRV_EEPROM_H
39
40 #include <cfg/compiler.h>
41 #include <cfg/config.h>
42
43 /*!
44  * \name Values for CONFIG_EEPROM_TYPE
45  * \{
46  */
47 #define EEPROM_24XX16 1
48 #define EEPROM_24XX256 2
49 /*\}*/
50
51 #if CONFIG_EEPROM_TYPE == EEPROM_24XX16
52         #define EEPROM_BLKSIZE   0x10 //!< Eeprom block size (16byte)
53         #define EEPROM_SIZE     0x800 //!< Eeprom total size (2kB)
54 #elif CONFIG_EEPROM_TYPE == EEPROM_24XX256
55         #define EEPROM_BLKSIZE   0x40 //!< Eeprom block size (64byte)
56         #define EEPROM_SIZE    0x8000 //!< Eeprom total size (32kB)
57 #else
58         #error Unsupported EEPROM type.
59 #endif
60
61 //! Type for EEPROM addresses
62 typedef uint16_t e2addr_t;
63
64 bool eeprom_write(e2addr_t addr, const void *buf, size_t count);
65 bool eeprom_read(e2addr_t addr, void *buf, size_t count);
66 bool eeprom_write_char(e2addr_t addr, char c);
67 int eeprom_read_char(e2addr_t addr);
68 void eeprom_erase(e2addr_t addr, size_t count);
69 void eeprom_init(void);
70 void eeprom_test(void);
71
72 #endif /* DRV_EEPROM_H */