You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.4 KiB
C
61 lines
1.4 KiB
C
#ifndef _SD_MMC_H_
|
|
#define _SD_MMC_H_
|
|
|
|
#include "atmel_start.h"
|
|
#include "sd_mmc_intf.h"
|
|
#include "pdebug.h"
|
|
typedef enum sd_mmc_mode_t
|
|
{
|
|
SD_MMC_MODE_SPI = 0,
|
|
SD_MMC_MODE_MCI = 1
|
|
}sd_mmc_mode_t;
|
|
|
|
typedef enum sd_mmc_err_t
|
|
{
|
|
SD_MMC_SUCCESS = 0,
|
|
SD_MMC_FAIL = 1,
|
|
SD_MMC_INIT_ONGOING = 2,
|
|
SD_MMC_ERR_NO_CARD = 3,
|
|
SD_MMC_ERR_UNUSABLE = 4,
|
|
SD_MMC_ERR_SLOT = 5,
|
|
SD_MMC_ERR_COMM = 6,
|
|
SD_MMC_ERR_PARAM = 7,
|
|
SD_MMC_ERR_WP = 8,
|
|
SD_MMC_INIT_FAILURE = 9,
|
|
SD_MMC_TIMEOUT = 10
|
|
} sd_mmc_err_t;
|
|
|
|
// The card detect function can be unused, used regularly, or via interrupt.
|
|
// SD_MMC_CD_MODE_UNUSED: The cd pin isn't used
|
|
// SD_MMC_CD_MODE_SYNC: The pin is just checked when needed.
|
|
// SD_MMC_CD_MODE_ASYNC: The pin's state is stored and updated via interrupt. CURRENTLY UNIMPLEMENTED
|
|
typedef enum sd_mmc_cd_mode_t
|
|
{
|
|
SD_MMC_CD_MODE_UNUSED = 0,
|
|
SD_MMC_CD_MODE_SYNC = 1,
|
|
SD_MMC_CD_MODE_ASYNC = 2
|
|
}sd_mmc_cd_mode_t;
|
|
|
|
|
|
sd_mmc_err_t sd_mmc_init(void);
|
|
sd_mmc_err_t sd_mmc_select(uint8_t slot, uint32_t clock, uint8_t bus_width, bool high_speed);
|
|
sd_mmc_err_t sd_mmc_deselect(uint8_t slot);
|
|
sd_mmc_err_t sd_mmc_send_command(uint8_t cmd, uint32_t arg, uint8_t crc);
|
|
sd_mmc_err_t sd_mmc_read_res1(uint8_t* ret_byte);
|
|
|
|
|
|
#define SD_MMC_CD_MODE SD_MMC_CD_MODE_SYNC
|
|
|
|
#ifndef SD_MMC_CD_MODE
|
|
#define SD_MMC_CD_MODE SD_MMC_MODE_UNUSED
|
|
#endif
|
|
|
|
#define CMD0 0
|
|
#define CMD0_ARG 0x00000000
|
|
#define CMD0_CRC 0x94
|
|
|
|
#define UNUSED(v) (void)(v)
|
|
|
|
|
|
#endif
|