Comments (9)
You usually can't do card init at full speed - you have to drop to 400 kHz to do the init, and once the card has responded, then you can go back to full speed.
from embedded-sdmmc-rs.
Good job , thank you. scard is work.
from embedded-sdmmc-rs.
Yes, you can. the esp32 hal crates all implement embedded_hal
traits which are compatible with embedded_sdmmc
:
https://github.com/esp-rs/esp-hal/blob/main/esp-hal-common/src/spi.rs
from embedded-sdmmc-rs.
Alright, thanks for confirming
from embedded-sdmmc-rs.
Has any code snippets for me to learn?
I used embedded_svc, embedded_hal, esp_idf_svc, esp_idf_hal, but I don't know how to get the parameters sdmmc_spi, sdmmc_cs, delay.
I hope to provide me with a link to take a look at the ESP code that uses this crate. Thank you for your help
let spi = esp_idf_hal::spi::Spi::device();
let sc = esp_idf_hal::spi::SpiConfig::default();
let sdcard = embedded_sdmmc::SdCard::new(sdmmc_spi, sdmmc_cs, delay);
from embedded-sdmmc-rs.
let mut spi_d_config = esp_idf_hal::spi::config::DriverConfig::default();
let spi_d = esp_idf_hal::spi::SpiDriver::new(
peripherals.spi3,
peripherals.pins.gpio18, // sclk
peripherals.pins.gpio23, // sdo
None::<Gpio0>, // sdi
&spi_d_config,
)
.expect("panic spi_d");
let mut spi_dd_config = esp_idf_hal::spi::SpiConfig {
baudrate: esp_idf_hal::units::Hertz(1000 * 1000),
..Default::default()
};
let sd_spi_dd = esp_idf_hal::spi::SpiDeviceDriver::new(
&spi_d,
Some(peripherals.pins.gpio4),
&spi_dd_config,
)?;
let sdcard = SdCard::new(
sd_spi_dd,
PinDriver::output(peripherals.pins.gpio19)?,
SdDelayer,
);
info!("sdcard init : {:?}", sdcard.get_card_type());
info!("sdcard init : {:?}", sdcard.num_bytes());
let mut volume_mgr = embedded_sdmmc::VolumeManager::new(sdcard, FakeTimesource {});
but ....
W (4729) embedded_sdmmc::sdcard: Got response: 0, trying again..
W (4739) embedded_sdmmc::sdcard: Got response: 0, trying again..
W (4739) embedded_sdmmc::sdcard: Got response: 0, trying again..
W (4749) embedded_sdmmc::sdcard: Got response: 0, trying again..
W (4759) embedded_sdmmc::sdcard: Got response: 0, trying again..
W
from embedded-sdmmc-rs.
I don't know how ESP-IDF works, but the pin you give to the SdCard
constructor should be DAT3/CD - so GPIO4 according to your picture. Not giving a pin for SDI in the SPI constructor also seems odd.
In any case, we can't give MCU specific instructions here otherwise we'd be spending forever looking at different MCUs. Maybe the ESP-RS team and put together an example, like the RP-RS team did for the Raspberry Pi Pico.
from embedded-sdmmc-rs.
I have any micro python is run ok.
class SDCard:
def __init__(self, spi=SoftSPI(sck=Pin(18), mosi=Pin(23), miso=Pin(19)), cs=Pin(4), debug=False):
"""
get ready to read/write, the default Pins are set up for M5Stack Core2 hardware
"""
self.spi = spi
self.cs = cs
self.cs.init(self.cs.OUT, value=0)
self.debug = debug
if self.debug:
print("{}{} {}, cs={} state={}".format(SDCard, SDCard.__init__, self.spi, self.cs, self.cs.value()))
self.sectors = None
self.cdv = None
self.init_card()
class SDCardTest:
""" run large and small files read/write and delete tests """
def __init__(self, mdir='/sd', debug=False):
self.mdir = mdir
self.debug = debug
self.run()
def run(self):
sdc = SDCard(debug=self.debug)
vfs = os.VfsFat(sdc)
os.mount(vfs, self.mdir)
from embedded-sdmmc-rs.
i am tried this, but not run ok
fn main(){
let mut spi_d_config = esp_idf_hal::spi::config::DriverConfig::default();
let spi_d = esp_idf_hal::spi::SpiDriver::new(
peripherals.spi2,
peripherals.pins.gpio18, // sclk
peripherals.pins.gpio23, // sdo
Some(peripherals.pins.gpio19), // sdi
&spi_d_config,
)
.expect("panic spi_d");
let mut spi_dd_config = esp_idf_hal::spi::SpiConfig::default();
spi_dd_config.baudrate = Hertz(24_000_000);
spi_dd_config.duplex = Duplex::Full;
let sd_spi_dd = esp_idf_hal::spi::SpiDeviceDriver::new(&spi_d, None::<Gpio0>, &spi_dd_config)?;
let sdcard = SdCard::new(
sd_spi_dd,
PinDriver::output(peripherals.pins.gpio4)?,
SdDelayer,
);
info!("sdcard init : {:?}", sdcard.get_card_type());
let mut volume_mgr = embedded_sdmmc::VolumeManager::new(sdcard, FakeTimesource {});
let mut volume0 = volume_mgr.get_volume(embedded_sdmmc::VolumeIdx(0)).unwrap();
}
from embedded-sdmmc-rs.
Related Issues (20)
- File.current_offset is private to the crate and there is no tell() HOT 5
- Make File and Directory safely droppable HOT 1
- No no-std example HOT 1
- Support different codepages
- Errors with initialization with latest develop: respone 8 and 3f HOT 2
- Async support HOT 1
- Reason for MS-DOS 8.3 filename compability HOT 3
- Update dependency to heapless = "0.8" HOT 1
- In case of early ejection of SD card, allow "closing" `RawFile` handle anyway HOT 3
- How to do multi-block writes? HOT 10
- Make Directory::iterate_dir version returning an Iterator HOT 3
- should use SpiBus, not SpiDevice HOT 12
- Ensuring generic device-level reset HOT 2
- warning: field `0` is never read HOT 3
- new() without chip-select? HOT 2
- `find_data_on_disk()` panics due to attempt to subtract with overflow HOT 2
- Accepting `Read + Write + Seek` HOT 2
- Simplify dir calcs
- Add a flush API HOT 3
- Re-add the File methods HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from embedded-sdmmc-rs.