found bug in get response function. compile with O0 works. Further checking required

This commit is contained in:
Mario Hüttel 2017-04-17 22:03:37 +02:00
parent 79d476e1eb
commit d7a2705056
3 changed files with 16 additions and 12 deletions

View File

@ -19,7 +19,7 @@
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.8818298" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
<builder autoBuildTarget="all" buildPath="${workspace_loc:/stm32f407vgt6-temp}/Debug" cleanBuildTarget="clean" id="org.eclipse.cdt.build.core.internal.builder.1393845362" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="org.eclipse.cdt.build.core.internal.builder"/>
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1425780702" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.245101596" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.c.optimization.level.none" valueType="enumerated"/>
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.245101596" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.c.optimization.level.most" valueType="enumerated"/>
<option id="gnu.c.compiler.option.debugging.level.1997908310" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="gnu.c.compiler.option.dialect.std.900002727" name="Language standard" superClass="gnu.c.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.c.compiler.dialect.default" valueType="enumerated"/>
<option id="gnu.c.compiler.option.misc.other.1543344021" name="Other flags" superClass="gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -mlittle-endian -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -nostartfiles" valueType="string"/>

View File

@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1055604707477708373" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1055349801614188373" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1055604707477708373" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1055349801614188373" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

View File

@ -23,6 +23,7 @@ extern void SDIO_wait_ms(unsigned int i);
#define CCRCFAIL 1
#define CTIMEOUT 2
#define CNOTEXPETED 3
/* OCR Register Masks */
#define OCS_CCS (1<<30)
@ -74,9 +75,9 @@ DSTATUS SDIO_status(){
}
return returnval;
}
uint32_t debug;
uint32_t debug_timeout;
int debug_acmd = 0;
volatile uint32_t debug;
volatile uint32_t debug_timeout;
volatile int debug_acmd = 0;
DSTATUS SDIO_initialize(){
int timeout = 0x3000;
int i;
@ -115,6 +116,7 @@ DSTATUS SDIO_initialize(){
debug++;
debug_timeout=timeout;
do {
//SDIO_wait_ms(2);
resa41 = SDIO_init_card_ACMD41(hcs_flag);
} while((resa41 == ACMD41_RESP_INIT) && (--timeout > 0));
@ -381,14 +383,16 @@ void SDIO_wait_cmd_sent() {
SDIO->ICR |= SDIO_ICR_CMDSENTC;
}
int SDIO_get_response(uint8_t expectedCMD, uint8_t typeOfAns, uint32_t *responseBuffer) {
int __attribute__((noinline)) __attribute__((optimize("O0"))) SDIO_get_response(uint8_t expectedCMD, uint8_t typeOfAns, uint32_t *responseBuffer) {
uint32_t sdio_status;
//Wait for error or success
while (1) {
if (SDIO->STA & SDIO_STA_CMDREND) break; //Correct Respone Received
if ((SDIO->STA & SDIO_STA_CMDSENT) && (typeOfAns == NO_ANS)) break; // No response required
sdio_status = SDIO->STA;
if (sdio_status & SDIO_STA_CMDREND) break; //Correct Respone Received
if ((sdio_status & SDIO_STA_CMDSENT) && (typeOfAns == NO_ANS)) break; // No response required
//Exclude ACMD41 and CMD2 from valid CRC check
if ((SDIO->STA & SDIO_STA_CCRCFAIL)) {
if ((sdio_status & SDIO_STA_CCRCFAIL)) {
if(expectedCMD == 0xff) {
break;
} else {
@ -397,12 +401,12 @@ int SDIO_get_response(uint8_t expectedCMD, uint8_t typeOfAns, uint32_t *response
}
if (SDIO->STA & SDIO_STA_CTIMEOUT)
if (sdio_status & SDIO_STA_CTIMEOUT)
return -CTIMEOUT;
}
//Valid Respone Received
if (((SDIO->RESPCMD & SDIO_RESPCMD_RESPCMD) != expectedCMD) && (expectedCMD != 0xff))
return -1; //Not the expected respose
return -CNOTEXPETED; //Not the expected respose
//If case of a correct Response
*(responseBuffer++) = SDIO->RESP1;