Код
....
char Command(unsigned char befF, unsigned int AdrH, unsigned int AdrL, unsigned char befH ){ // sends a command to the MMC
SPI(0xFF);
SPI(befF);
SPI((unsigned char)(AdrH >> 8));
SPI((unsigned char)AdrH);
SPI((unsigned char)(AdrL >> 8));
SPI((unsigned char)AdrL);
SPI(befH);
SPI(0xFF);
return SPI(0xFF); // return the last received character
}
int MMC_Init(void) { // init SPI
unsigned char i;
PORTB.4=1; // disable MMC
// start MMC in SPI mode
for(i=0; i < 10; i++) SPI(0xFF); // send 10*8=80 clock pulses
PORTB.4=0; // enable MMC
if (Command(0x40,0,0,0x95) !=1) goto mmcerror; // reset MMC
st: // if there is no MMC, prg. loops here
if (Command(0x41,0,0,0xFF) !=0) goto st;
return 1;
mmcerror:
return 0;
}
.....
int sendmmc(void) { // send 512 bytes from the MMC via the serial port
unsigned int i;
usart_tx_text("MMC read \r\n");
// 512 byte-read-mode
if (Command(0x51,0,512,0xFF)!= 0){usart_tx_text("MMC: read error 1 \r\n"); return 1; }
// wait for 0xFE - start of any transmission
// ATT: typecast (char)0xFE is a must!
while(SPI(0xFF)!=(char)0xFE);
for(i=0; i < 512; i++) {
while(!(UCSRA & (1 << 5))); // wait for serial port
UDR = SPI(0xFF); // send character
}
usart_tx_text("\r\n");
// at the end, send 2 dummy bytes
SPI(0xFF); // actually this returns the CRC/checksum byte
SPI(0xFF);
return 0;
}
......
Да ну переписывать весь код, вот мой подскажите плиз что надо изменить.