#ifndef __EMMC_H__
#define __EMMC_H__

/********************************************************************************************
include
********************************************************************************************/
#include <stdint.h>

/********************************************************************************************
define
********************************************************************************************/
#define CMD60  (0)
#define CMD63  (1)

#define CMD60_DATA_SIZE (64)
#define CMD25_BLOCK_SIZE (512)


#define CC_ERROR_ENABLE  (0x01u)
#define CC_ERROR_DISABLE (0x00u)
#define ERROR_DISABLE    (0x00u)


#define NO_ERROR      (0x00u)
#define BOOT_ERROR    (0x02u)
#define UNKNOWN_ERROR (0x03u)


/********************************************************************************************
macro
********************************************************************************************/
//
//
// BootCodeサイズを抑えるため、一部マクロ化しています
//
//

/*---------------------------------------------------------------------------
  function  : DeviceStatus.Lotus3_ERRORの設定
  arguments : lotus3Error       : I  : Lotus3_ERROR
  return    : void
  detail    : none
--------------------------------------------------------------------------*/
#define EMMC_SetLotus3Error CTL_EMMC_SetLotus3Error


/*---------------------------------------------------------------------------
  function  : Detailの設定
  arguments : detail           : I  : Lotus3_ERROR_Detail
  return    : void
  detail    : none
--------------------------------------------------------------------------*/
#define EMMC_SetDetail CTL_EMMC_SetDetail

/*---------------------------------------------------------------------------
  function  : DeviceStatus.CC_ERRORの設定
  arguments : none
  return    : void
  detail    : none
--------------------------------------------------------------------------*/
#define EMMC_SetCCError CTL_EMMC_SetCCError

/*---------------------------------------------------------------------------
  function  : DeviceStatus.ERRORの設定
  arguments : none
  return    : void
  detail    : none
--------------------------------------------------------------------------*/
#define EMMC_SetError  CTL_EMMC_SetError

/*---------------------------------------------------------------------------
  function  : EMMC Security Key Set
  arguments : pSK : I  : SK
              pIV : I  : IV
              pCV : I  : CVカウントの初期値
  return    : void
  detail    : none
--------------------------------------------------------------------------*/
#define EMMC_SetSecurityKey CTL_EMMC_SetSecurityKey

/*---------------------------------------------------------------------------
  function  : eMMC通信用CVカウント値の取得
  arguments : none
  return    : eMMC通信用CVカウント値
  detail    : none
--------------------------------------------------------------------------*/
#define EMMC_GetCVCount  CTL_EMMC_GetCVCount



/********************************************************************************************
prottype
********************************************************************************************/
void EMMC_Init(void);
int EMMC_WaitCMD(void);

int EMMC_Cmd60(uint32_t* pOperation);
int EMMC_Cmd25F2P(volatile uint32_t* pData, uint32_t blkNum);

void EMMC_Cmd61(void);


#endif //__EMMC_H__

