File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ //! SD card mock module.
2+
3+ /// SD card mock states.
4+ pub enum State {
5+ /// Idle state.
6+ Idle ,
7+ /// Ready state.
8+ Ready ,
9+ /// Identification state.
10+ Ident = 2 ,
11+ /// Standby state.
12+ Stby = 3 ,
13+ /// Transfer state.
14+ Tran = 4 ,
15+ /// Data state.
16+ Data = 5 ,
17+ /// Receive state.
18+ Rcv = 6 ,
19+ /// Programming state.
20+ Prg = 7 ,
21+ /// Disconnected state.
22+ Dis = 8 ,
23+ }
24+
25+ /// SD card mock.
26+ pub struct SdCardMock {
27+ state : State ,
28+ }
29+
30+ impl SdCardMock {
31+ /// Create a new SD card mock in the idle state.
32+ pub fn new ( ) -> Self {
33+ Self { state : State :: Idle }
34+ }
35+
36+ /// Insert a command into the SD card.
37+ pub fn insert_command ( & mut self , cmd_id : super :: CmdId , argument : u32 ) {
38+ match cmd_id {
39+ super :: CmdId :: CMD0_GoIdleState => self . state = State :: Idle ,
40+ _ => ( ) ,
41+ }
42+ }
43+ }
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ pub mod cid;
3434pub mod csd;
3535pub mod response;
3636pub mod spi;
37+ pub mod mock;
3738
3839/// The different types of card we support.
3940#[ cfg_attr( feature = "defmt-log" , derive( defmt:: Format ) ) ]
You can’t perform that action at this time.
0 commit comments