📄 storage.c
字号:
/*
**********************************************************************************************
* Project: FS7805 SD CARD READER
* File: main.c
* Contents:
* The main function is SD and MMC card reader.
*
* $Date: 12/15/06 Derek V1.0
*
* Coments: This is the SD/MMC card reader firmware.
* When read sector,the 512 pingpong FIFO mechanism
* is used to improve performance.But when write sector,
* only single FIFO is used.
*
* $Date: 12/27/06 Derek V1.1
*
* The 512 pingpong FIFO mechanism is also used when
* writting sectors.
*
* $Date: 01/09/07 Derek V1.11
*
* Fix read sector error bug .
* Don't set FIFO_FULL bit in SetBulkInFull() function.
* Setting it in BulkSetDmaIn() function.
*
* $Date: 01/18/07 Derek V1.11
*
* Ignor the OUT_OF_RANGE error in SdSendCmd() when
* multi read the last block.
*
* $Date: 03/29/07 Derek V1.2
*
* Add TDES module for data encrypt and decrypt.
*
* Copyright (c) 2007 Fameg, Inc. All rights reserved
*
*
***********************************************************************************************
*/
#include "include\Include.h"
#include "diskio.h" /* Include file for user provided functions */
INT16U CmdTimer; //modify by derek. from BYTE TO INT16U
BYTE LastDevice = 0; //用来指示设备的数目
xdata TDeviceInfo DeviceInfo;
xdata STATUS SdMediaStatus = STATUS_NO_MEDIA;
//----------------------------------------------------------------------------
// Description:
// Initiate the storage interfaces
//----------------------------------------------------------------------------
void StorageInit()
{
// LastDevice = 0;
SdInit();
}
DSTATUS disk_status ()
{
return 0;
}
DRESULT disk_read ( BYTE*buff, DWORD sector, BYTE count)
{
if (!count) return RES_PARERR;
do{
SdReadOneSector(buff,sector);
}while(count--);
}
DRESULT disk_write ( BYTE*buff, DWORD sector, BYTE count)
{
if (!count) return RES_PARERR;
do{
SdWriteOneSector(buff,sector);
}while(count--);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -