mirror of https://github.com/rusefi/openblt.git
Refs #847. Enabled firmware updates from SD card in the XMC4700 Relax Kit demo bootloader for Keil MDK for ARM.
git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@948 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
This commit is contained in:
parent
6e230b3ba8
commit
ffd5a22c07
File diff suppressed because it is too large
Load Diff
|
@ -185,7 +185,7 @@
|
|||
* firmware update is completed by the bootloader.
|
||||
*/
|
||||
/** \brief Enable/disable support for firmware updates from a locally attached storage.*/
|
||||
#define BOOT_FILE_SYS_ENABLE (0)
|
||||
#define BOOT_FILE_SYS_ENABLE (1)
|
||||
/** \brief Enable/disable logging messages during firmware updates. */
|
||||
#define BOOT_FILE_LOGGING_ENABLE (1)
|
||||
/** \brief Enable/disable a hook function that is called upon detection of an error. */
|
||||
|
|
|
@ -135,7 +135,7 @@
|
|||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DLGUARM</Key>
|
||||
<Name></Name>
|
||||
<Name>d</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
|
@ -1679,32 +1679,32 @@
|
|||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>Core</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<GroupName>Lib/FatFS</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>122</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\asserts.c</PathWithFileName>
|
||||
<FilenameWithoutPath>asserts.c</FilenameWithoutPath>
|
||||
<PathWithFileName>..\lib\FatFS\ffconf.h</PathWithFileName>
|
||||
<FilenameWithoutPath>ffconf.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>123</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\asserts.h</PathWithFileName>
|
||||
<FilenameWithoutPath>asserts.h</FilenameWithoutPath>
|
||||
<PathWithFileName>..\lib\FatFS\mmc.c</PathWithFileName>
|
||||
<FilenameWithoutPath>mmc.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
|
@ -1715,8 +1715,8 @@
|
|||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\backdoor.c</PathWithFileName>
|
||||
<FilenameWithoutPath>backdoor.c</FilenameWithoutPath>
|
||||
<PathWithFileName>..\lib\FatFS\SDMMC_BLOCK\sdmmc_block.c</PathWithFileName>
|
||||
<FilenameWithoutPath>sdmmc_block.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
|
@ -1727,8 +1727,8 @@
|
|||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\backdoor.h</PathWithFileName>
|
||||
<FilenameWithoutPath>backdoor.h</FilenameWithoutPath>
|
||||
<PathWithFileName>..\lib\FatFS\SDMMC_BLOCK\sdmmc_block.h</PathWithFileName>
|
||||
<FilenameWithoutPath>sdmmc_block.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
|
@ -1739,8 +1739,8 @@
|
|||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\boot.c</PathWithFileName>
|
||||
<FilenameWithoutPath>boot.c</FilenameWithoutPath>
|
||||
<PathWithFileName>..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_conf.c</PathWithFileName>
|
||||
<FilenameWithoutPath>sdmmc_block_conf.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
|
@ -1751,8 +1751,8 @@
|
|||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\boot.h</PathWithFileName>
|
||||
<FilenameWithoutPath>boot.h</FilenameWithoutPath>
|
||||
<PathWithFileName>..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_conf.h</PathWithFileName>
|
||||
<FilenameWithoutPath>sdmmc_block_conf.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
|
@ -1763,8 +1763,8 @@
|
|||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\can.h</PathWithFileName>
|
||||
<FilenameWithoutPath>can.h</FilenameWithoutPath>
|
||||
<PathWithFileName>..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_extern.h</PathWithFileName>
|
||||
<FilenameWithoutPath>sdmmc_block_extern.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
|
@ -1775,8 +1775,8 @@
|
|||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\com.c</PathWithFileName>
|
||||
<FilenameWithoutPath>com.c</FilenameWithoutPath>
|
||||
<PathWithFileName>..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_private_sd.c</PathWithFileName>
|
||||
<FilenameWithoutPath>sdmmc_block_private_sd.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
|
@ -1787,14 +1787,130 @@
|
|||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_private_sd.h</PathWithFileName>
|
||||
<FilenameWithoutPath>sdmmc_block_private_sd.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>Core</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>131</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\asserts.c</PathWithFileName>
|
||||
<FilenameWithoutPath>asserts.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>132</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\asserts.h</PathWithFileName>
|
||||
<FilenameWithoutPath>asserts.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>133</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\backdoor.c</PathWithFileName>
|
||||
<FilenameWithoutPath>backdoor.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>134</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\backdoor.h</PathWithFileName>
|
||||
<FilenameWithoutPath>backdoor.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>135</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\boot.c</PathWithFileName>
|
||||
<FilenameWithoutPath>boot.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>136</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\boot.h</PathWithFileName>
|
||||
<FilenameWithoutPath>boot.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>137</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\can.h</PathWithFileName>
|
||||
<FilenameWithoutPath>can.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>138</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\com.c</PathWithFileName>
|
||||
<FilenameWithoutPath>com.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>139</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\com.h</PathWithFileName>
|
||||
<FilenameWithoutPath>com.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>131</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>140</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -1805,8 +1921,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>132</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>141</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -1817,8 +1933,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>133</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>142</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -1829,8 +1945,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>134</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>143</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -1841,8 +1957,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>135</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>144</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -1853,8 +1969,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>136</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>145</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -1865,8 +1981,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>137</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>146</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -1877,8 +1993,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>138</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>147</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -1889,8 +2005,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>139</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>148</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -1901,8 +2017,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>140</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>149</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -1913,8 +2029,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>141</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>150</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -1925,8 +2041,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>142</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>151</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -1937,8 +2053,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>143</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>152</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -1949,8 +2065,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>144</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>153</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -1969,8 +2085,8 @@
|
|||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>145</FileNumber>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>154</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -1981,8 +2097,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>146</FileNumber>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>155</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -1993,8 +2109,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>147</FileNumber>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>156</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -2005,8 +2121,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>148</FileNumber>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>157</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -2017,8 +2133,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>149</FileNumber>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>158</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -2029,8 +2145,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>150</FileNumber>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>159</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -2041,8 +2157,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>151</FileNumber>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>160</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -2053,8 +2169,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>152</FileNumber>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>161</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -2065,8 +2181,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>153</FileNumber>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>162</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -2078,4 +2194,72 @@
|
|||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>Core/third_party/fatfs</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>163</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\third_party\fatfs\src\diskio.h</PathWithFileName>
|
||||
<FilenameWithoutPath>diskio.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>164</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\third_party\fatfs\src\ff.c</PathWithFileName>
|
||||
<FilenameWithoutPath>ff.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>165</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\third_party\fatfs\src\ff.h</PathWithFileName>
|
||||
<FilenameWithoutPath>ff.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>166</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\third_party\fatfs\src\integer.h</PathWithFileName>
|
||||
<FilenameWithoutPath>integer.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>167</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\Source\third_party\fatfs\src\option\unicode.c</PathWithFileName>
|
||||
<FilenameWithoutPath>unicode.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
</ProjectOpt>
|
||||
|
|
|
@ -339,7 +339,7 @@
|
|||
<MiscControls>--diag_suppress=111</MiscControls>
|
||||
<Define>XMC4700_F144x2048</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\Boot;..\lib;..\lib\cmsis;..\lib\xmclib\inc;..\..\..\..\Source;..\..\..\..\Source\ARMCM4_XMC4</IncludePath>
|
||||
<IncludePath>..\..\Boot;..\lib;..\lib\cmsis;..\lib\xmclib\inc;..\lib\FatFS;..\lib\FatFS\SDMMC_BLOCK;..\..\..\..\Source;..\..\..\..\Source\ARMCM4_XMC4;..\..\..\..\Source\third_party\fatfs\src</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
|
@ -1005,6 +1005,56 @@
|
|||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Lib/FatFS</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>ffconf.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\lib\FatFS\ffconf.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mmc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\lib\FatFS\mmc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sdmmc_block.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\lib\FatFS\SDMMC_BLOCK\sdmmc_block.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sdmmc_block.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\lib\FatFS\SDMMC_BLOCK\sdmmc_block.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sdmmc_block_conf.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_conf.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sdmmc_block_conf.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_conf.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sdmmc_block_extern.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_extern.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sdmmc_block_private_sd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_private_sd.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sdmmc_block_private_sd.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_private_sd.h</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Core</GroupName>
|
||||
<Files>
|
||||
|
@ -1175,6 +1225,36 @@
|
|||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Core/third_party/fatfs</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>diskio.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\..\..\..\Source\third_party\fatfs\src\diskio.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>ff.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\Source\third_party\fatfs\src\ff.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>ff.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\..\..\..\Source\third_party\fatfs\src\ff.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>integer.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\..\..\..\Source\third_party\fatfs\src\integer.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>unicode.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\Source\third_party\fatfs\src\option\unicode.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
|
|
@ -0,0 +1,780 @@
|
|||
|
||||
/**
|
||||
* @file sdmmc_block.c
|
||||
* @date 2016-08-24
|
||||
*
|
||||
* NOTE:
|
||||
* This file is generated by DAVE. Any manual modification done to this file will be lost when the code is regenerated.
|
||||
*
|
||||
* @cond
|
||||
***********************************************************************************************************************
|
||||
* SDMMC_BLOCK v4.0.22 - The SDMMC_BLOCK APP is a generic SD/MMC card block device driver designed to drive SDMMC cards
|
||||
* with all relevant functionalities like writing or reading blocks of data from the card.
|
||||
*
|
||||
* Copyright (c) 2016-2017, Infineon Technologies AG
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes
|
||||
* with Infineon Technologies AG (dave@infineon.com).
|
||||
***********************************************************************************************************************
|
||||
*
|
||||
* Change History
|
||||
* --------------
|
||||
*
|
||||
* 2016-01-20:
|
||||
* - Initial version. <br>
|
||||
*
|
||||
* 2016-02-05:
|
||||
* - RTOS support added. <br>
|
||||
* - Bug fixes done.<br>
|
||||
*
|
||||
* 2016-02-08:
|
||||
* - Help Doc updated. <br>
|
||||
* - Bug fixes done.<br>
|
||||
*
|
||||
* 2016-04-05:
|
||||
* - Remove dead code <br>
|
||||
* - MISRA fixes <br>
|
||||
*
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* HEADER FILES
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#include "sdmmc_block.h"
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
# if SDMMC_BLOCK_RTOS_MODE_SELECT
|
||||
# include "sdmmc_block_private_sd_rtos.h"
|
||||
#else
|
||||
# include "sdmmc_block_private_sd.h"
|
||||
# endif /* SDMMC_BLOCK_RTOS_MODE_SELECT */
|
||||
#endif /* SDMMC_BLOCK_SD */
|
||||
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
# if SDMMC_BLOCK_RTOS_MODE_SELECT
|
||||
# include "sdmmc_block_private_spi_rtos.h"
|
||||
#else
|
||||
# include "sdmmc_block_private_spi.h"
|
||||
# endif /* SDMMC_BLOCK_RTOS_MODE_SELECT */
|
||||
#endif /* SDMMC_BLOCK_SPI */
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* MACROS
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#define SDMMC_BLOCK_LOCK (0x4U) /* Lock the card */
|
||||
#define SDMMC_BLOCK_UNLOCK (0x0U) /* Unlock the card */
|
||||
#define SDMMC_BLOCK_SET_PASSWD (0x1U) /* Set the password for the card */
|
||||
#define SDMMC_BLOCK_CLR_PASSWD (0x2U) /* Clears the password */
|
||||
#define SDMMC_BLOCK_SET_PASSWD_AND_LOCK (0x5U) /* Set the password and locks the card */
|
||||
#define SDMMC_BLOCK_FORCE_ERASE (0x8U) /* Force erase the password data */
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* LOCAL DATA
|
||||
**********************************************************************************************************************/
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* LOCAL ROUTINES
|
||||
**********************************************************************************************************************/
|
||||
|
||||
static SDMMC_BLOCK_STATUS_t SDMMC_BLOCK_lFlushDiskWriteCache(SDMMC_BLOCK_t *obj);
|
||||
|
||||
/**********************************************************************************************************************
|
||||
* API IMPLEMENTATION
|
||||
**********************************************************************************************************************/
|
||||
|
||||
/* SDMMC_BLOCK initialization function */
|
||||
SDMMC_BLOCK_STATUS_t SDMMC_BLOCK_Init(SDMMC_BLOCK_t *const obj)
|
||||
{
|
||||
SDMMC_BLOCK_STATUS_t status = SDMMC_BLOCK_STATUS_SUCCESS;
|
||||
SDMMC_BLOCK_MODE_STATUS_t mode_status = SDMMC_BLOCK_MODE_STATUS_SUCCESS;
|
||||
|
||||
XMC_ASSERT("SDMMC_BLOCK_Init:Null obj is passed as input" , (obj != NULL))
|
||||
|
||||
if (obj->init_flag == 1U)
|
||||
{
|
||||
status = SDMMC_BLOCK_STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Setup pins */
|
||||
if (obj->init_pins != NULL)
|
||||
{
|
||||
obj->init_pins();
|
||||
}
|
||||
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_Init(obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_Init(obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mode_status != SDMMC_BLOCK_MODE_STATUS_SUCCESS)
|
||||
{
|
||||
status = SDMMC_BLOCK_STATUS_FAILURE;
|
||||
obj->init_flag = 0U;
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->init_flag = 1U;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Initialize the card identification process */
|
||||
SDMMC_BLOCK_STATUS_t SDMMC_BLOCK_Initialize(SDMMC_BLOCK_t *const obj)
|
||||
{
|
||||
SDMMC_BLOCK_MODE_STATUS_t mode_status = SDMMC_BLOCK_MODE_STATUS_SUCCESS;
|
||||
SDMMC_BLOCK_STATUS_t status = SDMMC_BLOCK_STATUS_FAILURE;
|
||||
|
||||
XMC_ASSERT("SDMMC_BLOCK_Initialize:Null obj is passed as input" , (obj != NULL))
|
||||
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_CardIdentificationProcess(obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_CardIdentificationProcess(obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mode_status == SDMMC_BLOCK_MODE_STATUS_SUCCESS)
|
||||
{
|
||||
status = SDMMC_BLOCK_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Read the specified number of sectors of data from the specified address */
|
||||
SDMMC_BLOCK_STATUS_t SDMMC_BLOCK_ReadBlock(SDMMC_BLOCK_t *const obj,
|
||||
uint8_t* read_buf,
|
||||
const uint32_t sector_number,
|
||||
const uint8_t sector_count)
|
||||
{
|
||||
SDMMC_BLOCK_STATUS_t status = SDMMC_BLOCK_STATUS_SUCCESS;
|
||||
|
||||
XMC_ASSERT("SDMMC_BLOCK_ReadBlock:Null obj is passed as input" , (obj != NULL))
|
||||
XMC_ASSERT("SDMMC_BLOCK_ReadBlock:Read buffer address is invalid" , (read_buf != NULL))
|
||||
XMC_ASSERT("SDMMC_BLOCK_ReadBlock:Sector count to be read is zero" , (sector_count != 0U))
|
||||
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
status = SDMMC_BLOCK_SPI_ReadBlock(obj, read_buf, sector_number, (uint32_t)sector_count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
status = SDMMC_BLOCK_SD_ReadBlock(obj, read_buf, sector_number, sector_count);
|
||||
}
|
||||
#endif
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Write the specified number of sectors of data from the specified address */
|
||||
SDMMC_BLOCK_STATUS_t SDMMC_BLOCK_WriteBlock(SDMMC_BLOCK_t *const obj,
|
||||
uint8_t* write_buf,
|
||||
const uint32_t sector_number,
|
||||
const uint8_t sector_count)
|
||||
{
|
||||
SDMMC_BLOCK_STATUS_t status = SDMMC_BLOCK_STATUS_SUCCESS;
|
||||
|
||||
XMC_ASSERT("SDMMC_BLOCK_WriteBlock:Null obj is passed as input" , (obj != NULL))
|
||||
XMC_ASSERT("SDMMC_BLOCK_WriteBlock:Write buffer address is invalid" , (write_buf != NULL))
|
||||
XMC_ASSERT("SDMMC_BLOCK_WriteBlock:Sector count to be written is zero" , (sector_count != 0U))
|
||||
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
status = SDMMC_BLOCK_SPI_WriteBlock(obj, write_buf, sector_number, (uint32_t)sector_count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
status = SDMMC_BLOCK_SD_WriteBlock(obj, write_buf, sector_number, sector_count);
|
||||
}
|
||||
#endif
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Get the current status of the card */
|
||||
uint8_t SDMMC_BLOCK_GetStatus(SDMMC_BLOCK_t *const obj)
|
||||
{
|
||||
uint8_t disk_status = 0U;
|
||||
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
disk_status = SDMMC_BLOCK_SPI_GetState(obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
disk_status = SDMMC_BLOCK_SD_GetState(obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
return disk_status;
|
||||
}
|
||||
|
||||
/* I/O control */
|
||||
SDMMC_BLOCK_STATUS_t SDMMC_BLOCK_Ioctl(SDMMC_BLOCK_t *const obj, const uint8_t command, void *buffer)
|
||||
{
|
||||
SDMMC_BLOCK_STATUS_t status = SDMMC_BLOCK_STATUS_SUCCESS;
|
||||
SDMMC_BLOCK_MODE_STATUS_t mode_status = SDMMC_BLOCK_MODE_STATUS_SUCCESS;
|
||||
uint8_t card_status;
|
||||
bool valid_command = true;
|
||||
SDMMC_BLOCK_ERASE_ADDRESS_t *erase_ptr;
|
||||
SDMMC_BLOCK_LOCK_STRUCTURE_t lock = {0U};
|
||||
const SDMMC_BLOCK_PASSWORD_t *password;
|
||||
|
||||
XMC_ASSERT("SDMMC_BLOCK_WriteBlock:Null obj is passed as input" , (obj != NULL))
|
||||
|
||||
/* If card is not initialized or inserted */
|
||||
if ((obj->card_state & (uint8_t)SDMMC_BLOCK_CARD_STATE_NOT_INITIALIZED) == (uint8_t)0)
|
||||
{
|
||||
card_status = SDMMC_BLOCK_GetStatus(obj);
|
||||
|
||||
if ((card_status & (uint8_t)SDMMC_BLOCK_CARD_STATE_LOCKED) != 0U)
|
||||
{
|
||||
status = SDMMC_BLOCK_STATUS_LOCKED;
|
||||
if ((command == (uint8_t)SDMMC_BLOCK_CTRL_SYNC) ||
|
||||
(command == (uint8_t)SDMMC_BLOCK_MMC_GET_OCR) ||
|
||||
(command == (uint8_t)SDMMC_BLOCK_MMC_GET_SDSTAT) ||
|
||||
(command == (uint8_t)SDMMC_BLOCK_CTRL_TRIM))
|
||||
{
|
||||
valid_command = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
valid_command = false;
|
||||
status = SDMMC_BLOCK_STATUS_NOTRDY;
|
||||
}
|
||||
|
||||
if (valid_command == true)
|
||||
{
|
||||
/* Switch to the respective IOCTL command */
|
||||
switch (command)
|
||||
{
|
||||
/*
|
||||
* Control sync
|
||||
*/
|
||||
case SDMMC_BLOCK_CTRL_SYNC:
|
||||
status = SDMMC_BLOCK_lFlushDiskWriteCache(obj);
|
||||
break;
|
||||
|
||||
/*
|
||||
* Get sector size
|
||||
*/
|
||||
case SDMMC_BLOCK_GET_SECTOR_SIZE:
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_GetSectorSize(obj, buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_GetSectorSize(obj, buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
||||
/*
|
||||
* Get sector count
|
||||
*/
|
||||
case SDMMC_BLOCK_GET_SECTOR_COUNT:
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_GetSectorCount(obj, buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_GetSectorCount(obj, buffer);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
/*
|
||||
* Control trim. Erase the content in the specified sectors
|
||||
*/
|
||||
case SDMMC_BLOCK_CTRL_TRIM:
|
||||
erase_ptr = (SDMMC_BLOCK_ERASE_ADDRESS_t *) buffer;
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_EraseBlock(obj, (erase_ptr->start_address), (erase_ptr->end_address));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_EraseBlock(obj, (erase_ptr->start_address), (erase_ptr->end_address));
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
/*
|
||||
* Get block size
|
||||
*/
|
||||
case SDMMC_BLOCK_GET_BLOCK_SIZE:
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_GetBlockSize(obj, buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_GetBlockSize(obj, buffer);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
/*
|
||||
* Get the type of the card
|
||||
*/
|
||||
case SDMMC_BLOCK_MMC_GET_TYPE:
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_GetCardType(obj, buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_GetCardType(obj, buffer);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
/*
|
||||
* Get CSD
|
||||
*/
|
||||
case SDMMC_BLOCK_MMC_GET_CSD:
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_GetCsd(obj, buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_GetCsd(obj, buffer);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
/*
|
||||
* Get CID
|
||||
*/
|
||||
case SDMMC_BLOCK_MMC_GET_CID:
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_GetCid(obj, buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_GetCid(obj, buffer);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
/*
|
||||
* Get OCR
|
||||
*/
|
||||
case SDMMC_BLOCK_MMC_GET_OCR:
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_GetOcr(obj, buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_GetOcr(obj, buffer);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
/*
|
||||
* Get SD status
|
||||
*/
|
||||
case SDMMC_BLOCK_MMC_GET_SDSTAT:
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_GetSdStatus(obj, buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_GetSdStatus(obj, buffer);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
/*
|
||||
* Lock card
|
||||
*/
|
||||
case SDMMC_BLOCK_MMC_LOCK_CARD:
|
||||
lock.mode = (uint8_t)SDMMC_BLOCK_LOCK;
|
||||
password = (const SDMMC_BLOCK_PASSWORD_t *)buffer;
|
||||
|
||||
/* Check password length doesn't exceeds the permitted length */
|
||||
if (password->old_pwd_len <= (uint8_t)SDMMC_BLOCK_MAX_PASSWORD_LENGTH)
|
||||
{
|
||||
lock.pwd_len = password->old_pwd_len;
|
||||
memcpy(lock.pwd_data, password->old_pwd, lock.pwd_len);
|
||||
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_LockUnlockCard(obj, &lock, SDMMC_BLOCK_CARD_LOCK_STATUS_LOCKED);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_LockUnlockCard(obj, &lock, SDMMC_BLOCK_CARD_LOCK_STATUS_LOCKED);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_MODE_STATUS_OUT_OF_RANGE_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
/*
|
||||
* Unlock card
|
||||
*/
|
||||
case SDMMC_BLOCK_MMC_UNLOCK_CARD:
|
||||
lock.mode = (uint8_t)SDMMC_BLOCK_UNLOCK;
|
||||
password = (const SDMMC_BLOCK_PASSWORD_t *)buffer;
|
||||
|
||||
if (password->old_pwd_len <= (uint8_t)SDMMC_BLOCK_MAX_PASSWORD_LENGTH)
|
||||
{
|
||||
lock.pwd_len = password->old_pwd_len;
|
||||
memcpy(lock.pwd_data, password->old_pwd, lock.pwd_len);
|
||||
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_LockUnlockCard(obj, &lock, SDMMC_BLOCK_CARD_LOCK_STATUS_UNLOCKED);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_LockUnlockCard(obj, &lock, SDMMC_BLOCK_CARD_LOCK_STATUS_UNLOCKED);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_MODE_STATUS_OUT_OF_RANGE_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
/*
|
||||
* Set card password
|
||||
*/
|
||||
case SDMMC_BLOCK_MMC_SET_PASSWD:
|
||||
lock.mode = (uint8_t)SDMMC_BLOCK_SET_PASSWD;
|
||||
password = (const SDMMC_BLOCK_PASSWORD_t *)buffer;
|
||||
|
||||
if ((password->old_pwd_len <= (uint8_t)SDMMC_BLOCK_MAX_PASSWORD_LENGTH) &&
|
||||
(password->new_pwd_len <= (uint8_t)SDMMC_BLOCK_MAX_PASSWORD_LENGTH))
|
||||
{
|
||||
lock.pwd_len = password->old_pwd_len + password->new_pwd_len;
|
||||
memcpy(lock.pwd_data, password->old_pwd, password->old_pwd_len);
|
||||
memcpy(&lock.pwd_data[password->old_pwd_len], password->new_pwd, password->new_pwd_len);
|
||||
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_LockUnlockCard(obj, &lock, SDMMC_BLOCK_CARD_LOCK_STATUS_UNLOCKED);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_LockUnlockCard(obj, &lock, SDMMC_BLOCK_CARD_LOCK_STATUS_UNLOCKED);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_MODE_STATUS_OUT_OF_RANGE_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
/*
|
||||
* Clear card password
|
||||
*/
|
||||
case SDMMC_BLOCK_MMC_CLEAR_PASSWD:
|
||||
lock.mode = (uint8_t)SDMMC_BLOCK_CLR_PASSWD;
|
||||
password = (const SDMMC_BLOCK_PASSWORD_t *)buffer;
|
||||
if (password->old_pwd_len <= (uint8_t)SDMMC_BLOCK_MAX_PASSWORD_LENGTH)
|
||||
{
|
||||
lock.pwd_len = password->old_pwd_len;
|
||||
memcpy(lock.pwd_data, password->old_pwd, lock.pwd_len);
|
||||
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_LockUnlockCard(obj, &lock, SDMMC_BLOCK_CARD_LOCK_STATUS_UNLOCKED);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_LockUnlockCard(obj, &lock, SDMMC_BLOCK_CARD_LOCK_STATUS_UNLOCKED);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_MODE_STATUS_OUT_OF_RANGE_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
/*
|
||||
* Set card lock
|
||||
*/
|
||||
case SDMMC_BLOCK_MMC_SET_LOCK:
|
||||
lock.mode = (uint8_t)SDMMC_BLOCK_SET_PASSWD_AND_LOCK;
|
||||
password = (const SDMMC_BLOCK_PASSWORD_t *)buffer;
|
||||
|
||||
if ((password->old_pwd_len <= (uint8_t)SDMMC_BLOCK_MAX_PASSWORD_LENGTH) &&
|
||||
(password->new_pwd_len <= (uint8_t)SDMMC_BLOCK_MAX_PASSWORD_LENGTH))
|
||||
{
|
||||
lock.pwd_len = password->old_pwd_len + password->new_pwd_len;
|
||||
memcpy(lock.pwd_data, password->old_pwd, password->old_pwd_len);
|
||||
memcpy(&lock.pwd_data[password->old_pwd_len], password->new_pwd, password->new_pwd_len);
|
||||
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_LockUnlockCard(obj, &lock, SDMMC_BLOCK_CARD_LOCK_STATUS_LOCKED);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_LockUnlockCard(obj, &lock, SDMMC_BLOCK_CARD_LOCK_STATUS_LOCKED);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_MODE_STATUS_OUT_OF_RANGE_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
/*
|
||||
* Read lock status
|
||||
*/
|
||||
case SDMMC_BLOCK_MMC_READ_LOCK_STATUS:
|
||||
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_GetLockStatus(obj, (SDMMC_BLOCK_CARD_LOCK_STATUS_t *)buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_GetLockStatus(obj, (SDMMC_BLOCK_CARD_LOCK_STATUS_t *)buffer);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
/*
|
||||
* Force card erase
|
||||
*/
|
||||
case SDMMC_BLOCK_MMC_FORCE_ERASE:
|
||||
lock.mode = (uint8_t)SDMMC_BLOCK_FORCE_ERASE;
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_LockUnlockCard(obj, &lock, SDMMC_BLOCK_CARD_LOCK_STATUS_UNLOCKED);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_LockUnlockCard(obj, &lock, SDMMC_BLOCK_CARD_LOCK_STATUS_UNLOCKED);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
/*
|
||||
* Eject card
|
||||
*/
|
||||
case SDMMC_BLOCK_CTRL_EJECT:
|
||||
#ifdef SDMMC_BLOCK_SPI
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SPI)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SPI_EjectCard(obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
if (obj->interface_mode == SDMMC_BLOCK_CARD_INTERFACE_SD)
|
||||
{
|
||||
mode_status = SDMMC_BLOCK_SD_EjectCard(obj);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
mode_status = SDMMC_BLOCK_MODE_STATUS_OUT_OF_RANGE_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if (mode_status == SDMMC_BLOCK_MODE_STATUS_SUCCESS)
|
||||
{
|
||||
status = SDMMC_BLOCK_STATUS_SUCCESS;
|
||||
}
|
||||
else if (mode_status == SDMMC_BLOCK_MODE_STATUS_WP_VIOLATION_ERROR)
|
||||
{
|
||||
status = SDMMC_BLOCK_STATUS_WRPRT;
|
||||
}
|
||||
else if ((mode_status == SDMMC_BLOCK_MODE_STATUS_OUT_OF_RANGE_ERROR) ||
|
||||
(mode_status == SDMMC_BLOCK_MODE_STATUS_SECTOR_OUT_OF_BOUND))
|
||||
{
|
||||
status = SDMMC_BLOCK_STATUS_PARERR;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = SDMMC_BLOCK_STATUS_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#if SDMMC_BLOCK_SD_CARD_DETECTION_SUPPORT
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
|
||||
/*
|
||||
* Registers the callback function for the card detection
|
||||
* mechanism.
|
||||
*/
|
||||
SDMMC_BLOCK_STATUS_t SDMMC_BLOCK_RegisterCallback(SDMMC_BLOCK_t *const obj,
|
||||
void (*cb)(SDMMC_BLOCK_SD_INTERRUPT_t))
|
||||
{
|
||||
SDMMC_BLOCK_STATUS_t status = SDMMC_BLOCK_STATUS_PARERR;
|
||||
|
||||
/* Check if the callback is not NULL */
|
||||
if (cb != NULL)
|
||||
{
|
||||
obj->sdmmc_sd->callback = cb;
|
||||
status = SDMMC_BLOCK_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif /* SDMMC_BLOCK_SD */
|
||||
|
||||
#endif /* SDMMC_BLOCK_SD_CARD_DETECTION_SUPPORT */
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* LOCAL ROUTINES IMPLEMENTATION
|
||||
**********************************************************************************************************************/
|
||||
|
||||
/* Flush disk cache */
|
||||
static SDMMC_BLOCK_STATUS_t SDMMC_BLOCK_lFlushDiskWriteCache(SDMMC_BLOCK_t *obj)
|
||||
{
|
||||
/*
|
||||
* A flush is generally meant for writing filled buffers/cache to the
|
||||
* media. We're already ensuring that a write block(s) operation completes
|
||||
* before it exits WriteBlock().
|
||||
* So, this function does nothing at the moment. We are simply going to
|
||||
* return success
|
||||
*/
|
||||
return SDMMC_BLOCK_STATUS_SUCCESS;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,326 @@
|
|||
/*********************************************************************************************************************
|
||||
* DAVE APP Name : SDMMC_BLOCK APP Version: 4.0.22
|
||||
*
|
||||
* NOTE:
|
||||
* This file is generated by DAVE. Any manual modification done to this file will be lost when the code is regenerated.
|
||||
*********************************************************************************************************************/
|
||||
|
||||
/**
|
||||
* @cond
|
||||
***********************************************************************************************************************
|
||||
* Copyright (c) 2016, Infineon Technologies AG
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes
|
||||
* with Infineon Technologies AG (dave@infineon.com).
|
||||
***********************************************************************************************************************
|
||||
*
|
||||
* Change History
|
||||
* --------------
|
||||
*
|
||||
* 2016-01-20:
|
||||
* - Initial version <br>
|
||||
*
|
||||
* 2016-02-05:
|
||||
* - RTOS support added <br>
|
||||
*
|
||||
* 2016-04-05:
|
||||
* - MISRA fixes.<br>
|
||||
* - Bug fixes done for PR.<br>
|
||||
*
|
||||
* 2016-04-05:
|
||||
* - Code genration fix for XMC4300 device.<br>
|
||||
*
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* HEADER FILES
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#include "sdmmc_block.h"
|
||||
|
||||
/**********************************************************************************************************************
|
||||
* LOCAL ROUTINES
|
||||
**********************************************************************************************************************/
|
||||
|
||||
/* SDMMC_BLOCK configuration initialization */
|
||||
static void SDMMC_BLOCK_0_Config_Init(void);
|
||||
|
||||
|
||||
/**********************************************************************************************************************
|
||||
* EXTERNAL REFERENCES
|
||||
**********************************************************************************************************************/
|
||||
|
||||
extern SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_ErrorInterruptHandler(SDMMC_BLOCK_t *const obj,
|
||||
uint16_t int_status);
|
||||
|
||||
extern SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_NormalInterruptHandler(SDMMC_BLOCK_t *const obj,
|
||||
uint16_t int_status);
|
||||
|
||||
|
||||
/**********************************************************************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
**********************************************************************************************************************/
|
||||
|
||||
volatile uint16_t normal_int_status; /* Normal interrupt status */
|
||||
volatile uint16_t err_int_status; /* Error interrupt status */
|
||||
|
||||
|
||||
/**********************************************************************************************************************
|
||||
* DATA STRUCTURES
|
||||
**********************************************************************************************************************/
|
||||
|
||||
|
||||
/* SDMMC_BLOCK Data 0 pin config */
|
||||
const SDMMC_BLOCK_GPIO_CONFIG_t SDMMC_BLOCK_0_DATA_0_PIN_CONFIG =
|
||||
{
|
||||
.config =
|
||||
{
|
||||
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL,
|
||||
.output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_MEDIUM_EDGE,
|
||||
.output_level = XMC_GPIO_OUTPUT_LEVEL_LOW,
|
||||
},
|
||||
.hw_control = XMC_GPIO_HWCTRL_PERIPHERAL1,
|
||||
};
|
||||
|
||||
/* SDMMC_BLOCK Data 0 pin */
|
||||
const SDMMC_BLOCK_PIN_CONFIG_t SDMMC_BLOCK_0_DATA_0 =
|
||||
{
|
||||
.port = (XMC_GPIO_PORT_t *)PORT4_BASE,
|
||||
.pin = (uint8_t)0,
|
||||
.config = &SDMMC_BLOCK_0_DATA_0_PIN_CONFIG
|
||||
};
|
||||
|
||||
|
||||
/* SDMMC_BLOCK Data 1 pin config */
|
||||
const SDMMC_BLOCK_GPIO_CONFIG_t SDMMC_BLOCK_0_DATA_1_PIN_CONFIG =
|
||||
{
|
||||
.config =
|
||||
{
|
||||
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL,
|
||||
.output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_MEDIUM_EDGE,
|
||||
.output_level = XMC_GPIO_OUTPUT_LEVEL_LOW,
|
||||
},
|
||||
.hw_control = XMC_GPIO_HWCTRL_PERIPHERAL1,
|
||||
};
|
||||
|
||||
/* SDMMC_BLOCK Data 1 pin */
|
||||
const SDMMC_BLOCK_PIN_CONFIG_t SDMMC_BLOCK_0_DATA_1 =
|
||||
{
|
||||
.port = (XMC_GPIO_PORT_t *)PORT1_BASE,
|
||||
.pin = (uint8_t)6,
|
||||
.config = &SDMMC_BLOCK_0_DATA_1_PIN_CONFIG
|
||||
};
|
||||
|
||||
|
||||
/* SDMMC_BLOCK Data 2 pin config */
|
||||
const SDMMC_BLOCK_GPIO_CONFIG_t SDMMC_BLOCK_0_DATA_2_PIN_CONFIG =
|
||||
{
|
||||
.config =
|
||||
{
|
||||
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL,
|
||||
.output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_MEDIUM_EDGE,
|
||||
.output_level = XMC_GPIO_OUTPUT_LEVEL_LOW,
|
||||
},
|
||||
.hw_control = XMC_GPIO_HWCTRL_PERIPHERAL1,
|
||||
};
|
||||
|
||||
/* SDMMC_BLOCK Data 2 pin */
|
||||
const SDMMC_BLOCK_PIN_CONFIG_t SDMMC_BLOCK_0_DATA_2 =
|
||||
{
|
||||
.port = (XMC_GPIO_PORT_t *)PORT1_BASE,
|
||||
.pin = (uint8_t)7,
|
||||
.config = &SDMMC_BLOCK_0_DATA_2_PIN_CONFIG
|
||||
};
|
||||
|
||||
|
||||
/* SDMMC_BLOCK Data 3 pin config */
|
||||
const SDMMC_BLOCK_GPIO_CONFIG_t SDMMC_BLOCK_0_DATA_3_PIN_CONFIG =
|
||||
{
|
||||
.config =
|
||||
{
|
||||
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL,
|
||||
.output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_MEDIUM_EDGE,
|
||||
.output_level = XMC_GPIO_OUTPUT_LEVEL_LOW,
|
||||
},
|
||||
.hw_control = XMC_GPIO_HWCTRL_PERIPHERAL1,
|
||||
};
|
||||
|
||||
/* SDMMC_BLOCK Data 3 pin */
|
||||
const SDMMC_BLOCK_PIN_CONFIG_t SDMMC_BLOCK_0_DATA_3 =
|
||||
{
|
||||
.port = (XMC_GPIO_PORT_t *)PORT4_BASE,
|
||||
.pin = (uint8_t)1,
|
||||
.config = &SDMMC_BLOCK_0_DATA_3_PIN_CONFIG
|
||||
};
|
||||
|
||||
|
||||
/* SDMMC_BLOCK Command pin config */
|
||||
const SDMMC_BLOCK_GPIO_CONFIG_t SDMMC_BLOCK_0_COMMAND_PIN_CONFIG =
|
||||
{
|
||||
.config =
|
||||
{
|
||||
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL,
|
||||
.output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_MEDIUM_EDGE,
|
||||
.output_level = XMC_GPIO_OUTPUT_LEVEL_LOW,
|
||||
},
|
||||
.hw_control = XMC_GPIO_HWCTRL_PERIPHERAL1,
|
||||
};
|
||||
|
||||
/* SDMMC_BLOCK Command pin */
|
||||
const SDMMC_BLOCK_PIN_CONFIG_t SDMMC_BLOCK_0_COMMAND =
|
||||
{
|
||||
.port = (XMC_GPIO_PORT_t *)PORT3_BASE,
|
||||
.pin = (uint8_t)5,
|
||||
.config = &SDMMC_BLOCK_0_COMMAND_PIN_CONFIG
|
||||
};
|
||||
|
||||
|
||||
/* SDMMC_BLOCK Clock pin config */
|
||||
const SDMMC_BLOCK_GPIO_CONFIG_t SDMMC_BLOCK_0_CLK_PIN_CONFIG =
|
||||
{
|
||||
.config =
|
||||
{
|
||||
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL,
|
||||
.output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_MEDIUM_EDGE,
|
||||
.output_level = XMC_GPIO_OUTPUT_LEVEL_LOW,
|
||||
},
|
||||
.hw_control = XMC_GPIO_HWCTRL_PERIPHERAL1,
|
||||
};
|
||||
|
||||
/* SDMMC_BLOCK Clock pin */
|
||||
const SDMMC_BLOCK_PIN_CONFIG_t SDMMC_BLOCK_0_CLK =
|
||||
{
|
||||
.port = (XMC_GPIO_PORT_t *)PORT3_BASE,
|
||||
.pin = (uint8_t)6,
|
||||
.config = &SDMMC_BLOCK_0_CLK_PIN_CONFIG
|
||||
};
|
||||
|
||||
|
||||
/* SDMMC SD mode instance */
|
||||
SDMMC_BLOCK_SD_t SDMMC_BLOCK_0_SD =
|
||||
{
|
||||
.sdmmc = XMC_SDMMC, /* SDMMC instance */
|
||||
.int_priority = 63U, /* Node interrupt priority */
|
||||
.int_sub_priority = 0U, /* Node interrupt sub-priority */
|
||||
.mode_init_flag = false, /* Mode initialization false by default */
|
||||
};
|
||||
|
||||
/* SDMMC_BLOCK APP instance */
|
||||
SDMMC_BLOCK_t SDMMC_BLOCK_0 =
|
||||
{
|
||||
.interface_mode = SDMMC_BLOCK_CARD_INTERFACE_SD, /* SD interface */
|
||||
.sdmmc_sd = &SDMMC_BLOCK_0_SD, /* SDMMC_SD instance */
|
||||
.rtos_mode = SDMMC_BLOCK_RTOS_MODE_DISABLED, /* RTOS mose is not used */
|
||||
|
||||
#if SDMMC_BLOCK_RTOS_MODE_SELECT
|
||||
.cmsis_rtos = NULL, /* RTOS mose is not used */
|
||||
#endif /* SDMMC_BLOCK_RTOS_MODE_SELECT */
|
||||
|
||||
.init_pins = SDMMC_BLOCK_0_Config_Init, /* true: Initialized; false: Uninitialized */
|
||||
.init_flag = false, /* true: Initialized; false: Uninitialized */
|
||||
.card_state = ((uint8_t)SDMMC_BLOCK_CARD_STATE_NOT_INITIALIZED |
|
||||
(uint8_t)SDMMC_BLOCK_CARD_STATE_NO_CARD) /* Card state */
|
||||
};
|
||||
|
||||
/**********************************************************************************************************************
|
||||
* FUNCTION DEFINITIONS
|
||||
**********************************************************************************************************************/
|
||||
|
||||
/* SDMMC SD interrupt handler */
|
||||
void SDMMC0_0_IRQHandler(void)
|
||||
{
|
||||
normal_int_status = SDMMC_BLOCK_0.sdmmc_sd->sdmmc->INT_STATUS_NORM;
|
||||
err_int_status = SDMMC_BLOCK_0.sdmmc_sd->sdmmc->INT_STATUS_ERR;
|
||||
|
||||
if (normal_int_status & SDMMC_INT_STATUS_NORM_ERR_INT_Msk)
|
||||
{
|
||||
SDMMC_BLOCK_SD_ErrorInterruptHandler(&SDMMC_BLOCK_0, err_int_status);
|
||||
}
|
||||
|
||||
if (normal_int_status & SDMMC_BLOCK_NORMAL_INT_STATUS_BITS)
|
||||
{
|
||||
SDMMC_BLOCK_SD_NormalInterruptHandler(&SDMMC_BLOCK_0, normal_int_status);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Configuration initialization:
|
||||
* For pins and other mode specific settings
|
||||
*/
|
||||
static void SDMMC_BLOCK_0_Config_Init(void)
|
||||
{
|
||||
/* Enable delay on command and data lines */
|
||||
XMC_SDMMC_EnableDelayCmdDatLines();
|
||||
|
||||
/* Set the delay value chosen in the APP user interface */
|
||||
XMC_SDMMC_SetDelay(SDMMC_BLOCK_SD_NUM_DELAY_ELEMENTS);
|
||||
|
||||
XMC_GPIO_Init(SDMMC_BLOCK_0_COMMAND.port,
|
||||
SDMMC_BLOCK_0_COMMAND.pin,
|
||||
&SDMMC_BLOCK_0_COMMAND.config->config);
|
||||
XMC_GPIO_SetHardwareControl(SDMMC_BLOCK_0_COMMAND.port,
|
||||
SDMMC_BLOCK_0_COMMAND.pin,
|
||||
SDMMC_BLOCK_0_COMMAND.config->hw_control);
|
||||
|
||||
XMC_GPIO_Init(SDMMC_BLOCK_0_CLK.port,
|
||||
SDMMC_BLOCK_0_CLK.pin,
|
||||
&SDMMC_BLOCK_0_CLK.config->config);
|
||||
XMC_GPIO_SetHardwareControl(SDMMC_BLOCK_0_CLK.port,
|
||||
SDMMC_BLOCK_0_CLK.pin,
|
||||
SDMMC_BLOCK_0_CLK.config->hw_control);
|
||||
|
||||
XMC_GPIO_Init(SDMMC_BLOCK_0_DATA_0.port,
|
||||
SDMMC_BLOCK_0_DATA_0.pin,
|
||||
&SDMMC_BLOCK_0_DATA_0.config->config);
|
||||
XMC_GPIO_SetHardwareControl(SDMMC_BLOCK_0_DATA_0.port,
|
||||
SDMMC_BLOCK_0_DATA_0.pin,
|
||||
SDMMC_BLOCK_0_DATA_0.config->hw_control);
|
||||
|
||||
XMC_GPIO_Init(SDMMC_BLOCK_0_DATA_1.port,
|
||||
SDMMC_BLOCK_0_DATA_1.pin,
|
||||
&SDMMC_BLOCK_0_DATA_1.config->config);
|
||||
XMC_GPIO_SetHardwareControl(SDMMC_BLOCK_0_DATA_1.port,
|
||||
SDMMC_BLOCK_0_DATA_1.pin,
|
||||
SDMMC_BLOCK_0_DATA_1.config->hw_control);
|
||||
|
||||
XMC_GPIO_Init(SDMMC_BLOCK_0_DATA_2.port,
|
||||
SDMMC_BLOCK_0_DATA_2.pin,
|
||||
&SDMMC_BLOCK_0_DATA_2.config->config);
|
||||
XMC_GPIO_SetHardwareControl(SDMMC_BLOCK_0_DATA_2.port,
|
||||
SDMMC_BLOCK_0_DATA_2.pin,
|
||||
SDMMC_BLOCK_0_DATA_2.config->hw_control);
|
||||
|
||||
XMC_GPIO_Init(SDMMC_BLOCK_0_DATA_3.port,
|
||||
SDMMC_BLOCK_0_DATA_3.pin,
|
||||
&SDMMC_BLOCK_0_DATA_3.config->config);
|
||||
XMC_GPIO_SetHardwareControl(SDMMC_BLOCK_0_DATA_3.port,
|
||||
SDMMC_BLOCK_0_DATA_3.pin,
|
||||
SDMMC_BLOCK_0_DATA_3.config->hw_control);
|
||||
|
||||
XMC_SDMMC_SetCardDetectionSource(XMC_SDMMC, XMC_SDMMC_CD_SOURCE_SW);
|
||||
XMC_SDMMC_SetCardDetectionStatus(XMC_SDMMC, XMC_SDMMC_CD_STATUS_INSERTED);
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*********************************************************************************************************************
|
||||
* DAVE APP Name : SDMMC_BLOCK APP Version: 4.0.22
|
||||
*
|
||||
* NOTE:
|
||||
* This file is generated by DAVE. Any manual modification done to this file will be lost when the code is regenerated.
|
||||
*********************************************************************************************************************/
|
||||
|
||||
/**
|
||||
* @cond
|
||||
***********************************************************************************************************************
|
||||
* Copyright (c) 2016, Infineon Technologies AG
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes
|
||||
* with Infineon Technologies AG (dave@infineon.com).
|
||||
***********************************************************************************************************************
|
||||
*
|
||||
* Change History
|
||||
* --------------
|
||||
*
|
||||
* 2016-01-20:
|
||||
* - Initial version <br>
|
||||
*
|
||||
* 2016-02-05:
|
||||
* - RTOS support added <br>
|
||||
*
|
||||
* 2016-04-05:
|
||||
* - Bug fixes done for PR.<br>
|
||||
*
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
#ifndef SDMMC_BLOCK_CONF_H
|
||||
#define SDMMC_BLOCK_CONF_H
|
||||
|
||||
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* HEADER FILES
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#include "xmc_scu.h"
|
||||
#include "xmc_sdmmc.h"
|
||||
|
||||
|
||||
/**********************************************************************************************************************
|
||||
* MACROS
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#define SDMMC_BLOCK_MAJOR_VERSION (4U) /**< Major version */
|
||||
#define SDMMC_BLOCK_MINOR_VERSION (0U) /**< Minor version */
|
||||
#define SDMMC_BLOCK_PATCH_VERSION (22U) /**< Patch version */
|
||||
|
||||
#define SDMMC_BLOCK_SD
|
||||
#define SDMMC_BLOCK_SD_NUM_DELAY_ELEMENTS (8U)
|
||||
#define SDMMC_BLOCK_SD_SUPPORT_4_BUS_WIDTH (1U)
|
||||
#define SDMMC_BLOCK_RTOS_MODE_SELECT (0U)
|
||||
|
||||
/* Added configurable to support polling mode operation instead of interrupt driven. */
|
||||
#define SDMMC_BLOCK_POLLING_MODE (1U)
|
||||
|
||||
#endif /* ifndef SDMMC_BLOCK_CONF_H */
|
|
@ -0,0 +1,79 @@
|
|||
/*********************************************************************************************************************
|
||||
* DAVE APP Name : SDMMC_BLOCK APP Version: 4.0.22
|
||||
*
|
||||
* NOTE:
|
||||
* This file is generated by DAVE. Any manual modification done to this file will be lost when the code is regenerated.
|
||||
*********************************************************************************************************************/
|
||||
|
||||
/**
|
||||
* @cond
|
||||
***********************************************************************************************************************
|
||||
* Copyright (c) 2016, Infineon Technologies AG
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes
|
||||
* with Infineon Technologies AG (dave@infineon.com).
|
||||
***********************************************************************************************************************
|
||||
*
|
||||
* Change History
|
||||
* --------------
|
||||
*
|
||||
* 2016-01-20:
|
||||
* - Initial version <br>
|
||||
*
|
||||
* 2016-02-05:
|
||||
* - RTOS support added <br>
|
||||
*
|
||||
* 2016-04-05:
|
||||
* - Test hooks is added to emulates the hardware failures.<br>
|
||||
* - Bug fixes done for PR.<br>
|
||||
*
|
||||
* 2016-06-07:
|
||||
* - Fixed code generation error for project folder paths with spaces in between.
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
#ifndef SDMMC_BLOCK_EXTERN_H
|
||||
#define SDMMC_BLOCK_EXTERN_H
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* HEADER FILES
|
||||
**********************************************************************************************************************/
|
||||
|
||||
/**********************************************************************************************************************
|
||||
* MACROS
|
||||
**********************************************************************************************************************/
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* EXTERN DECLARATIONS
|
||||
***********************************************************************************************************************/
|
||||
|
||||
extern SDMMC_BLOCK_t SDMMC_BLOCK_0;
|
||||
|
||||
#ifdef SDMMC_BLOCK_TEST_HOOK_ENABLE
|
||||
extern uint32_t sdmmc_block_test_hook_expected_command;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif /* ifndef SDMMC_BLOCK_EXTERN_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,263 @@
|
|||
/**
|
||||
* @file sdmmc_block_private_sd.h
|
||||
* @date 2016-08-24
|
||||
*
|
||||
* NOTE:
|
||||
* This file is generated by DAVE. Any manual modification done to this file will be lost when the code is regenerated.
|
||||
*
|
||||
* @cond
|
||||
***********************************************************************************************************************
|
||||
* SDMMC_BLOCK v4.0.22 - Configures the SD host to interface with the SDMMC card.
|
||||
*
|
||||
* Copyright (c) 2016-2017, Infineon Technologies AG
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes
|
||||
* with Infineon Technologies AG (dave@infineon.com).
|
||||
***********************************************************************************************************************
|
||||
*
|
||||
* Change History
|
||||
* --------------
|
||||
*
|
||||
* 2016-01-20:
|
||||
* - Initial version. <br>
|
||||
*
|
||||
* 2016-02-08:
|
||||
* - Help Doc updated. <br>
|
||||
* - Bug fixes done.<br>
|
||||
*
|
||||
* 2016-04-05:
|
||||
* - MISRA fixes <br>
|
||||
*
|
||||
* @endcond
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SDMMC_BLOCK_SD_H
|
||||
#define SDMMC_BLOCK_SD_H
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* HEADER FILES
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include "sdmmc_block.h"
|
||||
|
||||
#ifdef SDMMC_BLOCK_SD
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* LOCAL DATA
|
||||
**********************************************************************************************************************/
|
||||
|
||||
extern const XMC_SDMMC_COMMAND_t sdmmc_block_command[40];
|
||||
extern const uint8_t sdmmc_block_sd_hash_table[65];
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* MACROS
|
||||
**********************************************************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This structure stores the command register fields.
|
||||
*/
|
||||
#define SDMMC_BLOCK_COMMON_COMMAND(c) sdmmc_block_command[sdmmc_block_sd_hash_table[c]]
|
||||
#define SDMMC_BLOCK_SD_COMMAND(c) SDMMC_BLOCK_COMMON_COMMAND(c)
|
||||
|
||||
#define SDMMC_BLOCK_ERROR_CMD_STATUS_BITMASK (0x000FU) /* Command line Int errors status bit-mask */
|
||||
#define SDMMC_BLOCK_ERROR_DATA_STATUS_BITMASK (0x0070U) /* Data line Error status bitmask */
|
||||
#define SDMMC_BLOCK_TX_BLOCK_SIZE_VALUE (0x0200U) /* Transfer block register */
|
||||
#define SDMMC_BLOCK_HC_RESPONSE1_BITPOS (0x10U) /* Response register */
|
||||
#define SDMMC_BLOCK_SWITCH_FUNC_GRP1_STATUS_BITMASK (0x0000000FU) /* Switch speed function bit-mask */
|
||||
#define SDMMC_BLOCK_SWITCH_FUNC_GRP1_STATUS_BITPOS (0x0U) /* Switch speed function bit-position */
|
||||
|
||||
/*
|
||||
* Append by 3 zeros since the SYSTIMER APP takes
|
||||
* time in microseconds
|
||||
*/
|
||||
#define SDMMC_BLOCK_CARD_POWER_DELAY (20000U) /* Card power delay */
|
||||
#define SDMMC_BLOCK_DELAY_IN_TRANSFER (1000000U) /* Transfer delay */
|
||||
#define SDMMC_BLOCK_RESET_IN_DATA_TRANSFER (1000000U) /* Reset in data transfer */
|
||||
#define SDMMC_BLOCK_DELAY_IN_COMMAND (1000000U) /* Command delay */
|
||||
#define SDMMC_BLOCK_RESET_DELAY (500000U) /* Reset delay */
|
||||
#define SDMMC_BLOCK_CLOCK_STABLE_DELAY (1000000U) /* Clock stable delay */
|
||||
|
||||
#define SDMMC_BLOCK_NUM_CARD_RESET_RETRIES (2U) /* Number of reset retries at card init */
|
||||
#define SDMMC_BLOCK_BLOCK_SIZE (512U) /* Block Size in bytes */
|
||||
#define SDMMC_BLOCK_NUM_QUADLETS_IN_BLOCK (SDMMC_BLOCK_BLOCK_SIZE >> 2U) /* Block size in quad bytes */
|
||||
|
||||
/* Command index */
|
||||
#define SDMMC_BLOCK_GO_IDLE_STATE (0x00U) /* CMD0 */
|
||||
#define SDMMC_BLOCK_MMC_SEND_OP_COND (0x01U) /* MMC CMD1 */
|
||||
#define SDMMC_BLOCK_ALL_SEND_CID (0x02U) /* CMD2 */
|
||||
#define SDMMC_BLOCK_SEND_RELATIVE_ADDR (0x03U) /* CMD3 */
|
||||
#define SDMMC_BLOCK_SET_DSR (0x04U) /* CMD4 */
|
||||
#define SDMMC_BLOCK_MMC_SLEEP_AWAKE (0x05U) /* MMC CMD5 */
|
||||
#define SDMMC_BLOCK_SWITCH_FUNC (0x06U) /* CMD6 */
|
||||
#define SDMMC_BLOCK_SELECT_DESELECT_CARD (0x07U) /* CMD7 */
|
||||
#define SDMMC_BLOCK_SD_SEND_IF_COND (0x08U) /* SD CMD8 */
|
||||
#define SDMMC_BLOCK_MMC_SEND_EXT_CSD (0x08U) /* MMC CMD8 */
|
||||
#define SDMMC_BLOCK_SEND_CSD (0x09U) /* CMD9 */
|
||||
#define SDMMC_BLOCK_SEND_CID (0x0AU) /* CMD10 */
|
||||
#define SDMMC_BLOCK_STOP_TRANSMISSION (0x0CU) /* CMD12 */
|
||||
#define SDMMC_BLOCK_SEND_STATUS (0x0DU) /* CMD13 */
|
||||
#define SDMMC_BLOCK_GO_INACTIVE_STATE (0x0FU) /* CMD15 */
|
||||
#define SDMMC_BLOCK_SET_BLOCKLEN (0x10U) /* CMD16 */
|
||||
#define SDMMC_BLOCK_READ_SINGLE_BLOCK (0x11U) /* CMD17 */
|
||||
#define SDMMC_BLOCK_READ_MULTIPLE_BLOCK (0x12U) /* CMD18 */
|
||||
#define SDMMC_BLOCK_WRITE_BLOCK (0x18U) /* CMD24 */
|
||||
#define SDMMC_BLOCK_WRITE_MULTIPLE_BLOCK (0x19U) /* CMD25 */
|
||||
#define SDMMC_BLOCK_PROGRAM_CSD (0x1BU) /* CMD27 */
|
||||
#define SDMMC_BLOCK_SET_WRITE_PROT (0x1CU) /* CMD28 */
|
||||
#define SDMMC_BLOCK_CLR_WRITE_PROT (0x1DU) /* CMD29 */
|
||||
#define SDMMC_BLOCK_SEND_WRITE_PROT (0x1EU) /* CMD30 */
|
||||
#define SDMMC_BLOCK_ERASE_WR_BLK_START (0x20U) /* CMD32 */
|
||||
#define SDMMC_BLOCK_ERASE_WR_BLK_END (0x21U) /* CMD33 */
|
||||
#define SDMMC_BLOCK_ERASE_GROUP_START (0x23U) /* CMD35 */
|
||||
#define SDMMC_BLOCK_ERASE_GROUP_END (0x24U) /* CMD36 */
|
||||
#define SDMMC_BLOCK_ERASE (0x26U) /* CMD38 */
|
||||
#define SDMMC_BLOCK_LOCK_UNLOCK (0x2AU) /* CMD42 */
|
||||
#define SDMMC_BLOCK_APP_CMD (0x37U) /* CMD55 */
|
||||
#define SDMMC_BLOCK_GEN_CMD (0x38U) /* CMD56 */
|
||||
#define SDMMC_BLOCK_SET_BUS_WIDTH (0x06U) /* ACMD6 */
|
||||
#define SDMMC_BLOCK_SD_STATUS (0x0DU) /* ACMD13 */
|
||||
#define SDMMC_BLOCK_SEND_NUM_WR_BLOCKS (0x16U) /* ACMD22 */
|
||||
#define SDMMC_BLOCK_SET_WR_BLK_ERASE_COUNT (0x17U) /* ACMD23 */
|
||||
#define SDMMC_BLOCK_SD_SEND_OP_COND (0x29U) /* ACMD41 */
|
||||
#define SDMMC_BLOCK_SET_CLR_CARD_DETECT (0x2AU) /* ACMD42 */
|
||||
#define SDMMC_BLOCK_SEND_SCR (0x33U) /* ACMD51 */
|
||||
|
||||
/* Start of Card Status Register i.e CSR Error Bits bitmask */
|
||||
#define SDMMC_BLOCK_SD_CSR_OUT_OF_RANGE_BITMASK (0x80000000U)
|
||||
#define SDMMC_BLOCK_SD_CSR_ADDRESS_ERROR_BITMASK (0x40000000U)
|
||||
#define SDMMC_BLOCK_SD_CSR_BLOCK_LEN_ERROR_BITMASK (0x20000000U)
|
||||
#define SDMMC_BLOCK_SD_CSR_ERASE_SEQ_ERROR_BITMASK (0x10000000U)
|
||||
#define SDMMC_BLOCK_SD_CSR_ERASE_PARAM_BITMASK (0x08000000U)
|
||||
#define SDMMC_BLOCK_SD_CSR_WP_VIOLATION_BITMASK (0x04000000U)
|
||||
#define SDMMC_BLOCK_SD_CSR_LOCK_UNLOCK_FAILED_BITMASK (0x01000000U)
|
||||
#define SDMMC_BLOCK_SD_CSR_COM_CRC_ERROR_BITMASK (0x00800000U)
|
||||
#define SDMMC_BLOCK_SD_CSR_ILLEGAL_COMMAND_BITMASK (0x00400000U)
|
||||
#define SDMMC_BLOCK_SD_CSR_CARD_ECC_FAILED_BITMASK (0x00200000U)
|
||||
#define SDMMC_BLOCK_SD_CSR_CC_ERROR_BITMASK (0x00100000U)
|
||||
#define SDMMC_BLOCK_SD_CSR_ERROR_BITMASK (0x00080000U)
|
||||
#define SDMMC_BLOCK_SD_CSR_CSD_OVERWRITE_BITMASK (0x00010000U)
|
||||
#define SDMMC_BLOCK_SD_CSR_WP_ERASE_SKIP_BITMASK (0x00008000U)
|
||||
#define SDMMC_BLOCK_SD_SWITCH_ERROR_BITMASK (0x00000080U)
|
||||
#define SDMMC_BLOCK_SD_CSR_ASK_SEQ_ERROR_BITMASK (0x00000008U)
|
||||
#define SDMMC_BLOCK_SD_CSR_CARD_IS_LOCKED_BITMASK (0x02000000U)
|
||||
#define SDMMC_BLOCK_SD_CSR_CURRENT_STATE_BITMASK (0x00001D00U)
|
||||
#define SDMMC_BLOCK_SD_CSR_CURRENT_STATE_BITPOS (0x00000009U)
|
||||
#define SDMMC_BLOCK_SD_CSR_CURRENT_STATE_TRANS_VALUE (0x00000004U)
|
||||
#define SDMMC_BLOCK_SD_CSR_CARD_IS_LOCKED_BITMASK (0x02000000U)
|
||||
|
||||
/* Normal and error interrupt status defines */
|
||||
#define SDMMC_BLOCK_NORMAL_INT_STATUS_ENABLE (0x00F3U)
|
||||
#define SDMMC_BLOCK_ERROR_INT_STATUS_ENABLE (0xE0FFU)
|
||||
#define SDMMC_BLOCK_NORMAL_INT_SIGNAL_ENABLE (0x0033U)
|
||||
#define SDMMC_BLOCK_ERROR_INT_SIGNAL_ENABLE (0xE0FFU)
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* ENUMS
|
||||
**********************************************************************************************************************/
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* DATA STRUCTURES
|
||||
**********************************************************************************************************************/
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* API PROTOTYPES
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_GetLockStatus(SDMMC_BLOCK_t *const obj, SDMMC_BLOCK_CARD_LOCK_STATUS_t *lock_stat);
|
||||
|
||||
SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_CardIdentificationProcess(SDMMC_BLOCK_t *const obj);
|
||||
|
||||
SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_GetSdStatus(SDMMC_BLOCK_t *const obj, void *buf);
|
||||
|
||||
SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_GetSectorCount(SDMMC_BLOCK_t *const obj, void *buf);
|
||||
|
||||
SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_GetCid(SDMMC_BLOCK_t *const obj, void *buf);
|
||||
|
||||
SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_GetOcr(SDMMC_BLOCK_t *const obj, void *buf);
|
||||
|
||||
SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_GetCsd(SDMMC_BLOCK_t *const obj, void *buf);
|
||||
|
||||
SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_GetCardType(SDMMC_BLOCK_t *const obj, uint32_t *card_type);
|
||||
|
||||
SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_EraseBlock(SDMMC_BLOCK_t *const obj, uint32_t start_addr, uint32_t end_addr);
|
||||
|
||||
SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_GetSectorSize(SDMMC_BLOCK_t *const obj, void *buf);
|
||||
|
||||
SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_GetBlockSize(SDMMC_BLOCK_t *const obj, void *buf);
|
||||
|
||||
uint8_t
|
||||
SDMMC_BLOCK_SD_GetState(SDMMC_BLOCK_t *const obj);
|
||||
|
||||
SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_Init(SDMMC_BLOCK_t *const obj);
|
||||
|
||||
SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_CheckLockStatus(SDMMC_BLOCK_t *const obj,
|
||||
SDMMC_BLOCK_CARD_LOCK_STATUS_t mode);
|
||||
|
||||
SDMMC_BLOCK_STATUS_t
|
||||
SDMMC_BLOCK_SD_ReadBlock(SDMMC_BLOCK_t *const obj,
|
||||
uint8_t *read_buf,
|
||||
uint32_t sector_num,
|
||||
uint8_t sector_count);
|
||||
|
||||
SDMMC_BLOCK_STATUS_t
|
||||
SDMMC_BLOCK_SD_WriteBlock(SDMMC_BLOCK_t *const obj,
|
||||
const uint8_t *write_buf,
|
||||
uint32_t sector_num,
|
||||
uint8_t sector_count);
|
||||
|
||||
SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_LockUnlockCard(SDMMC_BLOCK_t *const obj,
|
||||
SDMMC_BLOCK_LOCK_STRUCTURE_t *lock,
|
||||
SDMMC_BLOCK_CARD_LOCK_STATUS_t mode);
|
||||
|
||||
SDMMC_BLOCK_MODE_STATUS_t
|
||||
SDMMC_BLOCK_SD_EjectCard(SDMMC_BLOCK_t *const obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifdef SDMMC_BLOCK_SD */
|
||||
|
||||
#endif /* SDMMC_BLOCK_SD_H */
|
|
@ -0,0 +1,266 @@
|
|||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module configuration file R0.12 (C)ChaN, 2016
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FFCONF 88100 /* Revision ID */
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Function Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_READONLY 0
|
||||
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
|
||||
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
|
||||
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
|
||||
/ and optional writing functions as well. */
|
||||
|
||||
|
||||
#define _FS_MINIMIZE 0
|
||||
/* This option defines minimization level to remove some basic API functions.
|
||||
/
|
||||
/ 0: All basic functions are enabled.
|
||||
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename()
|
||||
/ are removed.
|
||||
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
|
||||
/ 3: f_lseek() function is removed in addition to 2. */
|
||||
|
||||
|
||||
#define _USE_STRFUNC 2 /* 0:Disable or 1-2:Enable */
|
||||
/* This option switches string functions, f_gets(), f_putc(), f_puts() and
|
||||
/ f_printf().
|
||||
/
|
||||
/ 0: Disable string functions.
|
||||
/ 1: Enable without LF-CRLF conversion.
|
||||
/ 2: Enable with LF-CRLF conversion. */
|
||||
|
||||
|
||||
#define _USE_FIND 0
|
||||
/* This option switches filtered directory read functions, f_findfirst() and
|
||||
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
|
||||
|
||||
|
||||
#define _USE_MKFS 0
|
||||
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_FASTSEEK 0
|
||||
/* This option switches fast seek function. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_EXPAND 0
|
||||
/* This option switches f_expand function. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_CHMOD 0
|
||||
/* This option switches attribute manipulation functions, f_chmod() and f_utime().
|
||||
/ (0:Disable or 1:Enable) Also _FS_READONLY needs to be 0 to enable this option. */
|
||||
|
||||
|
||||
#define _USE_LABEL 0
|
||||
/* This option switches volume label functions, f_getlabel() and f_setlabel().
|
||||
/ (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_FORWARD 0
|
||||
/* This option switches f_forward() function. (0:Disable or 1:Enable)
|
||||
/ To enable it, also _FS_TINY need to be 1. */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Locale and Namespace Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _CODE_PAGE 437
|
||||
/* This option specifies the OEM code page to be used on the target system.
|
||||
/ Incorrect setting of the code page can cause a file open failure.
|
||||
/
|
||||
/ 1 - ASCII (No extended character. Non-LFN cfg. only)
|
||||
/ 437 - U.S.
|
||||
/ 720 - Arabic
|
||||
/ 737 - Greek
|
||||
/ 771 - KBL
|
||||
/ 775 - Baltic
|
||||
/ 850 - Latin 1
|
||||
/ 852 - Latin 2
|
||||
/ 855 - Cyrillic
|
||||
/ 857 - Turkish
|
||||
/ 860 - Portuguese
|
||||
/ 861 - Icelandic
|
||||
/ 862 - Hebrew
|
||||
/ 863 - Canadian French
|
||||
/ 864 - Arabic
|
||||
/ 865 - Nordic
|
||||
/ 866 - Russian
|
||||
/ 869 - Greek 2
|
||||
/ 932 - Japanese (DBCS)
|
||||
/ 936 - Simplified Chinese (DBCS)
|
||||
/ 949 - Korean (DBCS)
|
||||
/ 950 - Traditional Chinese (DBCS)
|
||||
*/
|
||||
|
||||
|
||||
#define _USE_LFN 1 /* 0 to 3 */
|
||||
#define _MAX_LFN 255
|
||||
/* The _USE_LFN switches the support of long file name (LFN).
|
||||
/
|
||||
/ 0: Disable support of LFN. _MAX_LFN has no effect.
|
||||
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
|
||||
/ 2: Enable LFN with dynamic working buffer on the STACK.
|
||||
/ 3: Enable LFN with dynamic working buffer on the HEAP.
|
||||
/
|
||||
/ To enable the LFN, Unicode handling functions (option/unicode.c) must be added
|
||||
/ to the project. The working buffer occupies (_MAX_LFN + 1) * 2 bytes and
|
||||
/ additional 608 bytes at exFAT enabled. _MAX_LFN can be in range from 12 to 255.
|
||||
/ It should be set 255 to support full featured LFN operations.
|
||||
/ When use stack for the working buffer, take care on stack overflow. When use heap
|
||||
/ memory for the working buffer, memory management functions, ff_memalloc() and
|
||||
/ ff_memfree(), must be added to the project. */
|
||||
|
||||
|
||||
#define _LFN_UNICODE 0
|
||||
/* This option switches character encoding on the API. (0:ANSI/OEM or 1:Unicode)
|
||||
/ To use Unicode string for the path name, enable LFN and set _LFN_UNICODE = 1.
|
||||
/ This option also affects behavior of string I/O functions. */
|
||||
|
||||
|
||||
#define _STRF_ENCODE 3
|
||||
/* When _LFN_UNICODE == 1, this option selects the character encoding on the file to
|
||||
/ be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf().
|
||||
/
|
||||
/ 0: ANSI/OEM
|
||||
/ 1: UTF-16LE
|
||||
/ 2: UTF-16BE
|
||||
/ 3: UTF-8
|
||||
/
|
||||
/ This option has no effect when _LFN_UNICODE == 0. */
|
||||
|
||||
|
||||
#define _FS_RPATH 0
|
||||
/* This option configures support of relative path.
|
||||
/
|
||||
/ 0: Disable relative path and remove related functions.
|
||||
/ 1: Enable relative path. f_chdir() and f_chdrive() are available.
|
||||
/ 2: f_getcwd() function is available in addition to 1.
|
||||
*/
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Drive/Volume Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _VOLUMES 1
|
||||
/* Number of volumes (logical drives) to be used. */
|
||||
|
||||
|
||||
#define _STR_VOLUME_ID 0
|
||||
#define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"
|
||||
/* _STR_VOLUME_ID switches string support of volume ID.
|
||||
/ When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
|
||||
/ number in the path name. _VOLUME_STRS defines the drive ID strings for each
|
||||
/ logical drives. Number of items must be equal to _VOLUMES. Valid characters for
|
||||
/ the drive ID strings are: A-Z and 0-9. */
|
||||
|
||||
|
||||
#define _MULTI_PARTITION 0
|
||||
/* This option switches support of multi-partition on a physical drive.
|
||||
/ By default (0), each logical drive number is bound to the same physical drive
|
||||
/ number and only an FAT volume found on the physical drive will be mounted.
|
||||
/ When multi-partition is enabled (1), each logical drive number can be bound to
|
||||
/ arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
|
||||
/ funciton will be available. */
|
||||
|
||||
|
||||
#define _MIN_SS 512
|
||||
#define _MAX_SS 512
|
||||
/* These options configure the range of sector size to be supported. (512, 1024,
|
||||
/ 2048 or 4096) Always set both 512 for most systems, all type of memory cards and
|
||||
/ harddisk. But a larger value may be required for on-board flash memory and some
|
||||
/ type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured
|
||||
/ to variable sector size and GET_SECTOR_SIZE command must be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
|
||||
#define _USE_TRIM 0
|
||||
/* This option switches support of ATA-TRIM. (0:Disable or 1:Enable)
|
||||
/ To enable Trim function, also CTRL_TRIM command should be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
|
||||
#define _FS_NOFSINFO 0
|
||||
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
||||
/ option, and f_getfree() function at first time after volume mount will force
|
||||
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
|
||||
/
|
||||
/ bit0=0: Use free cluster count in the FSINFO if available.
|
||||
/ bit0=1: Do not trust free cluster count in the FSINFO.
|
||||
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
|
||||
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ System Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_TINY 0
|
||||
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
|
||||
/ At the tiny configuration, size of the file object (FIL) is reduced _MAX_SS bytes.
|
||||
/ Instead of private sector buffer eliminated from the file object, common sector
|
||||
/ buffer in the file system object (FATFS) is used for the file data transfer. */
|
||||
|
||||
|
||||
#define _FS_EXFAT 0
|
||||
/* This option switches support of exFAT file system in addition to the traditional
|
||||
/ FAT file system. (0:Disable or 1:Enable) To enable exFAT, also LFN must be enabled.
|
||||
/ Note that enabling exFAT discards C89 compatibility. */
|
||||
|
||||
|
||||
#define _FS_NORTC 1
|
||||
#define _NORTC_MON 3
|
||||
#define _NORTC_MDAY 1
|
||||
#define _NORTC_YEAR 2016
|
||||
/* The option _FS_NORTC switches timestamp functiton. If the system does not have
|
||||
/ any RTC function or valid timestamp is not needed, set _FS_NORTC = 1 to disable
|
||||
/ the timestamp function. All objects modified by FatFs will have a fixed timestamp
|
||||
/ defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR in local time.
|
||||
/ To enable timestamp function (_FS_NORTC = 0), get_fattime() function need to be
|
||||
/ added to the project to get current time form real-time clock. _NORTC_MON,
|
||||
/ _NORTC_MDAY and _NORTC_YEAR have no effect.
|
||||
/ These options have no effect at read-only configuration (_FS_READONLY = 1). */
|
||||
|
||||
|
||||
#define _FS_LOCK 0
|
||||
/* The option _FS_LOCK switches file lock function to control duplicated file open
|
||||
/ and illegal operation to open objects. This option must be 0 when _FS_READONLY
|
||||
/ is 1.
|
||||
/
|
||||
/ 0: Disable file lock function. To avoid volume corruption, application program
|
||||
/ should avoid illegal open, remove and rename to the open objects.
|
||||
/ >0: Enable file lock function. The value defines how many files/sub-directories
|
||||
/ can be opened simultaneously under file lock control. Note that the file
|
||||
/ lock control is independent of re-entrancy. */
|
||||
|
||||
|
||||
#define _FS_REENTRANT 0
|
||||
#define _FS_TIMEOUT 1000
|
||||
#define _SYNC_t HANDLE
|
||||
/* The option _FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
|
||||
/ module itself. Note that regardless of this option, file access to different
|
||||
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||
/ and f_fdisk() function, are always not re-entrant. Only file/directory access
|
||||
/ to the same volume is under control of this function.
|
||||
/
|
||||
/ 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect.
|
||||
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
||||
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
|
||||
/ function, must be added to the project. Samples are available in
|
||||
/ option/syscall.c.
|
||||
/
|
||||
/ The _FS_TIMEOUT defines timeout period in unit of time tick.
|
||||
/ The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
|
||||
/ SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be
|
||||
/ included somewhere in the scope of ff.c. */
|
||||
|
||||
|
||||
/*--- End of configuration options ---*/
|
|
@ -0,0 +1,217 @@
|
|||
/*------------------------------------------------------------------------/
|
||||
/ MMCv3/SDv1/SDv2 (in SDIO mode) control module
|
||||
/-------------------------------------------------------------------------/
|
||||
/
|
||||
/ Copyright (C) 2013, ChaN, all right reserved.
|
||||
/
|
||||
/ * This software is a free software and there is NO WARRANTY.
|
||||
/ * No restriction on use. You can use, modify and redistribute it for
|
||||
/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
|
||||
/ * Redistributions of source code must retain the above copyright notice.
|
||||
/
|
||||
/-------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*
|
||||
* This file was modified from a sample available from the FatFs
|
||||
* web site. It was modified to work with a Infineon XMC4700 Relax Kit
|
||||
* evaluation board. It is based on the DAVE 4 SDMMC_BLOCK app, which was modified
|
||||
* to work with an existing timer and for operation in polling mode.
|
||||
*
|
||||
*/
|
||||
#include "diskio.h"
|
||||
#include "boot.h"
|
||||
#include "sdmmc_block.h"
|
||||
|
||||
|
||||
static volatile
|
||||
DSTATUS Stat = STA_NOINIT; /* Disk status */
|
||||
|
||||
const
|
||||
DRESULT FATFS_errorcodes[5] = {
|
||||
RES_OK ,
|
||||
RES_ERROR,
|
||||
RES_WRPRT,
|
||||
RES_NOTRDY,
|
||||
RES_PARERR
|
||||
};
|
||||
const
|
||||
DSTATUS FATFS_statuscodes[4] = {
|
||||
(DSTATUS)0,
|
||||
(DSTATUS)STA_NOINIT,
|
||||
(DSTATUS)STA_NODISK,
|
||||
(DSTATUS)STA_PROTECT
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
|
||||
Public Functions
|
||||
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Initialize Disk Drive */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DSTATUS disk_initialize (
|
||||
BYTE pdrv /* Physical drive number (0) */
|
||||
)
|
||||
{
|
||||
DSTATUS diskstatus;
|
||||
uint32_t status;
|
||||
|
||||
/* Make sure the SDMMC block is initialized. Note that it has a protection
|
||||
* against mutiple initialization.
|
||||
*/
|
||||
SDMMC_BLOCK_Init(&SDMMC_BLOCK_0);
|
||||
|
||||
/* If drive number is greater than the maximum drives allowed */
|
||||
if (pdrv > 0)
|
||||
{
|
||||
diskstatus = (DSTATUS)((uint8_t)STA_NODISK | (uint8_t)STA_NOINIT);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Call the Initialize function. */
|
||||
status = SDMMC_BLOCK_Initialize(&SDMMC_BLOCK_0);
|
||||
/* Fatfs to Device Abstraction Layer Error Code Mapping */
|
||||
diskstatus = FATFS_statuscodes[status];
|
||||
}
|
||||
|
||||
return (diskstatus);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Get Disk Status */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DSTATUS disk_status (
|
||||
BYTE pdrv /* Physical drive nmuber (0) */
|
||||
)
|
||||
{
|
||||
DSTATUS diskstatus;
|
||||
uint32_t status;
|
||||
|
||||
/* If drive number is greater than the maximum drives allowed */
|
||||
if (pdrv > 0)
|
||||
{
|
||||
diskstatus = (DSTATUS)((uint8_t)STA_NODISK | (uint8_t)STA_NOINIT);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Call the Initialize function.*/
|
||||
status = SDMMC_BLOCK_GetStatus(&SDMMC_BLOCK_0);
|
||||
/* Fatfs to Block Layer Error Code Mapping */
|
||||
diskstatus = FATFS_statuscodes[status];
|
||||
}
|
||||
return (diskstatus);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Read Sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DRESULT disk_read (
|
||||
BYTE pdrv, /* Physical drive nmuber to identify the drive */
|
||||
BYTE *buff, /* Data buffer to store read data */
|
||||
DWORD sector, /* Sector address in LBA */
|
||||
UINT count /* Number of sectors to read */
|
||||
)
|
||||
{
|
||||
DRESULT diskresult;
|
||||
uint32_t result;
|
||||
|
||||
/* If drive number is greater than the maximum drives allowed */
|
||||
if (pdrv > 0)
|
||||
{
|
||||
diskresult = RES_PARERR;
|
||||
}
|
||||
/* If sector count is less than 1. Minimum 1 sector is needed*/
|
||||
else if (count < (uint8_t)1)
|
||||
{
|
||||
diskresult = RES_PARERR;
|
||||
}
|
||||
/*Call the ReadBlk function.*/
|
||||
else
|
||||
{
|
||||
result = (uint32_t)SDMMC_BLOCK_ReadBlock(&SDMMC_BLOCK_0, (uint8_t *)buff,
|
||||
(uint32_t)sector, count);
|
||||
|
||||
/* FatFs to Device Abstraction Layer Error Code Mapping */
|
||||
diskresult = FATFS_errorcodes[result];
|
||||
}
|
||||
return (diskresult);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Write Sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DRESULT disk_write (
|
||||
BYTE pdrv, /* Physical drive nmuber to identify the drive */
|
||||
const BYTE *buff, /* Data to be written */
|
||||
DWORD sector, /* Sector address in LBA */
|
||||
UINT count /* Number of sectors to write */
|
||||
)
|
||||
{
|
||||
DRESULT diskresult;
|
||||
uint32_t result;
|
||||
|
||||
/* If drive number is greater than the maximum drives allowed */
|
||||
if (pdrv > 0)
|
||||
{
|
||||
diskresult = RES_PARERR;
|
||||
}
|
||||
/* If sector count is less than 1. Minimum 1 sector is needed*/
|
||||
else if (count < (uint8_t)1)
|
||||
{
|
||||
diskresult = RES_PARERR;
|
||||
}
|
||||
/*Call the WriteBlk function.*/
|
||||
else
|
||||
{
|
||||
result = (uint32_t)SDMMC_BLOCK_WriteBlock(&SDMMC_BLOCK_0,(uint8_t *)buff,
|
||||
(uint32_t)sector, count);
|
||||
/* FatFs to Device Abstraction Layer Error Code Mapping */
|
||||
diskresult = FATFS_errorcodes[result];
|
||||
}
|
||||
return (diskresult);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Miscellaneous Functions */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DRESULT disk_ioctl (
|
||||
BYTE pdrv, /* Physical drive nmuber (0) */
|
||||
BYTE cmd, /* Control code */
|
||||
void *buff /* Buffer to send/receive data block */
|
||||
)
|
||||
{
|
||||
DRESULT diskresult;
|
||||
uint32_t result;
|
||||
if (pdrv > 0)
|
||||
{
|
||||
diskresult = RES_PARERR;
|
||||
}
|
||||
/*Call the Ioctl function.*/
|
||||
else
|
||||
{
|
||||
result = SDMMC_BLOCK_Ioctl(&SDMMC_BLOCK_0, cmd, buff);
|
||||
/* FatFs to Block Layer Error Code Mapping */
|
||||
diskresult = FATFS_errorcodes[result];
|
||||
}
|
||||
return (diskresult);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue