Sistema l'errore da me commesso in fase di conversione...
[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 README.devlib 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.10  2006/09/13 18:29:54  bernie
19  *#* e2addr(): New macro.
20  *#*
21  *#* Revision 1.9  2006/07/19 12:56:25  bernie
22  *#* Convert to new Doxygen style.
23  *#*
24  *#* Revision 1.8  2005/11/27 23:33:40  bernie
25  *#* Use appconfig.h instead of cfg/config.h.
26  *#*
27  *#* Revision 1.7  2005/11/04 16:20:02  bernie
28  *#* Fix reference to README.devlib in header.
29  *#*
30  *#* Revision 1.6  2005/04/11 19:10:27  bernie
31  *#* Include top-level headers from cfg/ subdir.
32  *#*
33  *#* Revision 1.5  2004/11/02 17:50:02  bernie
34  *#* CONFIG_EEPROM_VERIFY: New config option.
35  *#*
36  *#* Revision 1.4  2004/08/25 14:12:08  rasky
37  *#* Aggiornato il comment block dei log RCS
38  *#*
39  *#* Revision 1.3  2004/08/10 06:57:22  bernie
40  *#* eeprom_erase(): New function.
41  *#*
42  *#* Revision 1.2  2004/07/29 22:57:09  bernie
43  *#* Add 24LC16 support.
44  *#*
45  *#* Revision 1.1  2004/07/20 17:11:18  bernie
46  *#* Import into DevLib.
47  *#*
48  *#*/
49 #ifndef DRV_EEPROM_H
50 #define DRV_EEPROM_H
51
52 #include <cfg/compiler.h>
53 #include <appconfig.h>
54
55 /**
56  * \name Values for CONFIG_EEPROM_TYPE
57  * \{
58  */
59 #define EEPROM_24XX16 1
60 #define EEPROM_24XX256 2
61 /*\}*/
62
63 #if CONFIG_EEPROM_TYPE == EEPROM_24XX16
64         #define EEPROM_BLKSIZE   0x10 ///< Eeprom block size (16byte)
65         #define EEPROM_SIZE     0x800 ///< Eeprom total size (2kB)
66 #elif CONFIG_EEPROM_TYPE == EEPROM_24XX256
67         #define EEPROM_BLKSIZE   0x40 ///< Eeprom block size (64byte)
68         #define EEPROM_SIZE    0x8000 ///< Eeprom total size (32kB)
69 #else
70         #error Unsupported EEPROM type.
71 #endif
72
73 /// Type for EEPROM addresses
74 typedef uint16_t e2addr_t;
75
76 /**
77  * Macro for E2Layout offset calculation
78  *
79  * \note We can't just use offsetof() here because we could use
80  *       non-constant expressions to access array elements.
81  *
82  * \note E2Layout is a structure that must be defined in user files.
83  */
84 #define e2addr(x) ((e2addr_t)&(((struct E2Layout *)0)->x))
85
86
87 bool eeprom_write(e2addr_t addr, const void *buf, size_t count);
88 bool eeprom_read(e2addr_t addr, void *buf, size_t count);
89 bool eeprom_write_char(e2addr_t addr, char c);
90 int eeprom_read_char(e2addr_t addr);
91 void eeprom_erase(e2addr_t addr, size_t count);
92 void eeprom_init(void);
93 void eeprom_test(void);
94
95 #endif /* DRV_EEPROM_H */