2015-04-26 17:54:51 +02:00
|
|
|
/*
|
|
|
|
* shimatta_sdio-driver.h
|
|
|
|
*
|
|
|
|
* Created on: Apr 26, 2015
|
2015-10-13 18:39:29 +02:00
|
|
|
* Mario Hüttel
|
2015-04-26 17:54:51 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FATFS_SHIMATTA_SDIO_DRIVER_SHIMATTA_SDIO_DRIVER_H_
|
|
|
|
#define FATFS_SHIMATTA_SDIO_DRIVER_SHIMATTA_SDIO_DRIVER_H_
|
|
|
|
|
2017-03-31 13:25:42 +02:00
|
|
|
#include <fatfs/diskio.h>
|
2017-04-02 23:54:06 +02:00
|
|
|
#include <stdint.h>
|
2015-04-26 17:54:51 +02:00
|
|
|
|
2015-04-30 11:59:37 +02:00
|
|
|
DSTATUS SDIO_status();
|
|
|
|
DSTATUS SDIO_initialize();
|
|
|
|
DRESULT SDIO_disk_read(BYTE *buff, DWORD sector, UINT count);
|
2015-10-13 18:39:29 +02:00
|
|
|
DRESULT SDIO_disk_write(const BYTE *buff, DWORD sector, UINT count);
|
2015-04-30 11:59:37 +02:00
|
|
|
DRESULT SDIO_disk_ioctl(BYTE cmd, void* buff);
|
|
|
|
DWORD get_fattime();
|
2015-04-26 17:54:51 +02:00
|
|
|
|
2015-11-24 12:14:45 +01:00
|
|
|
|
|
|
|
//Defines for Card Status in struct _CardStatus
|
2015-10-13 18:39:29 +02:00
|
|
|
#define CURRENT_STATE_IDLE 0
|
|
|
|
#define CURRENT_STATE_READY 1
|
|
|
|
#define CURRENT_STATE_IDENT 2
|
|
|
|
#define CURRENT_STATE_STBY 3
|
|
|
|
#define CURRENT_STATE_TRAN 4
|
|
|
|
#define CURRENT_STATE_DATA 5
|
|
|
|
#define CURRENT_STATE_RCV 6
|
|
|
|
#define CURRENT_STATE_PRG 7
|
|
|
|
#define CURRENT_STATE_DIS 8
|
|
|
|
|
|
|
|
|
2015-11-24 12:14:45 +01:00
|
|
|
|
2015-10-13 18:39:29 +02:00
|
|
|
typedef struct _CardStatus {
|
|
|
|
uint32_t reserved : 3;
|
|
|
|
uint32_t AKE_SEQ_ERROR : 1;
|
|
|
|
uint32_t reserved_2 : 1;
|
|
|
|
uint32_t APP_CMD : 1;
|
|
|
|
uint32_t reserved_3 : 2;
|
|
|
|
uint32_t READY_FOR_DATA : 1;
|
|
|
|
uint32_t CURRENT_STATE : 4;
|
|
|
|
uint32_t ERASE_RESET : 1;
|
|
|
|
uint32_t CARD_ECC_DIABLED : 1;
|
|
|
|
uint32_t WP_ERASE_SKIP : 1;
|
|
|
|
uint32_t CSD_OVERWRITE : 1;
|
|
|
|
uint32_t reserved17 : 1;
|
|
|
|
uint32_t reserved18 : 1;
|
|
|
|
uint32_t ERROR : 1;
|
|
|
|
uint32_t CC_ERROR : 1;
|
|
|
|
uint32_t CARD_ECC_FAILED : 1;
|
|
|
|
uint32_t ILLEGAL_COMMAND : 1;
|
|
|
|
uint32_t COM_CRC_ERROR : 1;
|
|
|
|
uint32_t LOCK_UNLOCK_FAILED : 1;
|
|
|
|
uint32_t CARD_IS_LOCKED : 1;
|
|
|
|
uint32_t WP_VIOLATION : 1;
|
|
|
|
uint32_t ERASE_PARAM : 1;
|
|
|
|
uint32_t ERASE_SEQ_ERROR : 1;
|
|
|
|
uint32_t BLOCK_LEN_ERROR : 1;
|
|
|
|
uint32_t ADDRESS_ERROR : 1;
|
|
|
|
uint32_t OUT_OF_RANGE : 1;
|
|
|
|
}CardStatus_t;
|
|
|
|
|
|
|
|
|
2015-11-24 12:14:45 +01:00
|
|
|
|
2016-09-25 19:34:41 +02:00
|
|
|
typedef enum {CARD_NONE = 0, MMC, SD_V1, SD_V2_SC, SD_V2_HC} card_type_t;
|
|
|
|
// MMC not supported
|
2015-10-13 18:39:29 +02:00
|
|
|
typedef struct _SDInfo {
|
2016-09-25 19:34:41 +02:00
|
|
|
uint16_t rca;
|
|
|
|
card_type_t type;
|
2017-04-03 18:56:02 +02:00
|
|
|
uint32_t sector_count;
|
2015-10-23 22:08:43 +02:00
|
|
|
}SDInfo_t;
|
2015-10-13 18:39:29 +02:00
|
|
|
|
|
|
|
typedef union _StatusConv {
|
|
|
|
CardStatus_t statusstruct;
|
|
|
|
uint32_t value;
|
|
|
|
}StatusConv_t;
|
|
|
|
|
2015-04-26 17:54:51 +02:00
|
|
|
#endif /* FATFS_SHIMATTA_SDIO_DRIVER_SHIMATTA_SDIO_DRIVER_H_ */
|