Advertisement
Guest User

stm8 read from sd to ring buffer

a guest
Oct 23rd, 2012
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. uint8_t sd_multiread_next(void)
  2. {
  3.     extern uint8_t dac_buf[dac_buf_size];
  4.     extern uint32_t sd_addr;
  5.  
  6.     uint32_t tmr=0;
  7.     uint8_t res=res_ERROR,rc=0;
  8.    
  9.   tmr = 30000;
  10.   do {              //Wait for data packet in timeout of 100ms
  11.     rc = sd_txrx_byte(SD_DUMMY_BYTE);
  12.   } while (rc == 0xFF && --tmr);
  13.   if (rc == 0xFE) {
  14.     for (tmr = 0; tmr < SD_BLOCK_SIZE; tmr++) {
  15.         //push data to ring buffer
  16.         //
  17.         dac_buf[tmr]=sd_txrx_byte(SD_DUMMY_BYTE);
  18.         }
  19.  
  20.     sd_txrx_byte(SD_DUMMY_BYTE);//get 2 bytes of crc into /dev/null
  21.     sd_txrx_byte(SD_DUMMY_BYTE);
  22.   res = res_OK;
  23.   }
  24. if (res==res_OK)
  25.     if (!(CardType & CT_BLOCK)) sd_addr+=SD_BLOCK_SIZE;
  26.     else sd_addr++;
  27. return res;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement