Small Fix && cargo fmt
This commit is contained in:
parent
c9583b0f53
commit
ae3ba9c26f
83 changed files with 1085 additions and 1079 deletions
|
@ -2,21 +2,21 @@
|
|||
#![allow(non_camel_case_types)]
|
||||
#![allow(unused)]
|
||||
|
||||
use k210_pac::{Peripherals, SPI0};
|
||||
use super::BlockDevice;
|
||||
use crate::sync::UPSafeCell;
|
||||
use core::convert::TryInto;
|
||||
use k210_hal::prelude::*;
|
||||
use k210_pac::{Peripherals, SPI0};
|
||||
use k210_soc::{
|
||||
fpioa::{self, io},
|
||||
//dmac::{dma_channel, DMAC, DMACExt},
|
||||
gpio,
|
||||
gpiohs,
|
||||
spi::{aitm, frame_format, tmod, work_mode, SPI, SPIExt, SPIImpl},
|
||||
fpioa::{self, io},
|
||||
sysctl,
|
||||
sleep::usleep,
|
||||
spi::{aitm, frame_format, tmod, work_mode, SPIExt, SPIImpl, SPI},
|
||||
sysctl,
|
||||
};
|
||||
use crate::sync::UPSafeCell;
|
||||
use lazy_static::*;
|
||||
use super::BlockDevice;
|
||||
use core::convert::TryInto;
|
||||
|
||||
pub struct SDCard<SPI> {
|
||||
spi: SPI,
|
||||
|
@ -160,7 +160,11 @@ pub struct SDCardInfo {
|
|||
}
|
||||
|
||||
impl</*'a,*/ X: SPI> SDCard</*'a,*/ X> {
|
||||
pub fn new(spi: X, spi_cs: u32, cs_gpionum: u8/*, dmac: &'a DMAC, channel: dma_channel*/) -> Self {
|
||||
pub fn new(
|
||||
spi: X,
|
||||
spi_cs: u32,
|
||||
cs_gpionum: u8, /*, dmac: &'a DMAC, channel: dma_channel*/
|
||||
) -> Self {
|
||||
Self {
|
||||
spi,
|
||||
spi_cs,
|
||||
|
@ -606,7 +610,7 @@ impl</*'a,*/ X: SPI> SDCard</*'a,*/ X> {
|
|||
}
|
||||
let mut error = false;
|
||||
//let mut dma_chunk = [0u32; SEC_LEN];
|
||||
let mut tmp_chunk= [0u8; SEC_LEN];
|
||||
let mut tmp_chunk = [0u8; SEC_LEN];
|
||||
for chunk in data_buf.chunks_mut(SEC_LEN) {
|
||||
if self.get_response() != SD_START_DATA_SINGLE_BLOCK_READ {
|
||||
error = true;
|
||||
|
@ -616,7 +620,7 @@ impl</*'a,*/ X: SPI> SDCard</*'a,*/ X> {
|
|||
//self.read_data_dma(&mut dma_chunk);
|
||||
self.read_data(&mut tmp_chunk);
|
||||
/* Place the data received as u32 units from DMA into the u8 target buffer */
|
||||
for (a, b) in chunk.iter_mut().zip(/*dma_chunk*/tmp_chunk.iter()) {
|
||||
for (a, b) in chunk.iter_mut().zip(/*dma_chunk*/ tmp_chunk.iter()) {
|
||||
//*a = (b & 0xff) as u8;
|
||||
*a = *b;
|
||||
}
|
||||
|
@ -675,7 +679,7 @@ impl</*'a,*/ X: SPI> SDCard</*'a,*/ X> {
|
|||
/* Send the data token to signify the start of the data */
|
||||
self.write_data(&frame);
|
||||
/* Write the block data to SD : write count data by block */
|
||||
for (a, &b) in /*dma_chunk*/tmp_chunk.iter_mut().zip(chunk.iter()) {
|
||||
for (a, &b) in /*dma_chunk*/ tmp_chunk.iter_mut().zip(chunk.iter()) {
|
||||
//*a = b.into();
|
||||
*a = b;
|
||||
}
|
||||
|
@ -711,9 +715,8 @@ fn io_init() {
|
|||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref PERIPHERALS: UPSafeCell<Peripherals> = unsafe {
|
||||
UPSafeCell::new(Peripherals::take().unwrap())
|
||||
};
|
||||
static ref PERIPHERALS: UPSafeCell<Peripherals> =
|
||||
unsafe { UPSafeCell::new(Peripherals::take().unwrap()) };
|
||||
}
|
||||
|
||||
fn init_sdcard() -> SDCard<SPIImpl<SPI0>> {
|
||||
|
@ -747,9 +750,15 @@ impl SDCardWrapper {
|
|||
|
||||
impl BlockDevice for SDCardWrapper {
|
||||
fn read_block(&self, block_id: usize, buf: &mut [u8]) {
|
||||
self.0.exclusive_access().read_sector(buf,block_id as u32).unwrap();
|
||||
self.0
|
||||
.exclusive_access()
|
||||
.read_sector(buf, block_id as u32)
|
||||
.unwrap();
|
||||
}
|
||||
fn write_block(&self, block_id: usize, buf: &[u8]) {
|
||||
self.0.exclusive_access().write_sector(buf,block_id as u32).unwrap();
|
||||
self.0
|
||||
.exclusive_access()
|
||||
.write_sector(buf, block_id as u32)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue