• 大小: 103KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-23
  • 语言: 其他
  • 标签: MSP430F149  SD  

资源简介

MSP430F149的SD卡模块驱动

资源截图

代码片段和文件信息

//-------------------------------------------------------------------------
/*FAT16.C - LINO TECH
  Designed by Carter
  2008-03-19
*/

#include 

#include “FAT16.h“
#include “sd.h“
//------------------------------------------------------------------------
#define SEC_Size 512
#define MBR_Sector 0 //绝对地址
#define FAT_Sector 0 //逻辑地址
//-------------------------------------------------------------------------
uint8_t BUFFER[SEC_Size];
uint8_t PB_RelativeSector;
uint16_t BPB_BytesPerSec;
uint8_t BPB_SecPerClus;
uint16_t BPB_RsvdSecCnt;
uint8_t BPB_NumFATs;
uint16_t BPB_RootEntCnt;
uint16_t BPB_TotSec16;
uint16_t BPB_FATSz16; //FAT占用的sectors
uint32_t BPB_HiddSec;
//-------------------------------------------------------------------------
uint8_t ReadSector(uint32_t sector uint8_t* buffer )
{
    int8 stat;
    
    hwInterface sdNow;  
    sdNow.sectorCount = 1;
    stat = sd_readSector(&sdNowsectorbuffer512);
    
    if(stat==0)
    {
        return SD_SUCC;
    }
    else
    {
        return SD_FAIL;
    };
}
uint8_t WriteSector(uint32_t sector uint8_t* buffer)
{
    hwInterface sdNow;  
    sdNow.sectorCount = 1;
    sd_writeSector(&sdNowsectorbuffer);
    
    return 0;
}

uint8_t ReadBlock(uint32_t LBA){ //绝对地址读一个扇区
if(ReadSector(LBABUFFER)!=0)return SD_FAIL;
return SD_SUCC;
}
//-------------------------------------------------------------------------
uint8_t WriteBlock(uint32_t LBA){ //绝对地址写一个扇区
if(WriteSector(LBABUFFER)!=0)return SD_FAIL;
return SD_SUCC;
}
//-------------------------------------------------------------------------
uint8_t ReadFatBlock(uint32_t Add){ //逻辑地址读一个扇区
// return ReadBlock(Add+PB_RelativeSector);  //for HardDisk
   return ReadBlock(Add+BPB_HiddSec);
}
//-------------------------------------------------------------------------
uint8_t WriteFatBlock(uint32_t Add){ //逻辑地址写一个扇区
// return WriteBlock(Add+PB_RelativeSector);  //for HardDisk
    return WriteBlock(Add+BPB_HiddSec);
}
//-------------------------------------------------------------------------
void CopyBytes(uint8_t *psuint8_t *pduint16_t size){ //内存拷贝
for(;size;size--)*pd++=*ps++;
}
//-------------------------------------------------------------------------
uint8_t IsEqual(uint8_t *pauint8_t *pbuint8_t size){ //内存比较
for(;size;size--)if(*pa++!=*pb++)return 0;
return 1;
}
//-------------------------------------------------------------------------
void EmptyBytes(uint8_t *pduint16_t size){ //内存清空
for(;size;size--)*pd++ =0;
}
//-------------------------------------------------------------------------
uint8_t ReadMBR(void){ //读取MBR数据结构
uint8_t ok;
FAT_MBR * MBR=(FAT_MBR*)BUFFER;
ok=ReadBlock(MBR_Sector);
if(ok==SD_FAIL)return SD_FAIL;
if(MBR->MBR_Signature!=0xAA55)return SD_FAIL; //读有效标志

//获取参数
PB_RelativeSector=MBR->MBR_pb[0].PB_RelativeSector;//读逻辑地址与绝对地址的偏移
return SD_SUCC;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      38569  2007-06-16 19:01  SD_FAT\Debug\Exe\PCF8563.d43

     文件      41448  2008-01-25 22:27  SD_FAT\Debug\Exe\SD.d43

     文件      59309  2008-03-20 02:23  SD_FAT\Debug\Exe\SD_FAT.d43

     文件      61761  2008-03-20 02:23  SD_FAT\Debug\Obj\FAT16.r43

     文件      13056  2008-03-20 02:23  SD_FAT\Debug\Obj\main.r43

     文件        116  2007-06-19 16:15  SD_FAT\Debug\Obj\PCF8563.pbd

     文件        154  2008-03-19 22:43  SD_FAT\Debug\Obj\SD.pbd

     文件      39148  2008-03-20 00:17  SD_FAT\Debug\Obj\sd.r43

     文件        206  2008-03-20 02:23  SD_FAT\Debug\Obj\SD_FAT.pbd

     文件      11230  2008-03-20 09:36  SD_FAT\FAT16.c

     文件       2550  2008-03-20 09:36  SD_FAT\FAT16.h

     文件       2597  2008-03-20 09:36  SD_FAT\main.c

     文件       9797  2008-03-19 23:42  SD_FAT\sd.c

     文件       3418  2007-06-19 16:45  SD_FAT\sd.h

     文件       4151  2008-03-20 02:25  SD_FAT\SD_FAT.dep

     文件      11915  2008-03-19 23:48  SD_FAT\SD_FAT.ewd

     文件      44308  2008-03-19 23:14  SD_FAT\SD_FAT.ewp

     文件        160  2008-03-19 23:14  SD_FAT\SD_FAT.eww

     文件       6055  2007-06-19 16:23  SD_FAT\settings\PCF8563.dbgdt

     文件        937  2007-06-19 16:23  SD_FAT\settings\PCF8563.dni

     文件       3334  2007-06-19 17:19  SD_FAT\settings\PCF8563.wsdt

     文件       5097  2008-01-25 22:31  SD_FAT\settings\SD.dbgdt

     文件        996  2008-03-19 22:46  SD_FAT\settings\SD.dni

     文件       3324  2008-03-19 22:45  SD_FAT\settings\SD.wsdt

     文件       6114  2008-03-20 02:25  SD_FAT\settings\SD_FAT.dbgdt

     文件        996  2008-03-20 02:25  SD_FAT\settings\SD_FAT.dni

     文件       4222  2008-03-20 02:25  SD_FAT\settings\SD_FAT.wsdt

     文件        623  2008-03-19 23:25  SD_FAT\xtype.h

    ...D..R         0  2013-04-21 20:21  SD_FAT\Debug\Exe

    ...D..R         0  2009-11-12 15:14  SD_FAT\Debug\List

............此处省略7个文件信息

评论

共有 条评论