File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 3
3
//! See STM32L0x2 reference manual, chapter 3.
4
4
5
5
6
+ use cortex_m:: interrupt;
7
+
6
8
use crate :: {
7
9
pac,
8
10
rcc:: Rcc ,
@@ -200,9 +202,15 @@ impl FLASH {
200
202
w
201
203
} ) ;
202
204
203
- // Safe, because we've verified the valididty of `address` and the
204
- // length `words`.
205
- unsafe { write_half_page ( address, words. as_ptr ( ) ) ; }
205
+ // We absoluty can't have any access to Flash while preparing the
206
+ // write, or the process will be interrupted. This includes any
207
+ // access to the vector table or interrupt handlers that might be
208
+ // caused by an interrupt.
209
+ interrupt:: free ( |_| {
210
+ // Safe, because we've verified the valididty of `address` and
211
+ // the length `words`.
212
+ unsafe { write_half_page ( address, words. as_ptr ( ) ) ; }
213
+ } ) ;
206
214
207
215
// Wait for operation to complete
208
216
while self_. flash . sr . read ( ) . bsy ( ) . is_active ( ) { }
You can’t perform that action at this time.
0 commit comments