Advertisement
sniper_nuko

SPI_Flash_Read_Data

Nov 4th, 2020
1,944
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. // フラッシュメモリからデータ読み出し
  2. static void spi_flash_read_data(uint32_t f_addr, void* sf_buf, int32_t e_count)
  3. {
  4.     int32_t  count;
  5.     uint8_t* r_buf = (uint8_t*)sf_buf;
  6.    
  7.     if(e_count <= 0)
  8.         return;
  9.    
  10.     // SPI通信開始
  11.     spi_flash_comm_start();
  12.  
  13.     // コマンド送信
  14.     spi_flash_transfer(FCMD_RD_BYTE);
  15.    
  16.     // メモリアドレス送信
  17.     spi_flash_transfer(f_addr >> 16);
  18.     spi_flash_transfer(f_addr >> 8);
  19.     spi_flash_transfer(f_addr);
  20.    
  21.     // 読み出し
  22.     for(count = 0; count < e_count; count++)
  23.     {
  24.         r_buf[count] = spi_flash_transfer(0);
  25.     }
  26.  
  27.     // SPI通信終了
  28.     spi_flash_comm_end();
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement