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.

93 lines
3.4 KiB
C

4 years ago
#ifndef _SD_MMC_INTF_
#define _SD_MMC_INTF_
4 years ago
#define DEFAULT_IMPL 0
4 years ago
// SD MMC Interface
// Define FUNCTIONS and stuff here
4 years ago
#include "sd_mmc_spi_impl.h"
4 years ago
/**
* @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
*/
4 years ago
#define SD_MMC_INTF_SELECT_DEVICE() sd_mmc_spi_impl_select_device()
4 years ago
/**
* @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
*/
4 years ago
#define SD_MMC_INTF_DESELECT_DEVICE() sd_mmc_spi_impl_deselect_device()
4 years ago
/**
* @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 --
*/
4 years ago
#define SD_MMC_INTF_READ(bytes, len) sd_mmc_spi_impl_read(bytes, len)
4 years ago
/**
* @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 --
*/
4 years ago
#define SD_MMC_INTF_WRITE(bytes, len) sd_mmc_spi_impl_write(bytes, len)
4 years ago
/**
* @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 --
*/
4 years ago
#define SD_MMC_INTF_INIT() sd_mmc_spi_impl_init()
4 years ago
4 years ago
/**
* @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
4 years ago
#endif