@@ -11,19 +11,29 @@ Currently only SDRAM functions are implemented.
11
11
12
12
** This crate is a work in progress! Contributions very welcome**
13
13
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
+
14
22
### SDRAM
15
23
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.
19
31
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:
23
33
24
34
``` rust
25
35
let pins = (
26
- // A0-A11
36
+ // A0-A12
27
37
pa0 , ...
28
38
// BA0-BA1
29
39
// D0-D31
@@ -37,71 +47,47 @@ let pins = (
37
47
);
38
48
```
39
49
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.
44
51
45
- TODO
46
-
47
- ### NAND Flash
48
-
49
- TODO
50
-
51
- ## Implementing
52
-
53
- See the [ docs] ( https://docs.rs/stm32-fmc )
52
+ #### Constructing
54
53
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.
59
55
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.
61
63
62
- <!-- ```rust -->
63
- <!-- let mut sdram = -->
64
- <!-- stm32_fmc::Sdram::new_unchecked(fmc, is42s32800g_6::Is42s32800g {}); -->
65
- <!-- ``` -->
64
+ #### Initialising
66
65
66
+ Once you have an ` Sdram ` type, you can:
67
67
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
93
71
* Convert the raw pointer to a sized slice using ` from_raw_parts_mut `
94
72
95
73
``` rust
96
74
let ram = unsafe {
97
75
// 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 );
99
77
100
78
// 32 MByte = 256Mbit SDRAM = 8M u32 words
101
79
slice :: from_raw_parts_mut (ram_ptr , 8 * 1024 * 1024 )
102
80
};
103
81
```
104
82
83
+ ### NOR Flash/PSRAM
84
+
85
+ TODO
86
+
87
+ ### NAND Flash
88
+
89
+ TODO
90
+
105
91
## Releasing
106
92
107
93
* Update Cargo.toml
0 commit comments