Sensor-Watch/group__storage.html
2025-03-08 22:43:34 +00:00

235 lines
14 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Sensor Watch: Flash Storage</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">Sensor Watch<span id="projectnumber">&#160;0.0.2</span>
</div>
<div id="projectbrief">A board replacement for the classic Casio F-91W wristwatch, powered by a Microchip SAM L22 microcontroller.</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.12.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search',false);
$(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="doc-content">
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#func-members">Functions</a> </div>
<div class="headertitle"><div class="title">Flash Storage</div></div>
</div><!--header-->
<div class="contents">
<p>This section covers functions related to the SAM L22's 8 kilobyte EEPROM emulation area.
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gae11f49f5d9adee2ee89ec92c8026ca49" id="r_gae11f49f5d9adee2ee89ec92c8026ca49"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#gae11f49f5d9adee2ee89ec92c8026ca49">watch_storage_read</a> (uint32_t row, uint32_t offset, uint8_t *buffer, uint32_t size)</td></tr>
<tr class="memdesc:gae11f49f5d9adee2ee89ec92c8026ca49"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reads a range of bytes from the storage area. <br /></td></tr>
<tr class="separator:gae11f49f5d9adee2ee89ec92c8026ca49"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad0fd4b333d95a0e50ac8e9a23620b861" id="r_gad0fd4b333d95a0e50ac8e9a23620b861"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#gad0fd4b333d95a0e50ac8e9a23620b861">watch_storage_write</a> (uint32_t row, uint32_t offset, const uint8_t *buffer, uint32_t size)</td></tr>
<tr class="memdesc:gad0fd4b333d95a0e50ac8e9a23620b861"><td class="mdescLeft">&#160;</td><td class="mdescRight">Writes bytes to a page in the storage area. Note that the row should already be erased before writing. <br /></td></tr>
<tr class="separator:gad0fd4b333d95a0e50ac8e9a23620b861"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5e27f4d34bd3b602988af59c6068bd0c" id="r_ga5e27f4d34bd3b602988af59c6068bd0c"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ga5e27f4d34bd3b602988af59c6068bd0c">watch_storage_erase</a> (uint32_t row)</td></tr>
<tr class="memdesc:ga5e27f4d34bd3b602988af59c6068bd0c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Erases a row in the storage area, setting all its bytes to 0xFF. <br /></td></tr>
<tr class="separator:ga5e27f4d34bd3b602988af59c6068bd0c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga6531bfebac4e4f81fd37168fdaa98904" id="r_ga6531bfebac4e4f81fd37168fdaa98904"><td class="memItemLeft" align="right" valign="top"><a id="ga6531bfebac4e4f81fd37168fdaa98904" name="ga6531bfebac4e4f81fd37168fdaa98904"></a>
bool&#160;</td><td class="memItemRight" valign="bottom"><b>watch_storage_sync</b> (void)</td></tr>
<tr class="memdesc:ga6531bfebac4e4f81fd37168fdaa98904"><td class="mdescLeft">&#160;</td><td class="mdescRight">Waits for any pending writes to complete. <br /></td></tr>
<tr class="separator:ga6531bfebac4e4f81fd37168fdaa98904"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>This section covers functions related to the SAM L22's 8 kilobyte EEPROM emulation area. </p>
<p>The SAM L22 inside Sensor Watch has a 256 kilobyte Flash memory array that can be programmed with whatever data we want. We use most of it to store the bootloader and the application code that runs on your wrist. The bootloader region is read-only, and the main application area is only writable by the bootloader (when you drag new code onto the WATCHBOOT drive). However! there's also a special 8 kilobyte region at the end of the Flash memory called the EEPROM Emulation Area. This EEPROM emulation area can be written or erased while the main Flash array is being read. This makes it super easy to work with, and useful for storing a small amount of non-volatile data that persists across reboots, even when power is lost. The functions in this section are very basic, and only cover reading and writing data in this area. The region is laid out as 32 rows consisting of 4 pages of 64 bytes. 32*4*64 = 8192 bytes. The area can be written one page at a time, but it can only be erased one row at a time. You can read at arbitrary word-aligned offsets within a row. </p><pre class="fragment"> ┌──────────────┬──────────────┬──────────────┬──────────────┐
</pre><p> Row 0 │ 64 bytes │ 64 bytes │ 64 bytes │ 64 bytes │ ├──────────────┼──────────────┼──────────────┼──────────────┤ Row 1 │ 64 bytes │ 64 bytes │ 64 bytes │ 64 bytes │ ├──────────────┼──────────────┼──────────────┼──────────────┤ ... │ │ │ │ │ ├──────────────┼──────────────┼──────────────┼──────────────┤ Row 31 │ 64 bytes │ 64 bytes │ 64 bytes │ 64 bytes │ └──────────────┴──────────────┴──────────────┴──────────────┘ </p>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga5e27f4d34bd3b602988af59c6068bd0c" name="ga5e27f4d34bd3b602988af59c6068bd0c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5e27f4d34bd3b602988af59c6068bd0c">&#9670;&#160;</a></span>watch_storage_erase()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool watch_storage_erase </td>
<td>(</td>
<td class="paramtype">uint32_t</td> <td class="paramname"><span class="paramname"><em>row</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Erases a row in the storage area, setting all its bytes to 0xFF. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">row</td><td>The row you want to erase. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="gae11f49f5d9adee2ee89ec92c8026ca49" name="gae11f49f5d9adee2ee89ec92c8026ca49"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae11f49f5d9adee2ee89ec92c8026ca49">&#9670;&#160;</a></span>watch_storage_read()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool watch_storage_read </td>
<td>(</td>
<td class="paramtype">uint32_t</td> <td class="paramname"><span class="paramname"><em>row</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t</td> <td class="paramname"><span class="paramname"><em>offset</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t *</td> <td class="paramname"><span class="paramname"><em>buffer</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t</td> <td class="paramname"><span class="paramname"><em>size</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Reads a range of bytes from the storage area. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">row</td><td>The row you want to read. </td></tr>
<tr><td class="paramname">offset</td><td>The offset from the beginning of the row. </td></tr>
<tr><td class="paramname">buffer</td><td>A buffer of at least <code>size</code> bytes. </td></tr>
<tr><td class="paramname">size</td><td>The number of bytes you wish to read. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="gad0fd4b333d95a0e50ac8e9a23620b861" name="gad0fd4b333d95a0e50ac8e9a23620b861"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad0fd4b333d95a0e50ac8e9a23620b861">&#9670;&#160;</a></span>watch_storage_write()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool watch_storage_write </td>
<td>(</td>
<td class="paramtype">uint32_t</td> <td class="paramname"><span class="paramname"><em>row</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t</td> <td class="paramname"><span class="paramname"><em>offset</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const uint8_t *</td> <td class="paramname"><span class="paramname"><em>buffer</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t</td> <td class="paramname"><span class="paramname"><em>size</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Writes bytes to a page in the storage area. Note that the row should already be erased before writing. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">row</td><td>The row containing the page you want to write. </td></tr>
<tr><td class="paramname">offset</td><td>The offset from the beginning of the row. Must be a multiple of 64. </td></tr>
<tr><td class="paramname">buffer</td><td>The buffer containing the bytes you wish to set. </td></tr>
<tr><td class="paramname">size</td><td>The number of bytes you wish to write. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0
</small></address>
</div><!-- doc-content -->
</body>
</html>