HEPTA-Sat Hands-On
/
HeptaXbee_CountUp
Xbee CountUp
Fork of HeptaXbee_CountUp by
hepta_sat/SDFileSystem/FATFileSystem/ChaN/diskio.h@1:715b80d2a02b, 2016-12-13 (annotated)
- Committer:
- tomoya123
- Date:
- Tue Dec 13 07:55:03 2016 +0000
- Revision:
- 1:715b80d2a02b
- Parent:
- 0:0a7fa0911e6c
Xbee CountUp
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tomoya123 | 0:0a7fa0911e6c | 1 | //----------------------------------------------------------------------- |
tomoya123 | 0:0a7fa0911e6c | 2 | // Low level disk interface modlue include file |
tomoya123 | 0:0a7fa0911e6c | 3 | //----------------------------------------------------------------------- |
tomoya123 | 0:0a7fa0911e6c | 4 | |
tomoya123 | 0:0a7fa0911e6c | 5 | #ifndef _DISKIO |
tomoya123 | 0:0a7fa0911e6c | 6 | |
tomoya123 | 0:0a7fa0911e6c | 7 | #define _READONLY 0 // 1: Remove write functions |
tomoya123 | 0:0a7fa0911e6c | 8 | #define _USE_IOCTL 1 // 1: Use disk_ioctl fucntion |
tomoya123 | 0:0a7fa0911e6c | 9 | |
tomoya123 | 0:0a7fa0911e6c | 10 | #include "integer.h" |
tomoya123 | 0:0a7fa0911e6c | 11 | |
tomoya123 | 0:0a7fa0911e6c | 12 | |
tomoya123 | 0:0a7fa0911e6c | 13 | // Status of Disk Functions |
tomoya123 | 0:0a7fa0911e6c | 14 | typedef BYTE DSTATUS; |
tomoya123 | 0:0a7fa0911e6c | 15 | |
tomoya123 | 0:0a7fa0911e6c | 16 | // Results of Disk Functions |
tomoya123 | 0:0a7fa0911e6c | 17 | typedef enum { |
tomoya123 | 0:0a7fa0911e6c | 18 | RES_OK = 0, // 0: Successful |
tomoya123 | 0:0a7fa0911e6c | 19 | RES_ERROR, // 1: R/W Error |
tomoya123 | 0:0a7fa0911e6c | 20 | RES_WRPRT, // 2: Write Protected |
tomoya123 | 0:0a7fa0911e6c | 21 | RES_NOTRDY, // 3: Not Ready |
tomoya123 | 0:0a7fa0911e6c | 22 | RES_PARERR // 4: Invalid Parameter |
tomoya123 | 0:0a7fa0911e6c | 23 | } DRESULT; |
tomoya123 | 0:0a7fa0911e6c | 24 | |
tomoya123 | 0:0a7fa0911e6c | 25 | |
tomoya123 | 0:0a7fa0911e6c | 26 | // Prototypes for disk control functions |
tomoya123 | 0:0a7fa0911e6c | 27 | |
tomoya123 | 0:0a7fa0911e6c | 28 | int assign_drives (int, int); |
tomoya123 | 0:0a7fa0911e6c | 29 | DSTATUS disk_initialize (BYTE); |
tomoya123 | 0:0a7fa0911e6c | 30 | DSTATUS disk_status (BYTE); |
tomoya123 | 0:0a7fa0911e6c | 31 | DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE); |
tomoya123 | 0:0a7fa0911e6c | 32 | #if _READONLY == 0 |
tomoya123 | 0:0a7fa0911e6c | 33 | DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE); |
tomoya123 | 0:0a7fa0911e6c | 34 | #endif |
tomoya123 | 0:0a7fa0911e6c | 35 | DRESULT disk_ioctl (BYTE, BYTE, void*); |
tomoya123 | 0:0a7fa0911e6c | 36 | |
tomoya123 | 0:0a7fa0911e6c | 37 | |
tomoya123 | 0:0a7fa0911e6c | 38 | |
tomoya123 | 0:0a7fa0911e6c | 39 | // Disk Status Bits (DSTATUS) |
tomoya123 | 0:0a7fa0911e6c | 40 | #define STA_NOINIT 0x01 // Drive not initialized |
tomoya123 | 0:0a7fa0911e6c | 41 | #define STA_NODISK 0x02 // No medium in the drive |
tomoya123 | 0:0a7fa0911e6c | 42 | #define STA_PROTECT 0x04 // Write protected |
tomoya123 | 0:0a7fa0911e6c | 43 | |
tomoya123 | 0:0a7fa0911e6c | 44 | |
tomoya123 | 0:0a7fa0911e6c | 45 | // Command code for disk_ioctrl fucntion |
tomoya123 | 0:0a7fa0911e6c | 46 | |
tomoya123 | 0:0a7fa0911e6c | 47 | // Generic command (defined for FatFs) |
tomoya123 | 0:0a7fa0911e6c | 48 | #define CTRL_SYNC 0 // Flush disk cache (for write functions) |
tomoya123 | 0:0a7fa0911e6c | 49 | #define GET_SECTOR_COUNT 1 // Get media size (for only f_mkfs()) |
tomoya123 | 0:0a7fa0911e6c | 50 | #define GET_SECTOR_SIZE 2 // Get sector size (for multiple sector size (_MAX_SS >= 1024)) |
tomoya123 | 0:0a7fa0911e6c | 51 | #define GET_BLOCK_SIZE 3 // Get erase block size (for only f_mkfs()) |
tomoya123 | 0:0a7fa0911e6c | 52 | #define CTRL_ERASE_SECTOR 4 // Force erased a block of sectors (for only _USE_ERASE) |
tomoya123 | 0:0a7fa0911e6c | 53 | |
tomoya123 | 0:0a7fa0911e6c | 54 | // Generic command |
tomoya123 | 0:0a7fa0911e6c | 55 | #define CTRL_POWER 5 // Get/Set power status |
tomoya123 | 0:0a7fa0911e6c | 56 | #define CTRL_LOCK 6 // Lock/Unlock media removal |
tomoya123 | 0:0a7fa0911e6c | 57 | #define CTRL_EJECT 7 // Eject media |
tomoya123 | 0:0a7fa0911e6c | 58 | |
tomoya123 | 0:0a7fa0911e6c | 59 | // MMC/SDC specific ioctl command |
tomoya123 | 0:0a7fa0911e6c | 60 | #define MMC_GET_TYPE 10 // Get card type |
tomoya123 | 0:0a7fa0911e6c | 61 | #define MMC_GET_CSD 11 // Get CSD |
tomoya123 | 0:0a7fa0911e6c | 62 | #define MMC_GET_CID 12 // Get CID |
tomoya123 | 0:0a7fa0911e6c | 63 | #define MMC_GET_OCR 13 // Get OCR |
tomoya123 | 0:0a7fa0911e6c | 64 | #define MMC_GET_SDSTAT 14 // Get SD status |
tomoya123 | 0:0a7fa0911e6c | 65 | |
tomoya123 | 0:0a7fa0911e6c | 66 | // ATA/CF specific ioctl command |
tomoya123 | 0:0a7fa0911e6c | 67 | #define ATA_GET_REV 20 // Get F/W revision |
tomoya123 | 0:0a7fa0911e6c | 68 | #define ATA_GET_MODEL 21 // Get model name |
tomoya123 | 0:0a7fa0911e6c | 69 | #define ATA_GET_SN 22 // Get serial number |
tomoya123 | 0:0a7fa0911e6c | 70 | |
tomoya123 | 0:0a7fa0911e6c | 71 | // NAND specific ioctl command |
tomoya123 | 0:0a7fa0911e6c | 72 | #define NAND_FORMAT 30 // Create physical format |
tomoya123 | 0:0a7fa0911e6c | 73 | |
tomoya123 | 0:0a7fa0911e6c | 74 | |
tomoya123 | 0:0a7fa0911e6c | 75 | #define _DISKIO |
tomoya123 | 0:0a7fa0911e6c | 76 | #endif |