Refs #303. Added support for firmware updates from SD-card to the XMC4700 Relax Kit demo programs.

git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@697 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
This commit is contained in:
Frank Voorburg 2019-06-13 10:07:51 +00:00
parent 542f59c068
commit b9bec8729f
52 changed files with 23382 additions and 7480 deletions

View File

@ -120,15 +120,19 @@
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/Libraries/CMSIS/Infineon/XMC4700_series/Include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/Libraries/XMCLib/inc&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/Libraries/uip&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/Libraries/FatFS&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/Libraries/FatFS/SDMMC_BLOCK&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../Source&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../Source/ARMCM4_XMC4&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../Source/third_party/uip/uip&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../Source/third_party/uip/apps/dhcpc&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../Source/third_party/fatfs/src&quot;"/>
</option>
<option id="org.eclipse.cdt.cross.arm.gnu.c.compiler.option.preprocessor.def.73574838" name="Defined symbols (-D)" superClass="org.eclipse.cdt.cross.arm.gnu.c.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="XMC4700_F144x2048"/>
<listOptionValue builtIn="false" value="XMC_ETH_PHY_KSZ8081RNB"/>
</option>
<option id="org.eclipse.cdt.cross.arm.gnu.c.compiler.option.other.otherflags.1030792093" name="Other flags" superClass="org.eclipse.cdt.cross.arm.gnu.c.compiler.option.other.otherflags" useByScannerDiscovery="false" value="-c -fmessage-length=0 -Wno-strict-aliasing" valueType="string"/>
<inputType id="org.eclipse.cdt.cross.arm.gnu.sourcery.windows.c.compiler.base.input.631714543" superClass="org.eclipse.cdt.cross.arm.gnu.sourcery.windows.c.compiler.base.input"/>
</tool>
<tool id="com.ifx.xmc4000.appDebug.cppcompiler.1452880549" name="ARM-GCC C++ Compiler" superClass="com.ifx.xmc4000.appDebug.cppcompiler">

View File

@ -61,7 +61,7 @@
</matcher>
</filter>
<filter>
<id>1534411697456</id>
<id>1560415660311</id>
<name>Core/third_party</name>
<type>9</type>
<matcher>
@ -69,6 +69,24 @@
<arguments>1.0-name-matches-false-false-uip</arguments>
</matcher>
</filter>
<filter>
<id>1560415660336</id>
<name>Core/third_party</name>
<type>9</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-fatfs</arguments>
</matcher>
</filter>
<filter>
<id>1560415680577</id>
<name>Core/third_party/fatfs</name>
<type>9</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-src</arguments>
</matcher>
</filter>
<filter>
<id>1534411724947</id>
<name>Core/third_party/uip</name>
@ -132,6 +150,15 @@
<arguments>1.0-name-matches-false-false-uip-split.c</arguments>
</matcher>
</filter>
<filter>
<id>1560415721483</id>
<name>Core/third_party/fatfs/src/option</name>
<type>5</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-unicode.c</arguments>
</matcher>
</filter>
</filteredResources>
<variableList>
<variable>

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 ---*/

View File

@ -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);
}

View File

@ -160,6 +160,42 @@
#define BOOT_COM_NET_DEFERRED_INIT_ENABLE (1)
/****************************************************************************************
* F I L E S Y S T E M I N T E R F A C E C O N F I G U R A T I O N
****************************************************************************************/
/* The file system interface is selected by setting the BOOT_FILE_SYS_ENABLE configurable
* to 1. This enables support for firmware updates from a file stored on a locally
* attached file system such as an SD-card. Note that this interface can be enabled
* together with one of the remote communication interfaces such as UART, CAN or USB.
*
* Set BOOT_FILE_LOGGING_ENABLE to 1 if you would like log messages to be created during
* a firmware update. The hook function FileFirmwareUpdateLogHook() will be called each
* time a new string formatted log entry is available. This could be used during testing
* by outputting the string on UART or to create a log file on the file system itself.
*
* Set BOOT_FILE_ERROR_HOOK_ENABLE to 1 if you would like to be informed in case an error
* occurs during the firmware update. This could for example be used to turn on an error
* LED to inform the user that something went wrong. Inspecting the log messages provides
* additional information on the error cause.
*
* Set BOOT_FILE_STARTED_HOOK_ENABLE to 1 if you would like to be informed when a new
* firmware update is started by the bootloader.
*
* Set BOOT_FILE_COMPLETED_HOOK_ENABLE to 1 if you would like to be informed when a
* firmware update is completed by the bootloader.
*/
/** \brief Enable/disable support for firmware updates from a locally attached storage.*/
#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. */
#define BOOT_FILE_ERROR_HOOK_ENABLE (1)
/** \brief Enable/disable a hook function that is called at the start of the update. */
#define BOOT_FILE_STARTED_HOOK_ENABLE (1)
/** \brief Enable/disable a hook function that is called at the end of the update. */
#define BOOT_FILE_COMPLETED_HOOK_ENABLE (1)
/****************************************************************************************
* B A C K D O O R E N T R Y C O N F I G U R A T I O N
****************************************************************************************/

View File

@ -32,6 +32,7 @@
#include "boot.h" /* bootloader generic header */
#include "led.h" /* LED driver header */
#include "xmc_gpio.h" /* GPIO module */
#include "xmc_uart.h" /* UART driver header */
/****************************************************************************************
@ -245,6 +246,194 @@ blt_bool NvmWriteChecksumHook(void)
#endif /* BOOT_NVM_CHECKSUM_HOOKS_ENABLE > 0 */
/****************************************************************************************
* F I L E S Y S T E M I N T E R F A C E H O O K F U N C T I O N S
****************************************************************************************/
#if (BOOT_FILE_SYS_ENABLE > 0)
/****************************************************************************************
* Constant data declarations
****************************************************************************************/
/** \brief Firmware filename. */
static const blt_char firmwareFilename[] = "/demoprog_xmc4700.srec";
/****************************************************************************************
* Local data declarations
****************************************************************************************/
#if (BOOT_FILE_LOGGING_ENABLE > 0)
/** \brief Data structure for grouping log-file related information. */
static struct
{
FIL handle; /**< FatFS handle to the log-file. */
blt_bool canUse; /**< Flag to indicate if the log-file can be used. */
} logfile;
#endif
/************************************************************************************//**
** \brief Callback that gets called to check whether a firmware update from
** local file storage should be started. This could for example be when
** a switch is pressed, when a certain file is found on the local file
** storage, etc.
** \return BLT_TRUE if a firmware update is requested, BLT_FALSE otherwise.
**
****************************************************************************************/
blt_bool FileIsFirmwareUpdateRequestedHook(void)
{
FILINFO fileInfoObject = { 0 }; /* needs to be zeroed according to f_stat docs */;
/* Current example implementation looks for a predetermined firmware file on the
* SD-card. If the SD-card is accessible and the firmware file was found the firmware
* update is started. When successfully completed, the firmware file is deleted.
* During the firmware update, progress information is written to a file called
* bootlog.txt and additionally outputted on UART @57600 bps for debugging purposes.
*/
/* check if firmware file is present and SD-card is accessible */
if (f_stat(firmwareFilename, &fileInfoObject) == FR_OK)
{
/* check if the filesize is valid and that it is not a directory */
if ( (fileInfoObject.fsize > 0) && (!(fileInfoObject.fattrib & AM_DIR)) )
{
/* all conditions are met to start a firmware update from local file storage */
return BLT_TRUE;
}
}
/* still here so no firmware update request is pending */
return BLT_FALSE;
} /*** end of FileIsFirmwareUpdateRequestedHook ***/
/************************************************************************************//**
** \brief Callback to obtain the filename of the firmware file that should be
** used during the firmware update from the local file storage. This
** hook function is called at the beginning of the firmware update from
** local storage sequence.
** \return valid firmware filename with full path or BLT_NULL.
**
****************************************************************************************/
const blt_char *FileGetFirmwareFilenameHook(void)
{
return firmwareFilename;
} /*** end of FileGetFirmwareFilenameHook ***/
#if (BOOT_FILE_STARTED_HOOK_ENABLE > 0)
/************************************************************************************//**
** \brief Callback that gets called to inform the application that a firmware
** update from local storage just started.
** \return none.
**
****************************************************************************************/
void FileFirmwareUpdateStartedHook(void)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0)
/* create/overwrite the logfile */
logfile.canUse = BLT_FALSE;
if (f_open(&logfile.handle, "/bootlog.txt", FA_CREATE_ALWAYS | FA_WRITE) == FR_OK)
{
logfile.canUse = BLT_TRUE;
}
#endif
} /*** end of FileFirmwareUpdateStartedHook ***/
#endif /* BOOT_FILE_STARTED_HOOK_ENABLE > 0 */
#if (BOOT_FILE_COMPLETED_HOOK_ENABLE > 0)
/************************************************************************************//**
** \brief Callback that gets called to inform the application that a firmware
** update was successfully completed.
** \return none.
**
****************************************************************************************/
void FileFirmwareUpdateCompletedHook(void)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0)
/* close the log file */
if (logfile.canUse == BLT_TRUE)
{
f_close(&logfile.handle);
}
#endif
/* now delete the firmware file from the disk since the update was successful */
f_unlink(firmwareFilename);
} /*** end of FileFirmwareUpdateCompletedHook ***/
#endif /* BOOT_FILE_COMPLETED_HOOK_ENABLE > 0 */
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
/************************************************************************************//**
** \brief Callback that gets called in case an error occurred during a firmware
** update. Refer to <file.h> for a list of available error codes.
** \return none.
**
****************************************************************************************/
void FileFirmwareUpdateErrorHook(blt_int8u error_code)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0)
/* error detected which stops the firmware update, so close the log file */
if (logfile.canUse == BLT_TRUE)
{
f_close(&logfile.handle);
}
#endif
} /*** end of FileFirmwareUpdateErrorHook ***/
#endif /* BOOT_FILE_ERROR_HOOK_ENABLE > 0 */
#if (BOOT_FILE_LOGGING_ENABLE > 0)
/************************************************************************************//**
** \brief Callback that gets called each time new log information becomes
** available during a firmware update.
** \param info_string Pointer to a character array with the log entry info.
** \return none.
**
****************************************************************************************/
void FileFirmwareUpdateLogHook(blt_char *info_string)
{
blt_int32u timeoutTime;
/* write the string to the log file */
if (logfile.canUse == BLT_TRUE)
{
if (f_puts(info_string, &logfile.handle) < 0)
{
logfile.canUse = BLT_FALSE;
f_close(&logfile.handle);
}
}
/* echo all characters in the string on UART */
while(*info_string != '\0')
{
/* write byte to transmit holding register */
XMC_UART_CH_Transmit(XMC_UART0_CH0, *info_string);
/* set timeout time to wait for transmit completion. */
timeoutTime = TimerGet() + 10;
/* wait for tx holding register to be empty */
while( (XMC_USIC_CH_TXFIFO_GetEvent(XMC_UART0_CH0) & XMC_USIC_CH_TXFIFO_EVENT_STANDARD) == 0)
{
/* keep the watchdog happy */
CopService();
/* break loop upon timeout. this would indicate a hardware failure. */
if (TimerGet() > timeoutTime)
{
break;
}
}
/* reset event */
XMC_USIC_CH_TXFIFO_ClearEvent(XMC_UART0_CH0, XMC_USIC_CH_TXFIFO_EVENT_STANDARD);
/* point to the next character in the string */
info_string++;
}
} /*** end of FileFirmwareUpdateLogHook ***/
#endif /* BOOT_FILE_LOGGING_ENABLE > 0 */
#endif /* BOOT_FILE_SYS_ENABLE > 0 */
/****************************************************************************************
* S E E D / K E Y S E C U R I T Y H O O K F U N C T I O N S
****************************************************************************************/

View File

@ -65,8 +65,8 @@ no_init_size = 64;
MEMORY
{
FLASH_1_cached(RX) : ORIGIN = 0x08000000, LENGTH = 0x8000
FLASH_1_uncached(RX) : ORIGIN = 0x0C000000, LENGTH = 0x8000
FLASH_1_cached(RX) : ORIGIN = 0x08000000, LENGTH = 0xC000
FLASH_1_uncached(RX) : ORIGIN = 0x0C000000, LENGTH = 0xC000
PSRAM_1(!RX) : ORIGIN = 0x1FFE8040, LENGTH = 0x17fc0
DSRAM_1_system(!RX) : ORIGIN = 0x20000000, LENGTH = 0x20000
DSRAM_2_comm(!RX) : ORIGIN = 0x20020000, LENGTH = 0x20000

View File

@ -111,11 +111,31 @@ int main(void)
****************************************************************************************/
static void Init(void)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0) && (BOOT_COM_UART_ENABLE == 0)
XMC_UART_CH_CONFIG_t uart_config;
#endif
/* initialize LED1 on P5.9 as digital output */
XMC_GPIO_SetMode(P5_9, XMC_GPIO_MODE_OUTPUT_PUSH_PULL);
/* initialize BUTTON1 as digital input. */
XMC_GPIO_SetMode(P15_13, XMC_GPIO_MODE_INPUT_TRISTATE);
XMC_GPIO_EnableDigitalInput(P15_13);
#if (BOOT_FILE_LOGGING_ENABLE > 0) && (BOOT_COM_UART_ENABLE == 0)
/* set configuration and initialize UART channel */
uart_config.baudrate = BOOT_COM_UART_BAUDRATE;
uart_config.data_bits = 8;
uart_config.frame_length = 8;
uart_config.stop_bits = 1;
uart_config.oversampling = 16;
uart_config.parity_mode = XMC_USIC_CH_PARITY_MODE_NONE;
XMC_UART_CH_Init(XMC_UART0_CH0, &uart_config);
/* configure small transmit and receive FIFO */
XMC_USIC_CH_TXFIFO_Configure(XMC_UART0_CH0, 16U, XMC_USIC_CH_FIFO_SIZE_16WORDS, 1U);
XMC_USIC_CH_RXFIFO_Configure(XMC_UART0_CH0, 0U, XMC_USIC_CH_FIFO_SIZE_16WORDS, 1U);
/* start UART */
XMC_UART_CH_Start(XMC_UART0_CH0);
#endif
} /*** end of Init ***/
@ -127,7 +147,7 @@ static void Init(void)
****************************************************************************************/
static void PostInit(void)
{
#if (BOOT_COM_UART_ENABLE > 0)
#if (BOOT_COM_UART_ENABLE > 0) || (BOOT_FILE_LOGGING_ENABLE > 0)
XMC_GPIO_CONFIG_t rx_uart_config;
XMC_GPIO_CONFIG_t tx_uart_config;
#endif
@ -136,7 +156,7 @@ static void PostInit(void)
XMC_GPIO_CONFIG_t tx_can_config;
#endif
#if (BOOT_COM_UART_ENABLE > 0)
#if (BOOT_COM_UART_ENABLE > 0) || (BOOT_FILE_LOGGING_ENABLE > 0)
/* initialize UART Rx pin */
rx_uart_config.mode = XMC_GPIO_MODE_INPUT_TRISTATE;
rx_uart_config.output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH;

View File

@ -65,8 +65,8 @@ no_init_size = 64;
MEMORY
{
FLASH_1_cached(RX) : ORIGIN = 0x08008000, LENGTH = 0x1f8000
FLASH_1_uncached(RX) : ORIGIN = 0x0C008000, LENGTH = 0x1f8000
FLASH_1_cached(RX) : ORIGIN = 0x0800C000, LENGTH = 0x1f4000
FLASH_1_uncached(RX) : ORIGIN = 0x0C00C000, LENGTH = 0x1f4000
PSRAM_1(!RX) : ORIGIN = 0x1FFE8040, LENGTH = 0x17fc0
DSRAM_1_system(!RX) : ORIGIN = 0x20000000, LENGTH = 0x20000
DSRAM_2_comm(!RX) : ORIGIN = 0x20020000, LENGTH = 0x20000

View File

@ -160,6 +160,42 @@
#define BOOT_COM_NET_DEFERRED_INIT_ENABLE (1)
/****************************************************************************************
* F I L E S Y S T E M I N T E R F A C E C O N F I G U R A T I O N
****************************************************************************************/
/* The file system interface is selected by setting the BOOT_FILE_SYS_ENABLE configurable
* to 1. This enables support for firmware updates from a file stored on a locally
* attached file system such as an SD-card. Note that this interface can be enabled
* together with one of the remote communication interfaces such as UART, CAN or USB.
*
* Set BOOT_FILE_LOGGING_ENABLE to 1 if you would like log messages to be created during
* a firmware update. The hook function FileFirmwareUpdateLogHook() will be called each
* time a new string formatted log entry is available. This could be used during testing
* by outputting the string on UART or to create a log file on the file system itself.
*
* Set BOOT_FILE_ERROR_HOOK_ENABLE to 1 if you would like to be informed in case an error
* occurs during the firmware update. This could for example be used to turn on an error
* LED to inform the user that something went wrong. Inspecting the log messages provides
* additional information on the error cause.
*
* Set BOOT_FILE_STARTED_HOOK_ENABLE to 1 if you would like to be informed when a new
* firmware update is started by the bootloader.
*
* Set BOOT_FILE_COMPLETED_HOOK_ENABLE to 1 if you would like to be informed when a
* firmware update is completed by the bootloader.
*/
/** \brief Enable/disable support for firmware updates from a locally attached storage.*/
#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. */
#define BOOT_FILE_ERROR_HOOK_ENABLE (1)
/** \brief Enable/disable a hook function that is called at the start of the update. */
#define BOOT_FILE_STARTED_HOOK_ENABLE (1)
/** \brief Enable/disable a hook function that is called at the end of the update. */
#define BOOT_FILE_COMPLETED_HOOK_ENABLE (1)
/****************************************************************************************
* B A C K D O O R E N T R Y C O N F I G U R A T I O N
****************************************************************************************/

View File

@ -5,7 +5,7 @@
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_IROM1_start__ = 0x08000000;
define symbol __ICFEDIT_region_IROM1_end__ = 0x08007FFF;
define symbol __ICFEDIT_region_IROM1_end__ = 0x0800BFFF;
define symbol __ICFEDIT_region_IROM2_start__ = 0x0;
define symbol __ICFEDIT_region_IROM2_end__ = 0x0;
define symbol __ICFEDIT_region_EROM1_start__ = 0x0;

View File

@ -32,6 +32,7 @@
#include "boot.h" /* bootloader generic header */
#include "led.h" /* LED driver header */
#include "xmc_gpio.h" /* GPIO module */
#include "xmc_uart.h" /* UART driver header */
/****************************************************************************************
@ -245,6 +246,194 @@ blt_bool NvmWriteChecksumHook(void)
#endif /* BOOT_NVM_CHECKSUM_HOOKS_ENABLE > 0 */
/****************************************************************************************
* F I L E S Y S T E M I N T E R F A C E H O O K F U N C T I O N S
****************************************************************************************/
#if (BOOT_FILE_SYS_ENABLE > 0)
/****************************************************************************************
* Constant data declarations
****************************************************************************************/
/** \brief Firmware filename. */
static const blt_char firmwareFilename[] = "/demoprog_xmc4700.srec";
/****************************************************************************************
* Local data declarations
****************************************************************************************/
#if (BOOT_FILE_LOGGING_ENABLE > 0)
/** \brief Data structure for grouping log-file related information. */
static struct
{
FIL handle; /**< FatFS handle to the log-file. */
blt_bool canUse; /**< Flag to indicate if the log-file can be used. */
} logfile;
#endif
/************************************************************************************//**
** \brief Callback that gets called to check whether a firmware update from
** local file storage should be started. This could for example be when
** a switch is pressed, when a certain file is found on the local file
** storage, etc.
** \return BLT_TRUE if a firmware update is requested, BLT_FALSE otherwise.
**
****************************************************************************************/
blt_bool FileIsFirmwareUpdateRequestedHook(void)
{
FILINFO fileInfoObject = { 0 }; /* needs to be zeroed according to f_stat docs */;
/* Current example implementation looks for a predetermined firmware file on the
* SD-card. If the SD-card is accessible and the firmware file was found the firmware
* update is started. When successfully completed, the firmware file is deleted.
* During the firmware update, progress information is written to a file called
* bootlog.txt and additionally outputted on UART @57600 bps for debugging purposes.
*/
/* check if firmware file is present and SD-card is accessible */
if (f_stat(firmwareFilename, &fileInfoObject) == FR_OK)
{
/* check if the filesize is valid and that it is not a directory */
if ( (fileInfoObject.fsize > 0) && (!(fileInfoObject.fattrib & AM_DIR)) )
{
/* all conditions are met to start a firmware update from local file storage */
return BLT_TRUE;
}
}
/* still here so no firmware update request is pending */
return BLT_FALSE;
} /*** end of FileIsFirmwareUpdateRequestedHook ***/
/************************************************************************************//**
** \brief Callback to obtain the filename of the firmware file that should be
** used during the firmware update from the local file storage. This
** hook function is called at the beginning of the firmware update from
** local storage sequence.
** \return valid firmware filename with full path or BLT_NULL.
**
****************************************************************************************/
const blt_char *FileGetFirmwareFilenameHook(void)
{
return firmwareFilename;
} /*** end of FileGetFirmwareFilenameHook ***/
#if (BOOT_FILE_STARTED_HOOK_ENABLE > 0)
/************************************************************************************//**
** \brief Callback that gets called to inform the application that a firmware
** update from local storage just started.
** \return none.
**
****************************************************************************************/
void FileFirmwareUpdateStartedHook(void)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0)
/* create/overwrite the logfile */
logfile.canUse = BLT_FALSE;
if (f_open(&logfile.handle, "/bootlog.txt", FA_CREATE_ALWAYS | FA_WRITE) == FR_OK)
{
logfile.canUse = BLT_TRUE;
}
#endif
} /*** end of FileFirmwareUpdateStartedHook ***/
#endif /* BOOT_FILE_STARTED_HOOK_ENABLE > 0 */
#if (BOOT_FILE_COMPLETED_HOOK_ENABLE > 0)
/************************************************************************************//**
** \brief Callback that gets called to inform the application that a firmware
** update was successfully completed.
** \return none.
**
****************************************************************************************/
void FileFirmwareUpdateCompletedHook(void)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0)
/* close the log file */
if (logfile.canUse == BLT_TRUE)
{
f_close(&logfile.handle);
}
#endif
/* now delete the firmware file from the disk since the update was successful */
f_unlink(firmwareFilename);
} /*** end of FileFirmwareUpdateCompletedHook ***/
#endif /* BOOT_FILE_COMPLETED_HOOK_ENABLE > 0 */
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
/************************************************************************************//**
** \brief Callback that gets called in case an error occurred during a firmware
** update. Refer to <file.h> for a list of available error codes.
** \return none.
**
****************************************************************************************/
void FileFirmwareUpdateErrorHook(blt_int8u error_code)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0)
/* error detected which stops the firmware update, so close the log file */
if (logfile.canUse == BLT_TRUE)
{
f_close(&logfile.handle);
}
#endif
} /*** end of FileFirmwareUpdateErrorHook ***/
#endif /* BOOT_FILE_ERROR_HOOK_ENABLE > 0 */
#if (BOOT_FILE_LOGGING_ENABLE > 0)
/************************************************************************************//**
** \brief Callback that gets called each time new log information becomes
** available during a firmware update.
** \param info_string Pointer to a character array with the log entry info.
** \return none.
**
****************************************************************************************/
void FileFirmwareUpdateLogHook(blt_char *info_string)
{
blt_int32u timeoutTime;
/* write the string to the log file */
if (logfile.canUse == BLT_TRUE)
{
if (f_puts(info_string, &logfile.handle) < 0)
{
logfile.canUse = BLT_FALSE;
f_close(&logfile.handle);
}
}
/* echo all characters in the string on UART */
while(*info_string != '\0')
{
/* write byte to transmit holding register */
XMC_UART_CH_Transmit(XMC_UART0_CH0, *info_string);
/* set timeout time to wait for transmit completion. */
timeoutTime = TimerGet() + 10;
/* wait for tx holding register to be empty */
while( (XMC_USIC_CH_TXFIFO_GetEvent(XMC_UART0_CH0) & XMC_USIC_CH_TXFIFO_EVENT_STANDARD) == 0)
{
/* keep the watchdog happy */
CopService();
/* break loop upon timeout. this would indicate a hardware failure. */
if (TimerGet() > timeoutTime)
{
break;
}
}
/* reset event */
XMC_USIC_CH_TXFIFO_ClearEvent(XMC_UART0_CH0, XMC_USIC_CH_TXFIFO_EVENT_STANDARD);
/* point to the next character in the string */
info_string++;
}
} /*** end of FileFirmwareUpdateLogHook ***/
#endif /* BOOT_FILE_LOGGING_ENABLE > 0 */
#endif /* BOOT_FILE_SYS_ENABLE > 0 */
/****************************************************************************************
* S E E D / K E Y S E C U R I T Y H O O K F U N C T I O N S
****************************************************************************************/

View File

@ -25,7 +25,7 @@ if not "%~1" == "" goto debugFile
@echo on
"C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.5\common\bin\cspybat" -f "C:\Work\software\OpenBLT_XMC4700_extras\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\settings\xmc4700.Debug.general.xcl" --backend -f "C:\Work\software\OpenBLT_XMC4700_extras\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\settings\xmc4700.Debug.driver.xcl"
"C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.5\common\bin\cspybat" -f "C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\settings\xmc4700.Debug.general.xcl" --backend -f "C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\settings\xmc4700.Debug.driver.xcl"
@echo off
goto end
@ -34,7 +34,7 @@ goto end
@echo on
"C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.5\common\bin\cspybat" -f "C:\Work\software\OpenBLT_XMC4700_extras\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\settings\xmc4700.Debug.general.xcl" "--debug_file=%~1" --backend -f "C:\Work\software\OpenBLT_XMC4700_extras\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\settings\xmc4700.Debug.driver.xcl"
"C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.5\common\bin\cspybat" -f "C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\settings\xmc4700.Debug.general.xcl" "--debug_file=%~1" --backend -f "C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\settings\xmc4700.Debug.driver.xcl"
@echo off
:end

View File

@ -2,7 +2,7 @@
"C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.5\arm\bin\armjlink2.dll"
"C:\Work\software\OpenBLT_XMC4700_extras\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\bin\openblt_xmc4700.out"
"C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\bin\openblt_xmc4700.out"
--plugin "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.5\arm\bin\armbat.dll"

View File

@ -39,7 +39,7 @@
<Wnd0>
<Wnd3>
<Tabs>
<Tab>
<Identity>TabID-6569-18762</Identity>
@ -55,7 +55,7 @@
</Tab>
</Tabs>
<SelectedTab>0</SelectedTab></Wnd0><Wnd1>
<SelectedTab>0</SelectedTab></Wnd3><Wnd4>
<Tabs>
<Tab>
<Identity>TabID-17318-18765</Identity>
@ -67,7 +67,7 @@
</Tab>
</Tabs>
<SelectedTab>0</SelectedTab></Wnd1><Wnd2>
<SelectedTab>0</SelectedTab></Wnd4><Wnd5>
<Tabs>
<Tab>
<Identity>TabID-28066-18768</Identity>
@ -77,7 +77,7 @@
</Tab>
</Tabs>
<SelectedTab>0</SelectedTab></Wnd2></Windows>
<SelectedTab>0</SelectedTab></Wnd5></Windows>
<Editor>
@ -90,7 +90,7 @@
<Top><Row0><Sizes><Toolbar-051A02B0><key>iaridepm.enu1</key></Toolbar-051A02B0></Sizes></Row0><Row1><Sizes><Toolbar-15B93740><key>debuggergui.enu1</key></Toolbar-15B93740></Sizes></Row1><Row2><Sizes><Toolbar-15B93358><key>armjlink2.enu1</key></Toolbar-15B93358></Sizes></Row2></Top><Left><Row0><Sizes><Wnd1><Rect><Top>-2</Top><Left>-2</Left><Bottom>716</Bottom><Right>374</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>104167</sizeHorzCX><sizeHorzCY>198610</sizeHorzCY><sizeVertCX>195833</sizeVertCX><sizeVertCY>713009</sizeVertCY></Rect></Wnd1></Sizes></Row0></Left><Right><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>716</Bottom><Right>198</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>104167</sizeHorzCX><sizeHorzCY>198610</sizeHorzCY><sizeVertCX>104167</sizeVertCX><sizeVertCY>713009</sizeVertCY></Rect></Wnd2></Sizes></Row0></Right><Bottom><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1922</Right><x>-2</x><y>-2</y><xscreen>1924</xscreen><yscreen>200</yscreen><sizeHorzCX>1002083</sizeHorzCX><sizeHorzCY>198610</sizeHorzCY><sizeVertCX>104167</sizeVertCX><sizeVertCY>198610</sizeVertCY></Rect></Wnd0></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
<Top><Row0><Sizes><Toolbar-04A1C478><key>iaridepm.enu1</key></Toolbar-04A1C478></Sizes></Row0><Row1><Sizes><Toolbar-0D083948><key>debuggergui.enu1</key></Toolbar-0D083948></Sizes></Row1><Row2><Sizes><Toolbar-0D0853D8><key>armjlink2.enu1</key></Toolbar-0D0853D8></Sizes></Row2></Top><Left><Row0><Sizes><Wnd4><Rect><Top>-2</Top><Left>-2</Left><Bottom>716</Bottom><Right>374</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>104167</sizeHorzCX><sizeHorzCY>198610</sizeHorzCY><sizeVertCX>195833</sizeVertCX><sizeVertCY>713009</sizeVertCY></Rect></Wnd4></Sizes></Row0></Left><Right><Row0><Sizes><Wnd5><Rect><Top>-2</Top><Left>-2</Left><Bottom>716</Bottom><Right>198</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>104167</sizeHorzCX><sizeHorzCY>198610</sizeHorzCY><sizeVertCX>104167</sizeVertCX><sizeVertCY>713009</sizeVertCY></Rect></Wnd5></Sizes></Row0></Right><Bottom><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1922</Right><x>-2</x><y>-2</y><xscreen>1924</xscreen><yscreen>200</yscreen><sizeHorzCX>1002083</sizeHorzCX><sizeHorzCY>198610</sizeHorzCY><sizeVertCX>104167</sizeVertCX><sizeVertCY>198610</sizeVertCY></Rect></Wnd3></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
</Desktop>
</Project>

View File

@ -26,7 +26,7 @@ TraceBufferSize=0x00010000
TraceStallIfFIFOFull=0x00000000
TracePortSize=0x00000004
[DebugChecksum]
Checksum=1184049083
Checksum=2017057073
[Exceptions]
StopOnUncaught=_ 0
StopOnThrow=_ 0

View File

@ -52,7 +52,7 @@
<Factory>Workspace</Factory>
<Session>
<NodeDict><ExpandedNode>xmc4700</ExpandedNode><ExpandedNode>xmc4700/Boot</ExpandedNode><ExpandedNode>xmc4700/Boot/lib</ExpandedNode><ExpandedNode>xmc4700/Boot/lib/uip</ExpandedNode><ExpandedNode>xmc4700/Output</ExpandedNode></NodeDict></Session>
<NodeDict><ExpandedNode>xmc4700</ExpandedNode><ExpandedNode>xmc4700/Boot</ExpandedNode><ExpandedNode>xmc4700/Output</ExpandedNode><ExpandedNode>xmc4700/Source</ExpandedNode></NodeDict></Session>
</Tab>
</Tabs>
@ -69,7 +69,7 @@
<Top><Row0><Sizes><Toolbar-051A02B0><key>iaridepm.enu1</key></Toolbar-051A02B0></Sizes></Row0><Row1><Sizes/></Row1></Top><Left><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>962</Bottom><Right>314</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>104167</sizeHorzCX><sizeHorzCY>198610</sizeHorzCY><sizeVertCX>164583</sizeVertCX><sizeVertCY>957299</sizeVertCY></Rect></Wnd3></Sizes></Row0></Left><Right><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>962</Bottom><Right>410</Right><x>-2</x><y>-2</y><xscreen>1924</xscreen><yscreen>247</yscreen><sizeHorzCX>1002083</sizeHorzCX><sizeHorzCY>245283</sizeHorzCY><sizeVertCX>214583</sizeVertCX><sizeVertCY>957299</sizeVertCY></Rect></Wnd2></Sizes></Row0></Right><Bottom><Row0><Sizes/></Row0></Bottom><Float><Sizes/></Float></Positions>
<Top><Row0><Sizes><Toolbar-04A1C478><key>iaridepm.enu1</key></Toolbar-04A1C478></Sizes></Row0><Row1><Sizes/></Row1></Top><Left><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>962</Bottom><Right>314</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>104167</sizeHorzCX><sizeHorzCY>198610</sizeHorzCY><sizeVertCX>164583</sizeVertCX><sizeVertCY>957299</sizeVertCY></Rect></Wnd3></Sizes></Row0></Left><Right><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>962</Bottom><Right>410</Right><x>-2</x><y>-2</y><xscreen>1924</xscreen><yscreen>247</yscreen><sizeHorzCX>1002083</sizeHorzCX><sizeHorzCY>245283</sizeHorzCY><sizeVertCX>214583</sizeVertCX><sizeVertCY>957299</sizeVertCY></Rect></Wnd2></Sizes></Row0></Right><Bottom><Row0><Sizes/></Row0></Bottom><Float><Sizes/></Float></Positions>
</Desktop>
</Workspace>

View File

@ -222,7 +222,7 @@
</option>
<option>
<name>CCDiagSuppress</name>
<state></state>
<state>Pa082</state>
</option>
<option>
<name>CCDiagRemark</name>
@ -316,11 +316,14 @@
<state>$PROJ_DIR$\..\lib\cmsis</state>
<state>$PROJ_DIR$\..\lib\uip</state>
<state>$PROJ_DIR$\..\lib\xmclib\inc</state>
<state>$PROJ_DIR$\..\lib\FatFS</state>
<state>$PROJ_DIR$\..\lib\FatFS\SDMMC_BLOCK</state>
<state>$PROJ_DIR$\..\..\..\..\Source</state>
<state>$PROJ_DIR$\..\..\..\..\Source\ARMCM4_XMC4</state>
<state>$PROJ_DIR$\..\..\..\..\Source\ARMCM4_XMC4\IAR</state>
<state>$PROJ_DIR$\..\..\..\..\Source\third_party\uip\uip</state>
<state>$PROJ_DIR$\..\..\..\..\Source\third_party\uip\apps\dhcpc</state>
<state>$PROJ_DIR$\..\..\..\..\Source\third_party\fatfs\src</state>
</option>
<option>
<name>CCStdIncCheck</name>
@ -1957,6 +1960,36 @@
<name>$PROJ_DIR$\..\lib\cmsis\core_cmSimd.h</name>
</file>
</group>
<group>
<name>fatfs</name>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\ffconf.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\mmc.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\SDMMC_BLOCK\sdmmc_block.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\SDMMC_BLOCK\sdmmc_block.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_conf.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_conf.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_extern.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_private_sd.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_private_sd.h</name>
</file>
</group>
<group>
<name>uip</name>
<file>
@ -2296,6 +2329,24 @@
</group>
<group>
<name>third_party</name>
<group>
<name>fatfs</name>
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\third_party\fatfs\src\diskio.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\third_party\fatfs\src\ff.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\third_party\fatfs\src\ff.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\third_party\fatfs\src\integer.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\third_party\fatfs\src\option\unicode.c</name>
</file>
</group>
<group>
<name>uip</name>
<file>

View File

@ -2333,6 +2333,36 @@
<name>$PROJ_DIR$\..\lib\cmsis\core_cmSimd.h</name>
</file>
</group>
<group>
<name>fatfs</name>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\ffconf.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\mmc.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\SDMMC_BLOCK\sdmmc_block.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\SDMMC_BLOCK\sdmmc_block.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_conf.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_conf.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_extern.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_private_sd.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\lib\FatFS\SDMMC_BLOCK\sdmmc_block_private_sd.h</name>
</file>
</group>
<group>
<name>uip</name>
<file>
@ -2672,6 +2702,24 @@
</group>
<group>
<name>third_party</name>
<group>
<name>fatfs</name>
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\third_party\fatfs\src\diskio.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\third_party\fatfs\src\ff.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\third_party\fatfs\src\ff.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\third_party\fatfs\src\integer.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\third_party\fatfs\src\option\unicode.c</name>
</file>
</group>
<group>
<name>uip</name>
<file>

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 ---*/

View File

@ -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);
}

View File

@ -108,11 +108,31 @@ void main(void)
****************************************************************************************/
static void Init(void)
{
#if (BOOT_FILE_LOGGING_ENABLE > 0) && (BOOT_COM_UART_ENABLE == 0)
XMC_UART_CH_CONFIG_t uart_config;
#endif
/* initialize LED1 on P5.9 as digital output */
XMC_GPIO_SetMode(P5_9, XMC_GPIO_MODE_OUTPUT_PUSH_PULL);
/* initialize BUTTON1 as digital input. */
XMC_GPIO_SetMode(P15_13, XMC_GPIO_MODE_INPUT_TRISTATE);
XMC_GPIO_EnableDigitalInput(P15_13);
#if (BOOT_FILE_LOGGING_ENABLE > 0) && (BOOT_COM_UART_ENABLE == 0)
/* set configuration and initialize UART channel */
uart_config.baudrate = BOOT_COM_UART_BAUDRATE;
uart_config.data_bits = 8;
uart_config.frame_length = 8;
uart_config.stop_bits = 1;
uart_config.oversampling = 16;
uart_config.parity_mode = XMC_USIC_CH_PARITY_MODE_NONE;
XMC_UART_CH_Init(XMC_UART0_CH0, &uart_config);
/* configure small transmit and receive FIFO */
XMC_USIC_CH_TXFIFO_Configure(XMC_UART0_CH0, 16U, XMC_USIC_CH_FIFO_SIZE_16WORDS, 1U);
XMC_USIC_CH_RXFIFO_Configure(XMC_UART0_CH0, 0U, XMC_USIC_CH_FIFO_SIZE_16WORDS, 1U);
/* start UART */
XMC_UART_CH_Start(XMC_UART0_CH0);
#endif
} /*** end of Init ***/
@ -124,7 +144,7 @@ static void Init(void)
****************************************************************************************/
static void PostInit(void)
{
#if (BOOT_COM_UART_ENABLE > 0)
#if (BOOT_COM_UART_ENABLE > 0) || (BOOT_FILE_LOGGING_ENABLE > 0)
XMC_GPIO_CONFIG_t rx_uart_config;
XMC_GPIO_CONFIG_t tx_uart_config;
#endif
@ -133,7 +153,7 @@ static void PostInit(void)
XMC_GPIO_CONFIG_t tx_can_config;
#endif
#if (BOOT_COM_UART_ENABLE > 0)
#if (BOOT_COM_UART_ENABLE > 0) || (BOOT_FILE_LOGGING_ENABLE > 0)
/* initialize UART Rx pin */
rx_uart_config.mode = XMC_GPIO_MODE_INPUT_TRISTATE;
rx_uart_config.output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH;

View File

@ -2,9 +2,9 @@
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_1.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x08008000;
define symbol __ICFEDIT_intvec_start__ = 0x0800C000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_IROM1_start__ = 0x08008000;
define symbol __ICFEDIT_region_IROM1_start__ = 0x0800C000;
define symbol __ICFEDIT_region_IROM1_end__ = 0x081FFFFF;
define symbol __ICFEDIT_region_IROM2_start__ = 0x0;
define symbol __ICFEDIT_region_IROM2_end__ = 0x0;

View File

@ -25,7 +25,7 @@ if not "%~1" == "" goto debugFile
@echo on
"C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.5\common\bin\cspybat" -f "C:\Work\software\OpenBLT_XMC4700_extras\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Prog\ide\settings\xmc4700.Debug.general.xcl" --backend -f "C:\Work\software\OpenBLT_XMC4700_extras\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Prog\ide\settings\xmc4700.Debug.driver.xcl"
"C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.5\common\bin\cspybat" -f "C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Prog\ide\settings\xmc4700.Debug.general.xcl" --backend -f "C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Prog\ide\settings\xmc4700.Debug.driver.xcl"
@echo off
goto end
@ -34,7 +34,7 @@ goto end
@echo on
"C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.5\common\bin\cspybat" -f "C:\Work\software\OpenBLT_XMC4700_extras\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Prog\ide\settings\xmc4700.Debug.general.xcl" "--debug_file=%~1" --backend -f "C:\Work\software\OpenBLT_XMC4700_extras\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Prog\ide\settings\xmc4700.Debug.driver.xcl"
"C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.5\common\bin\cspybat" -f "C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Prog\ide\settings\xmc4700.Debug.general.xcl" "--debug_file=%~1" --backend -f "C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Prog\ide\settings\xmc4700.Debug.driver.xcl"
@echo off
:end

View File

@ -2,7 +2,7 @@
"C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.5\arm\bin\armjlink2.dll"
"C:\Work\software\OpenBLT_XMC4700_extras\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Prog\bin\demoprog_xmc4700.out"
"C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Prog\bin\demoprog_xmc4700.out"
--plugin "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.5\arm\bin\armbat.dll"

View File

@ -28,7 +28,7 @@
<Windows>
<Wnd0>
<Wnd2>
<Tabs>
<Tab>
<Identity>TabID-16961-13040</Identity>
@ -44,7 +44,7 @@
</Tab>
<Tab><Identity>TabID-8639-16881</Identity><TabName>Find in Files</TabName><Factory>Find-in-Files</Factory><Session/></Tab></Tabs>
<SelectedTab>0</SelectedTab></Wnd0><Wnd1>
<SelectedTab>0</SelectedTab></Wnd2><Wnd3>
<Tabs>
<Tab>
<Identity>TabID-27710-13044</Identity>
@ -56,20 +56,20 @@
</Tab>
</Tabs>
<SelectedTab>0</SelectedTab></Wnd1></Windows>
<SelectedTab>0</SelectedTab></Wnd3></Windows>
<Editor>
<Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>24</YPos2><SelStart2>2884</SelStart2><SelEnd2>2884</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\net.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>135</YPos2><SelStart2>6630</SelStart2><SelEnd2>6630</SelEnd2></Tab><ActiveTab>1</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
<Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>24</YPos2><SelStart2>2884</SelStart2><SelEnd2>2884</SelEnd2></Tab><ActiveTab>0</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
<Positions>
<Top><Row0><Sizes><Toolbar-04AB02B0><key>iaridepm.enu1</key></Toolbar-04AB02B0></Sizes></Row0></Top><Left><Row0><Sizes><Wnd1><Rect><Top>-2</Top><Left>-2</Left><Bottom>962</Bottom><Right>475</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>104167</sizeHorzCX><sizeHorzCY>198610</sizeHorzCY><sizeVertCX>248438</sizeVertCX><sizeVertCY>957299</sizeVertCY></Rect></Wnd1></Sizes></Row0></Left><Right><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>962</Bottom><Right>376</Right><x>-2</x><y>-2</y><xscreen>1924</xscreen><yscreen>211</yscreen><sizeHorzCX>1002083</sizeHorzCX><sizeHorzCY>209533</sizeHorzCY><sizeVertCX>196875</sizeVertCX><sizeVertCY>957299</sizeVertCY></Rect></Wnd0></Sizes></Row0></Right><Bottom><Row0><Sizes/></Row0></Bottom><Float><Sizes/></Float></Positions>
<Top><Row0><Sizes><Toolbar-0680C478><key>iaridepm.enu1</key></Toolbar-0680C478></Sizes></Row0></Top><Left><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>962</Bottom><Right>475</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>104167</sizeHorzCX><sizeHorzCY>198610</sizeHorzCY><sizeVertCX>248438</sizeVertCX><sizeVertCY>957299</sizeVertCY></Rect></Wnd3></Sizes></Row0></Left><Right><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>962</Bottom><Right>376</Right><x>-2</x><y>-2</y><xscreen>1924</xscreen><yscreen>211</yscreen><sizeHorzCX>1002083</sizeHorzCX><sizeHorzCY>209533</sizeHorzCY><sizeVertCX>196875</sizeVertCX><sizeVertCY>957299</sizeVertCY></Rect></Wnd2></Sizes></Row0></Right><Bottom><Row0><Sizes/></Row0></Bottom><Float><Sizes/></Float></Positions>
</Desktop>
</Workspace>

View File

@ -222,7 +222,7 @@
</option>
<option>
<name>CCDiagSuppress</name>
<state></state>
<state>Pa082</state>
</option>
<option>
<name>CCDiagRemark</name>

View File

@ -177,7 +177,7 @@ static const tFlashSector flashLayout[] =
*/
/* { 0x0c000000, 0x04000, 0}, flash sector 0 - reserved for bootloader */
/* { 0x0c004000, 0x04000, 1}, flash sector 1 - reserved for bootloader */
{ 0x0c008000, 0x04000, 2}, /* flash sector 2 - 16kb */
/* { 0x0c008000, 0x04000, 2}, flash sector 2 - reserved for bootloader */
{ 0x0c00c000, 0x04000, 3}, /* flash sector 3 - 16kb */
{ 0x0c010000, 0x04000, 4}, /* flash sector 4 - 16kb */
{ 0x0c014000, 0x04000, 5}, /* flash sector 5 - 16kb */