forked from M-Labs/zynq-rs
1
0
Fork 0

Modified SDIO to handle u8 buffer instead of u32.

This commit is contained in:
pca006132 2020-06-09 17:03:17 +08:00
parent 40d5eb8232
commit 0ebc4a61c8
3 changed files with 11 additions and 11 deletions

View File

@ -91,17 +91,17 @@ pub fn main_core0() {
Ok(_) => info!("OK!"), Ok(_) => info!("OK!"),
Err(a) => info!("{:?}", a), Err(a) => info!("{:?}", a),
}; };
const SIZE: usize = 512 / 2; const SIZE: usize = 512 * 2 + 1;
let mut sd_card = result.unwrap(); let mut sd_card = result.unwrap();
let mut buffer: [u32; SIZE] = [0; SIZE]; let mut buffer: [u8; SIZE] = [0; SIZE];
for i in 0..buffer.len() { for i in 0..buffer.len() {
buffer[i] = (i % 16) as u32; buffer[i] = (i % 16) as u8;
} }
sd_card.write_block(0x0, 2, &mut buffer).unwrap(); sd_card.write_block(0x0, 2, &mut buffer).unwrap();
for i in 0..buffer.len() { for i in 0..buffer.len() {
buffer[i] = 0; buffer[i] = 0;
} }
sd_card.read_block(0x1, 2, &mut buffer).unwrap(); sd_card.read_block(0x1, 2, &mut buffer[1..]).unwrap();
for i in 0..buffer.len() { for i in 0..buffer.len() {
info!("buffer[{}] = {}", i, buffer[i]); info!("buffer[{}] = {}", i, buffer[i]);
} }

View File

@ -62,7 +62,7 @@ impl Adma2Desc32 {
} }
} }
pub fn setup_adma2_descr32(sdio: &mut SDIO, blk_cnt: u32, buffer: &mut [u32]) { pub fn setup_adma2_descr32(sdio: &mut SDIO, blk_cnt: u32, buffer: &mut [u8]) {
let descr_table = unsafe { &mut ADMA2_DESCR32_TABLE }; let descr_table = unsafe { &mut ADMA2_DESCR32_TABLE };
let blk_size = sdio let blk_size = sdio
.regs .regs

View File

@ -143,7 +143,7 @@ impl SdCard {
self.sdio.cmd_transfer(CMD55, self.rel_card_addr, 0)?; self.sdio.cmd_transfer(CMD55, self.rel_card_addr, 0)?;
self.sdio.cmd_transfer(ACMD42, 0, 0)?; self.sdio.cmd_transfer(ACMD42, 0, 0)?;
let mut scr: [u32; 8] = [0; 8]; let mut scr: [u8; 32] = [0; 32];
self.get_bus_width(&mut scr)?; self.get_bus_width(&mut scr)?;
debug!("{:?}", scr); debug!("{:?}", scr);
if scr[1] & 0x4 != 0 { if scr[1] & 0x4 != 0 {
@ -188,9 +188,9 @@ impl SdCard {
&mut self, &mut self,
address: u32, address: u32,
block_cnt: u16, block_cnt: u16,
buffer: &mut [u32], buffer: &mut [u8],
) -> Result<(), CmdTransferError> { ) -> Result<(), CmdTransferError> {
assert!(buffer.len() >= (block_cnt as usize) * (512 / 4)); assert!(buffer.len() >= (block_cnt as usize) * 512);
// set block size if not set already // set block size if not set already
if self if self
.sdio .sdio
@ -241,9 +241,9 @@ impl SdCard {
&mut self, &mut self,
address: u32, address: u32,
block_cnt: u16, block_cnt: u16,
buffer: &mut [u32], buffer: &mut [u8],
) -> Result<(), CmdTransferError> { ) -> Result<(), CmdTransferError> {
assert!(buffer.len() >= (block_cnt as usize) * (512 / 4)); assert!(buffer.len() >= (block_cnt as usize) * 512);
// set block size if not set already // set block size if not set already
if self if self
.sdio .sdio
@ -287,7 +287,7 @@ impl SdCard {
Ok(()) Ok(())
} }
fn get_bus_width(&mut self, buf: &mut [u32]) -> Result<(), CmdTransferError> { fn get_bus_width(&mut self, buf: &mut [u8]) -> Result<(), CmdTransferError> {
use cmd::SdCmd::*; use cmd::SdCmd::*;
debug!("Getting bus width"); debug!("Getting bus width");
for i in 0..8 { for i in 0..8 {