Struct capsules::sdcard::SDCard
[−]
[src]
pub struct SDCard<'a, A: Alarm + 'a> { spi: &'a SpiMasterDevice, state: Cell<SpiState>, after_state: Cell<SpiState>, alarm: &'a A, alarm_state: Cell<AlarmState>, alarm_count: Cell<u8>, is_initialized: Cell<bool>, card_type: Cell<SDCardType>, detect_pin: Cell<Option<&'static Pin>>, txbuffer: TakeCell<'static, [u8]>, rxbuffer: TakeCell<'static, [u8]>, client: Cell<Option<&'static SDCardClient>>, client_buffer: TakeCell<'static, [u8]>, client_offset: Cell<usize>, }
SD Card capsule, capable of being built on top of by other kernel capsules
Fields
spi: &'a SpiMasterDevice
state: Cell<SpiState>
after_state: Cell<SpiState>
alarm: &'a A
alarm_state: Cell<AlarmState>
alarm_count: Cell<u8>
is_initialized: Cell<bool>
card_type: Cell<SDCardType>
detect_pin: Cell<Option<&'static Pin>>
txbuffer: TakeCell<'static, [u8]>
rxbuffer: TakeCell<'static, [u8]>
client: Cell<Option<&'static SDCardClient>>
client_buffer: TakeCell<'static, [u8]>
client_offset: Cell<usize>
Methods
impl<'a, A: Alarm + 'a> SDCard<'a, A>
[src]
Functions for initializing and accessing an SD card
pub fn new(
spi: &'a SpiMasterDevice,
alarm: &'a A,
detect_pin: Option<&'static Pin>,
txbuffer: &'static mut [u8; 515],
rxbuffer: &'static mut [u8; 515]
) -> SDCard<'a, A>
[src]
spi: &'a SpiMasterDevice,
alarm: &'a A,
detect_pin: Option<&'static Pin>,
txbuffer: &'static mut [u8; 515],
rxbuffer: &'static mut [u8; 515]
) -> SDCard<'a, A>
Create a new SD card interface
spi - virtualized SPI to use for communication with SD card alarm - virtualized Timer with a granularity of at least 1 ms detect_pin - active low GPIO pin used to detect if an SD card is installed txbuffer - buffer for holding SPI write data, at least 515 bytes in length rxbuffer - buffer for holding SPI read data, at least 515 bytes in length
fn set_spi_slow_mode(&self)
[src]
fn set_spi_fast_mode(&self)
[src]
fn send_command(
&self,
cmd: SDCmd,
arg: u32,
write_buffer: &'static mut [u8],
read_buffer: &'static mut [u8],
recv_len: usize
)
[src]
&self,
cmd: SDCmd,
arg: u32,
write_buffer: &'static mut [u8],
read_buffer: &'static mut [u8],
recv_len: usize
)
send a command over SPI and collect the response Handles encoding of command, checksum, and padding bytes. The response still needs to be parsed out of the read_buffer when complete
fn read_bytes(
&self,
write_buffer: &'static mut [u8],
read_buffer: &'static mut [u8],
recv_len: usize
)
[src]
&self,
write_buffer: &'static mut [u8],
read_buffer: &'static mut [u8],
recv_len: usize
)
wrapper for easy reading of bytes over SPI
fn write_bytes(
&self,
write_buffer: &'static mut [u8],
read_buffer: &'static mut [u8],
recv_len: usize
)
[src]
&self,
write_buffer: &'static mut [u8],
read_buffer: &'static mut [u8],
recv_len: usize
)
wrapper for easy writing of bytes over SPI
fn get_response(
&self,
response: SDResponse,
read_buffer: &[u8]
) -> (u8, u8, u32)
[src]
&self,
response: SDResponse,
read_buffer: &[u8]
) -> (u8, u8, u32)
parse response bytes from SPI read buffer Unfortunately there is a variable amount of delay in SD card responses, so these bytes must be searched for
fn process_spi_states(
&self,
write_buffer: &'static mut [u8],
read_buffer: &'static mut [u8],
_: usize
)
[src]
&self,
write_buffer: &'static mut [u8],
read_buffer: &'static mut [u8],
_: usize
)
updates SD card state on SPI transaction returns
fn process_alarm_states(&self)
[src]
updates SD card state upon timer alarm fired
pub fn set_client<C: SDCardClient>(&self, client: &'static C)
[src]
pub fn is_installed(&self) -> bool
[src]
pub fn is_initialized(&self) -> bool
[src]
pub fn detect_changes(&self)
[src]
watches SD card detect pin for changes, sends callback on change
pub fn initialize(&self) -> ReturnCode
[src]
pub fn read_blocks(
&self,
buffer: &'static mut [u8],
sector: u32,
count: u32
) -> ReturnCode
[src]
&self,
buffer: &'static mut [u8],
sector: u32,
count: u32
) -> ReturnCode
pub fn write_blocks(
&self,
buffer: &'static mut [u8],
sector: u32,
count: u32
) -> ReturnCode
[src]
&self,
buffer: &'static mut [u8],
sector: u32,
count: u32
) -> ReturnCode
Trait Implementations
impl<'a, A: Alarm + 'a> SpiMasterClient for SDCard<'a, A>
[src]
Handle callbacks from the SPI peripheral
fn read_write_done(
&self,
write_buffer: &'static mut [u8],
read_buffer: Option<&'static mut [u8]>,
len: usize
)
[src]
&self,
write_buffer: &'static mut [u8],
read_buffer: Option<&'static mut [u8]>,
len: usize
)
Called when a read/write operation finishes
impl<'a, A: Alarm + 'a> Client for SDCard<'a, A>
[src]
Handle callbacks from the timer
fn fired(&self)
[src]
Callback signaled when the alarm's clock reaches the value set in Alarm#set_alarm
. Read more
impl<'a, A: Alarm + 'a> Client for SDCard<'a, A>
[src]
Handle callbacks from the card detection pin