embedded_hal_sdmmc/
lib.rs1#![cfg_attr(not(feature = "std"), no_std)]
4
5mod bus_width;
6mod card_mode;
7mod card_type;
8mod fifo_status;
9mod reset;
10
11pub mod command;
12pub mod response;
13pub mod tuning;
14
15pub use bus_width::{MmcBusWidth, SdBusWidth};
16pub use card_mode::CardMode;
17pub use card_type::CardType;
18pub use fifo_status::FifoStatus;
19pub use reset::Reset;
20
21use command::Command;
22use response::Response;
23use tuning::{TuningMode, TuningWidth};
24
25pub trait Common {
27 type Error;
29
30 fn card_type(&self) -> CardType;
32
33 fn card_mode(&self) -> CardMode;
35
36 fn setup_bus(&mut self) -> Result<(), Self::Error>;
38
39 fn init(&mut self) -> Result<(), Self::Error>;
41
42 fn wait_for_reset(&mut self, reset: Reset, timeout: u64) -> Result<(), Self::Error>;
44
45 fn wait_while_busy(&mut self, timout_us: u64) -> Result<(), Self::Error>;
47
48 fn read_data(&mut self, data: &mut [u8]) -> Result<(), Self::Error>;
50
51 fn write_data(&mut self, data: &[u8]) -> Result<(), Self::Error>;
53
54 fn set_sample_phase(&mut self, sample_phase: u8);
56
57 fn fifo_ready(&self, fifo_status: FifoStatus) -> Result<(), Self::Error>;
59
60 fn send_tuning(&mut self, mode: TuningMode, width: TuningWidth) -> Result<(), Self::Error>;
70
71 fn interrupt(&self) -> u32;
73
74 fn set_interrupt(&mut self, int: u32);
76
77 fn clear_all_interrupt(&mut self);
79
80 fn response_interrupt(&self) -> u32;
82
83 fn set_response_interrupt(&mut self, int: u32);
85
86 fn clear_all_response_interrupt(&mut self);
88}
89
90pub trait Host: Common {
92 fn write_command<C: Command>(&mut self, cmd: &C) -> Result<(), Self::Error>;
94
95 fn read_response<C: Command, R: Response>(&mut self, cmd: &C) -> Result<R, Self::Error>;
101}
102
103pub trait Device: Common {
105 fn read_command<C: Command>(&mut self) -> Result<C, Self::Error>;
107
108 fn write_response<R: Response>(&mut self, response: &R) -> Result<(), Self::Error>;
110}