Mercurial > ~darius > hgwebdir.cgi > stm32temp
annotate fatfs/diskio.h @ 49:ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
LFN doesn't work reliably so it's disabled for now.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Wed, 03 Apr 2013 23:34:20 +1030 |
parents | |
children |
rev | line source |
---|---|
49
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
1 /*----------------------------------------------------------------------- |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
2 / Low level disk interface modlue include file (C)ChaN, 2013 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
3 /-----------------------------------------------------------------------*/ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
4 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
5 #ifndef _DISKIO_DEFINED |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
6 #define _DISKIO_DEFINED |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
7 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
8 #ifdef __cplusplus |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
9 extern "C" { |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
10 #endif |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
11 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
12 #define _USE_WRITE 1 /* 1: Enable disk_write function */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
13 #define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
14 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
15 #include "integer.h" |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
16 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
17 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
18 /* Status of Disk Functions */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
19 typedef BYTE DSTATUS; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
20 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
21 /* Results of Disk Functions */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
22 typedef enum { |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
23 RES_OK = 0, /* 0: Successful */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
24 RES_ERROR, /* 1: R/W Error */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
25 RES_WRPRT, /* 2: Write Protected */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
26 RES_NOTRDY, /* 3: Not Ready */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
27 RES_PARERR /* 4: Invalid Parameter */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
28 } DRESULT; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
29 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
30 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
31 /*---------------------------------------*/ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
32 /* Prototypes for disk control functions */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
33 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
34 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
35 DSTATUS disk_initialize (BYTE pdrv); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
36 DSTATUS disk_status (BYTE pdrv); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
37 DRESULT disk_read (BYTE pdrv, BYTE*buff, DWORD sector, BYTE count); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
38 DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, BYTE count); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
39 DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
40 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
41 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
42 /* Disk Status Bits (DSTATUS) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
43 #define STA_NOINIT 0x01 /* Drive not initialized */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
44 #define STA_NODISK 0x02 /* No medium in the drive */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
45 #define STA_PROTECT 0x04 /* Write protected */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
46 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
47 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
48 /* Command code for disk_ioctrl fucntion */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
49 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
50 /* Generic command (used by FatFs) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
51 #define CTRL_SYNC 0 /* Flush disk cache (for write functions) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
52 #define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
53 #define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
54 #define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
55 #define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
56 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
57 /* Generic command (not used by FatFs) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
58 #define CTRL_POWER 5 /* Get/Set power status */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
59 #define CTRL_LOCK 6 /* Lock/Unlock media removal */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
60 #define CTRL_EJECT 7 /* Eject media */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
61 #define CTRL_FORMAT 8 /* Create physical format on the media */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
62 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
63 /* MMC/SDC specific ioctl command */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
64 #define MMC_GET_TYPE 10 /* Get card type */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
65 #define MMC_GET_CSD 11 /* Get CSD */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
66 #define MMC_GET_CID 12 /* Get CID */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
67 #define MMC_GET_OCR 13 /* Get OCR */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
68 #define MMC_GET_SDSTAT 14 /* Get SD status */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
69 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
70 /* ATA/CF specific ioctl command */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
71 #define ATA_GET_REV 20 /* Get F/W revision */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
72 #define ATA_GET_MODEL 21 /* Get model name */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
73 #define ATA_GET_SN 22 /* Get serial number */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
74 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
75 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
76 /* MMC card type flags (MMC_GET_TYPE) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
77 #define CT_MMC 0x01 /* MMC ver 3 */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
78 #define CT_SD1 0x02 /* SD ver 1 */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
79 #define CT_SD2 0x04 /* SD ver 2 */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
80 #define CT_SDC (CT_SD1|CT_SD2) /* SD */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
81 #define CT_BLOCK 0x08 /* Block addressing */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
82 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
83 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
84 #ifdef __cplusplus |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
85 } |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
86 #endif |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
87 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
88 #endif |