?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 6

Line No. Rev Author Line
1 6 kaklik <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3 <title>Procyon AVRlib: mmc.h Source File</title>
4 <link href="dox.css" rel="stylesheet" type="text/css">
5 </head><body>
6 <!-- Generated by Doxygen 1.4.2 -->
7 <div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
8 <h1>mmc.h</h1><a href="mmc_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file mmc.h \brief MultiMedia and SD Flash Card Interface. */</span>
9 00002 <span class="comment">//*****************************************************************************</span>
10 00003 <span class="comment">//</span>
11 00004 <span class="comment">// File Name : 'mmc.h'</span>
12 00005 <span class="comment">// Title : MultiMedia and SD Flash Card Interface</span>
13 00006 <span class="comment">// Author : Pascal Stang - Copyright (C) 2004</span>
14 00007 <span class="comment">// Created : 2004.09.22</span>
15 00008 <span class="comment">// Revised : 2004.09.22</span>
16 00009 <span class="comment">// Version : 0.1</span>
17 00010 <span class="comment">// Target MCU : Atmel AVR Series</span>
18 00011 <span class="comment">// Editor Tabs : 4</span>
19 00012 <span class="comment">//</span><span class="comment"></span>
20 00013 <span class="comment">/// \ingroup driver_hw</span>
21 00014 <span class="comment">/// \defgroup mmc MultiMedia and SD Flash Card Interface (mmc.c)</span>
22 00015 <span class="comment">/// \code #include "mmc.h" \endcode</span>
23 00016 <span class="comment">/// \par Description</span>
24 00017 <span class="comment">/// This library offers some simple functions which can be used</span>
25 00018 <span class="comment">/// to read and write data on a MultiMedia or SecureDigital (SD) Flash</span>
26 00019 <span class="comment">/// Card. Although MM and SD Cards are designed to operate with their own</span>
27 00020 <span class="comment">/// special bus wiring and protocols, both types of cards also provide a</span>
28 00021 <span class="comment">/// simple SPI-like interface mode which is exceptionally useful when </span>
29 00022 <span class="comment">/// attempting to use the cards in embedded systems.</span>
30 00023 <span class="comment">///</span>
31 00024 <span class="comment">/// \par Wiring</span>
32 00025 <span class="comment">/// To work with this library, the card must be wired to the SPI port of</span>
33 00026 <span class="comment">/// the Atmel microcontroller as described below. Typical cards can</span>
34 00027 <span class="comment">/// operate at up to 25MHz maximum SPI clock rate (thus faster than most</span>
35 00028 <span class="comment">/// AVR's maximum SPI clock rate).</span>
36 00029 <span class="comment">/// &lt;pre&gt;</span>
37 00030 <span class="comment">/// _________________</span>
38 00031 <span class="comment">/// / 1 2 3 4 5 6 78 | &lt;- view of MMC/SD card looking at contacts</span>
39 00032 <span class="comment">/// / 9 | Pins 8 and 9 are present only on SD cards</span>
40 00033 <span class="comment">/// | MMC/SD Card |</span>
41 00034 <span class="comment">/// | |</span>
42 00035 <span class="comment">/// /\/\/\/\/\/\/\/\/\/\</span>
43 00036 <span class="comment">/// 1 - CS (chip select) - wire to any available I/O pin(*)</span>
44 00037 <span class="comment">/// 2 - DIN (data in, card&lt;-host) - wire to SPI MOSI pin</span>
45 00038 <span class="comment">/// 3 - VSS (ground) - wire to ground</span>
46 00039 <span class="comment">/// 4 - VDD (power, 3.3V only?) - wire to power (MIGHT BE 3.3V ONLY!)</span>
47 00040 <span class="comment">/// 5 - SCLK (data clock) - wire to SPI SCK pin</span>
48 00041 <span class="comment">/// 6 - VSS (ground) - wire to ground</span>
49 00042 <span class="comment">/// 7 - DOUT (data out, card-&gt;host) - wire to SPI MISO pin</span>
50 00043 <span class="comment">///</span>
51 00044 <span class="comment">/// (*) you must define this chip select I/O pin in mmcconf.h</span>
52 00045 <span class="comment">/// &lt;/pre&gt;</span>
53 00046 <span class="comment">/// \note This code is currently below version 1.0, and therefore is considered</span>
54 00047 <span class="comment">/// to be lacking in some functionality or documentation, or may not be fully</span>
55 00048 <span class="comment">/// tested. Nonetheless, you can expect most functions to work.</span>
56 00049 <span class="comment"></span><span class="comment">//</span>
57 00050 <span class="comment">// This code is distributed under the GNU Public License</span>
58 00051 <span class="comment">// which can be found at http://www.gnu.org/licenses/gpl.txt</span>
59 00052 <span class="comment">//</span>
60 00053 <span class="comment">//*****************************************************************************</span><span class="comment"></span>
61 00054 <span class="comment">//@{</span>
62 00055 <span class="comment"></span>
63 00056 <span class="preprocessor">#ifndef MMC_H</span>
64 00057 <span class="preprocessor"></span><span class="preprocessor">#define MMC_H</span>
65 00058 <span class="preprocessor"></span>
66 00059 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span>
67 00060
68 00061 <span class="comment">// constants/macros/typdefs</span>
69 00062 <span class="comment">// MMC commands (taken from sandisk MMC reference)</span>
70 <a name="l00063"></a><a class="code" href="group__mmc.html#ga6">00063</a> <span class="preprocessor">#define MMC_GO_IDLE_STATE 0 </span><span class="comment">///&lt; initialize card to SPI-type access</span>
71 <a name="l00064"></a><a class="code" href="group__mmc.html#ga7">00064</a> <span class="comment"></span>#define MMC_SEND_OP_COND 1 <span class="comment">///&lt; set card operational mode</span>
72 <a name="l00065"></a><a class="code" href="group__mmc.html#ga8">00065</a> <span class="comment"></span>#define MMC_SEND_CSD 9 <span class="comment">///&lt; get card's CSD</span>
73 <a name="l00066"></a><a class="code" href="group__mmc.html#ga9">00066</a> <span class="comment"></span>#define MMC_SEND_CID 10 <span class="comment">///&lt; get card's CID</span>
74 00067 <span class="comment"></span>#define MMC_SEND_STATUS 13
75 <a name="l00068"></a><a class="code" href="group__mmc.html#ga11">00068</a> <span class="preprocessor">#define MMC_SET_BLOCKLEN 16 </span><span class="comment">///&lt; Set number of bytes to transfer per block</span>
76 <a name="l00069"></a><a class="code" href="group__mmc.html#ga12">00069</a> <span class="comment"></span>#define MMC_READ_SINGLE_BLOCK 17 <span class="comment">///&lt; read a block</span>
77 <a name="l00070"></a><a class="code" href="group__mmc.html#ga13">00070</a> <span class="comment"></span>#define MMC_WRITE_BLOCK 24 <span class="comment">///&lt; write a block</span>
78 00071 <span class="comment"></span>#define MMC_PROGRAM_CSD 27
79 00072 <span class="preprocessor">#define MMC_SET_WRITE_PROT 28</span>
80 00073 <span class="preprocessor"></span><span class="preprocessor">#define MMC_CLR_WRITE_PROT 29</span>
81 00074 <span class="preprocessor"></span><span class="preprocessor">#define MMC_SEND_WRITE_PROT 30</span>
82 00075 <span class="preprocessor"></span><span class="preprocessor">#define MMC_TAG_SECTOR_START 32</span>
83 00076 <span class="preprocessor"></span><span class="preprocessor">#define MMC_TAG_SECTOR_END 33</span>
84 00077 <span class="preprocessor"></span><span class="preprocessor">#define MMC_UNTAG_SECTOR 34</span>
85 <a name="l00078"></a><a class="code" href="group__mmc.html#ga21">00078</a> <span class="preprocessor"></span><span class="preprocessor">#define MMC_TAG_ERASE_GROUP_START 35 </span><span class="comment">///&lt; Sets beginning of erase group (mass erase)</span>
86 <a name="l00079"></a><a class="code" href="group__mmc.html#ga22">00079</a> <span class="comment"></span>#define MMC_TAG_ERARE_GROUP_END 36 <span class="comment">///&lt; Sets end of erase group (mass erase)</span>
87 <a name="l00080"></a><a class="code" href="group__mmc.html#ga23">00080</a> <span class="comment"></span>#define MMC_UNTAG_ERASE_GROUP 37 <span class="comment">///&lt; Untag (unset) erase group (mass erase)</span>
88 <a name="l00081"></a><a class="code" href="group__mmc.html#ga24">00081</a> <span class="comment"></span>#define MMC_ERASE 38 <span class="comment">///&lt; Perform block/mass erase</span>
89 <a name="l00082"></a><a class="code" href="group__mmc.html#ga25">00082</a> <span class="comment"></span>#define MMC_CRC_ON_OFF 59 <span class="comment">///&lt; Turns CRC check on/off</span>
90 00083 <span class="comment"></span>// R1 Response bit-defines
91 <a name="l00084"></a><a class="code" href="group__mmc.html#ga26">00084</a> <span class="preprocessor">#define MMC_R1_BUSY 0x80 </span><span class="comment">///&lt; R1 response: bit indicates card is busy</span>
92 00085 <span class="comment"></span>#define MMC_R1_PARAMETER 0x40
93 00086 <span class="preprocessor">#define MMC_R1_ADDRESS 0x20</span>
94 00087 <span class="preprocessor"></span><span class="preprocessor">#define MMC_R1_ERASE_SEQ 0x10</span>
95 00088 <span class="preprocessor"></span><span class="preprocessor">#define MMC_R1_COM_CRC 0x08</span>
96 00089 <span class="preprocessor"></span><span class="preprocessor">#define MMC_R1_ILLEGAL_COM 0x04</span>
97 00090 <span class="preprocessor"></span><span class="preprocessor">#define MMC_R1_ERASE_RESET 0x02</span>
98 00091 <span class="preprocessor"></span><span class="preprocessor">#define MMC_R1_IDLE_STATE 0x01</span>
99 00092 <span class="preprocessor"></span><span class="comment">// Data Start tokens</span>
100 <a name="l00093"></a><a class="code" href="group__mmc.html#ga34">00093</a> <span class="preprocessor">#define MMC_STARTBLOCK_READ 0xFE </span><span class="comment">///&lt; when received from card, indicates that a block of data will follow</span>
101 <a name="l00094"></a><a class="code" href="group__mmc.html#ga35">00094</a> <span class="comment"></span>#define MMC_STARTBLOCK_WRITE 0xFE <span class="comment">///&lt; when sent to card, indicates that a block of data will follow</span>
102 00095 <span class="comment"></span>#define MMC_STARTBLOCK_MWRITE 0xFC
103 00096 <span class="comment">// Data Stop tokens</span>
104 00097 <span class="preprocessor">#define MMC_STOPTRAN_WRITE 0xFD</span>
105 00098 <span class="preprocessor"></span><span class="comment">// Data Error Token values</span>
106 00099 <span class="preprocessor">#define MMC_DE_MASK 0x1F</span>
107 00100 <span class="preprocessor"></span><span class="preprocessor">#define MMC_DE_ERROR 0x01</span>
108 00101 <span class="preprocessor"></span><span class="preprocessor">#define MMC_DE_CC_ERROR 0x02</span>
109 00102 <span class="preprocessor"></span><span class="preprocessor">#define MMC_DE_ECC_FAIL 0x04</span>
110 00103 <span class="preprocessor"></span><span class="preprocessor">#define MMC_DE_OUT_OF_RANGE 0x04</span>
111 00104 <span class="preprocessor"></span><span class="preprocessor">#define MMC_DE_CARD_LOCKED 0x04</span>
112 00105 <span class="preprocessor"></span><span class="comment">// Data Response Token values</span>
113 00106 <span class="preprocessor">#define MMC_DR_MASK 0x1F</span>
114 00107 <span class="preprocessor"></span><span class="preprocessor">#define MMC_DR_ACCEPT 0x05</span>
115 00108 <span class="preprocessor"></span><span class="preprocessor">#define MMC_DR_REJECT_CRC 0x0B</span>
116 00109 <span class="preprocessor"></span><span class="preprocessor">#define MMC_DR_REJECT_WRITE_ERROR 0x0D</span>
117 00110 <span class="preprocessor"></span>
118 00111 <span class="comment">// functions</span>
119 00112 <span class="comment"></span>
120 00113 <span class="comment">//! Initialize AVR&lt;-&gt;MMC hardware interface.</span>
121 00114 <span class="comment">/// Prepares hardware for MMC access.</span>
122 00115 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__mmc.html#ga0">mmcInit</a>(<span class="keywordtype">void</span>);
123 00116 <span class="comment"></span>
124 00117 <span class="comment">//! Initialize the card and prepare it for use.</span>
125 00118 <span class="comment">/// Returns zero if successful.</span>
126 00119 <span class="comment"></span>u08 <a class="code" href="group__mmc.html#ga1">mmcReset</a>(<span class="keywordtype">void</span>);
127 00120 <span class="comment"></span>
128 00121 <span class="comment">//! Send card an MMC command.</span>
129 00122 <span class="comment">/// Returns R1 result code.</span>
130 00123 <span class="comment"></span>u08 <a class="code" href="group__mmc.html#ga2">mmcSendCommand</a>(u08 cmd, u32 arg);
131 00124 <span class="comment"></span>
132 00125 <span class="comment">//! Read 512-byte sector from card to buffer</span>
133 00126 <span class="comment">/// Returns zero if successful.</span>
134 00127 <span class="comment"></span>u08 <a class="code" href="group__mmc.html#ga3">mmcRead</a>(u32 sector, u08* buffer);
135 00128 <span class="comment"></span>
136 00129 <span class="comment">//! Write 512-byte sector from buffer to card</span>
137 00130 <span class="comment">/// Returns zero if successful.</span>
138 00131 <span class="comment"></span>u08 <a class="code" href="group__mmc.html#ga4">mmcWrite</a>(u32 sector, u08* buffer);
139 00132 <span class="comment"></span>
140 00133 <span class="comment">//! Internal command function.</span>
141 00134 <span class="comment">/// Issues a generic MMC command as specified by cmd and arg.</span>
142 00135 <span class="comment"></span>u08 <a class="code" href="group__mmc.html#ga5">mmcCommand</a>(u08 cmd, u32 arg);
143 00136
144 00137 <span class="preprocessor">#endif</span>
145 00138 <span class="preprocessor"></span><span class="comment">//@}</span>
146 </span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:07 2006 for Procyon AVRlib by&nbsp;
147 <a href="http://www.doxygen.org/index.html">
148 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address>
149 </body>
150 </html>
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3