Skip to content

Commit 90ca932

Browse files
authored
Merge pull request #168 from maximeborges/bugfix/flash_on_big_chips
Add support for flash.rs on bigger chips
2 parents 679b4d9 + 4ab3693 commit 90ca932

File tree

2 files changed

+42
-21
lines changed

2 files changed

+42
-21
lines changed

src/flash.rs

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,25 @@ 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(
176+
feature = "stm32f765",
177+
feature = "stm32f767",
178+
feature = "stm32f769",
179+
feature = "stm32f777",
180+
feature = "stm32f778",
181+
feature = "stm32f779",
182+
))]
183+
w.mer1().clear_bit().mer2().clear_bit();
184+
#[cfg(not(any(
185+
feature = "stm32f765",
186+
feature = "stm32f767",
187+
feature = "stm32f769",
188+
feature = "stm32f777",
189+
feature = "stm32f778",
190+
feature = "stm32f779",
191+
)))]
192+
w.mer().clear_bit();
193+
w.ser().set_bit().snb().bits(sector_number)
181194
});
182195
flash.registers.cr.modify(|_, w| w.strt().start());
183196

@@ -189,10 +202,28 @@ impl<'a> EraseSequence<'a> {
189202
flash.check_locked_or_busy()?;
190203
flash.clear_errors();
191204

192-
flash
193-
.registers
194-
.cr
195-
.modify(|_, w| w.mer().set_bit().ser().clear_bit());
205+
flash.registers.cr.modify(|_, w| unsafe {
206+
#[cfg(any(
207+
feature = "stm32f765",
208+
feature = "stm32f767",
209+
feature = "stm32f769",
210+
feature = "stm32f777",
211+
feature = "stm32f778",
212+
feature = "stm32f779",
213+
))]
214+
w.mer1().set_bit().mer2().set_bit();
215+
#[cfg(not(any(
216+
feature = "stm32f765",
217+
feature = "stm32f767",
218+
feature = "stm32f769",
219+
feature = "stm32f777",
220+
feature = "stm32f778",
221+
feature = "stm32f779",
222+
)))]
223+
w.mer().clear_bit();
224+
w.ser().clear_bit()
225+
});
226+
196227
flash.registers.cr.modify(|_, w| w.strt().start());
197228

198229
Ok(Self { flash })

src/lib.rs

Lines changed: 1 addition & 11 deletions
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)