Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
emfile/Config/FS_ConfigMMC_CM_HS.c
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
156 lines (143 sloc)
5.12 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************************* | |
* (c) SEGGER Microcontroller GmbH * | |
* The Embedded Experts * | |
* www.segger.com * | |
********************************************************************** | |
---------------------------------------------------------------------- | |
Licensing information | |
Licensor: SEGGER Microcontroller Systems LLC | |
Licensed to: Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA | |
Licensed SEGGER software: emFile | |
License number: FS-00227 | |
License model: Cypress Services and License Agreement, signed November 17th/18th, 2010 | |
and Amendment Number One, signed December 28th, 2020 and February 10th, 2021 | |
Licensed platform: Any Cypress platform (Initial targets are: PSoC3, PSoC5, PSoC6) | |
---------------------------------------------------------------------- | |
Support and Update Agreement (SUA) | |
SUA period: 2010-12-01 - 2022-07-27 | |
Contact to extend SUA: sales@segger.com | |
-------------------------- END-OF-HEADER ----------------------------- | |
File : FS_ConfigMMC_CM_HS.c | |
Purpose : Configuration functions for FS with MMC/SD card mode driver | |
using 4-bit or 8-bit data bus and high speed access mode. | |
*/ | |
/********************************************************************* | |
* | |
* #include section | |
* | |
********************************************************************** | |
*/ | |
#include "FS.h" | |
#include "FS_MMC_HW_CM.h" | |
#include "cybsp.h" | |
/********************************************************************* | |
* | |
* Defines, configurable | |
* | |
********************************************************************** | |
*/ | |
#define ALLOC_SIZE 0x2000 // Size defined in bytes | |
/********************************************************************* | |
* | |
* Static data | |
* | |
********************************************************************** | |
*/ | |
static U32 _aMemBlock[ALLOC_SIZE / 4]; // Memory pool used for semi-dynamic allocation. | |
static FS_MMC_HW_CM_SDHostConfig_t SDConfig = | |
{ | |
.Config = | |
{ | |
.enableLedControl = false, | |
.lowVoltageSignaling = false, | |
.isEmmc = false, | |
.busWidth = 4 | |
}, | |
.Cmd = CYBSP_SDHC_CMD, | |
.Clk = CYBSP_SDHC_CLK, | |
.Data0 = CYBSP_SDHC_IO0, | |
.Data1 = CYBSP_SDHC_IO1, | |
.Data2 = CYBSP_SDHC_IO2, | |
.Data3 = CYBSP_SDHC_IO3, | |
.Data4 = NC, | |
.Data5 = NC, | |
.Data6 = NC, | |
.Data7 = NC, | |
.CardDetect = CYBSP_SDHC_DETECT, | |
.IoVoltSel = NC, | |
.CardPwrEn = NC, | |
.CardWriteProt = NC, | |
.LedControl = NC, | |
.EmmcReset = NC, | |
.BlockClk = NULL | |
}; | |
/********************************************************************* | |
* | |
* Public code | |
* | |
********************************************************************** | |
*/ | |
/********************************************************************* | |
* | |
* FS_X_AddDevices | |
* | |
* Function description | |
* This function is called by the FS during FS_Init(). | |
* It is supposed to add all devices, using primarily FS_AddDevice(). | |
* | |
* Note | |
* (1) Other API functions may NOT be called, since this function is called | |
* during initialization. The devices are not yet ready at this point. | |
*/ | |
void FS_X_AddDevices(void) { | |
// | |
// Give file system memory to work with. | |
// | |
FS_AssignMemory(&_aMemBlock[0], sizeof(_aMemBlock)); | |
// | |
// Add and configure the driver. | |
// | |
FS_AddDevice(&FS_MMC_CM_Driver); | |
FS_MMC_CM_Allow4bitMode(0, 1); | |
FS_MMC_CM_AllowHighSpeedMode(0, 1); | |
// Configure the HW layer and add it. | |
(void) FS_MMC_HW_CM_Configure(0, &SDConfig); | |
FS_MMC_CM_SetHWType(0, &FS_MMC_HW_CM); | |
// | |
// Configure the file system for fast write operations. | |
// | |
#if FS_SUPPORT_FILE_BUFFER | |
FS_ConfigFileBufferDefault(512, FS_FILE_BUFFER_WRITE); | |
#endif // FS_SUPPORT_FILE_BUFFER | |
FS_SetFileWriteMode(FS_WRITEMODE_FAST); | |
} | |
/********************************************************************* | |
* | |
* FS_X_GetTimeDate | |
* | |
* Function description | |
* Current time and date in a format suitable for the file system. | |
* | |
* Additional information | |
* Bit 0-4: 2-second count (0-29) | |
* Bit 5-10: Minutes (0-59) | |
* Bit 11-15: Hours (0-23) | |
* Bit 16-20: Day of month (1-31) | |
* Bit 21-24: Month of year (1-12) | |
* Bit 25-31: Count of years from 1980 (0-127) | |
*/ | |
U32 FS_X_GetTimeDate(void) { | |
U32 r; | |
U16 Sec, Min, Hour; | |
U16 Day, Month, Year; | |
Sec = 0; // 0 based. Valid range: 0..59 | |
Min = 0; // 0 based. Valid range: 0..59 | |
Hour = 0; // 0 based. Valid range: 0..23 | |
Day = 1; // 1 based. Means that 1 is 1. Valid range is 1..31 (depending on month) | |
Month = 1; // 1 based. Means that January is 1. Valid range is 1..12. | |
Year = 0; // 1980 based. Means that 2007 would be 27. | |
r = Sec / 2 + (Min << 5) + (Hour << 11); | |
r |= (U32)(Day + (Month << 5) + (Year << 9)) << 16; | |
return r; | |
} | |
/*************************** End of file ****************************/ |