File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change 6
6
use cortex_m:: interrupt;
7
7
8
8
use crate :: {
9
- pac,
9
+ pac:: {
10
+ self ,
11
+ flash:: acr:: LATENCY_A ,
12
+ } ,
10
13
rcc:: Rcc ,
11
14
} ;
12
15
@@ -75,11 +78,6 @@ impl FLASH {
75
78
// Enable the peripheral interface
76
79
rcc. rb . ahbenr . modify ( |_, w| w. mifen ( ) . set_bit ( ) ) ;
77
80
78
- // Set the number of wait states to 1. This is never wrong, but will
79
- // lead to suboptimal performance at lower frequencies. See STM32L0x2
80
- // reference manual, section 3.3.3.
81
- flash. acr . modify ( |_, w| w. latency ( ) . set_bit ( ) ) ;
82
-
83
81
Self {
84
82
flash,
85
83
flash_end,
@@ -88,6 +86,18 @@ impl FLASH {
88
86
}
89
87
}
90
88
89
+ /// Set wait states
90
+ ///
91
+ /// By default, the number of wait states is zero. This is not suitable for
92
+ /// all configurations. Depending on the processor's voltage range and
93
+ /// frequency, it might be necessary to set the number of wait states to 1.
94
+ ///
95
+ /// This is explained, for example, in the STM32L0x2 Reference Manual,
96
+ /// section 3.3.3.
97
+ pub fn set_wait_states ( & mut self , wait_states : LATENCY_A ) {
98
+ self . flash . acr . modify ( |_, w| w. latency ( ) . variant ( wait_states) ) ;
99
+ }
100
+
91
101
/// Erases a page of flash memory
92
102
///
93
103
/// Attention: You must make sure that your program is not executed from the
You can’t perform that action at this time.
0 commit comments