Skip to content

Commit dbd46e4

Browse files
bors[bot]Dirbaio
andauthored
Merge #315
315: Fix EasyDMA max size. r=jonas-schievink a=Dirbaio EASY_DMA_SIZE changes based on peripheral, but it is always equal for UARTE, SPIx, TWIx, so I've kept a single variable. Data source is nrfx files, like [this one](https://github.com/NordicSemiconductor/nrfx/blob/b5399066bd7f3dc32ee15510d06ef7137bcacf36/mdk/nrf9160_peripherals.h#L150). I've added the values for all nrf chips, even currently unsupported ones, because they'll likely be supported soon. Can remove it if that's not wanted. Fixes #314 Co-authored-by: Dario Nieuwenhuis <[email protected]>
2 parents 1c76cbe + 35282f8 commit dbd46e4

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

nrf-hal-common/src/lib.rs

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -92,29 +92,35 @@ pub mod prelude {
9292
}
9393

9494
/// Length of Nordic EasyDMA differs for MCUs
95-
#[cfg(any(
96-
feature = "52810",
97-
feature = "52811",
98-
feature = "52832",
99-
feature = "51"
100-
))]
10195
pub mod target_constants {
102-
// NRF52832 8 bits1..0xFF
103-
pub const EASY_DMA_SIZE: usize = 255;
104-
// Easy DMA can only read from data ram
105-
pub const SRAM_LOWER: usize = 0x2000_0000;
106-
pub const SRAM_UPPER: usize = 0x3000_0000;
107-
pub const FORCE_COPY_BUFFER_SIZE: usize = 255;
108-
const _CHECK_FORCE_COPY_BUFFER_SIZE: usize = EASY_DMA_SIZE - FORCE_COPY_BUFFER_SIZE;
109-
// ERROR: FORCE_COPY_BUFFER_SIZE must be <= EASY_DMA_SIZE
110-
}
111-
#[cfg(any(feature = "52840", feature = "52833", feature = "9160"))]
112-
pub mod target_constants {
113-
// NRF52840 and NRF9160 16 bits 1..0xFFFF
114-
pub const EASY_DMA_SIZE: usize = 65535;
96+
#[cfg(feature = "51")]
97+
pub const EASY_DMA_SIZE: usize = (1 << 8) - 1;
98+
#[cfg(feature = "52805")]
99+
pub const EASY_DMA_SIZE: usize = (1 << 14) - 1;
100+
#[cfg(feature = "52810")]
101+
pub const EASY_DMA_SIZE: usize = (1 << 10) - 1;
102+
#[cfg(feature = "52811")]
103+
pub const EASY_DMA_SIZE: usize = (1 << 14) - 1;
104+
#[cfg(feature = "52820")]
105+
pub const EASY_DMA_SIZE: usize = (1 << 15) - 1;
106+
#[cfg(feature = "52832")]
107+
pub const EASY_DMA_SIZE: usize = (1 << 8) - 1;
108+
#[cfg(feature = "52833")]
109+
pub const EASY_DMA_SIZE: usize = (1 << 16) - 1;
110+
#[cfg(feature = "52840")]
111+
pub const EASY_DMA_SIZE: usize = (1 << 16) - 1;
112+
#[cfg(feature = "5340")]
113+
pub const EASY_DMA_SIZE: usize = (1 << 16) - 1;
114+
#[cfg(feature = "9160")]
115+
pub const EASY_DMA_SIZE: usize = (1 << 12) - 1;
116+
115117
// Limits for Easy DMA - it can only read from data ram
116118
pub const SRAM_LOWER: usize = 0x2000_0000;
117119
pub const SRAM_UPPER: usize = 0x3000_0000;
120+
121+
#[cfg(any(feature = "51", feature = "52810", feature = "52832"))]
122+
pub const FORCE_COPY_BUFFER_SIZE: usize = 255;
123+
#[cfg(not(any(feature = "51", feature = "52810", feature = "52832")))]
118124
pub const FORCE_COPY_BUFFER_SIZE: usize = 1024;
119125
const _CHECK_FORCE_COPY_BUFFER_SIZE: usize = EASY_DMA_SIZE - FORCE_COPY_BUFFER_SIZE;
120126
// ERROR: FORCE_COPY_BUFFER_SIZE must be <= EASY_DMA_SIZE

0 commit comments

Comments
 (0)