Skip to content

Commit eb594d9

Browse files
Update to embedded-storage 0.2.0
1 parent 7777a7c commit eb594d9

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

examples/nvmc-demo/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ publish = false
1010
[dependencies]
1111
cortex-m = "0.7.3"
1212
cortex-m-rt = "0.7.0"
13-
embedded-storage = "0.1.0"
13+
embedded-storage = "0.2.0"
1414
rtt-target = {version = "0.2.0", features = ["cortex-m"] }
1515

1616
[dependencies.embedded-hal]

examples/nvmc-demo/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ fn main() -> ! {
2828
#[cfg(feature = "52840")]
2929
let mut nvmc = Nvmc::new(p.NVMC, unsafe { &mut CONFIG });
3030

31-
assert!(nvmc.try_erase(0, CONFIG_SIZE as u32 * 4).is_ok());
31+
assert!(nvmc.erase(0, CONFIG_SIZE as u32 * 4).is_ok());
3232
let write_buf: [u8; 4] = [1, 2, 3, 4];
33-
assert!(nvmc.try_write(0, &write_buf).is_ok());
33+
assert!(nvmc.write(0, &write_buf).is_ok());
3434
let mut read_buf = [0u8; 2];
35-
assert!(nvmc.try_read(0, &mut read_buf).is_ok());
35+
assert!(nvmc.read(0, &mut read_buf).is_ok());
3636
assert_eq!(read_buf, write_buf[0..2]);
3737

3838
rprintln!("What was written to flash was read!");

nrf-hal-common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fixed = "1.0.0"
2626
rand_core = "0.6.3"
2727
cfg-if = "1.0.0"
2828
embedded-dma = "0.1.1"
29-
embedded-storage = "0.1.0"
29+
embedded-storage = "0.2.0"
3030

3131
[dependencies.void]
3232
default-features = false

nrf-hal-common/src/nvmc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ where
9999

100100
const READ_SIZE: usize = 4;
101101

102-
fn try_read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
102+
fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
103103
let offset = offset as usize;
104104
let bytes_len = bytes.len();
105105
let read_len = bytes_len + (Self::READ_SIZE - (bytes_len % Self::READ_SIZE));
@@ -151,7 +151,7 @@ where
151151

152152
const ERASE_SIZE: usize = 4 * 1024;
153153

154-
fn try_erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
154+
fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
155155
if from as usize % Self::ERASE_SIZE == 0 && to as usize % Self::ERASE_SIZE == 0 {
156156
self.enable_erase();
157157
for offset in (from..to).step_by(Self::ERASE_SIZE) {
@@ -164,7 +164,7 @@ where
164164
}
165165
}
166166

167-
fn try_write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> {
167+
fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> {
168168
let offset = offset as usize;
169169
if offset % Self::WRITE_SIZE == 0 && bytes.len() % Self::WRITE_SIZE == 0 {
170170
self.enable_write();

nrf52840-hal-tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ cortex-m-rt = { version = "0.6.14", features = ["device"] }
3434
defmt = "0.2.0"
3535
defmt-rtt = "0.2.0"
3636
defmt-test = "0.2.0"
37-
embedded-storage = "0.1.0"
37+
embedded-storage = "0.2.0"
3838
nrf52840-hal = { path = "../nrf52840-hal" }
3939
panic-probe = { version = "0.2.0", features = ["print-defmt"] }
4040

nrf52840-hal-tests/tests/nvmc.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,60 +41,60 @@ mod tests {
4141
#[test]
4242
fn read_unaligned(state: &mut State) {
4343
let mut buf = [0u8; 1];
44-
assert!(state.nvmc.try_read(1, &mut buf).is_err());
44+
assert!(state.nvmc.read(1, &mut buf).is_err());
4545
}
4646

4747
#[test]
4848
fn read_beyond_buffer(state: &mut State) {
4949
let mut buf = [0u8; CONFIG_SIZE * 4 + 1];
50-
assert!(state.nvmc.try_read(0, &mut buf).is_err());
50+
assert!(state.nvmc.read(0, &mut buf).is_err());
5151
}
5252

5353
#[test]
5454
fn erase_unaligned_from(state: &mut State) {
55-
assert!(state.nvmc.try_erase(1, 4096).is_err());
55+
assert!(state.nvmc.erase(1, 4096).is_err());
5656
}
5757

5858
#[test]
5959
fn erase_unaligned_to(state: &mut State) {
60-
assert!(state.nvmc.try_erase(0, 4097).is_err());
60+
assert!(state.nvmc.erase(0, 4097).is_err());
6161
}
6262

6363
#[test]
6464
fn write_unaligned(state: &mut State) {
6565
let buf = [0u8; 1];
66-
assert!(state.nvmc.try_write(1, &buf).is_err());
66+
assert!(state.nvmc.write(1, &buf).is_err());
6767
}
6868

6969
#[test]
7070
fn read_write_and_then_read(state: &mut State) {
71-
assert!(state.nvmc.try_erase(0, CONFIG_SIZE as u32 * 4).is_ok());
71+
assert!(state.nvmc.erase(0, CONFIG_SIZE as u32 * 4).is_ok());
7272
let mut read_buf = [0u8; 1];
73-
assert!(state.nvmc.try_read(0, &mut read_buf).is_ok());
73+
assert!(state.nvmc.read(0, &mut read_buf).is_ok());
7474
assert_eq!(read_buf[0], 0xff);
7575
let write_buf = [1u8; 4];
76-
assert!(state.nvmc.try_write(0, &write_buf).is_ok());
77-
assert!(state.nvmc.try_read(0, &mut read_buf).is_ok());
76+
assert!(state.nvmc.write(0, &write_buf).is_ok());
77+
assert!(state.nvmc.read(0, &mut read_buf).is_ok());
7878
assert_eq!(read_buf[0], 0x1);
7979
}
8080

8181
#[test]
8282
fn read_what_is_written(state: &mut State) {
83-
assert!(state.nvmc.try_erase(0, CONFIG_SIZE as u32 * 4).is_ok());
83+
assert!(state.nvmc.erase(0, CONFIG_SIZE as u32 * 4).is_ok());
8484
let write_buf: [u8; 8] = [1, 2, 3, 4, 5, 6, 7, 8];
85-
assert!(state.nvmc.try_write(0, &write_buf).is_ok());
85+
assert!(state.nvmc.write(0, &write_buf).is_ok());
8686
let mut read_buf = [0u8; 8];
87-
assert!(state.nvmc.try_read(0, &mut read_buf).is_ok());
87+
assert!(state.nvmc.read(0, &mut read_buf).is_ok());
8888
assert_eq!(read_buf, write_buf);
8989
}
9090

9191
#[test]
9292
fn partially_read_what_is_written(state: &mut State) {
93-
assert!(state.nvmc.try_erase(0, CONFIG_SIZE as u32 * 4).is_ok());
93+
assert!(state.nvmc.erase(0, CONFIG_SIZE as u32 * 4).is_ok());
9494
let write_buf: [u8; 4] = [1, 2, 3, 4];
95-
assert!(state.nvmc.try_write(0, &write_buf).is_ok());
95+
assert!(state.nvmc.write(0, &write_buf).is_ok());
9696
let mut read_buf = [0u8; 2];
97-
assert!(state.nvmc.try_read(0, &mut read_buf).is_ok());
97+
assert!(state.nvmc.read(0, &mut read_buf).is_ok());
9898
assert_eq!(read_buf, write_buf[0..2]);
9999
}
100100
}

0 commit comments

Comments
 (0)