⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dmssimpletest.c

📁 AMD公司官方版FLASH文件系统。有详细说明文档和Windows仿真测试环境。
💻 C
字号:
/**
 * DmsSimpleTest.c
 * A very simple test that tests nothing other than the dms 
 *   is able to read and write to the flash.
 */

#include "../dms.h"

SECTOR_DESCRIPTIOR gpDeviceArchitecture[] =
{
	{ 0x20000, 0x10000 },
	{ 0x30000, 0x10000 },
	{ 0x40000, 0x10000 },
	{ 0x50000, 0x10000 },
	{ 0L,      0L   }
};

int equal(char *a, char *b);

/**
 * returns zero on success.
 */
int main(int argc, char **argv){
  DWORD pdwCellList[] = {100, 200, 300, 400};
  WORD wCellListSize = 4;
  char cCellData0[] = {"This is the data that is to be put into cell zero."};
  char cCellData1[] = {"This is the second set of data."};
  char cTempBuffer[400];
  DMS_STATUS eStatus;

  eStatus = dms_Format(pdwCellList,wCellListSize);
  if (eStatus != No_Error) return -1;

  eStatus = dms_Initialize();
  if (eStatus != No_Error) return -1;
  
  eStatus = dms_Write(0,cCellData0);
  if (eStatus != No_Error) return -1;
  
  eStatus = dms_Write(1,cCellData1);
  if (eStatus != No_Error) return -1;
  
  eStatus = dms_Read(0,cTempBuffer);
  if (eStatus != No_Error) return -1;
  if (!equal(cCellData0,cTempBuffer)) return -1;
  
  eStatus = dms_Read(1,cTempBuffer);
  if (eStatus != No_Error) return -1;
  if (!equal(cCellData1,cTempBuffer)) return -1;

  dms_Shutdown();
  
  return 0;
}

int equal(char *a, char *b){
  int i = 0;
  while (a[i] != '\0' && b[i] != '\0'){
    if (a[i] != b[i]) return 0;
    i++;
  }
  if (a[i] == b[i]) return 1;
  else return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -