PDL for FM4
Version1.2
Peripheral Driverl Library for FM4
Main Page
Modules
Data Structures
Files
File List
Globals
sdcmd.c
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
/******************************************************************************/
53
/* Include files */
54
/******************************************************************************/
55
#include "
sdcmd.h
"
56
57
#if (defined(PDL_PERIPHERAL_SD_ACTIVE))
58
64
65
/******************************************************************************/
66
/* Local pre-processor symbols/macros ('#define') */
67
/******************************************************************************/
68
69
/******************************************************************************/
70
/* Global variable definitions (declared in header file with 'extern') */
71
/******************************************************************************/
72
73
/******************************************************************************/
74
/* Local type definitions ('typedef') */
75
/******************************************************************************/
76
77
/******************************************************************************/
78
/* Local function prototypes ('static') */
79
/******************************************************************************/
80
81
/******************************************************************************/
82
/* Local variable definitions ('static') */
83
/******************************************************************************/
84
85
/******************************************************************************/
86
/* Function implementation - global ('extern') and local ('static') */
87
/******************************************************************************/
88
89
/******************************************************************************/
90
/* Local Functions */
91
/******************************************************************************/
92
93
/******************************************************************************/
94
/* Global Functions */
95
/******************************************************************************/
108
boolean_t
Sdcmd_RxData
(uint32_t* pu32Buf)
109
{
110
return
Sd_RxData
(
SINGLE_BLOCK
,
Sd_stcCtrl
,&
Sd_stcCmdCfg
,pu32Buf);
111
}
112
125
boolean_t
Sdcmd_TxData
(uint32_t* pu32Buf)
126
{
127
return
Sd_TxData
(
Sd_stcCtrl
,&
Sd_stcCmdCfg
,pu32Buf);
128
}
144
boolean_t
Sdcmd_SendCmd
(uint8_t u8Cmd,uint32_t u32Arg,uint32_t *pu32Buf)
145
{
146
en_sd_transaction_t
enTran ;
147
boolean_t
result =
FALSE
;
148
uint8_t u8Cmdindex = u8Cmd;
149
150
switch
(u8Cmdindex)
151
{
152
case
SD_CMD0
:
153
enTran =
NO_RESPONSE
;
154
Sd_stcCmdCfg
.
enReadWrite
=
SD_WRITE
;
155
Sd_stcCmdCfg
.
enResponse
=
NO_RSP
;
156
Sd_stcCmdCfg
.
enCmdType
=
NORMAL
;
157
Sd_stcCmdCfg
.
bDataPresent
=
FALSE
;
158
Sd_stcCmdCfg
.
u16BlockSize
= 0;
159
Sd_stcCmdCfg
.
u16BlockCount
= 0;
160
break
;
161
case
SD_CMD2
:
162
case
SD_CMD9
:
163
case
SD_CMD10
:
164
enTran =
NO_DATA
;
165
Sd_stcCmdCfg
.
enReadWrite
=
SD_WRITE
;
166
Sd_stcCmdCfg
.
enResponse
=
R2
;
167
Sd_stcCmdCfg
.
enCmdType
=
NORMAL
;
168
Sd_stcCmdCfg
.
bDataPresent
=
FALSE
;
169
Sd_stcCmdCfg
.
u16BlockSize
= 0;
170
Sd_stcCmdCfg
.
u16BlockCount
= 0;
171
break
;
172
case
SD_CMD3
:
173
case
SD_CMD8
:
174
case
SD_CMD13
:
175
case
SD_CMD16
:
176
case
SD_CMD55
:
177
case
SD_ACMD6
:
178
enTran =
NO_DATA
;
179
Sd_stcCmdCfg
.
enReadWrite
=
SD_WRITE
;
180
Sd_stcCmdCfg
.
enResponse
=
R1NORMAL_R5_R6_R7
;
181
Sd_stcCmdCfg
.
enCmdType
=
NORMAL
;
182
Sd_stcCmdCfg
.
bDataPresent
=
FALSE
;
183
Sd_stcCmdCfg
.
u16BlockSize
= 0;
184
Sd_stcCmdCfg
.
u16BlockCount
= 0;
185
break
;
186
case
SD_CMD7
:
187
enTran =
NO_DATA
;
188
Sd_stcCmdCfg
.
enReadWrite
=
SD_WRITE
;
189
Sd_stcCmdCfg
.
enResponse
=
R1B_NORMAL
;
190
Sd_stcCmdCfg
.
enCmdType
=
NORMAL
;
191
Sd_stcCmdCfg
.
bDataPresent
=
FALSE
;
192
Sd_stcCmdCfg
.
u16BlockSize
= 0;
193
Sd_stcCmdCfg
.
u16BlockCount
= 0;
194
break
;
195
case
SD_CMD12
:
196
enTran =
NO_DATA
;
197
Sd_stcCmdCfg
.
enReadWrite
=
SD_WRITE
;
198
Sd_stcCmdCfg
.
enResponse
=
R1B_AUTO
;
199
Sd_stcCmdCfg
.
enCmdType
=
ABORT
;
200
Sd_stcCmdCfg
.
bDataPresent
=
FALSE
;
201
Sd_stcCmdCfg
.
u16BlockSize
= 0;
202
Sd_stcCmdCfg
.
u16BlockCount
= 0;
203
break
;
204
case
SD_CMD17
:
205
enTran =
SINGLE_BLOCK
;
206
Sd_stcCmdCfg
.
enReadWrite
=
SD_READ
;
207
Sd_stcCmdCfg
.
enResponse
=
R1NORMAL_R5_R6_R7
;
208
Sd_stcCmdCfg
.
enCmdType
=
NORMAL
;
209
Sd_stcCmdCfg
.
bDataPresent
=
TRUE
;
210
Sd_stcCmdCfg
.
u16BlockSize
= 512;
211
Sd_stcCmdCfg
.
u16BlockCount
= 1;
212
break
;
213
case
SD_CMD24
:
214
enTran =
SINGLE_BLOCK
;
215
Sd_stcCmdCfg
.
enReadWrite
=
SD_WRITE
;
216
Sd_stcCmdCfg
.
enResponse
=
R1NORMAL_R5_R6_R7
;
217
Sd_stcCmdCfg
.
enCmdType
=
NORMAL
;
218
Sd_stcCmdCfg
.
bDataPresent
=
TRUE
;
219
Sd_stcCmdCfg
.
u16BlockSize
= 512;
220
Sd_stcCmdCfg
.
u16BlockCount
= 1;
221
break
;
222
case
SD_ACMD13
:
223
enTran =
SINGLE_BLOCK
;
224
Sd_stcCmdCfg
.
enReadWrite
=
SD_WRITE
;
225
Sd_stcCmdCfg
.
enResponse
=
R1NORMAL_R5_R6_R7
;
226
Sd_stcCmdCfg
.
enCmdType
=
NORMAL
;
227
Sd_stcCmdCfg
.
bDataPresent
=
TRUE
;
228
Sd_stcCmdCfg
.
u16BlockSize
= 512;
229
Sd_stcCmdCfg
.
u16BlockCount
= 1;
230
break
;
231
case
SD_ACMD41
:
232
enTran =
NO_DATA
;
233
Sd_stcCmdCfg
.
enReadWrite
=
SD_WRITE
;
234
Sd_stcCmdCfg
.
enResponse
=
R3_R4
;
235
Sd_stcCmdCfg
.
enCmdType
=
NORMAL
;
236
Sd_stcCmdCfg
.
bDataPresent
=
FALSE
;
237
Sd_stcCmdCfg
.
u16BlockSize
= 0;
238
Sd_stcCmdCfg
.
u16BlockCount
= 0;
239
break
;
240
default
:
241
break
;
242
}
243
244
Sd_stcCmdCfg
.
u8Index
= u8Cmdindex;
245
246
Sd_stcCmdCfg
.
u32Argument1
= u32Arg;
247
248
result =
Sd_SendCmd
(enTran,
Sd_stcCtrl
,&
Sd_stcCmdCfg
,pu32Buf);
249
250
return
result;
251
}
252
254
255
#endif // #if (defined(PDL_PERIPHERAL_SD_ACTIVE))
256
257
/******************************************************************************/
258
/* EOF (not truncated) */
259
/******************************************************************************/
260
PDL_1_2
library
highlevel
sd
sdcmd.c
Generated on Wed May 28 2014 09:28:11 for PDL for FM4 by
1.8.3.1