Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Mine
Monday, November 13th, 2006 at 6:55:10pm UTC 

  1. void sd_select_bank(unsigned char bank)
  2. {
  3.     unsigned int response;
  4.     unsigned char card_data[512];
  5.     unsigned char* write_buf;
  6.     int i;
  7.     tSDCardInfo *card = &card_info[0]; /* Bank selection will only be done on
  8.                                         the onboard flash */
  9.     lcd_puts(0,11,"test0");
  10.     lcd_update();
  11.     if (current_bank != bank)
  12.     {
  13.         memset(card_data, 0, 512);
  14.         response = 0;
  15.         while(((response >> 9) & 0xf) != TRAN)
  16.         {
  17.             sd_send_command(SEND_STATUS, (card->rca) << 16, 1);
  18.             sd_read_response(&response, 1);
  19.         }
  20.     lcd_puts(0,11,"test1");
  21.     lcd_update();
  22.         SD_STATE_REG = TRAN;
  23.     lcd_puts(0,11,"test2");
  24.     lcd_update();
  25.         BLOCK_SIZE_REG = 512;
  26.     lcd_puts(0,11,"test3");
  27.     lcd_update();
  28.         BLOCK_COUNT_REG = 1;
  29.     lcd_puts(0,11,"test4");
  30.     lcd_update();
  31.         sd_send_command(35, 0, 0x1c0d); /* CMD35 is vendor specific */
  32.     lcd_puts(0,11,"test5");
  33.     lcd_update();
  34.         sd_read_response(&response, 1);
  35.     lcd_puts(0,11,"test6");
  36.     lcd_update();
  37.         SD_STATE_REG = PRG;
  38.     lcd_puts(0,11,"test7");
  39.     lcd_update();
  40.  
  41.         card_data[0] = bank;
  42.  
  43.     lcd_puts(0,11,"test8");
  44.     lcd_update();
  45.         /* Write the card data */
  46.         write_buf = card_data;
  47.         for (i = 0; i < BLOCK_SIZE / 2; i += FIFO_SIZE)
  48.         {
  49.             /* Wait for the FIFO to be empty */
  50.             while((STATUS_REG & FIFO_EMPTY) == 0) {} /* Erm... is this right? */
  51.  
  52.  
  53.             copy_write_sectors(write_buf, FIFO_SIZE);
  54.  
  55.             write_buf += FIFO_SIZE*2; /* Advance one chunk of 16 words */
  56.             udelay(50); /* Don't flood the FIFO.  This can go when we know how
  57.                         to check if the FIFO is empty */
  58.  
  59.         }
  60.  
  61.         while((STATUS_REG & DATA_DONE) == 0) {}
  62.         current_bank = bank;
  63.     }
  64. }

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right