Skip to content

Commit a7c2f09

Browse files
Report media_present based on card presence.
1 parent b1f4db9 commit a7c2f09

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/main.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1841,6 +1841,20 @@ extern "C" fn bus_interrupt_status() -> u32 {
18411841
pub extern "C" fn block_dev_get_info(device: u8) -> common::Option<common::block_dev::DeviceInfo> {
18421842
match device {
18431843
0 => {
1844+
let mut lock = HARDWARE.lock();
1845+
let hw = lock.as_mut().unwrap();
1846+
1847+
let media_present = match hw.card_state {
1848+
CardState::Unplugged => false,
1849+
CardState::Errored => false,
1850+
CardState::Uninitialised => {
1851+
// Init the card here
1852+
true
1853+
}
1854+
CardState::Online => true,
1855+
};
1856+
1857+
// This is our on-board card slot
18441858
common::Option::Some(common::block_dev::DeviceInfo {
18451859
// This is the built-in SD card slot
18461860
name: common::types::ApiString::new("SdCard0"),
@@ -1854,7 +1868,7 @@ pub extern "C" fn block_dev_get_info(device: u8) -> common::Option<common::block
18541868
// But you can take the card out
18551869
removable: true,
18561870
// Pretend the card is out
1857-
media_present: true,
1871+
media_present,
18581872
// Don't care about this value when card is out
18591873
read_only: false,
18601874
})

0 commit comments

Comments
 (0)