rendered paste bodyvoid sd_select_bank(unsigned char bank)
{
unsigned int response;
unsigned char card_data[512];
unsigned char* write_buf;
int i;
tSDCardInfo *card = &card_info[0]; /* Bank selection will only be done on
the onboard flash */
lcd_puts(0,11,"test0");
lcd_update();
if (current_bank != bank)
{
memset(card_data, 0, 512);
response = 0;
while(((response >> 9) & 0xf) != TRAN)
{
sd_send_command(SEND_STATUS, (card->rca) << 16, 1);
sd_read_response(&response, 1);
}
lcd_puts(0,11,"test1");
lcd_update();
SD_STATE_REG = TRAN;
lcd_puts(0,11,"test2");
lcd_update();
BLOCK_SIZE_REG = 512;
lcd_puts(0,11,"test3");
lcd_update();
BLOCK_COUNT_REG = 1;
lcd_puts(0,11,"test4");
lcd_update();
sd_send_command(35, 0, 0x1c0d); /* CMD35 is vendor specific */
lcd_puts(0,11,"test5");
lcd_update();
sd_read_response(&response, 1);
lcd_puts(0,11,"test6");
lcd_update();
SD_STATE_REG = PRG;
lcd_puts(0,11,"test7");
lcd_update();
card_data[0] = bank;
lcd_puts(0,11,"test8");
lcd_update();
/* Write the card data */
write_buf = card_data;
for (i = 0; i < BLOCK_SIZE / 2; i += FIFO_SIZE)
{
/* Wait for the FIFO to be empty */
while((STATUS_REG & FIFO_EMPTY) == 0) {} /* Erm... is this right? */
copy_write_sectors(write_buf, FIFO_SIZE);
write_buf += FIFO_SIZE*2; /* Advance one chunk of 16 words */
udelay(50); /* Don't flood the FIFO. This can go when we know how
to check if the FIFO is empty */
}
while((STATUS_REG & DATA_DONE) == 0) {}
current_bank = bank;
}
}