Skip to content

Commit 4f6a7a5

Browse files
committed
Add UniformNorFlash trait
1 parent 5f422d8 commit 4f6a7a5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,23 @@ pub trait NorFlash {
136136
/// Currently limited to 4 regions, but could be increased if necessary
137137
fn regions(&self) -> Vec<Self::Region, U4>;
138138
}
139+
140+
/// ...
141+
pub trait UniformNorFlash: NorFlash {
142+
/// The range of possible addresses within the peripheral.
143+
///
144+
/// (start_addr, end_addr)
145+
fn range(&self) -> (Address, Address) {
146+
self.regions()[0].range()
147+
}
148+
/// Maximum number of bytes that can be written at once.
149+
fn page_size(&self) -> usize {
150+
self.regions()[0].page_size()
151+
}
152+
/// List of avalable erase sizes in this region.
153+
/// Should be sorted in ascending order.
154+
/// Currently limited to 5 sizes, but could be increased if necessary.
155+
fn erase_sizes(&self) -> Vec<usize, U5> {
156+
self.regions()[0].erase_sizes()
157+
}
158+
}

0 commit comments

Comments
 (0)