Skip to content

Commit 578d7d8

Browse files
committed
Allow single or dual-bank flash on stm32g474, l5 and simillar
1 parent a1a4f66 commit 578d7d8

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/flash/mod.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,16 @@ pub struct Flash {
7272

7373
/// Contains code common to both modules.
7474
impl Flash {
75+
#[cfg(not(any(feature = "g473", feature = "g474", feature = "g483", feature = "g484", feature = "l5")))]
7576
/// Create a struct used to perform operations on Flash.
7677
pub fn new(regs: FLASH) -> Self {
77-
cfg_if! {
78-
if #[cfg(any(feature = "g473", feature = "g474", feature = "g483", feature = "g484", feature = "l5"))] {
79-
// Some G4 variants let you select dual or single-bank mode.
80-
// Self { regs, dual_bank: DualBank::Single }
81-
Self { regs, dual_bank: DualBank::Dual } // todo: Experimenting
82-
} else {
83-
Self { regs }
84-
}
85-
}
78+
Self { regs }
79+
}
80+
81+
#[cfg(any(feature = "g473", feature = "g474", feature = "g483", feature = "g484", feature = "l5"))]
82+
pub fn new(regs: FLASH, dual_bank: DualBank) -> Self {
83+
// Some G4 variants let you select dual or single-bank mode. via the Option bit.
84+
Self { regs, dual_bank }
8685
}
8786

8887
/// Read flash memory at a given page and offset into an 8-bit-dword buffer.

0 commit comments

Comments
 (0)