Skip to content

Add support for flash.rs on bigger chips #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 41 additions & 10 deletions src/flash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,25 @@ impl<'a> EraseSequence<'a> {
//TODO: This should check if sector_number is valid for this device

flash.registers.cr.modify(|_, w| unsafe {
w.mer()
.clear_bit()
.ser()
.set_bit()
.snb()
.bits(sector_number)
#[cfg(any(
feature = "stm32f765",
feature = "stm32f767",
feature = "stm32f769",
feature = "stm32f777",
feature = "stm32f778",
feature = "stm32f779",
))]
w.mer1().clear_bit().mer2().clear_bit();
#[cfg(not(any(
feature = "stm32f765",
feature = "stm32f767",
feature = "stm32f769",
feature = "stm32f777",
feature = "stm32f778",
feature = "stm32f779",
)))]
w.mer().clear_bit();
w.ser().set_bit().snb().bits(sector_number)
});
flash.registers.cr.modify(|_, w| w.strt().start());

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

flash
.registers
.cr
.modify(|_, w| w.mer().set_bit().ser().clear_bit());
flash.registers.cr.modify(|_, w| unsafe {
#[cfg(any(
feature = "stm32f765",
feature = "stm32f767",
feature = "stm32f769",
feature = "stm32f777",
feature = "stm32f778",
feature = "stm32f779",
))]
w.mer1().set_bit().mer2().set_bit();
#[cfg(not(any(
feature = "stm32f765",
feature = "stm32f767",
feature = "stm32f769",
feature = "stm32f777",
feature = "stm32f778",
feature = "stm32f779",
)))]
w.mer().clear_bit();
w.ser().clear_bit()
});

flash.registers.cr.modify(|_, w| w.strt().start());

Ok(Self { flash })
Expand Down
12 changes: 1 addition & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,7 @@ pub mod qei;
#[cfg(feature = "ltdc")]
pub mod ltdc;

#[cfg(all(
feature = "device-selected",
not(any(
feature = "stm32f765",
feature = "stm32f767",
feature = "stm32f769",
feature = "stm32f777",
feature = "stm32f778",
feature = "stm32f779",
))
))]
#[cfg(feature = "device-selected")]
pub mod flash;

pub mod state {
Expand Down