Skip to content

Commit 8c46b5c

Browse files
committed
flash: use mer[12] fields for erase on big chips
1 parent 551d59b commit 8c46b5c

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src/flash.rs

+20-10
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,15 @@ impl<'a> EraseSequence<'a> {
172172
//TODO: This should check if sector_number is valid for this device
173173

174174
flash.registers.cr.modify(|_, w| unsafe {
175-
w.mer()
176-
.clear_bit()
177-
.ser()
178-
.set_bit()
179-
.snb()
180-
.bits(sector_number)
175+
#[cfg(any(feature = "svd-f7x6", feature = "svd-f7x7", feature = "svd-f7x9"))]
176+
w
177+
.mer1().clear_bit()
178+
.mer2().clear_bit();
179+
#[cfg(not(any(feature = "svd-f7x6", feature = "svd-f7x7", feature = "svd-f7x9")))]
180+
w.mer().clear_bit();
181+
w
182+
.ser().set_bit()
183+
.snb().bits(sector_number)
181184
});
182185
flash.registers.cr.modify(|_, w| w.strt().start());
183186

@@ -189,10 +192,17 @@ impl<'a> EraseSequence<'a> {
189192
flash.check_locked_or_busy()?;
190193
flash.clear_errors();
191194

192-
flash
193-
.registers
194-
.cr
195-
.modify(|_, w| w.mer().set_bit().ser().clear_bit());
195+
flash.registers.cr.modify(|_, w| unsafe {
196+
#[cfg(any(feature = "svd-f7x6", feature = "svd-f7x7", feature = "svd-f7x9"))]
197+
w
198+
.mer1().set_bit()
199+
.mer2().set_bit();
200+
#[cfg(not(any(feature = "svd-f7x6", feature = "svd-f7x7", feature = "svd-f7x9")))]
201+
w.mer().clear_bit();
202+
w
203+
.ser().clear_bit()
204+
});
205+
196206
flash.registers.cr.modify(|_, w| w.strt().start());
197207

198208
Ok(Self { flash })

src/lib.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,7 @@ pub mod qei;
160160
#[cfg(feature = "ltdc")]
161161
pub mod ltdc;
162162

163-
#[cfg(all(
164-
feature = "device-selected",
165-
not(any(
166-
feature = "stm32f765",
167-
feature = "stm32f767",
168-
feature = "stm32f769",
169-
feature = "stm32f777",
170-
feature = "stm32f778",
171-
feature = "stm32f779",
172-
))
173-
))]
163+
#[cfg(feature = "device-selected")]
174164
pub mod flash;
175165

176166
pub mod state {

0 commit comments

Comments
 (0)