NetBurner 3.5.8
PDF Version
Toggle main menu visibility
NANO54415/include/esdhc.h
1
/*NB_REVISION*/
2
3
/*NB_COPYRIGHT*/
4
5
#ifndef _ESDHC_H
6
#define _ESDHC_H
7
8
#include <predef.h>
9
#include <stdio.h>
10
#include <init.h>
11
#include <sim.h>
/*on-chip register definitions*/
12
#include <pins.h>
13
#include <nbrtos.h>
14
15
#include <sim5441x.h>
16
#include "effs_fat/sdhc_mcf.h"
17
18
#ifndef __cplusplus
19
#error eSDHC driver is a C++ only library
20
#endif
21
22
/*
23
ESDHC state
24
*/
25
#define ESDHC_OK (0)
26
#define ESDHC_BUSY (1)
27
#define ESDHC_ERROR (2)
28
#define ESDHC_TIMEOUT (3)
29
30
//#define __DEBUG_ESDHC // Enable debug messages
31
32
#define DMA_MODE_SIMPLE 1
33
//#define DMA_MODE_ADMA2 1
34
#define ESDHC_IRQ_MODE 1
35
36
/*
37
*****************************************************************************-
38
*
39
* dspiDriverStruct
40
*
41
* This struct contains the major variables/configurations used for a eSDHC transfer
42
*
43
*
44
* OS_SEM* ESDHC_Sem - This is a pointer to an external semaphore provided by ()
45
*
46
* uint8_t ESDHC_INT_STATUS - Status of the spi device
47
*
48
*
49
*****************************************************************************-
50
*/
51
typedef
struct
52
{
53
void
*pBlockData;
54
uint16_t BlockSize;
55
uint32_t BlocksCount;
56
uint32_t CmdMask;
57
uint32_t CmdArg;
58
OS_SEM
*finishedSem;
59
void
*pResp;
60
volatile
uint8_t ESDHC_INT_STATUS;
61
volatile
BOOL ESDHCfinished;
62
} esdhcDriverStruct;
63
64
class
ESDHCModule
65
{
66
OS_CRIT m_critSec;
67
OS_SEM *m_finishedSem;
68
uint32_t m_actualBaudrate;
69
70
public
:
71
// static ESDHCModule *lastCxts;
72
static
esdhcDriverStruct tranCtx;
73
static
bool
m_inProgress;
74
75
public
:
76
ESDHCModule();
77
~ESDHCModule();
78
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
);
85
86
void
SetTimeouts(
double
rdTimeout_us,
double
wrTimeout_us);
87
88
bool
RegisterSem(OS_SEM *finishedSem);
89
inline
bool
ClrSem() {
return
RegisterSem(NULL); }
90
inline
OS_SEM *GetSem() {
return
m_finishedSem; }
91
92
uint8_t TransferCmd(uint8_t cmdIdx, uint32_t cmdArg = 0,
void
*cmdRsp = NULL);
93
uint8_t TransferCmdData(uint8_t cmdIdx,
94
uint32_t cmdArg,
95
bool
dataRead,
96
void
*blkData,
97
uint16_t blk_size,
98
uint16_t blkCount = 1,
99
void
*cmdRsp = NULL,
100
bool
autoCMD12 =
true
);
101
uint8_t GetTransferStatus();
102
bool
AbortTransfer(uint32_t timeout,
bool
force =
false
);
103
104
inline
bool
Done() {
return
!m_inProgress; }
105
106
inline
uint32_t GetActualBaudrate() {
return
m_actualBaudrate; }
107
108
bool
CardReady();
109
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,
114
void
*data,
115
unsigned
short
data_size,
116
void
*resp_data = NULL);
117
// static uint8_t read_block(int drv, unsigned long blk_addr, unsigned short blk_size, void *buff);
118
// static uint8_t write_block(int drv, unsigned long blk_addr, unsigned short blk_size, void *buff);
119
#endif
120
121
private
:
122
bool
TransferDone();
123
124
uint32_t mRdDTOCV;
125
uint32_t mWrDTOCV;
126
};
127
128
#endif
/* _ESDHC_H_ */
OS_SEM
Semaphores are used to control access to shared resources or or to communicate between tasks in a mul...
Definition
nbrtos.h:407
platform
NANO54415
include
esdhc.h
Generated by
1.18.0