Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async SPI bus not instatiable on Pi Pico (embassy-rs) #163

Closed
arminveres opened this issue Oct 30, 2024 · 1 comment
Closed

Async SPI bus not instatiable on Pi Pico (embassy-rs) #163

arminveres opened this issue Oct 30, 2024 · 1 comment

Comments

@arminveres
Copy link

Hello there, when trying to use a shared SPI bus, which is async, the SdCard cannot be instantiated, since the trait is not implemented. Is there a specific technical reason for this, or was this just not yet implemented?
As you may gather, I am trying to complement this with the oled_async crate, since i need a driver for SH1107

the trait `embedded_hal::spi::SpiDevice` is not implemented for `embassy_embedded_hal::shared_bus::asynch::spi::SpiDevice<'_, NoopRawMutex, embassy_rp::spi::Spi<'static, SPI0, embassy_rp::spi::Async>, Output<'_>>`

main.rs (other initializations for i2c and oled left out):

type Spi0Bus = Mutex<NoopRawMutex, Spi<'static, SPI0, spi::Async>>;

#[embassy_executor::main]
async fn main(spawner: Spawner) {
    info!("Starting main!");
    embassy_rp::pac::SIO.spinlock(31).write_value(1);
    let p = embassy_rp::init(Default::default());

    // SPI clock needs to be running at <= 400kHz during initialization
    let mut spi_config = spi::Config::default();
    spi_config.frequency = 400_000;

    let spi = Spi::new(
        p.SPI0, p.PIN_2, p.PIN_3, p.PIN_4, p.DMA_CH0, p.DMA_CH1, spi_config,
    );
    static SPI_BUS: StaticCell<Spi0Bus> = StaticCell::new();
    let spi_bus = SPI_BUS.init(Mutex::new(spi));

    let cs = Output::new(p.PIN_5, Level::High);
    let spi_dev = SpiDevice::new(&spi_bus, cs);
    let sdcard = SdCard::new(spi_dev, embassy_time::Delay);
}

Cargo.toml:

[dependencies]
embassy-embedded-hal = { version = "0.2.0", features = ["defmt"] }
embassy-sync = { version = "0.6.0", features = ["defmt"] }
embassy-executor = { version = "0.6.0", features = [
    "arch-cortex-m",
    "executor-thread",
    "executor-interrupt",
    "defmt",
    "integrated-timers",
] }
embassy-time = { version = "0.3.2", features = [
    "defmt",
    "defmt-timestamp-uptime",
] }
embassy-rp = { version = "0.2.0", features = [
    "defmt",
    "unstable-pac",
    "time-driver",
    "critical-section-impl",
] }
embassy-futures = { version = "0.1.1" }
embassy-usb = { version = "0.3.0", features = ["defmt"] }

# WARN(aver): this causes issues with dependency: byteorder and since use defmt for logging, we are
# not going to use this for now. Also some issues with `embassy-usb`
# embassy-usb-logger = { version = "0.2.0", git = "https://github.com/embassy-rs/embassy.git" }

embassy-net = { version = "0.4.0", features = [
    "defmt",
    "tcp",
    "udp",
    "dhcpv4",
    "medium-ethernet",
] }
cyw43-pio = { version = "0.2.0", features = ["defmt", "overclock"] }
cyw43 = { version = "0.2.0", features = ["defmt", "firmware-logs"] }

defmt = "0.3"
defmt-rtt = "0.4"
fixed = "1.28.0"
fixed-macro = "1.2"

cortex-m = { version = "0.7.7", features = ["inline-asm"] }
cortex-m-rt = "0.7.3"
panic-probe = { version = "0.3", features = ["print-defmt"] }
futures = { version = "0.3.30", default-features = false, features = [
    "async-await",
    "cfg-target-has-atomic",
    "unstable",
] }
heapless = "0.8"

embedded-hal = { version = "1.0.0" }
embedded-hal-async = "1.0.0"
embedded-hal-bus = { version = "0.1.0", features = ["async"] }
embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
static_cell = "2"
portable-atomic = { version = "1.9", features = ["critical-section"] }
log = "0.4"
pio-proc = "0.2"
pio = "0.2.1"
rand = { version = "0.8.5", default-features = false }
embedded-sdmmc = "0.8.0"
fugit = { version = "0.3.7", features = ["defmt"] }
adxl345-eh-driver = "0.2.2"
oled_async = { version = "0.1.0-alpha1", features = ["spi"], git = "https://github.com/cschuhen/oled_drivers" }
embedded-graphics = { version = "0.8.1", features = ["defmt"] }
display-interface-spi = "0.5.0"
@thejpster
Copy link
Member

thejpster commented Oct 30, 2024

There is no async support in this crate at this time. See #50 and #154

@thejpster thejpster closed this as not planned Won't fix, can't repro, duplicate, stale Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants