NiboRoboLib 3.6 - NIBO burger Library
storage.h
gehe zur Dokumentation dieser Datei
1 /* BSD-License:
2 
3 Copyright (c) 2007 by Nils Springob, nicai-systems, Germany
4 
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9 
10  * Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12  * Redistributions in binary form must reproduce the above copyright notice,
13  this list of conditions and the following disclaimer in the documentation
14  and/or other materials provided with the distribution.
15  * Neither the name nicai-systems nor the names of its contributors may be
16  used to endorse or promote products derived from this software without
17  specific prior written permission.
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 */
32 
50 #ifndef _STORAGE_H_
51 #define _STORAGE_H_
52 
53 
54 #include <avr/io.h>
55 
56 
57 #define STORAGE_ENTRY(owner, type, version, size) ((((uint32_t)(owner))<<24) | (((uint32_t)(type))<<16) | (((uint32_t)(version))<<8) | ((uint32_t)(size)))
58 
59 
60 /* some standard system entries. Owner 0x00 - 0x7f are reserved for libraries, 0x80+ for custom purposes */
61 #define STORAGE_SYS_ID 0x01
62 #define STORAGE_USER0_ID 0x80
63 #define STORAGE_USER1_ID 0x81
64 #define STORAGE_USER2_ID 0x82
65 #define STORAGE_USER3_ID 0x83
66 #define STORAGE_USER4_ID 0x84
67 #define STORAGE_USER5_ID 0x85
68 #define STORAGE_USER6_ID 0x86
69 #define STORAGE_USER7_ID 0x87
70 #define STORAGE_USER8_ID 0x88
71 #define STORAGE_USER9_ID 0x89
72 
73 /* entry types for system */
74 #define STORAGE_SYS_KEY_ID 0x01
75 #define STORAGE_SYS_NAME_ID 0x02
76 #define STORAGE_SYS_UART0_ID 0x03
77 #define STORAGE_SYS_UART1_ID 0x04
78 
79 #define STORAGE_SYS_KEY STORAGE_ENTRY(STORAGE_SYS_ID, STORAGE_SYS_KEY_ID, 1, 4)
80 #define STORAGE_SYS_NAME STORAGE_ENTRY(STORAGE_SYS_ID, STORAGE_SYS_NAME_ID, 1, 20)
81 #define STORAGE_SYS_UART0_BAUDRATE STORAGE_ENTRY(STORAGE_SYS_ID, STORAGE_SYS_UART0_ID, 1, 4)
82 #define STORAGE_SYS_UART1_BAUDRATE STORAGE_ENTRY(STORAGE_SYS_ID, STORAGE_SYS_UART1_ID, 1, 4)
83 
84 
85 
92 uint8_t storage_read(uint32_t entry, void * ram);
93 
94 
101 uint8_t storage_write(uint32_t entry, const void * ram);
102 
103 
109 uint8_t storage_delete(uint32_t entry);
110 
111 
116 uint8_t storage_optimize();
117 
118 
123 uint8_t storage_format();
124 
125 
126 #endif
uint8_t storage_delete(uint32_t entry)
delete the entry in EEPROM
uint8_t storage_write(uint32_t entry, const void *ram)
copy the entry data from RAM to EEPROM
uint8_t storage_optimize()
optimize data in EEPROM (TODO)
uint8_t storage_format()
delete all data in EEPROM
uint8_t storage_read(uint32_t entry, void *ram)
copy the entry data from EEPROM to RAM