📄 mmc_8h-source.html
字号:
<!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: mmc.h Source File</title><link href="dox.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.6 --><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="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a></div><h1>mmc.h</h1><a href="mmc_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*! \file mmc.h \brief MultiMedia and SD Flash Card Interface. */</span>00002 <span class="comment">//*****************************************************************************</span>00003 <span class="comment">//</span>00004 <span class="comment">// File Name : 'mmc.h'</span>00005 <span class="comment">// Title : MultiMedia and SD Flash Card Interface</span>00006 <span class="comment">// Author : Pascal Stang - Copyright (C) 2004</span>00007 <span class="comment">// Created : 2004.09.22</span>00008 <span class="comment">// Revised : 2004.09.22</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">// Description : This library offers some simple function which can be used</span>00014 <span class="comment">// to read and write data on a MultiMedia or SecureDigital (SD) Flash</span>00015 <span class="comment">// Card. Although MM and SD Cards are designed to operate with their own</span>00016 <span class="comment">// special bus wiring and protocols, both types of cards also provide a</span>00017 <span class="comment">// simple SPI-like interface mode which is exceptionally useful when </span>00018 <span class="comment">// attempting to use the cards in embedded systems.</span>00019 <span class="comment">//</span>00020 <span class="comment">// To work with this library, the card must be wired to the SPI port of</span>00021 <span class="comment">// the Atmel microcontroller as described below.</span>00022 <span class="comment">// _________________</span>00023 <span class="comment">// / 1 2 3 4 5 6 78 | <- view of MMC/SD card looking at contacts</span>00024 <span class="comment">// / 9 | Pins 8 and 9 are present only on SD cards</span>00025 <span class="comment">// | MMC/SD Card |</span>00026 <span class="comment">// /\/\/\/\/\/\/\/\/\/</span>00027 <span class="comment">//</span>00028 <span class="comment">// 1 - CS (chip select) - wire to any available I/O pin(*)</span>00029 <span class="comment">// 2 - DIN (data in, host->card) - wire to SPI MOSI pin</span>00030 <span class="comment">// 3 - VSS (ground) - wire to ground</span>00031 <span class="comment">// 4 - VDD (power, 3.3V only?) - wire to power (MIGHT BE 3.3V ONLY!)</span>00032 <span class="comment">// 5 - SCLK (data clock) - wire to SPI SCLK pin</span>00033 <span class="comment">// 6 - VSS (ground) - wire to ground</span>00034 <span class="comment">// 7 - DOUT (data out, card->host) - wire to SPI MISO pin</span>00035 <span class="comment">//</span>00036 <span class="comment">// (*) you must define this chip select I/O pin in mmcconf.h</span>00037 <span class="comment">//</span>00038 <span class="comment">// NOTE: This code is currently below version 1.0, and therefore is considered</span>00039 <span class="comment">// to be lacking in some functionality or documentation, or may not be fully</span>00040 <span class="comment">// tested. Nonetheless, you can expect most functions to work.</span>00041 <span class="comment">//</span>00042 <span class="comment">// This code is distributed under the GNU Public License</span>00043 <span class="comment">// which can be found at http://www.gnu.org/licenses/gpl.txt</span>00044 <span class="comment">//</span>00045 <span class="comment">//*****************************************************************************</span>00046 00047 <span class="preprocessor">#ifndef MMC_H</span>00048 <span class="preprocessor"></span><span class="preprocessor">#define MMC_H</span>00049 <span class="preprocessor"></span>00050 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span>00051 00052 <span class="comment">// constants/macros/typdefs</span>00053 <span class="comment">// MMC commands (taken from sandisk MMC reference)</span>00054 <span class="preprocessor">#define MMC_GO_IDLE_STATE 0</span>00055 <span class="preprocessor"></span><span class="preprocessor">#define MMC_SEND_OP_COND 1</span>00056 <span class="preprocessor"></span><span class="preprocessor">#define MMC_SEND_CSD 9</span>00057 <span class="preprocessor"></span><span class="preprocessor">#define MMC_SEND_CID 10</span>00058 <span class="preprocessor"></span><span class="preprocessor">#define MMC_SEND_STATUS 13</span>00059 <span class="preprocessor"></span><span class="preprocessor">#define MMC_SET_BLOCKLEN 16</span>00060 <span class="preprocessor"></span><span class="preprocessor">#define MMC_READ_SINGLE_BLOCK 17</span>00061 <span class="preprocessor"></span><span class="preprocessor">#define MMC_WRITE_BLOCK 24</span>00062 <span class="preprocessor"></span><span class="preprocessor">#define MMC_PROGRAM_CSD 27</span>00063 <span class="preprocessor"></span><span class="preprocessor">#define MMC_SET_WRITE_PROT 28</span>00064 <span class="preprocessor"></span><span class="preprocessor">#define MMC_CLR_WRITE_PROT 29</span>00065 <span class="preprocessor"></span><span class="preprocessor">#define MMC_SEND_WRITE_PROT 30</span>00066 <span class="preprocessor"></span><span class="preprocessor">#define MMC_TAG_SECTOR_START 32</span>00067 <span class="preprocessor"></span><span class="preprocessor">#define MMC_TAG_SECTOR_END 33</span>00068 <span class="preprocessor"></span><span class="preprocessor">#define MMC_UNTAG_SECTOR 34</span>00069 <span class="preprocessor"></span><span class="preprocessor">#define MMC_TAG_ERASE_GROUP_START 35</span>00070 <span class="preprocessor"></span><span class="preprocessor">#define MMC_TAG_ERARE_GROUP_END 36</span>00071 <span class="preprocessor"></span><span class="preprocessor">#define MMC_UNTAG_ERASE_GROUP 37</span>00072 <span class="preprocessor"></span><span class="preprocessor">#define MMC_ERASE 38</span>00073 <span class="preprocessor"></span><span class="preprocessor">#define MMC_CRC_ON_OFF 59</span>00074 <span class="preprocessor"></span><span class="comment">// R1 Response bit-defines</span>00075 <span class="preprocessor">#define MMC_R1_BUSY 0x80</span>00076 <span class="preprocessor"></span><span class="preprocessor">#define MMC_R1_PARAMETER 0x40</span>00077 <span class="preprocessor"></span><span class="preprocessor">#define MMC_R1_ADDRESS 0x20</span>00078 <span class="preprocessor"></span><span class="preprocessor">#define MMC_R1_ERASE_SEQ 0x10</span>00079 <span class="preprocessor"></span><span class="preprocessor">#define MMC_R1_COM_CRC 0x08</span>00080 <span class="preprocessor"></span><span class="preprocessor">#define MMC_R1_ILLEGAL_COM 0x04</span>00081 <span class="preprocessor"></span><span class="preprocessor">#define MMC_R1_ERASE_RESET 0x02</span>00082 <span class="preprocessor"></span><span class="preprocessor">#define MMC_R1_IDLE_STATE 0x01</span>00083 <span class="preprocessor"></span><span class="comment">// Data Start tokens</span>00084 <span class="preprocessor">#define MMC_STARTBLOCK_READ 0xFE</span>00085 <span class="preprocessor"></span><span class="preprocessor">#define MMC_STARTBLOCK_WRITE 0xFE</span>00086 <span class="preprocessor"></span><span class="preprocessor">#define MMC_STARTBLOCK_MWRITE 0xFC</span>00087 <span class="preprocessor"></span><span class="comment">// Data Stop tokens</span>00088 <span class="preprocessor">#define MMC_STOPTRAN_WRITE 0xFD</span>00089 <span class="preprocessor"></span><span class="comment">// Data Error Token values</span>00090 <span class="preprocessor">#define MMC_DE_MASK 0x1F</span>00091 <span class="preprocessor"></span><span class="preprocessor">#define MMC_DE_ERROR 0x01</span>00092 <span class="preprocessor"></span><span class="preprocessor">#define MMC_DE_CC_ERROR 0x02</span>00093 <span class="preprocessor"></span><span class="preprocessor">#define MMC_DE_ECC_FAIL 0x04</span>00094 <span class="preprocessor"></span><span class="preprocessor">#define MMC_DE_OUT_OF_RANGE 0x04</span>00095 <span class="preprocessor"></span><span class="preprocessor">#define MMC_DE_CARD_LOCKED 0x04</span>00096 <span class="preprocessor"></span><span class="comment">// Data Response Token values</span>00097 <span class="preprocessor">#define MMC_DR_MASK 0x1F</span>00098 <span class="preprocessor"></span><span class="preprocessor">#define MMC_DR_ACCEPT 0x05</span>00099 <span class="preprocessor"></span><span class="preprocessor">#define MMC_DR_REJECT_CRC 0x0B</span>00100 <span class="preprocessor"></span><span class="preprocessor">#define MMC_DR_REJECT_WRITE_ERROR 0x0D</span>00101 <span class="preprocessor"></span>00102 <span class="comment">// functions</span>00103 <span class="comment"></span>00104 <span class="comment">//! Initialize hardware interface</span>00105 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="mmc_8c.html#a0">mmcInit</a>(<span class="keywordtype">void</span>);00106 <span class="comment"></span>00107 <span class="comment">//! Initialize the card and prepare it for use</span>00108 <span class="comment"></span><span class="comment">// returns zero if successful</span>00109 u08 <a class="code" href="mmc_8c.html#a1">mmcReset</a>(<span class="keywordtype">void</span>);00110 <span class="comment"></span>00111 <span class="comment">//! Send card an MMC command</span>00112 <span class="comment"></span><span class="comment">// returns R1 result code</span>00113 u08 <a class="code" href="mmc_8h.html#a44">mmcSendCommand</a>(u08 cmd, u32 arg);00114 <span class="comment"></span>00115 <span class="comment">//! Read 512-byte sector from card to buffer</span>00116 <span class="comment"></span><span class="comment">// returns zero if successful</span>00117 u08 <a class="code" href="mmc_8h.html#a45">mmcRead</a>(u32 sector, u08* buffer);<span class="comment"></span>00118 <span class="comment">//! Write 512-byte sector from buffer to card</span>00119 <span class="comment"></span><span class="comment">// returns zero if successful</span>00120 u08 <a class="code" href="mmc_8h.html#a46">mmcWrite</a>(u32 sector, u08* buffer);00121 <span class="comment"></span>00122 <span class="comment">//! internal command function</span>00123 <span class="comment"></span>u08 <a class="code" href="mmc_8h.html#a47">mmcCommand</a>(u08 cmd, u32 arg);00124 00125 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Oct 15 03:50:22 2004 for Procyon AVRlib by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 > </a>1.3.6 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -