[stock] around 200bytes flash saving

[all] WSHH used for vario - not tested at all
[all] correction for d>=ofs used with timers
[sky9x/gruvin9x] SD needs 2/3 files opened in the same time
[sky9x] low speed SD when high speed not allowed
This commit is contained in:
bsongis
2012-09-20 17:50:52 +00:00
parent 2fa4a6bb3f
commit 77c87e5da3
14 changed files with 151 additions and 178 deletions
+24 -3
View File
@@ -86,6 +86,8 @@ uint32_t Sd_rca ;
uint32_t Cmd_8_resp ;
uint32_t Cmd_A41_resp ;
uint8_t cardType;
const uint8_t SpeedTable[] = { 1, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80 } ;
uint32_t sdSpeedAllowed ;
/*-----------------------------------------------------------------------*/
/* Lock / unlock functions */
@@ -144,7 +146,8 @@ uint32_t sdSetSpeed(uint32_t mciSpeed )
/* Actual MCI speed */
mciSpeed = Master_frequency / 2 / (clkdiv + 1);
/* Modify MR */HSMCI->HSMCI_MR = mciMr | clkdiv;
/* Modify MR */
HSMCI->HSMCI_MR = mciMr | clkdiv;
return mciSpeed;
}
@@ -363,6 +366,24 @@ const char * sdCmd9()
Card_CSD[1] = phsmci->HSMCI_RSPR[1] ;
Card_CSD[2] = phsmci->HSMCI_RSPR[2] ;
Card_CSD[3] = phsmci->HSMCI_RSPR[3] ;
// Calc transmission speed
uint32_t i = Card_CSD[0] & 0x0000007F ;
uint32_t j ;
j = i >> 3 ;
j = SpeedTable[j] ;
j *= 10000 ;
i &= 7 ;
if ( i-- )
j *= 10 ;
if ( i-- )
j *= 10 ;
if ( i )
j *= 10 ;
if ( j > 9000000 )
j = 9000000 ;
sdSpeedAllowed = j ;
return 0;
}
@@ -452,8 +473,8 @@ const char * sdAcmd6()
if (result)
return result;
sdSetBusWidth( HSMCI_SDCR_SDCBUS_4 ) ;
sdSetSpeed(9000000);
sdSetBusWidth(HSMCI_SDCR_SDCBUS_4);
sdSetSpeed(sdSpeedAllowed);
return 0;
}