?lang_form?
?lang_select?
?lang_submit?
?lang_endform?
{HEADER END}
{FILE START}
library
?curdirlinks? - Rev 6
?prevdifflink? - Blame - ?getfile?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Procyon AVRlib: param.c Source File</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.2 -->
<div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div>
<h1>param.c</h1><a href="param_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file param.c \brief EEPROM Parameter Storage Library. */</span>
00002 <span class="comment">//*****************************************************************************</span>
00003 <span class="comment">//</span>
00004 <span class="comment">// File Name : 'param.c'</span>
00005 <span class="comment">// Title : EEPROM Parameter Storage Library</span>
00006 <span class="comment">// Author : Pascal Stang (c)2005</span>
00007 <span class="comment">// Created : 9/16/2005</span>
00008 <span class="comment">// Revised : 9/20/2005</span>
00009 <span class="comment">// Version : 0.1</span>
00010 <span class="comment">// Target MCU : Atmel AVR series</span>
00011 <span class="comment">// Editor Tabs : 4</span>
00012 <span class="comment">//</span>
00013 <span class="comment">//*****************************************************************************</span>
00014
00015 <span class="preprocessor">#include <avr/eeprom.h></span>
00016
00017 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span>
00018
<a name="l00019"></a><a class="code" href="group__param.html#ga1">00019</a> u08 <a class="code" href="group__param.html#ga1">paramLoad</a>(u08* parameters, u08* memaddr, u16 sizebytes)
00020 {
00021 u16 i;
00022 u08 checksum_stored=0;
00023 u08 checksum=0;
00024
00025 <span class="comment">// load parameters</span>
00026 eeprom_read_block(parameters, memaddr, sizebytes);
00027 <span class="comment">// load checksum</span>
00028 eeprom_read_block(&checksum_stored, memaddr+sizebytes, <span class="keyword">sizeof</span>(u08));
00029
00030 <span class="comment">// calculate own checksum</span>
00031 <span class="keywordflow">for</span>(i=0;i<sizebytes;i++)
00032 checksum += parameters[i];
00033 checksum = ~checksum;
00034
00035 <span class="keywordflow">if</span>(checksum == checksum_stored)
00036 <span class="keywordflow">return</span> TRUE;
00037 <span class="keywordflow">else</span>
00038 <span class="keywordflow">return</span> FALSE;
00039 }
00040
<a name="l00041"></a><a class="code" href="group__param.html#ga0">00041</a> <span class="keywordtype">void</span> <a class="code" href="group__param.html#ga0">paramStore</a>(u08* parameters, u08* memaddr, u16 sizebytes)
00042 {
00043 u16 i;
00044 u08 checksum=0;
00045
00046 <span class="comment">// calculate checksum</span>
00047 <span class="keywordflow">for</span>(i=0;i<sizebytes;i++)
00048 checksum += parameters[i];
00049 checksum = ~checksum;
00050
00051 <span class="comment">// store parameters</span>
00052 eeprom_write_block(parameters, memaddr, sizebytes);
00053 <span class="comment">// store checksum</span>
00054 eeprom_write_block(&checksum, memaddr+sizebytes, <span class="keyword">sizeof</span>(u08));
00055 }
00056
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:07 2006 for Procyon AVRlib by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address>
</body>
</html>
|
{FILE END}
{FOOTER START}
Powered by WebSVN v2.8.3