#ifndef _SD_MMC_INTF_
#define _SD_MMC_INTF_

#define DEFAULT_IMPL 0

// SD MMC Interface
// Define FUNCTIONS and stuff here

#include "sd_mmc_spi_impl.h"
/**
 * @brief Selects device for use with the SD MMC driver.
 *
 * This function selects the device for use. This can mean a number of things,
 * but the only thing the implementer needs to worry about is hardware selection.
 * This means setting the CS pin low for SPI or <whatever the mci version needs>
 *
 * @return 0 if successful, else return anything else.
 * @todo implement mci support and spi support
 */
#define SD_MMC_INTF_SELECT_DEVICE() sd_mmc_spi_impl_select_device()

/**
 * @brief Deselects device for use with the SD MMC driver.
 *
 * This function deselects the device for use. This can mean a number of things,
 * but the only thing the implementer needs to worry about is hardware deselection.
 *
 * This means setting the CS pin high for SPI or <whatever the mci version needs>
 * @return 0 if successul, else return anything else.
 * @todo implement mci support and mci support
 */
#define SD_MMC_INTF_DESELECT_DEVICE() sd_mmc_spi_impl_deselect_device()

/**
 * @brief Reads bytes from device in the most primitive form.  *
 *
 * This function reads bytes from the device. It is up to the implementer to simply read the bytes
 * and return the number of bytes read. Only supports synchronous transactions currently.
 * This assumes the implementer writes a dummy byte for initiating
 * an spi read. The slave selection is handled by the driver. There is no need to include
 * selecting the device in the read function. Doing so could actually interfere with the driver.
 *
 * @return The number of bytes read. Failed reads can be <= 0.
 * @todo --
 */
#define SD_MMC_INTF_READ(bytes, len) sd_mmc_spi_impl_read(bytes, len)

/**
 * @brief Writes bytes from the device in the most primitive form.
 *
 * This function writes bytes to the device. Only supports synchronous transactions currently.
 * The slave selection is handled by the driver. There is no need to include
 * selecting the device in the read function. Doing so could actually interfere with the driver.
 *
 * @return The number of bytes written. Failed reads can be <= 0.
 * @todo --
 */
#define SD_MMC_INTF_WRITE(bytes, len) sd_mmc_spi_impl_write(bytes, len)

/**
 * @brief Initializes hardware for the device.
 *
 * This function initializes the device. This initialization can be ignored if it is done by your HAL,
 * but some stub at the very least needs to be provided.
 *
 * @return 0 if successful, anything else signifies failure
 * @todo --
 */
#define SD_MMC_INTF_INIT() sd_mmc_spi_impl_init()

/**
 * @brief checks the status of the card detect pin.
 *
 * This function checks the card detect pin. It is implemented by the user,
 * so it is up to the user to know if the cd pin should be high or low
 * to detect the card. This function is only used in synchronous mode.
 *
 * @return true if a card was detected, false if not.
 */
#define SD_MMC_INTF_CHECK_CD() sd_mmc_spi_impl_check_cd()
#ifndef SD_MMC_INTF_INIT
#error SD_MMC_INTF_INIT must be defined!
#elif !defined(SD_MMC_INTF_WRITE)
#error SD_MMC_INTF_WRITE must be defined!
#elif !defined(SD_MMC_INTF_READ)
#error SD_MMC_INTF_READ must be defined!
#elif !defined(SD_MMC_INTF_SELECT_DEVICE)
#error SD_MMC_INTF_SELECT_DEVICE must be defined!
#elif !defined(SD_MMC_INTF_DESELECT_DEVICE)
#error SD_MMC_INTF_DESELECT_DEVICE must be defined!
#endif
#endif
