#ifndef SD_CARD_DRIVER_H_
#define SD_CARD_DRIVER_H_

#include "my_types.h"
#include "alt_types.h"  // alt_u32
#include "io.h"
#include "system.h"


#define SD_CMD_IN   IOWR(SD_CMD_BASE, 1, 0)
#define SD_CMD_OUT  IOWR(SD_CMD_BASE, 1, 1)
#define SD_DAT_IN   IOWR(SD_DAT_BASE, 1, 0)
#define SD_DAT_OUT  IOWR(SD_DAT_BASE, 1, 1)
#define SD_DAT3_IN   IOWR(SD_DAT3_BASE, 1, 0)
#define SD_DAT3_OUT  IOWR(SD_DAT3_BASE, 1, 1)
//  SD Card Output High/Low
#define SD_CMD_LOW  IOWR(SD_CMD_BASE, 0, 0)
#define SD_CMD_HIGH IOWR(SD_CMD_BASE, 0, 1)
#define SD_DAT_LOW  IOWR(SD_DAT_BASE, 0, 0)
#define SD_DAT_HIGH IOWR(SD_DAT_BASE, 0, 1)
#define SD_DAT3_LOW  IOWR(SD_DAT3_BASE, 0, 0)
#define SD_DAT3_HIGH IOWR(SD_DAT3_BASE, 0, 1)
#define SD_CLK_LOW  IOWR(SD_CLK_BASE, 0, 0)
#define SD_CLK_HIGH IOWR(SD_CLK_BASE, 0, 1)
//  SD Card Input Read
#define SD_TEST_CMD IORD(SD_CMD_BASE, 0)
#define SD_TEST_DAT IORD(SD_DAT_BASE, 0)
#define SD_TEST_DAT3 IORD(SD_DAT3_BASE, 0)



bool SD_card_init(void);
bool SD_read_block(alt_u32 block_number, alt_u8 *buff); // richard add, return 0: success
bool SD_GetCSD(alt_u8 szCSD[], alt_u8 len);
bool SD_GetCID(alt_u8 szCID[], alt_u8 len);




#endif /*SD_CARD_DRIVER_H_*/
