📄 block.c
字号:
/**
* Block.c
*
*/
#include "Block.h"
#include "SectorInfo.h"
#include "BlockTable.h"
#include "Device.h"
/**
* dms_BlockRead
* Reads the block data form the flash.
* Assumes that the status of the block is valid.
*
* Prerequisites:
* dms_SectorInfoDeviceDeviceArchitecture()
* Uses:
* dms_SectorInfoGetBlockAddress()
* dms_DeviceRead()
* Used By:
* dms_CellRead()
* dms_SectorCleanup()
*/
DMS_STATUS dms_BlockRead(WORD awSectorIndex, WORD awSectorBlockIndex, BYTE *apbData){
DMS_STATUS eStatus;
DWORD dwAddress;
dwAddress = dms_SectorInfoGetBlockAddress(awSectorIndex,awSectorBlockIndex);
eStatus = dms_DeviceRead(dwAddress, sizeof(DATABLOCK), apbData);
if (eStatus != No_Error){
return eStatus;
}
return No_Error;
}
/**
* dms_BlockWrite
* Writes block data to flash and writes block table information.
* The Block Write Process:
* Write BlockBeingWritten in block status.
* Write cell number.
* Write block number.
* Write cell status.
* Write block data.
* Write BlockValid in block status.
*
* Prerequisites:
* dms_SectorInfoDeviceDeviceArchitecture()
* Uses:
* dms_SectorInfoGetBlockAddress()
* dms_DeviceWrite()
* dms_BlockTableWriteBlockStatus()
* dms_BlockTableWriteCellIndex()
* dms_BlockTableWriteBlockIndex()
* dms_BlockTableWriteCellStatus()
* Used By:
* dms_CellWrite()
* dms_CellFormat()
* dms_SectorCleanup()
*/
DMS_STATUS dms_BlockWrite(WORD awCellIndex, WORD awBlockIndex, BYTE abCellStatus,
WORD awSectorIndex, WORD awSectorBlockIndex, BYTE *apbData){
DMS_STATUS eStatus;
DWORD dwAddress;
/* Write Block Status */
eStatus = dms_BlockTableWriteBlockStatus(awSectorIndex,awSectorBlockIndex,BlockBeingWritten);
if (eStatus != No_Error){
return eStatus;
}
/* Write Cell Index */
eStatus = dms_BlockTableWriteCellIndex(awSectorIndex,awSectorBlockIndex,awCellIndex);
if (eStatus != No_Error){
return eStatus;
}
/* Write Block Index */
eStatus = dms_BlockTableWriteBlockIndex(awSectorIndex,awSectorBlockIndex,awBlockIndex);
if (eStatus != No_Error){
return eStatus;
}
/* Write Cell Status */
eStatus = dms_BlockTableWriteCellStatus(awSectorIndex,awSectorBlockIndex,abCellStatus);
if (eStatus != No_Error){
return eStatus;
}
/* Write Block Data */
dwAddress = dms_SectorInfoGetBlockAddress(awSectorIndex,awSectorBlockIndex);
eStatus = dms_DeviceWrite(dwAddress, sizeof(DATABLOCK), apbData);
if (eStatus != No_Error){
return eStatus;
}
/* Write Block Status */
eStatus = dms_BlockTableWriteBlockStatus(awSectorIndex,awSectorBlockIndex,BlockValid);
if (eStatus != No_Error){
return eStatus;
}
return No_Error;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -