PER Firmware
Loading...
Searching...
No Matches
diskio.h
1/*-----------------------------------------------------------------------/
2/ Low level disk interface modlue include file (C)ChaN, 2013 /
3/-----------------------------------------------------------------------*/
4
5#ifndef _DISKIO_DEFINED
6#define _DISKIO_DEFINED
7
8#include "ff.h"
9
10#define _USE_WRITE 1 /* 1: Enable disk_write function */
11#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
12
13// #include "integer.h"
14// #include "defines.h"
15// #include "attributes.h"
16
17/* Status of Disk Functions */
18typedef BYTE DSTATUS;
19
20/* Results of Disk Functions */
21typedef enum {
22 RES_OK = 0, /* 0: Successful */
23 RES_ERROR, /* 1: R/W Error */
24 RES_WRPRT, /* 2: Write Protected */
25 RES_NOTRDY, /* 3: Not Ready */
26 RES_PARERR /* 4: Invalid Parameter */
27} DRESULT;
28
29//#define FATFS_DEBUG_SEND_USART(x) TM_USART_Puts(USART6, x); TM_USART_Puts(USART6, "\n");
30#define FATFS_DEBUG_SEND_USART(x)
31
32/*---------------------------------------*/
33/* Prototypes for disk control functions */
34
35/* FATFS related */
36DSTATUS disk_initialize(BYTE pdrv);
37DSTATUS disk_status(BYTE pdrv);
38DRESULT disk_read(BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
39DRESULT disk_write(BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
40DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void* buff);
41
42/* Disk Status Bits (DSTATUS) */
43#define STA_NOINIT 0x01 /* Drive not initialized */
44#define STA_NODISK 0x02 /* No medium in the drive */
45#define STA_PROTECT 0x04 /* Write protected */
46
47/* Command code for disk_ioctrl function */
48/* Generic command (used by FatFs) */
49#define CTRL_SYNC 0 /* Flush disk cache (for write functions) */
50#define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */
51#define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
52#define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */
53#define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */
54
55/* Generic command (not used by FatFs) */
56#define CTRL_POWER 5 /* Get/Set power status */
57#define CTRL_LOCK 6 /* Lock/Unlock media removal */
58#define CTRL_EJECT 7 /* Eject media */
59#define CTRL_FORMAT 8 /* Create physical format on the media */
60
61/* MMC/SDC specific ioctl command */
62#define MMC_GET_TYPE 10 /* Get card type */
63#define MMC_GET_CSD 11 /* Get CSD */
64#define MMC_GET_CID 12 /* Get CID */
65#define MMC_GET_OCR 13 /* Get OCR */
66#define MMC_GET_SDSTAT 14 /* Get SD status */
67
68/* ATA/CF specific ioctl command */
69#define ATA_GET_REV 20 /* Get F/W revision */
70#define ATA_GET_MODEL 21 /* Get model name */
71#define ATA_GET_SN 22 /* Get serial number */
72
73/* MMC card type flags (MMC_GET_TYPE) */
74#define CT_MMC 0x01 /* MMC ver 3 */
75#define CT_SD1 0x02 /* SD ver 1 */
76#define CT_SD2 0x04 /* SD ver 2 */
77#define CT_SDC (CT_SD1 | CT_SD2) /* SD */
78#define CT_BLOCK 0x08 /* Block addressing */
79
80#endif