17#include "effs_fat/sdhc_mcf.h"
20#error eSDHC driver is a C++ only library
27#define USDHC_BUSY ( 1 )
28#define USDHC_ERROR ( 2 )
29#define USDHC_TIMEOUT ( 3 )
33#define DMA_MODE_SIMPLE 1
35#define USDHC_IRQ_MODE 1
62 volatile uint8_t USDHC_INT_STATUS;
63 volatile BOOL USDHCfinished;
70 OS_SEM *m_finishedSem;
71 uint32_t m_actualBaudrate;
76 static esdhcDriverStruct tranCtx;
77 static bool m_inProgress;
80 USDHCModule(USDHC_Type &hw);
83 uint8_t Init(uint32_t Baudrate = 0,
bool hw_reset =
false);
84 void Reset(uint32_t Baudrate = INIT_BAUDRATE,
bool hw_reset =
true);
85 bool SetBaudrate(uint32_t Baudrate);
86 bool SetDataBusWidth(uint8_t width);
87 uint8_t GetDataBusWidth(
void);
88 void ClearTransferStatus(
bool abortTransfer =
true);
90 void SetTimeouts(
double rdTimeout_us,
double wrTimeout_us);
92 bool RegisterSem( OS_SEM *finishedSem );
93 inline bool ClrSem() {
return RegisterSem(NULL); }
94 inline OS_SEM * GetSem() {
return m_finishedSem; }
96 uint8_t TransferCmd(uint8_t cmdIdx, uint32_t cmdArg = 0,
void *cmdRsp = NULL);
97 uint8_t TransferCmdData(uint8_t cmdIdx, uint32_t cmdArg,
98 bool dataRead,
void *blkData,
99 uint16_t blk_size, uint16_t blkCount = 1,
100 void *cmdRsp = NULL,
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 USDHC_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,
unsigned long cmd_arg,
113 void *data,
unsigned short data_size,
114 void *resp_data = NULL);
120 bool TransferDone(
bool dataPresent =
true);