16#include "effs_fat/sdhc_mcf.h"
19#error eSDHC driver is a C++ only library
27#define ESDHC_ERROR (2)
28#define ESDHC_TIMEOUT (3)
32#define DMA_MODE_SIMPLE 1
34#define ESDHC_IRQ_MODE 1
60 volatile uint8_t ESDHC_INT_STATUS;
61 volatile BOOL ESDHCfinished;
67 OS_SEM *m_finishedSem;
68 uint32_t m_actualBaudrate;
72 static esdhcDriverStruct tranCtx;
73 static bool m_inProgress;
79 uint8_t Init(uint32_t Baudrate = 0,
bool hw_reset =
false);
80 void Reset(uint32_t Baudrate = INIT_BAUDRATE,
bool hw_reset =
true);
81 bool SetBaudrate(uint32_t Baudrate);
82 bool SetDataBusWidth(uint8_t width);
83 uint8_t GetDataBusWidth(
void);
84 void ClearTransferStatus(
bool abortTransfer =
true);
86 void SetTimeouts(
double rdTimeout_us,
double wrTimeout_us);
88 bool RegisterSem(OS_SEM *finishedSem);
89 inline bool ClrSem() {
return RegisterSem(NULL); }
90 inline OS_SEM *GetSem() {
return m_finishedSem; }
92 uint8_t TransferCmd(uint8_t cmdIdx, uint32_t cmdArg = 0,
void *cmdRsp = NULL);
93 uint8_t TransferCmdData(uint8_t cmdIdx,
98 uint16_t blkCount = 1,
100 bool autoCMD12 =
true);
101 uint8_t GetTransferStatus();
102 bool AbortTransfer(uint32_t timeout,
bool force =
false);
104 inline bool Done() {
return !m_inProgress; }
106 inline uint32_t GetActualBaudrate() {
return m_actualBaudrate; }
110#ifndef ESDHC_IRQ_MODE
111 static uint8_t send_cmd(
unsigned long cmd_index,
unsigned long cmd_arg = 0,
void *resp_data = NULL);
112 static uint8_t send_cmd_dt(
unsigned long cmd_index,
113 unsigned long cmd_arg,
115 unsigned short data_size,
116 void *resp_data = NULL);