File tree 1 file changed +21
-1
lines changed
1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,26 @@ pub struct RmwMultiwriteNorFlashStorage<'a, S> {
162
162
merge_buffer : & ' a mut [ u8 ] ,
163
163
}
164
164
165
+ impl < ' a , S > RmwNorFlashStorage < ' a , S >
166
+ where
167
+ S : MultiwriteNorFlash ,
168
+ {
169
+ /// Instantiate a new generic `Storage` from a `NorFlash` peripheral
170
+ ///
171
+ /// **NOTE** This will panic if the provided merge buffer,
172
+ /// is smaller than the erase size of the flash peripheral
173
+ pub fn new ( nor_flash : S , merge_buffer : & ' a mut [ u8 ] ) -> Self {
174
+ if merge_buffer. len ( ) < S :: ERASE_SIZE {
175
+ panic ! ( "Merge buffer is too small" ) ;
176
+ }
177
+
178
+ Self {
179
+ storage : nor_flash,
180
+ merge_buffer,
181
+ }
182
+ }
183
+ }
184
+
165
185
impl < ' a , S > ReadStorage for RmwMultiwriteNorFlashStorage < ' a , S >
166
186
where
167
187
S : ReadNorFlash ,
@@ -180,7 +200,7 @@ where
180
200
181
201
impl < ' a , S > Storage for RmwMultiwriteNorFlashStorage < ' a , S >
182
202
where
183
- S : NorFlash ,
203
+ S : MultiwriteNorFlash ,
184
204
{
185
205
fn try_write ( & mut self , address : u32 , bytes : & [ u8 ] ) -> Result < ( ) , Self :: Error > {
186
206
// Perform read/modify/write operations on the byte slice.
You can’t perform that action at this time.
0 commit comments