|
|
|
|
@ -92,6 +92,17 @@ unsigned char mmc_init ()
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//set MMC_Chip_Select to high (MMC/SD-Karte Inaktiv)
|
|
|
|
|
void MMC_Disable(){
|
|
|
|
|
WAIT_HALF_CLOCK; MMC_Write|= (1<<MMC_Chip_Select); WAIT_HALF_CLOCK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//set MMC_Chip_Select to low (MMC/SD-Karte Aktiv)
|
|
|
|
|
void MMC_Enable(){
|
|
|
|
|
WAIT_HALF_CLOCK; MMC_Write&=~(1<<MMC_Chip_Select); WAIT_HALF_CLOCK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//############################################################################
|
|
|
|
|
//Sendet ein Commando an die MMC/SD-Karte
|
|
|
|
|
unsigned char mmc_write_command (unsigned char *cmd)
|
|
|
|
|
@ -167,6 +178,7 @@ void mmc_write_byte (unsigned char Byte)
|
|
|
|
|
#else //Routine für Software SPI
|
|
|
|
|
for(uint8_t current_bit = 1 << 7; current_bit; current_bit >>= 1) //das Byte wird Bitweise nacheinander Gesendet MSB First
|
|
|
|
|
{
|
|
|
|
|
MMC_Write &= ~(1<<SPI_Clock); //erzeugt ein Clock Impuls (LOW)
|
|
|
|
|
if(Byte & current_bit) //Ist Bit a in Byte gesetzt
|
|
|
|
|
{
|
|
|
|
|
MMC_Write |= (1<<SPI_DO); //Set Output High
|
|
|
|
|
@ -175,9 +187,9 @@ void mmc_write_byte (unsigned char Byte)
|
|
|
|
|
{
|
|
|
|
|
MMC_Write &= ~(1<<SPI_DO); //Set Output Low
|
|
|
|
|
}
|
|
|
|
|
MMC_Write &= ~(1<<SPI_Clock); //erzeugt ein Clock Impuls (LOW)
|
|
|
|
|
WAIT_HALF_CLOCK;
|
|
|
|
|
MMC_Write |= (1<<SPI_Clock); //setzt Clock Impuls wieder auf (High)
|
|
|
|
|
// bei dieser flanke werden die daten von der karte gelesen
|
|
|
|
|
WAIT_HALF_CLOCK;
|
|
|
|
|
}
|
|
|
|
|
MMC_Write |= (1<<SPI_DO); //setzt Output wieder auf High
|
|
|
|
|
|