@@ -11,19 +11,29 @@ Currently only SDRAM functions are implemented.
1111
1212** This crate is a work in progress! Contributions very welcome**
1313
14+ ## Implementing
15+
16+ (If your HAL already implements FMC, you can skip this)
17+
18+ See the [ docs] ( https://docs.rs/stm32-fmc )
19+
20+ # Usage
21+
1422### SDRAM
1523
16- The hardware supports up to 2 external SDRAM devices. This library
17- currently only supports 1, although it may be on either bank 1 or
18- 2 .
24+ The FMC peripheral supports up to 2 external SDRAM devices. This crate currently
25+ only supports 1, although it may be on either bank 1 or 2.
26+
27+ External memories are defined by
28+ [ ` SdramChip ` ] ( https://docs.rs/stm32-fmc/latest/stm32_fmc/trait.SdramChip.html )
29+ implementations. There are several examples in the [ ` devices ` ] ( src/devices/ )
30+ folder, or you can make your own.
1931
20- To pass pins to
21- [ ` Sdram::new ` ] ( https://docs.rs/stm32-fmc/latest/stm32_fmc/struct.Sdram.html#method.new ) ,
22- create a tuple with the following ordering:
32+ To pass pins to a constructor, create a tuple with the following ordering:
2333
2434``` rust
2535let pins = (
26- // A0-A11
36+ // A0-A12
2737 pa0 , ...
2838 // BA0-BA1
2939 // D0-D31
@@ -37,71 +47,47 @@ let pins = (
3747);
3848```
3949
40- External memories are defined by ` SdramChip ` implementations. There are already
41- several examples in the ` devices/ ` folder.
42-
43- ### NOR Flash/PSRAM
50+ You can leave out address/data pins not used by your memory.
4451
45- TODO
46-
47- ### NAND Flash
48-
49- TODO
50-
51- ## Implementing
52-
53- See the [ docs] ( https://docs.rs/stm32-fmc )
52+ #### Constructing
5453
55- <!-- ```rust -->
56- <!-- let mut sdram = -->
57- <!-- stm32_fmc::Sdram::new(fmc, fmc_io, is42s32800g_6::Is42s32800g {}); -->
58- <!-- ``` -->
54+ If you are using a HAL, see the HAL documentation.
5955
60- <!-- Or use new_unchecked: -->
56+ Otherwise you can implement
57+ [ ` FmcPeripheral ` ] ( https://docs.rs/stm32-fmc/latest/stm32_fmc/trait.FmcPeripheral.html )
58+ yourself then use
59+ [ ` Sdram::new ` ] ( https://docs.rs/stm32-fmc/latest/stm32_fmc/struct.Sdram.html#method.new )
60+ /
61+ [ ` Sdram::new_unchecked ` ] ( https://docs.rs/stm32-fmc/latest/stm32_fmc/struct.Sdram.html#method.new_unchecked )
62+ directly.
6163
62- <!-- ```rust -->
63- <!-- let mut sdram = -->
64- <!-- stm32_fmc::Sdram::new_unchecked(fmc, is42s32800g_6::Is42s32800g {}); -->
65- <!-- ``` -->
64+ #### Initialising
6665
66+ Once you have an ` Sdram ` type, you can:
6767
68- <!-- ### IO Setup -->
69-
70- <!-- IO is constructed by configuring each pin as high speed and -->
71- <!-- assigning to the FMC block. -->
72-
73- <!-- ```rust -->
74- <!-- let pa0 = gpioa.pa0.into_push_pull_output() -->
75- <!-- .set_speed(Speed::VeryHigh) -->
76- <!-- .into_alternate_af12() -->
77- <!-- .internal_pull_up(true); -->
78- <!-- ``` -->
79-
80- <!-- Then contruct a PinSdram type from the required pins. They must be -->
81- <!-- specified in the order given here. -->
82-
83-
84- <!-- See the [examples](examples) for an ergonomic method using macros. -->
85-
86- # Usage
87-
88- Follow the documention in your HAL to initialise the FMC.
89-
90- Once you have an ` Sdram ` type from your HAL, you can:
91-
92- * Initialise it, which returns a raw pointer
68+ * Initialise it by calling
69+ [ ` init ` ] ( https://docs.rs/stm32-fmc/latest/stm32_fmc/struct.Sdram.html#method.init ) . This
70+ returns a raw pointer
9371* Convert the raw pointer to a sized slice using ` from_raw_parts_mut `
9472
9573``` rust
9674let ram = unsafe {
9775 // Initialise controller and SDRAM
98- let ram_ptr : * mut u32 = sdram . init (& mut delay , ccdr . clocks );
76+ let ram_ptr : * mut u32 = sdram . init (& mut delay );
9977
10078 // 32 MByte = 256Mbit SDRAM = 8M u32 words
10179 slice :: from_raw_parts_mut (ram_ptr , 8 * 1024 * 1024 )
10280};
10381```
10482
83+ ### NOR Flash/PSRAM
84+
85+ TODO
86+
87+ ### NAND Flash
88+
89+ TODO
90+
10591## Releasing
10692
10793* Update Cargo.toml
0 commit comments