Contiki-Inga 3.x
eeprom.h
Go to the documentation of this file.
1 /**
2  * \addtogroup dev
3  * @{
4  */
5 
6 /**
7  * \defgroup eeprom EEPROM API
8  *
9  * The EEPROM API defines a common interface for EEPROM access on
10  * Contiki platforms.
11  *
12  * A platform with EEPROM support must implement this API.
13  *
14  * @{
15  */
16 
17 /**
18  * \file
19  * EEPROM functions.
20  * \author Adam Dunkels <adam@sics.se>
21  */
22 
23 /* Copyright (c) 2004 Swedish Institute of Computer Science.
24  * All rights reserved.
25  *
26  * Redistribution and use in source and binary forms, with or without modification,
27  * are permitted provided that the following conditions are met:
28  *
29  * 1. Redistributions of source code must retain the above copyright notice,
30  * this list of conditions and the following disclaimer.
31  * 2. Redistributions in binary form must reproduce the above copyright notice,
32  * this list of conditions and the following disclaimer in the documentation
33  * and/or other materials provided with the distribution.
34  * 3. The name of the author may not be used to endorse or promote products
35  * derived from this software without specific prior written permission.
36  *
37  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
38  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
39  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
40  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
41  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
42  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
43  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
44  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
45  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
46  * OF SUCH DAMAGE.
47  *
48  *
49  * Author: Adam Dunkels <adam@sics.se>
50  *
51  */
52 
53 
54 #ifndef EEPROM_H_
55 #define EEPROM_H_
56 
57 typedef unsigned short eeprom_addr_t;
58 
59 #define EEPROM_NULL 0
60 
61 #ifdef EEPROM_CONF_SIZE
62 #define EEPROM_SIZE (EEPROM_CONF_SIZE)
63 #else
64 #define EEPROM_SIZE 0 /* Default to no EEPROM */
65 #endif
66 
67 #ifdef EEPROM_CONF_END_ADDR
68 #define EEPROM_END_ADDR (EEPROM_CONF_END_ADDR)
69 #else
70 #define EEPROM_END_ADDR (EEPROM_SIZE - 1)
71 #endif
72 
73 /**
74  * Write a buffer into EEPROM.
75  *
76  * This function writes a buffer of the specified size into EEPROM.
77  *
78  * \param addr The address in EEPROM to which the buffer should be written.
79  *
80  * \param buf A pointer to the buffer from which data is to be read.
81  *
82  * \param size The number of bytes to write into EEPROM.
83  *
84  *
85  */
86 void eeprom_write(eeprom_addr_t addr, unsigned char *buf, int size);
87 
88 /**
89  * Read data from the EEPROM.
90  *
91  * This function reads a number of bytes from the specified address in
92  * EEPROM and into a buffer in memory.
93  *
94  * \param addr The address in EEPROM from which the data should be read.
95  *
96  * \param buf A pointer to the buffer to which the data should be stored.
97  *
98  * \param size The number of bytes to read.
99  *
100  *
101  */
102 void eeprom_read(eeprom_addr_t addr, unsigned char *buf, int size);
103 
104 /**
105  * Initialize the EEPROM module
106  *
107  * This function initializes the EEPROM module and is called from the
108  * bootup code.
109  *
110  */
111 
112 void eeprom_init(void);
113 
114 #endif /* EEPROM_H_ */
115 
116 /** @} */
117 /** @} */