PDL for FM4
Version1.2
Peripheral Driverl Library for FM4
Main Page
Modules
Data Structures
Files
File List
Globals
sd.h
Go to the documentation of this file.
1
/*******************************************************************************
2
* Copyright (C) 2013 Spansion LLC. All Rights Reserved.
3
*
4
* This software is owned and published by:
5
* Spansion LLC, 915 DeGuigne Dr. Sunnyvale, CA 94088-3453 ("Spansion").
6
*
7
* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
8
* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
9
*
10
* This software contains source code for use with Spansion
11
* components. This software is licensed by Spansion to be adapted only
12
* for use in systems utilizing Spansion components. Spansion shall not be
13
* responsible for misuse or illegal use of this software for devices not
14
* supported herein. Spansion is providing this software "AS IS" and will
15
* not be responsible for issues arising from incorrect user implementation
16
* of the software.
17
*
18
* SPANSION MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
19
* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
20
* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
21
* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
22
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
23
* WARRANTY OF NONINFRINGEMENT.
24
* SPANSION SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
25
* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
26
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
27
* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
28
* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
29
* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
30
* SAVINGS OR PROFITS,
31
* EVEN IF SPANSION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32
* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
33
* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
34
* FROM, THE SOFTWARE.
35
*
36
* This software may be replicated in part or whole for the licensed use,
37
* with the restriction that this Disclaimer and Copyright notice must be
38
* included with each copy of this software, whether used in part or whole,
39
* at all times.
40
*/
41
/******************************************************************************/
52
#ifndef __SD_H__
53
#define __SD_H__
54
55
/******************************************************************************/
56
/* Include files */
57
/******************************************************************************/
58
#include "
pdl.h
"
59
#include "
sd_cfg.h
"
60
61
#if (defined(PDL_PERIPHERAL_SD_ACTIVE))
62
63
/* C binding of definitions if building with C++ compiler */
64
#ifdef __cplusplus
65
extern
"C"
66
{
67
#endif
68
74
75
/******************************************************************************
76
* SDIF registers definitions
77
******************************************************************************/
78
79
/******************************************************************************
80
* Global definitions
81
******************************************************************************/
82
#define stc_sd_t FM4_SDIF_TypeDef
83
84
/* The Physical Layer Specification Version 3.0x defines that SDXC card may indicate 500ms busy.
85
Then host driver may need to change timeout value for SDXC.It is set more than 500ms
86
timeout regardless of card capacities.*/
87
#define SD_TIMEOUT_DATLINE 1000 //ms
88
89
/* software reset options*/
90
#define RESET_DAT (1<<2)
91
#define RESET_CMD (1<<1)
92
#define RESET_ALL 1
93
/******************************************************************************
94
* Global type definitions
95
******************************************************************************/
96
typedef
void (*
func_ptr_sd_arg32_t
)(
volatile
stc_sd_t
*);
97
103
typedef
enum
en_sd_clk
104
{
105
CLK_25M
= 25,
106
CLK_50M
= 50
107
}
en_sd_clk_t
;
113
typedef
enum
en_sd_transaction
114
{
115
NO_RESPONSE
= 0,
116
NO_DATA
,
117
SINGLE_BLOCK
,
118
MULTI_BLOCK
119
}
en_sd_transaction_t
;
120
126
typedef
enum
en_sd_dir
127
{
128
SD_WRITE
= 0,
129
SD_READ
= 1
130
}
en_sd_dir_t
;
131
137
typedef
enum
en_sd_cmd_type
138
{
139
NORMAL
= 0,
140
SUSPEND
= 1,
141
RESUME
= 2,
142
ABORT
= 3
143
}
en_sd_scmd_type_t
;
149
typedef
enum
en_sd_existing
150
{
151
DEBOUNCING
= 0,
152
INSERTED
= 1,
153
REMOVAL
= 2
154
}
en_sd_existing_t
;
155
160
typedef
enum
en_sd_buswidth
161
{
162
BIT_1
= 0,
163
BIT_4
= 1
164
}
en_sd_buswidth_t
;
165
170
typedef
enum
en_sd_busvoltage
171
{
172
V1_8
= 0x05,
173
V3_0
= 0x06,
174
V3_3
= 0x07
175
}
en_sd_busvoltage_t
;
176
177
182
typedef
enum
en_sd_response
183
{
184
NO_RSP
= 0,
185
R1NORMAL_R5_R6_R7
,
//normal response
186
R1AUTO
,
187
R1B_NORMAL
,
188
R1B_AUTO
,
189
R2
,
190
R3_R4
,
191
R5B
192
}
en_sd_response_t
;
193
198
typedef
enum
en_sd_auto_cmd
199
{
200
AUTO_DISABLE
= 0,
//normal response
201
AUTO_CMD12
= 1 ,
202
AUTO_CMD23
=2
203
}
en_sd_auto_cmd_t
;
204
205
typedef
enum
en_sd_boundary
206
{
207
BOUND_4K
= 0,
208
BOUND_8K
= 1,
209
BOUND_16K
= 2,
210
BOUND_32K
= 3,
211
BOUND_64K
= 4,
212
BOUND_128K
= 5,
213
BOUND_256K
= 6,
214
BOUND_512K
= 7
215
}
en_sd_boundary_t
;
221
typedef
struct
stc_sd_cmdconfig
222
{
223
en_sd_response_t
enResponse
;
224
en_sd_dir_t
enReadWrite
;
225
en_sd_scmd_type_t
enCmdType
;
226
boolean_t
bDataPresent
;
227
uint8_t
u8Index
;
228
en_sd_auto_cmd_t
enAutoCmd
;
229
uint16_t
u16BlockCount
;
230
uint16_t
u16BlockSize
;
231
uint32_t
u32Argument1
;
232
#ifdef SD_DMA
233
uint32_t u32SysAddr_Arg2;
234
en_sd_boundary_t
enbound;
235
#endif
236
uint32_t *
pu32Buffer
;
237
func_ptr_sd_arg32_t
pfnErrorResponseCallback
;
238
}
stc_sd_comdconfig_t
;
244
typedef
struct
stc_sd_config
245
{
246
en_sd_existing_t
enExist
;
247
en_sd_buswidth_t
enBusWidth
;
248
boolean_t
bCmdComplete
;
249
boolean_t
bSendComplete
;
250
boolean_t
bDMAComplete
;
251
func_ptr_sd_arg32_t
pfnTxCallback
;
252
func_ptr_sd_arg32_t
pfnRxCallback
;
253
func_ptr_sd_arg32_t
pfnWakeupCallback
;
254
func_ptr_sd_arg32_t
pfnErrorCallback
;
255
}
stc_sd_config_t
;
256
257
258
/******************************************************************************/
259
/* Global variable declarations ('extern', definition in C source) */
260
/******************************************************************************/
261
extern
volatile
stc_sd_config_t
Sd_stcCfg
;
262
extern
stc_sd_comdconfig_t
Sd_stcCmdCfg
;
263
extern
volatile
stc_sd_t
*
Sd_stcCtrl
;
264
/******************************************************************************/
265
/* Global function prototypes ('extern', definition in C source) */
266
/******************************************************************************/
267
/******************************************************************************/
268
/* SDIF basic control function */
269
/******************************************************************************/
270
extern
en_result_t
Sd_HostInit
(
void
);
271
extern
en_result_t
Sd_HostDeInit
(
void
);
272
extern
en_result_t
Sd_SoftwareReset
(
volatile
stc_sd_t
* pstcSd,uint8_t u8reset);
273
extern
en_sd_existing_t
Sd_CardDetect
(
volatile
stc_sd_config_t
* pstcCfg);
274
extern
en_result_t
Sd_ClockSupply
(
volatile
stc_sd_t
* pstcSd,
en_sd_clk_t
enClk);
275
extern
en_result_t
Sd_ClockStop
(
volatile
stc_sd_t
*pstcSd);
276
extern
boolean_t
Sd_SendCmd
(
en_sd_transaction_t
enTran,
volatile
stc_sd_t
* pstcSd,
stc_sd_comdconfig_t
* pstcCmdCfg,uint32_t* pu32Buf);
277
/******************************************************************************/
278
/* SDIF interrupt function */
279
/******************************************************************************/
280
extern
void
Sd_Handler
(
void
);
281
extern
en_result_t
Sd_EnableInt
(
volatile
stc_sd_t
*pstcSd);
282
extern
en_result_t
Sd_DisableInt
(
volatile
stc_sd_t
*pstcSd);
283
/******************************************************************************/
284
/* SDIF data transfer function */
285
/******************************************************************************/
286
extern
boolean_t
Sd_TxData
(
volatile
stc_sd_t
* pstcSd,
stc_sd_comdconfig_t
* pstcCmdCfg,uint32_t* pu32Buf);
287
extern
boolean_t
Sd_RxData
(
en_sd_transaction_t
enTran,
volatile
stc_sd_t
* pstcSd,
stc_sd_comdconfig_t
* pstcCmdCfg,uint32_t* pu32Buf);
288
289
/***ToDo for second release
290
291
//power switch
292
//Error recovery
293
//Suspend/resume
294
//ADMA support
295
//MMC related
296
297
**/
//ToDo for second release
298
300
#ifdef __cplusplus
301
}
302
#endif
303
304
#endif // #if (defined(PDL_PERIPHERAL_SD_ACTIVE))
305
306
#endif
/* __SD_H__ */
307
/******************************************************************************/
308
/* EOF (not truncated) */
309
/******************************************************************************/
310
PDL_1_2
library
driver
sd
sd.h
Generated on Wed May 28 2014 09:28:11 for PDL for FM4 by
1.8.3.1