SD card data log

Dependents:   riset_Datalogger

Committer:
kotachi
Date:
Sun Nov 03 07:28:09 2019 +0000
Revision:
0:18d80d7403d3
SD card logging system

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kotachi 0:18d80d7403d3 1 /*-----------------------------------------------------------------------/
kotachi 0:18d80d7403d3 2 / Low level disk interface modlue include file (C)ChaN, 2014 /
kotachi 0:18d80d7403d3 3 /-----------------------------------------------------------------------*/
kotachi 0:18d80d7403d3 4
kotachi 0:18d80d7403d3 5 #ifndef _DISKIO_DEFINED
kotachi 0:18d80d7403d3 6 #define _DISKIO_DEFINED
kotachi 0:18d80d7403d3 7
kotachi 0:18d80d7403d3 8 #ifdef __cplusplus
kotachi 0:18d80d7403d3 9 extern "C" {
kotachi 0:18d80d7403d3 10 #endif
kotachi 0:18d80d7403d3 11
kotachi 0:18d80d7403d3 12 #define _USE_WRITE 1 /* 1: Enable disk_write function */
kotachi 0:18d80d7403d3 13 #define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
kotachi 0:18d80d7403d3 14
kotachi 0:18d80d7403d3 15 #include "integer.h"
kotachi 0:18d80d7403d3 16
kotachi 0:18d80d7403d3 17
kotachi 0:18d80d7403d3 18 /* Status of Disk Functions */
kotachi 0:18d80d7403d3 19 typedef BYTE DSTATUS;
kotachi 0:18d80d7403d3 20
kotachi 0:18d80d7403d3 21 /* Results of Disk Functions */
kotachi 0:18d80d7403d3 22 typedef enum {
kotachi 0:18d80d7403d3 23 RES_OK = 0, /* 0: Successful */
kotachi 0:18d80d7403d3 24 RES_ERROR, /* 1: R/W Error */
kotachi 0:18d80d7403d3 25 RES_WRPRT, /* 2: Write Protected */
kotachi 0:18d80d7403d3 26 RES_NOTRDY, /* 3: Not Ready */
kotachi 0:18d80d7403d3 27 RES_PARERR /* 4: Invalid Parameter */
kotachi 0:18d80d7403d3 28 } DRESULT;
kotachi 0:18d80d7403d3 29
kotachi 0:18d80d7403d3 30
kotachi 0:18d80d7403d3 31 /*---------------------------------------*/
kotachi 0:18d80d7403d3 32 /* Prototypes for disk control functions */
kotachi 0:18d80d7403d3 33
kotachi 0:18d80d7403d3 34
kotachi 0:18d80d7403d3 35 DSTATUS disk_initialize (BYTE pdrv);
kotachi 0:18d80d7403d3 36 DSTATUS disk_status (BYTE pdrv);
kotachi 0:18d80d7403d3 37 DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
kotachi 0:18d80d7403d3 38 DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
kotachi 0:18d80d7403d3 39 DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
kotachi 0:18d80d7403d3 40
kotachi 0:18d80d7403d3 41
kotachi 0:18d80d7403d3 42 /* Disk Status Bits (DSTATUS) */
kotachi 0:18d80d7403d3 43
kotachi 0:18d80d7403d3 44 #define STA_NOINIT 0x01 /* Drive not initialized */
kotachi 0:18d80d7403d3 45 #define STA_NODISK 0x02 /* No medium in the drive */
kotachi 0:18d80d7403d3 46 #define STA_PROTECT 0x04 /* Write protected */
kotachi 0:18d80d7403d3 47
kotachi 0:18d80d7403d3 48
kotachi 0:18d80d7403d3 49 /* Command code for disk_ioctrl fucntion */
kotachi 0:18d80d7403d3 50
kotachi 0:18d80d7403d3 51 /* Generic command (Used by FatFs) */
kotachi 0:18d80d7403d3 52 #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */
kotachi 0:18d80d7403d3 53 #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */
kotachi 0:18d80d7403d3 54 #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */
kotachi 0:18d80d7403d3 55 #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */
kotachi 0:18d80d7403d3 56 #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
kotachi 0:18d80d7403d3 57
kotachi 0:18d80d7403d3 58 /* Generic command (Not used by FatFs) */
kotachi 0:18d80d7403d3 59 #define CTRL_POWER 5 /* Get/Set power status */
kotachi 0:18d80d7403d3 60 #define CTRL_LOCK 6 /* Lock/Unlock media removal */
kotachi 0:18d80d7403d3 61 #define CTRL_EJECT 7 /* Eject media */
kotachi 0:18d80d7403d3 62 #define CTRL_FORMAT 8 /* Create physical format on the media */
kotachi 0:18d80d7403d3 63
kotachi 0:18d80d7403d3 64 /* MMC/SDC specific ioctl command */
kotachi 0:18d80d7403d3 65 #define MMC_GET_TYPE 10 /* Get card type */
kotachi 0:18d80d7403d3 66 #define MMC_GET_CSD 11 /* Get CSD */
kotachi 0:18d80d7403d3 67 #define MMC_GET_CID 12 /* Get CID */
kotachi 0:18d80d7403d3 68 #define MMC_GET_OCR 13 /* Get OCR */
kotachi 0:18d80d7403d3 69 #define MMC_GET_SDSTAT 14 /* Get SD status */
kotachi 0:18d80d7403d3 70
kotachi 0:18d80d7403d3 71 /* ATA/CF specific ioctl command */
kotachi 0:18d80d7403d3 72 #define ATA_GET_REV 20 /* Get F/W revision */
kotachi 0:18d80d7403d3 73 #define ATA_GET_MODEL 21 /* Get model name */
kotachi 0:18d80d7403d3 74 #define ATA_GET_SN 22 /* Get serial number */
kotachi 0:18d80d7403d3 75
kotachi 0:18d80d7403d3 76 #ifdef __cplusplus
kotachi 0:18d80d7403d3 77 }
kotachi 0:18d80d7403d3 78 #endif
kotachi 0:18d80d7403d3 79
kotachi 0:18d80d7403d3 80 #endif