reapplying mmc cmd changes

master
Nidan 14 years ago
parent 700c3e0bff
commit b9f1446f08

69
mmc.c

@ -122,21 +122,23 @@ unsigned char mmc_write_command (unsigned char *cmd)
//set MMC_Chip_Select to low (MMC/SD-Karte Aktiv)
MMC_Enable();
//sendet 6 Byte Commando
for (unsigned char a = 0;a<0x06;a++) //sendet 6 Byte Commando zur MMC/SD-Karte
{
//sendet 5 Byte Commando
for (unsigned char a = 0;a < 5; a++) //sendet 6 Byte Commando zur MMC/SD-Karte
{
mmc_write_byte(*cmd++);
}
}
//send 6th command byte / CRC
mmc_write_byte(0xFF);
//Wartet auf ein gültige Antwort von der MMC/SD-Karte
while (tmp == 0xff)
{
{
tmp = mmc_read_byte();
if (Timeout++ > 500)
{
{
break; //Abbruch da die MMC/SD-Karte nicht Antwortet
}
}
}
return(tmp);
}
@ -157,21 +159,23 @@ unsigned char mmc_write_command_slow(unsigned char *cmd)
//set MMC_Chip_Select to low (MMC/SD-Karte Aktiv)
MMC_Enable();
//sendet 6 Byte Commando
for (unsigned char a = 0;a<0x06;a++) //sendet 6 Byte Commando zur MMC/SD-Karte
{
//sendet 5 Byte Commando
for (unsigned char a = 0; a < 5; a++) //sendet 6 Byte Commando zur MMC/SD-Karte
{
mmc_write_byte_slow(*cmd++);
}
}
//send 6th command byte / CRC
mmc_write_byte_slow(0xFF);
//Wartet auf ein gültige Antwort von der MMC/SD-Karte
while (tmp == 0xff)
{
{
tmp = mmc_read_byte_slow();
if (Timeout++ > 500)
{
{
break; //Abbruch da die MMC/SD-Karte nicht Antwortet
}
}
}
return(tmp);
}
@ -299,8 +303,9 @@ unsigned char mmc_write_sector (unsigned long addr,unsigned char *Buffer)
{
unsigned char tmp;
//Commando 24 zum schreiben eines Blocks auf die MMC/SD - Karte
unsigned char cmd[] = {0x58,0x00,0x00,0x00,0x00,0xFF};
unsigned char cmd[5];// = {0x58,0x00,0x00,0x00,0x00,0xFF};
cmd[0] = 0x58;
cmd[4] = 0;
/*Die Adressierung der MMC/SD-Karte wird in Bytes angegeben,
addr wird von Blocks zu Bytes umgerechnet danach werden
diese in das Commando eingefügt*/
@ -357,9 +362,9 @@ void mmc_read_block(unsigned char *cmd,unsigned char *Buffer,unsigned int Bytes)
{
//Sendet Commando cmd an MMC/SD-Karte
if (mmc_write_command (cmd) != 0)
{
return;
}
{
return;
}
//Wartet auf Start Byte von der MMC/SD-Karte (FEh/Start Byte)
@ -386,7 +391,9 @@ unsigned char mmc_read_sector (unsigned long addr,unsigned char *Buffer)
//############################################################################
{
//Commando 16 zum lesen eines Blocks von der MMC/SD - Karte
unsigned char cmd[] = {0x51,0x00,0x00,0x00,0x00,0xFF};
unsigned char cmd[5];// = {0x51,0x00,0x00,0x00,0x00,0xFF};
cmd[0] = 0x51;
cmd[4] = 0;
/*Die Adressierung der MMC/SD-Karte wird in Bytes angegeben,
addr wird von Blocks zu Bytes umgerechnet danach werden
@ -440,7 +447,9 @@ uint8_t mmc_read_part(unsigned long addr,unsigned char *Buffer, uint16_t count)
//############################################################################
{
//Commando 16 zum lesen eines Blocks von der MMC/SD - Karte
unsigned char cmd[] = {0x51,0x00,0x00,0x00,0x00,0xFF};
unsigned char cmd[5];// = {0x51,0x00,0x00,0x00,0x00,0xFF};
cmd[0] = 0x51;
cmd[4] = 0;
/*Die Adressierung der MMC/SD-Karte wird in Bytes angegeben,
addr wird von Blocks zu Bytes umgerechnet danach werden
@ -493,7 +502,9 @@ void mmc_read_to_ringbuffer(unsigned long addr, ringbuf_t *buffer)
//############################################################################
{
//Commando 16 zum lesen eines Blocks von der MMC/SD - Karte
unsigned char cmd[] = {0x51,0x00,0x00,0x00,0x00,0xFF};
unsigned char cmd[5];// = {0x51,0x00,0x00,0x00,0x00,0xFF};
cmd[0] = 0x51;
cmd[4] = 0;
/*Die Adressierung der MMC/SD-Karte wird in Bytes angegeben,
addr wird von Blocks zu Bytes umgerechnet danach werden
@ -514,7 +525,12 @@ unsigned char mmc_read_cid (unsigned char *Buffer)
//############################################################################
{
//Commando zum lesen des CID Registers
unsigned char cmd[] = {0x4A,0x00,0x00,0x00,0x00,0xFF};
unsigned char cmd[5];// = {0x4A,0x00,0x00,0x00,0x00,0xFF};
cmd[0] = 0x4a;
cmd[1] = 0;
cmd[2] = 0;
cmd[3] = 0;
cmd[4] = 0;
mmc_read_block(cmd,Buffer,16);
@ -527,7 +543,12 @@ unsigned char mmc_read_csd (unsigned char *Buffer)
//############################################################################
{
//Commando zum lesen des CSD Registers
unsigned char cmd[] = {0x49,0x00,0x00,0x00,0x00,0xFF};
unsigned char cmd[5];// = {0x49,0x00,0x00,0x00,0x00,0xFF};
cmd[0] = 0x49;
cmd[1] = 0;
cmd[2] = 0;
cmd[3] = 0;
cmd[4] = 0;
mmc_read_block(cmd,Buffer,16);

Loading…
Cancel
Save