]> cloudbase.mooo.com Git - z180-stamp.git/blame - fatfs/documents/res/app6.c
new command: dissassemle - Disassemble Z180 code from memory
[z180-stamp.git] / fatfs / documents / res / app6.c
CommitLineData
5630b930
L
1/*---------------------------------------------------------------------*/\r
2/* Raw Read/Write Throughput Checker */\r
3/*---------------------------------------------------------------------*/\r
4\r
5#include <stdio.h>\r
6#include <systimer.h>\r
7#include "diskio.h"\r
8#include "ff.h"\r
9\r
10\r
11int test_raw_speed (\r
12 BYTE pdrv, /* Physical drive number */\r
13 DWORD lba, /* Start LBA for read/write test */\r
14 DWORD len, /* Number of bytes to read/write (must be multiple of sz_buff) */\r
15 void* buff, /* Read/write buffer */\r
16 UINT sz_buff /* Size of read/write buffer (must be multiple of FF_MAX_SS) */\r
17)\r
18{\r
19 WORD ss;\r
20 DWORD ofs, tmr;\r
21\r
22\r
23#if FF_MIN_SS != FF_MAX_SS\r
24 if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &ss) != RES_OK) {\r
25 printf("\ndisk_ioctl() failed.\n");\r
26 return 0;\r
27 }\r
28#else\r
29 ss = FF_MAX_SS;\r
30#endif\r
31\r
32 printf("Starting raw write test at sector %lu in %u bytes of data chunks...", lba, sz_buff);\r
33 tmr = systimer();\r
34 for (ofs = 0; ofs < len / ss; ofs += sz_buff / ss) {\r
35 if (disk_write(pdrv, buff, lba + ofs, sz_buff / ss) != RES_OK) {\r
36 printf("\ndisk_write() failed.\n");\r
37 return 0;\r
38 }\r
39 }\r
40 if (disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) {\r
41 printf("\ndisk_ioctl() failed.\n");\r
42 return 0;\r
43 }\r
44 tmr = systimer() - tmr;\r
45 printf("\n%lu bytes written and it took %lu timer ticks.\n", len, tmr);\r
46\r
47 printf("Starting raw read test at sector %lu in %u bytes of data chunks...", lba, sz_buff);\r
48 tmr = systimer();\r
49 for (ofs = 0; ofs < len / ss; ofs += sz_buff / ss) {\r
50 if (disk_read(pdrv, buff, lba + ofs, sz_buff / ss) != RES_OK) {\r
51 printf("\ndisk_read() failed.\n");\r
52 return 0;\r
53 }\r
54 }\r
55 tmr = systimer() - tmr;\r
56 printf("\n%lu bytes read and it took %lu timer ticks.\n", len, tmr);\r
57\r
58 printf("Test completed.\n");\r
59 return 1;\r
60}\r
61\r