Skip to content

Commit edc316d

Browse files
author
Henrik Alsér
committed
Compile time assert FORCE_COPY_BUFFER_SIZE <= EASY_DMA_SIZE
1 parent 45d9201 commit edc316d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

nrf-hal-common/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ pub mod target_constants {
7070
pub const SRAM_LOWER: usize = 0x2000_0000;
7171
pub const SRAM_UPPER: usize = 0x3000_0000;
7272
pub const FORCE_COPY_BUFFER_SIZE: usize = 255;
73+
const _CHECK_FORCE_COPY_BUFFER_SIZE: usize = EASY_DMA_SIZE - FORCE_COPY_BUFFER_SIZE;
74+
// ERROR: FORCE_COPY_BUFFER_SIZE must be <= EASY_DMA_SIZE
7375
}
7476
#[cfg(any(feature = "52840", feature = "52833", feature = "9160"))]
7577
pub mod target_constants {
@@ -79,6 +81,8 @@ pub mod target_constants {
7981
pub const SRAM_LOWER: usize = 0x2000_0000;
8082
pub const SRAM_UPPER: usize = 0x3000_0000;
8183
pub const FORCE_COPY_BUFFER_SIZE: usize = 1024;
84+
const _CHECK_FORCE_COPY_BUFFER_SIZE: usize = EASY_DMA_SIZE - FORCE_COPY_BUFFER_SIZE;
85+
// ERROR: FORCE_COPY_BUFFER_SIZE must be <= EASY_DMA_SIZE
8286
}
8387

8488
/// Does this slice reside entirely within RAM?

nrf-hal-common/src/twim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ where
381381

382382
// Chunk write data
383383
let wr_buffer = &mut [0; FORCE_COPY_BUFFER_SIZE][..];
384-
for chunk in tx_buffer.chunks(FORCE_COPY_BUFFER_SIZE.min(EASY_DMA_SIZE)) {
384+
for chunk in tx_buffer.chunks(FORCE_COPY_BUFFER_SIZE) {
385385
// Copy chunk into RAM
386386
wr_buffer[..chunk.len()].copy_from_slice(chunk);
387387

0 commit comments

Comments
 (0)