ardupilot/libraries/doc/html/_data_flash_8h_source.html

126 lines
16 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>ArduPilot Libraries: DataFlash.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Generated by Doxygen 1.7.1 -->
<div class="navigation" id="top">
<div class="tabs">
<ul class="tablist">
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul>
</div>
<div class="header">
<div class="headertitle">
<h1>DataFlash.h</h1> </div>
</div>
<div class="contents">
<a href="_data_flash_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* ************************************************************ */</span>
<a name="l00002"></a>00002 <span class="comment">/* Test for DataFlash Log library */</span>
<a name="l00003"></a>00003 <span class="comment">/* ************************************************************ */</span>
<a name="l00004"></a>00004 <span class="preprocessor">#ifndef DataFlash_h</span>
<a name="l00005"></a>00005 <span class="preprocessor"></span><span class="preprocessor">#define DataFlash_h</span>
<a name="l00006"></a>00006 <span class="preprocessor"></span>
<a name="l00007"></a>00007 <span class="comment">// arduino mega SPI pins</span>
<a name="l00008"></a>00008 <span class="preprocessor">#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)</span>
<a name="l00009"></a>00009 <span class="preprocessor"></span><span class="preprocessor"> #define DF_DATAOUT 51 // MOSI</span>
<a name="l00010"></a>00010 <span class="preprocessor"></span><span class="preprocessor"> #define DF_DATAIN 50 // MISO </span>
<a name="l00011"></a>00011 <span class="preprocessor"></span><span class="preprocessor"> #define DF_SPICLOCK 52 // SCK</span>
<a name="l00012"></a>00012 <span class="preprocessor"></span><span class="preprocessor"> #define DF_SLAVESELECT 53 // SS (PB0)</span>
<a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor"> #define DF_RESET 31 // RESET (PC6)</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#else // normal arduino SPI pins...</span>
<a name="l00015"></a><a class="code" href="_data_flash_8h.html#aaa2878b0f1626b886a345091dba1b092">00015</a> <span class="preprocessor"></span><span class="preprocessor"> #define DF_DATAOUT 11 //MOSI</span>
<a name="l00016"></a><a class="code" href="_data_flash_8h.html#a6419289dfca78751031fc7b4ed09bd92">00016</a> <span class="preprocessor"></span><span class="preprocessor"> #define DF_DATAIN 12 //MISO </span>
<a name="l00017"></a><a class="code" href="_data_flash_8h.html#a1489251f9709f3a899f66dbcb9a03580">00017</a> <span class="preprocessor"></span><span class="preprocessor"> #define DF_SPICLOCK 13 //SCK</span>
<a name="l00018"></a><a class="code" href="_data_flash_8h.html#a3d4144bb59959e2dbd29c59ffa7929c4">00018</a> <span class="preprocessor"></span><span class="preprocessor"> #define DF_SLAVESELECT 10 //SS</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span>
<a name="l00021"></a>00021 <span class="comment">// AT45DB161D Commands (from Datasheet)</span>
<a name="l00022"></a><a class="code" href="_data_flash_8h.html#aa2b2a3b0192a2a9575da517fe7b35139">00022</a> <span class="preprocessor">#define DF_TRANSFER_PAGE_TO_BUFFER_1 0x53</span>
<a name="l00023"></a><a class="code" href="_data_flash_8h.html#a4af5551c8aff40af21b589e979620997">00023</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_TRANSFER_PAGE_TO_BUFFER_2 0x55</span>
<a name="l00024"></a><a class="code" href="_data_flash_8h.html#a301281323b66b8625e78b7888032534d">00024</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_STATUS_REGISTER_READ 0xD7</span>
<a name="l00025"></a><a class="code" href="_data_flash_8h.html#a6eb7b731278d544c706f0d2f5751b93f">00025</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_READ_MANUFACTURER_AND_DEVICE_ID 0x9F</span>
<a name="l00026"></a><a class="code" href="_data_flash_8h.html#a67a17a041cf479bea2ee09ac71ecdc50">00026</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_PAGE_READ 0xD2</span>
<a name="l00027"></a><a class="code" href="_data_flash_8h.html#a19df818e83558b75d9e61f740bb346db">00027</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_BUFFER_1_READ 0xD4</span>
<a name="l00028"></a><a class="code" href="_data_flash_8h.html#a289a660c7c5cd95f0cea2ad1911bf8d6">00028</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_BUFFER_2_READ 0xD6</span>
<a name="l00029"></a><a class="code" href="_data_flash_8h.html#aa11f0619bf3eb94dc1cd4bc85de77c78">00029</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_BUFFER_1_WRITE 0x84</span>
<a name="l00030"></a><a class="code" href="_data_flash_8h.html#a21aa2e058c89c08ca202b67488bffc24">00030</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_BUFFER_2_WRITE 0x87</span>
<a name="l00031"></a><a class="code" href="_data_flash_8h.html#a459772a80f5fb0fbb18be7a0b5569cf5">00031</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_BUFFER_1_TO_PAGE_WITH_ERASE 0x83</span>
<a name="l00032"></a><a class="code" href="_data_flash_8h.html#a4c5025dd00c27c948575fde479403317">00032</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_BUFFER_2_TO_PAGE_WITH_ERASE 0x86</span>
<a name="l00033"></a><a class="code" href="_data_flash_8h.html#a51f149e02b27e8fa6b1a3e7140d95dcd">00033</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_PAGE_ERASE 0x81</span>
<a name="l00034"></a><a class="code" href="_data_flash_8h.html#a1cc0a21d5f7c6758ba5c78954c800632">00034</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_BLOCK_ERASE 0x50</span>
<a name="l00035"></a><a class="code" href="_data_flash_8h.html#a165195086cbf125eaa6cd7c3a1205777">00035</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_SECTOR_ERASE 0x7C</span>
<a name="l00036"></a><a class="code" href="_data_flash_8h.html#a75e08d7dd6b7a163aa78ae1600c5c002">00036</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_CHIP_ERASE_0 0xC7</span>
<a name="l00037"></a><a class="code" href="_data_flash_8h.html#a8f814e02ae29f1b809a8e6b48bc51b5c">00037</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_CHIP_ERASE_1 0x94</span>
<a name="l00038"></a><a class="code" href="_data_flash_8h.html#a21ba2f63934b883b60d1aba5b9ca8604">00038</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_CHIP_ERASE_2 0x80</span>
<a name="l00039"></a><a class="code" href="_data_flash_8h.html#a330e223d9225c3c1e9e6c98935a24f41">00039</a> <span class="preprocessor"></span><span class="preprocessor">#define DF_CHIP_ERASE_3 0x9A</span>
<a name="l00040"></a>00040 <span class="preprocessor"></span>
<a name="l00041"></a><a class="code" href="class_data_flash___class.html">00041</a> <span class="keyword">class </span><a class="code" href="class_data_flash___class.html">DataFlash_Class</a>
<a name="l00042"></a>00042 {
<a name="l00043"></a>00043 <span class="keyword">private</span>:
<a name="l00044"></a>00044 <span class="comment">// DataFlash Log variables... </span>
<a name="l00045"></a>00045 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> df_BufferNum;
<a name="l00046"></a>00046 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> df_Read_BufferNum;
<a name="l00047"></a>00047 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> df_BufferIdx;
<a name="l00048"></a>00048 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> df_Read_BufferIdx;
<a name="l00049"></a>00049 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> df_PageAdr;
<a name="l00050"></a>00050 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> df_Read_PageAdr;
<a name="l00051"></a>00051 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> df_Read_END;
<a name="l00052"></a>00052 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> df_Stop_Write;
<a name="l00053"></a>00053 <span class="comment">//Methods</span>
<a name="l00054"></a>00054 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> BufferRead (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> BufferNum, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> IntPageAdr);
<a name="l00055"></a>00055 <span class="keywordtype">void</span> BufferWrite (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> BufferNum, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> IntPageAdr, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> Data);
<a name="l00056"></a>00056 <span class="keywordtype">void</span> BufferToPage (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> BufferNum, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> PageAdr, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> wait);
<a name="l00057"></a>00057 <span class="keywordtype">void</span> PageToBuffer(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> BufferNum, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> PageAdr);
<a name="l00058"></a>00058 <span class="keywordtype">void</span> WaitReady();
<a name="l00059"></a>00059 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> ReadStatus();
<a name="l00060"></a>00060
<a name="l00061"></a>00061 <span class="keyword">public</span>:
<a name="l00062"></a><a class="code" href="class_data_flash___class.html#ad575934014354e081340a96073159d79">00062</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="class_data_flash___class.html#ad575934014354e081340a96073159d79">df_manufacturer</a>;
<a name="l00063"></a><a class="code" href="class_data_flash___class.html#a59c96ff23d9ae8c64b76f1a41b0a82c0">00063</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="class_data_flash___class.html#a59c96ff23d9ae8c64b76f1a41b0a82c0">df_device_0</a>;
<a name="l00064"></a><a class="code" href="class_data_flash___class.html#acacd168d6bf0cf536492ec857d134b40">00064</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="class_data_flash___class.html#acacd168d6bf0cf536492ec857d134b40">df_device_1</a>;
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <a class="code" href="class_data_flash___class.html#abcc7740c0c53f4594363724b8d11507e">DataFlash_Class</a>(); <span class="comment">// Constructor</span>
<a name="l00067"></a>00067 <span class="keywordtype">void</span> <a class="code" href="class_data_flash___class.html#a5fdc7b891bfc48371cc07cf0fa659a71">Init</a>();
<a name="l00068"></a>00068 <span class="keywordtype">void</span> <a class="code" href="class_data_flash___class.html#a213908bcc4846bb7425a910da9295d44">ReadManufacturerID</a>();
<a name="l00069"></a>00069 <span class="keywordtype">int</span> <a class="code" href="class_data_flash___class.html#a113d7be25c6f015b6a8bb3f909771281">GetPage</a>();
<a name="l00070"></a>00070 <span class="keywordtype">int</span> <a class="code" href="class_data_flash___class.html#a8aa52719daf5fa94306eb0f4d6ff7f28">GetWritePage</a>();
<a name="l00071"></a>00071 <span class="keywordtype">void</span> <a class="code" href="class_data_flash___class.html#ab311b3c84c326b3164f6669e94644866">PageErase</a> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> PageAdr);
<a name="l00072"></a>00072 <span class="comment">// Write methods</span>
<a name="l00073"></a>00073 <span class="keywordtype">void</span> <a class="code" href="class_data_flash___class.html#a2fcdc28eaa3667bb47f93a23bdc8855d">StartWrite</a>(<span class="keywordtype">int</span> PageAdr);
<a name="l00074"></a>00074 <span class="keywordtype">void</span> <a class="code" href="class_data_flash___class.html#a8c6c11c560d68667b326e52cc982d370">WriteByte</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> data);
<a name="l00075"></a>00075 <span class="keywordtype">void</span> <a class="code" href="class_data_flash___class.html#ad2cb46986e1be119087204ca546ef5a2">WriteInt</a>(<span class="keywordtype">int</span> data);
<a name="l00076"></a>00076 <span class="keywordtype">void</span> <a class="code" href="class_data_flash___class.html#aea5b8b87899d47b1daabe5e75204f8e9">WriteLong</a>(<span class="keywordtype">long</span> data);
<a name="l00077"></a>00077 <span class="comment">// Read methods</span>
<a name="l00078"></a>00078 <span class="keywordtype">void</span> <a class="code" href="class_data_flash___class.html#af5e4a1c7035f798620666eb58ea29e96">StartRead</a>(<span class="keywordtype">int</span> PageAdr);
<a name="l00079"></a>00079 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="class_data_flash___class.html#afc7e765678010e275d581746bb25cd6f">ReadByte</a>();
<a name="l00080"></a>00080 <span class="keywordtype">int</span> <a class="code" href="class_data_flash___class.html#a3da4020c0dab08fba5d1040c98d1adcc">ReadInt</a>();
<a name="l00081"></a>00081 <span class="keywordtype">long</span> <a class="code" href="class_data_flash___class.html#a389c31bb2e704bf92af0d168021cdaa1">ReadLong</a>();
<a name="l00082"></a>00082 };
<a name="l00083"></a>00083
<a name="l00084"></a>00084 <span class="keyword">extern</span> <a class="code" href="class_data_flash___class.html">DataFlash_Class</a> <a class="code" href="_data_flash_8cpp.html#aa1b5aafe46e4156944e292005b7020fd">DataFlash</a>;
<a name="l00085"></a>00085
<a name="l00086"></a>00086 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>
Generated for ArduPilot Libraries by&nbsp;<a href="http://www.doxygen.org/index.html"><img class="footer" src="doxygen.png" alt="doxygen"/></a></small></address>
</body>
</html>