aboutsummaryrefslogtreecommitdiff
path: root/embassy-boot/boot/src/test_flash
diff options
context:
space:
mode:
authorRasmus Melchior Jacobsen <[email protected]>2023-05-30 13:55:49 +0200
committerRasmus Melchior Jacobsen <[email protected]>2023-05-30 13:55:49 +0200
commitc6a984f506530bc08464800abc332be9c49ac198 (patch)
treef4050963011dd8c264e54b1b2de70fa281bc53f9 /embassy-boot/boot/src/test_flash
parent551f76c70067bfa14b159a198cdb92f810f40607 (diff)
Align tests
Diffstat (limited to 'embassy-boot/boot/src/test_flash')
-rw-r--r--embassy-boot/boot/src/test_flash/asynch.rs17
-rw-r--r--embassy-boot/boot/src/test_flash/blocking.rs22
2 files changed, 25 insertions, 14 deletions
diff --git a/embassy-boot/boot/src/test_flash/asynch.rs b/embassy-boot/boot/src/test_flash/asynch.rs
index b5b3c2538..3ac9e71ab 100644
--- a/embassy-boot/boot/src/test_flash/asynch.rs
+++ b/embassy-boot/boot/src/test_flash/asynch.rs
@@ -3,6 +3,8 @@ use embassy_sync::blocking_mutex::raw::NoopRawMutex;
3use embassy_sync::mutex::Mutex; 3use embassy_sync::mutex::Mutex;
4use embedded_storage_async::nor_flash::NorFlash; 4use embedded_storage_async::nor_flash::NorFlash;
5 5
6use crate::BootLoaderConfig;
7
6pub struct AsyncTestFlash<ACTIVE, DFU, STATE> 8pub struct AsyncTestFlash<ACTIVE, DFU, STATE>
7where 9where
8 ACTIVE: NorFlash, 10 ACTIVE: NorFlash,
@@ -20,11 +22,11 @@ where
20 DFU: NorFlash, 22 DFU: NorFlash,
21 STATE: NorFlash, 23 STATE: NorFlash,
22{ 24{
23 pub fn new(active: ACTIVE, dfu: DFU, state: STATE) -> Self { 25 pub fn new(config: BootLoaderConfig<ACTIVE, DFU, STATE>) -> Self {
24 Self { 26 Self {
25 active: Mutex::new(active), 27 active: Mutex::new(config.active),
26 dfu: Mutex::new(dfu), 28 dfu: Mutex::new(config.dfu),
27 state: Mutex::new(state), 29 state: Mutex::new(config.state),
28 } 30 }
29 } 31 }
30 32
@@ -52,6 +54,11 @@ where
52 STATE: NorFlash + embedded_storage::nor_flash::NorFlash, 54 STATE: NorFlash + embedded_storage::nor_flash::NorFlash,
53{ 55{
54 pub fn into_blocking(self) -> super::BlockingTestFlash<ACTIVE, DFU, STATE> { 56 pub fn into_blocking(self) -> super::BlockingTestFlash<ACTIVE, DFU, STATE> {
55 super::BlockingTestFlash::new(self.active.into_inner(), self.dfu.into_inner(), self.state.into_inner()) 57 let config = BootLoaderConfig {
58 active: self.active.into_inner(),
59 dfu: self.dfu.into_inner(),
60 state: self.state.into_inner(),
61 };
62 super::BlockingTestFlash::new(config)
56 } 63 }
57} 64}
diff --git a/embassy-boot/boot/src/test_flash/blocking.rs b/embassy-boot/boot/src/test_flash/blocking.rs
index 77876a218..ba33c9208 100644
--- a/embassy-boot/boot/src/test_flash/blocking.rs
+++ b/embassy-boot/boot/src/test_flash/blocking.rs
@@ -5,6 +5,8 @@ use embassy_sync::blocking_mutex::raw::NoopRawMutex;
5use embassy_sync::blocking_mutex::Mutex; 5use embassy_sync::blocking_mutex::Mutex;
6use embedded_storage::nor_flash::NorFlash; 6use embedded_storage::nor_flash::NorFlash;
7 7
8use crate::BootLoaderConfig;
9
8pub struct BlockingTestFlash<ACTIVE, DFU, STATE> 10pub struct BlockingTestFlash<ACTIVE, DFU, STATE>
9where 11where
10 ACTIVE: NorFlash, 12 ACTIVE: NorFlash,
@@ -22,11 +24,11 @@ where
22 DFU: NorFlash, 24 DFU: NorFlash,
23 STATE: NorFlash, 25 STATE: NorFlash,
24{ 26{
25 pub fn new(active: ACTIVE, dfu: DFU, state: STATE) -> Self { 27 pub fn new(config: BootLoaderConfig<ACTIVE, DFU, STATE>) -> Self {
26 Self { 28 Self {
27 active: Mutex::new(RefCell::new(active)), 29 active: Mutex::new(RefCell::new(config.active)),
28 dfu: Mutex::new(RefCell::new(dfu)), 30 dfu: Mutex::new(RefCell::new(config.dfu)),
29 state: Mutex::new(RefCell::new(state)), 31 state: Mutex::new(RefCell::new(config.state)),
30 } 32 }
31 } 33 }
32 34
@@ -49,6 +51,7 @@ where
49 } 51 }
50} 52}
51 53
54#[cfg(feature = "nightly")]
52impl<ACTIVE, DFU, STATE> BlockingTestFlash<ACTIVE, DFU, STATE> 55impl<ACTIVE, DFU, STATE> BlockingTestFlash<ACTIVE, DFU, STATE>
53where 56where
54 ACTIVE: NorFlash + embedded_storage_async::nor_flash::NorFlash, 57 ACTIVE: NorFlash + embedded_storage_async::nor_flash::NorFlash,
@@ -56,10 +59,11 @@ where
56 STATE: NorFlash + embedded_storage_async::nor_flash::NorFlash, 59 STATE: NorFlash + embedded_storage_async::nor_flash::NorFlash,
57{ 60{
58 pub fn into_async(self) -> super::AsyncTestFlash<ACTIVE, DFU, STATE> { 61 pub fn into_async(self) -> super::AsyncTestFlash<ACTIVE, DFU, STATE> {
59 super::AsyncTestFlash::new( 62 let config = BootLoaderConfig {
60 self.active.into_inner().into_inner(), 63 active: self.active.into_inner().into_inner(),
61 self.dfu.into_inner().into_inner(), 64 dfu: self.dfu.into_inner().into_inner(),
62 self.state.into_inner().into_inner(), 65 state: self.state.into_inner().into_inner(),
63 ) 66 };
67 super::AsyncTestFlash::new(config)
64 } 68 }
65} 69}