stm32h7-fmc 0.1.0

Hardware Abstraction Layer for Flexible Memory Controller (FMC) on STM32H7
docs.rs failed to build stm32h7-fmc-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: stm32h7-fmc-0.3.0

docs Build status

Documentation

stm32h7-fmc

Hardware Abstraction Layer for Flexible Memory Controller (FMC) on STM32H7

Currently only SDRAM functions are implemented.

This crate depends on the GPIO, Clock and Delay functionality from stm32h7xx-hal

SDRAM

The H7 supports up to 2 external SDRAM devices. This library currently only supports 1, although it may be on either bank 1 or 2.

IO Setup

IO is constructed by configuring each pin as high speed and assigning to the FMC block (usually AF12).

    let pa0 = gpioa.pa0.into_push_pull_output()
        .set_speed(Speed::VeryHigh)
        .into_alternate_af12()
        .internal_pull_up(true);

Then contruct a PinSdram type from the required pins. They must be specified in the order given here.

    let fmc_io = stm32h7_fmc::PinsSdramBank1(
        (
            // A0-A11
            pa0, ...
            // BA0-BA1
            // D0-D31
            // NBL0 - NBL3
            // SDCKE
            // SDCLK
            // SDNCAS
            // SDNE
            // SDRAS
            // SDNWE
        )
    );

See the examples for an ergonomic method using macros.

Usage

First create a new SDRAM from the FMC peripheral, IO and SDRAM device constants.

    let mut sdram =
        stm32h7_fmc::Sdram::new(dp.FMC, fmc_io, is42s32800g_6::Is42s32800g {});

Then initialise the controller and the SDRAM device. Convert the raw pointer to a sized slice using from_raw_parts_mut.

    let ram = unsafe {
        // Initialise controller and SDRAM
        let ram_ptr = sdram.init(&mut delay, ccdr.clocks);

        // 32 MByte = 256Mbit SDRAM
        slice::from_raw_parts_mut(ram_ptr, 32 * 1024 * 1024)
    };

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.