Add set_config method to RP SPI driver

Add a `set_config` method to `Spi` to allow reconfiguring SPI mode after creation.

The existing implementation of the `embassy-embedded-hal` trait `SetConfig` is changed to use the new method.

Existing uses of `SetConfig`  trait may need to explicitly call the trait method to maintain current return type.
This commit is contained in:
dstric-aqueduct
2024-10-15 11:48:54 -04:00
committed by Dario Nieuwenhuis
parent 333284588a
commit dcf228e448
2 changed files with 35 additions and 19 deletions

View File

@@ -56,7 +56,7 @@ async fn main(_spawner: Spawner) {
// Now that the card is initialized, the SPI clock can go faster
let mut config = spi::Config::default();
config.frequency = 16_000_000;
sdcard.spi(|dev| dev.bus_mut().set_config(&config)).ok();
sdcard.spi(|dev| SetConfig::set_config(dev.bus_mut(), &config)).ok();
// Now let's look for volumes (also known as partitions) on our block device.
// To do this we need a Volume Manager. It will take ownership of the block device.