資源簡(jiǎn)介
本程序是基于stm32f407vet6的SPI2操作SD卡,移植了FatFS文件系統(tǒng),代碼中有uC/OS-III的任務(wù)函數(shù),不需要可以刪除,本代碼只需要修改SPI接口和片選口就可以工作,在SD卡上電前,請(qǐng)先把SD卡格式化成FatFS支持的格式。

代碼片段和文件信息
/*
*********************************************************************************************************
*
*?Filename??????:?sdcard.c
*?Version???????:?V1.00
*?Programmer(s)?:?匡欣欣
*?????????????????
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*?????????????????????????????????????????????INCLUDE?FILES
*********************************************************************************************************
*/
#include??“sdcard.h“
#include??“ff.h“
#include??“app_cfg.h“
#include??“usercfg.h“
#include??“spi.h“
/*
*********************************************************************************************************
*????????????????????????????????????????????LOCAL?DEFINES(局部定義)
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*???????????????????????????????????????????LOCAL?CONSTANTS(局部常數(shù))
*********************************************************************************************************
*/
#define?SD_MSG_MAX 5
/*
*********************************************************************************************************
*??????????????????????????????????????????LOCAL?DATA?TYPES(本地?cái)?shù)據(jù)類(lèi)型)
*********************************************************************************************************
*/
static?FIL??????????gFilewFilevFile;
static?FATFS????????gFatFs;
SD_StatusFlag???????SD_Status;
static?BYTE?????????CardType;??????????????????????????????/*?Card?type?flags?*/
static?volatile?DSTATUS?Stat?=?STA_NOINIT; ???????????????/*?Physical?drive?status??????????*/
/*
*********************************************************************************************************
*????????????????????????????????????????????LOCAL?TABLES(本地表)
*********************************************************************************************************
*/
const?char?*pFileName[]?=?
{
“Pwrdw.dat“
“WRec1.dat“
“WRec2.dat“
“Para.dat“
“Idx.dat“
};
static?SD_MSG?SDMsg[SD_MSG_MAX];
/*
*********************************************************************************************************
*???????????????????????????????????????LOCAL?GLOBAL?VARIABLES(局部全局變量)
*********************************************************************************************************
*/
static?int?CheckFileStored(void);
/*----------------------------------------------------------------------------*/
/*?SD?card?bus?interface?initialization???????????????????????????????????????*/
/*----------------------------------------------------------------------------*/
static
void?MSD_Config(void)
{
????GPIO_InitTypeDef????GPIO_InitStructure;
?
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件???????2815??2012-07-25?00:19??FatFS\doc\css_e.css
?????文件???????3177??2012-07-25?00:19??FatFS\doc\css_j.css
?????文件???????1414??2011-09-02?22:10??FatFS\doc\img\f1.png
?????文件???????1458??2007-02-10?03:12??FatFS\doc\img\f2.png
?????文件???????1039??2007-02-10?03:12??FatFS\doc\img\f3.png
?????文件???????2335??2008-01-05?20:27??FatFS\doc\img\f4.png
?????文件???????2479??2008-01-05?20:27??FatFS\doc\img\f5.png
?????文件???????1436??2010-08-21?10:13??FatFS\doc\img\f6.png
?????文件???????2401??2009-03-20?21:57??FatFS\doc\img\la
?????文件???????2379??2009-06-13?21:48??FatFS\doc\img\la
?????文件???????5209??2012-07-27?01:26??FatFS\doc\img\modules.png
?????文件??????19068??2008-10-18?19:31??FatFS\doc\img\rwtest.png
?????文件???????8153??2010-09-13?10:55??FatFS\doc\img\rwtest2.png
?????文件???????3011??2009-06-15?00:03??FatFS\doc\img\rwtest3.png
?????文件???????4185??2012-08-27?21:56??FatFS\doc\updates.txt
?????文件??????18851??2015-09-09?16:48??FatFS\exfuns\exfuns.c
?????文件???????2362??2015-08-22?14:52??FatFS\exfuns\exfuns.h
?????文件???????1233??2015-08-14?20:05??FatFS\exfuns\fattester.c
?????文件???????1395??2015-08-14?19:56??FatFS\exfuns\fattester.h
?????文件???????4620??2015-08-14?20:07??FatFS\exfuns\mycc936.c
?????文件??????31870??2016-04-12?14:26??FatFS\sdcard.c
?????文件???????9262??2016-04-12?14:27??FatFS\sdcard.h
?????文件??????12281??2016-04-12?14:27??FatFS\spi.c
?????文件???????1744??2016-04-12?14:28??FatFS\spi.h
?????文件???????5371??2016-04-11?17:31??FatFS\src\diskio.c
?????文件???????2581??2016-04-11?21:21??FatFS\src\diskio.h
?????文件?????153824??2016-04-12?13:20??FatFS\src\ff.c
?????文件??????13189??2016-04-12?13:23??FatFS\src\ff.h
?????文件???????8604??2016-04-12?11:09??FatFS\src\ffconf.h
?????文件????????706??2014-05-19?11:34??FatFS\src\integer.h
............此處省略20個(gè)文件信息
評(píng)論
共有 條評(píng)論