• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

eeprom-wl.h

Go to the documentation of this file.
00001 /* EEPROM access and wear leveling */
00002 /* Copyright (C) 2010 Sebastian Klemm
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation; either version 2 of the License, or
00007  *   (at your option) version 3.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License along
00015  *   with this program; if not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #ifndef EEPROM_WL_H
00019 #define EEPROM_WL_H
00020 
00021 #include "config-params.h"
00022 
00050 #define EE_PARAM_BUFFER_SIZE  (8)
00051 #define EE_STATUS_BUFFER_SIZE  EE_PARAM_BUFFER_SIZE
00052 
00055 #define EE_BYTE_SIZE (1)
00056 #define EE_WORD_SIZE (2)
00057 #define EE_DWORD_SIZE (4)
00058 
00062 #define EE_STATIC_PARAM_1  (0)
00063 #define EE_STATIC_PARAM_2  (EE_STATIC_PARAM_1 + EE_STATIC_PARAM_1_SIZE)
00064 #define EE_STATIC_PARAM_3  (EE_STATIC_PARAM_2 + EE_STATIC_PARAM_2_SIZE)
00065 #define EE_STATIC_PARAM_4  (EE_STATIC_PARAM_3 + EE_STATIC_PARAM_3_SIZE)
00066 #define EE_STATIC_PARAM_5  (EE_STATIC_PARAM_4 + EE_STATIC_PARAM_4_SIZE)
00067 #define EE_STATIC_PARAM_6  (EE_STATIC_PARAM_5 + EE_STATIC_PARAM_5_SIZE)
00068 #define EE_STATIC_PARAM_7  (EE_STATIC_PARAM_6 + EE_STATIC_PARAM_6_SIZE)
00069 #define EE_STATIC_PARAM_LAST  (EE_STATIC_PARAM_7 + EE_STATIC_PARAM_7_SIZE)
00070 
00073 #define EE_PARAM_BUFFER_START (64)
00074 
00077 #define EE_PARAM_1  EE_PARAM_BUFFER_START
00078 #define EE_PARAM_2  (EE_PARAM_1 + EE_PARAM_1_SIZE * EE_PARAM_BUFFER_SIZE + EE_STATUS_BUFFER_SIZE)
00079 #define EE_PARAM_3  (EE_PARAM_2 + EE_PARAM_2_SIZE * EE_PARAM_BUFFER_SIZE + EE_STATUS_BUFFER_SIZE)
00080 #define EE_PARAM_4  (EE_PARAM_3 + EE_PARAM_3_SIZE * EE_PARAM_BUFFER_SIZE + EE_STATUS_BUFFER_SIZE)
00081 #define EE_PARAM_5  (EE_PARAM_4 + EE_PARAM_4_SIZE * EE_PARAM_BUFFER_SIZE + EE_STATUS_BUFFER_SIZE)
00082 #define EE_PARAM_6  (EE_PARAM_5 + EE_PARAM_5_SIZE * EE_PARAM_BUFFER_SIZE + EE_STATUS_BUFFER_SIZE)
00083 #define EE_PARAM_7  (EE_PARAM_6 + EE_PARAM_6_SIZE * EE_PARAM_BUFFER_SIZE + EE_STATUS_BUFFER_SIZE)
00084 #define EE_PARAM_LAST  (EE_PARAM_7 + EE_PARAM_7_SIZE * EE_PARAM_BUFFER_SIZE + EE_STATUS_BUFFER_SIZE)
00085 
00087 #if (EE_STATIC_PARAM_LAST + EE_STATIC_PARAM_LAST_SIZE) > EE_PARAM_BUFFER_START
00088 #error "Memory space needed for static config parameters exceeds reserved size!"
00089 #endif
00090 
00091 #if EE_PARAM_LAST > E2END
00092 #error "Memory space needed for config parameters exceeds size of EEPROM!"
00093 #endif
00094 
00099 #define EE_ECHO (1)
00100 
00103 #define EE_WRITE (1)
00104 
00106 typedef uint8_t * ee_addr_t;
00107 
00118 uint8_t read_config_byte (ee_addr_t parameter, ee_addr_t *address);
00119 uint16_t read_config_word (ee_addr_t parameter, ee_addr_t *address);
00120 uint32_t read_config_dword (ee_addr_t parameter, ee_addr_t *address);
00121 
00132 void write_config_byte (ee_addr_t parameter, ee_addr_t *address, uint8_t data);
00133 void write_config_word (ee_addr_t parameter, ee_addr_t *address, uint16_t data);
00134 void write_config_dword (ee_addr_t parameter, ee_addr_t *address, uint32_t data);
00135 
00136 
00143 void ee_find_current_buffer_address (ee_addr_t parameter, ee_addr_t *EeBufPtr, uint8_t param_size);
00144 
00151 void ee_read_buffer (ee_addr_t address, void *data, uint8_t param_size);
00152 
00158 void ee_write_byte (ee_addr_t address, uint8_t data);
00159 
00167 void ee_write_buffer (ee_addr_t parameter, ee_addr_t *address, void *data, uint8_t param_size);
00168 
00169 #endif

Generated by  doxygen 1.7.1