]>
cloudbase.mooo.com Git - z180-stamp.git/blob - fatfs/documents/res/app6.c
1 /*---------------------------------------------------------------------*/
2 /* Raw Read/Write Throughput Checker */
3 /*---------------------------------------------------------------------*/
12 BYTE pdrv
, /* Physical drive number */
13 DWORD lba
, /* Start LBA for read/write test */
14 DWORD len
, /* Number of bytes to read/write (must be multiple of sz_buff) */
15 void* buff
, /* Read/write buffer */
16 UINT sz_buff
/* Size of read/write buffer (must be multiple of FF_MAX_SS) */
23 #if FF_MIN_SS != FF_MAX_SS
24 if (disk_ioctl(pdrv
, GET_SECTOR_SIZE
, &ss
) != RES_OK
) {
25 printf("\ndisk_ioctl() failed.\n");
32 printf("Starting raw write test at sector %lu in %u bytes of data chunks...", lba
, sz_buff
);
34 for (ofs
= 0; ofs
< len
/ ss
; ofs
+= sz_buff
/ ss
) {
35 if (disk_write(pdrv
, buff
, lba
+ ofs
, sz_buff
/ ss
) != RES_OK
) {
36 printf("\ndisk_write() failed.\n");
40 if (disk_ioctl(pdrv
, CTRL_SYNC
, 0) != RES_OK
) {
41 printf("\ndisk_ioctl() failed.\n");
44 tmr
= systimer() - tmr
;
45 printf("\n%lu bytes written and it took %lu timer ticks.\n", len
, tmr
);
47 printf("Starting raw read test at sector %lu in %u bytes of data chunks...", lba
, sz_buff
);
49 for (ofs
= 0; ofs
< len
/ ss
; ofs
+= sz_buff
/ ss
) {
50 if (disk_read(pdrv
, buff
, lba
+ ofs
, sz_buff
/ ss
) != RES_OK
) {
51 printf("\ndisk_read() failed.\n");
55 tmr
= systimer() - tmr
;
56 printf("\n%lu bytes read and it took %lu timer ticks.\n", len
, tmr
);
58 printf("Test completed.\n");