roneos
Operating System for the r-one robot
 All Data Structures Files Functions Variables Typedefs Groups
diskio.h
Go to the documentation of this file.
1 
11 /*-----------------------------------------------------------------------
12 / Low level disk interface module include file
13 /-----------------------------------------------------------------------*/
14 
15 #ifndef _DISKIO
16 
17 #define _READONLY 0 /* 1: Remove write functions */
18 #define _USE_IOCTL 1 /* 1: Use disk_ioctl function */
19 
20 #include "integer.h"
21 
22 
23 /* Status of Disk Functions */
24 typedef BYTE DSTATUS;
25 
26 /* Results of Disk Functions */
27 typedef enum {
28  RES_OK = 0, /* 0: Successful */
29  RES_ERROR, /* 1: R/W Error */
30  RES_WRPRT, /* 2: Write Protected */
31  RES_NOTRDY, /* 3: Not Ready */
32  RES_PARERR /* 4: Invalid Parameter */
33 } DRESULT;
34 
35 
36 /*---------------------------------------*/
37 /* Prototypes for disk control functions */
38 
39 //int assign_drives (int, int);
40 DSTATUS disk_initialize (BYTE);
41 DSTATUS disk_status (BYTE);
42 DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);
43 #if _READONLY == 0
44 DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE);
45 #endif
46 DRESULT disk_ioctl (BYTE, BYTE, void*);
47 
48 #define READ_RETRIES 5 /* The number of read re-tries before giving up */
49 
50 
51 /* Disk Status Bits (DSTATUS) */
52 #define STA_OK 0x00 /* Status is OK */
53 #define STA_NOINIT 0x01 /* Drive not initialized */
54 #define STA_NODISK 0x02 /* No medium in the drive */
55 #define STA_PROTECT 0x04 /* Write protected */
56 
57 
58 /* Command code for disk_ioctrl fucntion */
59 
60 /* Generic command (defined for FatFs) */
61 #define CTRL_SYNC 0 /* Flush disk cache (for write functions) */
62 #define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */
63 #define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
64 #define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */
65 #define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */
66 
67 /* Generic command */
68 #define CTRL_POWER 5 /* Get/Set power status */
69 #define CTRL_LOCK 6 /* Lock/Unlock media removal */
70 #define CTRL_EJECT 7 /* Eject media */
71 
72 /* MMC/SDC specific ioctl command */
73 #define MMC_GET_TYPE 10 /* Get card type */
74 #define MMC_GET_CSD 11 /* Get CSD */
75 #define MMC_GET_CID 12 /* Get CID */
76 #define MMC_GET_OCR 13 /* Get OCR */
77 #define MMC_GET_SDSTAT 14 /* Get SD status */
78 
79 /* ATA/CF specific ioctl command */
80 #define ATA_GET_REV 20 /* Get F/W revision */
81 #define ATA_GET_MODEL 21 /* Get model name */
82 #define ATA_GET_SN 22 /* Get serial number */
83 
84 /* NAND specific ioctl command */
85 #define NAND_FORMAT 30 /* Create physical format */
86 
87 
94 DSTATUS disk_initialize (BYTE drive);
95 
96 
103 DSTATUS disk_status (BYTE drive);
104 
109 DWORD get_fattime (void);
110 
111 #define _DISKIO
112 #endif