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