File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 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> {
162162 merge_buffer : & ' a mut [ u8 ] ,
163163}
164164
165+ impl < ' a , S > RmwMultiwriteNorFlashStorage < ' 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+
165185impl < ' a , S > ReadStorage for RmwMultiwriteNorFlashStorage < ' a , S >
166186where
167187 S : ReadNorFlash ,
@@ -180,7 +200,7 @@ where
180200
181201impl < ' a , S > Storage for RmwMultiwriteNorFlashStorage < ' a , S >
182202where
183- S : NorFlash ,
203+ S : MultiwriteNorFlash ,
184204{
185205 fn try_write ( & mut self , address : u32 , bytes : & [ u8 ] ) -> Result < ( ) , Self :: Error > {
186206 // Perform read/modify/write operations on the byte slice.
You can’t perform that action at this time.
0 commit comments