-
Notifications
You must be signed in to change notification settings - Fork 2
/
FS_ConfigMMC_CM_HS.c
156 lines (143 loc) · 5.12 KB
/
FS_ConfigMMC_CM_HS.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*********************************************************************
* (c) SEGGER Microcontroller GmbH *
* The Embedded Experts *
* www.segger.com *
**********************************************************************
----------------------------------------------------------------------
Licensing information
Licensor: SEGGER Microcontroller Systems LLC
Licensed to: Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA
Licensed SEGGER software: emFile
License number: FS-00227
License model: Cypress Services and License Agreement, signed November 17th/18th, 2010
and Amendment Number One, signed December 28th, 2020 and February 10th, 2021
Licensed platform: Any Cypress platform (Initial targets are: PSoC3, PSoC5, PSoC6)
----------------------------------------------------------------------
Support and Update Agreement (SUA)
SUA period: 2010-12-01 - 2022-07-27
Contact to extend SUA: [email protected]
-------------------------- END-OF-HEADER -----------------------------
File : FS_ConfigMMC_CM_HS.c
Purpose : Configuration functions for FS with MMC/SD card mode driver
using 4-bit or 8-bit data bus and high speed access mode.
*/
/*********************************************************************
*
* #include section
*
**********************************************************************
*/
#include "FS.h"
#include "FS_MMC_HW_CM.h"
#include "cybsp.h"
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
#define ALLOC_SIZE 0x2000 // Size defined in bytes
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
static U32 _aMemBlock[ALLOC_SIZE / 4]; // Memory pool used for semi-dynamic allocation.
static FS_MMC_HW_CM_SDHostConfig_t SDConfig =
{
.Config =
{
.enableLedControl = false,
.lowVoltageSignaling = false,
.isEmmc = false,
.busWidth = 4
},
.Cmd = CYBSP_SDHC_CMD,
.Clk = CYBSP_SDHC_CLK,
.Data0 = CYBSP_SDHC_IO0,
.Data1 = CYBSP_SDHC_IO1,
.Data2 = CYBSP_SDHC_IO2,
.Data3 = CYBSP_SDHC_IO3,
.Data4 = NC,
.Data5 = NC,
.Data6 = NC,
.Data7 = NC,
.CardDetect = CYBSP_SDHC_DETECT,
.IoVoltSel = NC,
.CardPwrEn = NC,
.CardWriteProt = NC,
.LedControl = NC,
.EmmcReset = NC,
.BlockClk = NULL
};
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* FS_X_AddDevices
*
* Function description
* This function is called by the FS during FS_Init().
* It is supposed to add all devices, using primarily FS_AddDevice().
*
* Note
* (1) Other API functions may NOT be called, since this function is called
* during initialization. The devices are not yet ready at this point.
*/
void FS_X_AddDevices(void) {
//
// Give file system memory to work with.
//
FS_AssignMemory(&_aMemBlock[0], sizeof(_aMemBlock));
//
// Add and configure the driver.
//
FS_AddDevice(&FS_MMC_CM_Driver);
FS_MMC_CM_Allow4bitMode(0, 1);
FS_MMC_CM_AllowHighSpeedMode(0, 1);
// Configure the HW layer and add it.
(void) FS_MMC_HW_CM_Configure(0, &SDConfig);
FS_MMC_CM_SetHWType(0, &FS_MMC_HW_CM);
//
// Configure the file system for fast write operations.
//
#if FS_SUPPORT_FILE_BUFFER
FS_ConfigFileBufferDefault(512, FS_FILE_BUFFER_WRITE);
#endif // FS_SUPPORT_FILE_BUFFER
FS_SetFileWriteMode(FS_WRITEMODE_FAST);
}
/*********************************************************************
*
* FS_X_GetTimeDate
*
* Function description
* Current time and date in a format suitable for the file system.
*
* Additional information
* Bit 0-4: 2-second count (0-29)
* Bit 5-10: Minutes (0-59)
* Bit 11-15: Hours (0-23)
* Bit 16-20: Day of month (1-31)
* Bit 21-24: Month of year (1-12)
* Bit 25-31: Count of years from 1980 (0-127)
*/
U32 FS_X_GetTimeDate(void) {
U32 r;
U16 Sec, Min, Hour;
U16 Day, Month, Year;
Sec = 0; // 0 based. Valid range: 0..59
Min = 0; // 0 based. Valid range: 0..59
Hour = 0; // 0 based. Valid range: 0..23
Day = 1; // 1 based. Means that 1 is 1. Valid range is 1..31 (depending on month)
Month = 1; // 1 based. Means that January is 1. Valid range is 1..12.
Year = 0; // 1980 based. Means that 2007 would be 27.
r = Sec / 2 + (Min << 5) + (Hour << 11);
r |= (U32)(Day + (Month << 5) + (Year << 9)) << 16;
return r;
}
/*************************** End of file ****************************/