From 495fbc58b6f4d2e751b16883a2c5cee3c598fd79 Mon Sep 17 00:00:00 2001 From: Ian McIntyre Date: Sat, 12 Apr 2025 18:37:30 -0400 Subject: Prototype a v0.2 Needs to be documented. The gist: remove references to MMIO, and add support for nested structures. Drop the reset_reg! macro. --- tests/pathological.rs | 70 --------------------------------------------------- 1 file changed, 70 deletions(-) delete mode 100644 tests/pathological.rs (limited to 'tests/pathological.rs') diff --git a/tests/pathological.rs b/tests/pathological.rs deleted file mode 100644 index d463e29..0000000 --- a/tests/pathological.rs +++ /dev/null @@ -1,70 +0,0 @@ -//! Testing corner cases. - -#![allow(non_upper_case_globals, non_snake_case)] // Macro conventions. - -use ral_registers as ral; - -mod periph { - #[repr(C)] - pub struct RegisterBlock { - /// Multi-dimensional arrays. - #[allow(clippy::type_complexity)] // Intentionally complex type. - pub DEEP_LEARNING: [[[[[[[[ral_registers::RWRegister; 1]; 2]; 3]; 4]; 5]; 6]; 7]; 8], - } - - pub mod DEEP_LEARNING { - pub mod GRADIENT { - pub const offset: u32 = 3; - pub const mask: u32 = 0x1F << offset; - pub mod R {} - pub mod W {} - pub mod RW {} - } - } - - pub struct ResetValues { - pub DEEP_LEARNING: u32, - } - - pub mod INST { - pub const reset: super::ResetValues = super::ResetValues { DEEP_LEARNING: 42 }; - } -} - -fn register_block() -> periph::RegisterBlock { - // Safety: bitpattern of zero is fine. - use std::mem::MaybeUninit; - unsafe { MaybeUninit::zeroed().assume_init() } -} - -#[test] -fn read_deep_array() { - let rb = register_block(); - rb.DEEP_LEARNING[7][6][5][4][3][2][1][0].write(u32::MAX); - let gradient = ral::read_reg!(periph, &rb, DEEP_LEARNING[7][6][5][4][3][2][1][0], GRADIENT); - assert_eq!(gradient, 0x1F); -} - -#[test] -fn write_deep_array() { - let rb = register_block(); - ral::write_reg!(periph, &rb, DEEP_LEARNING[7][6][5][4][3][2][1][0], 23); - assert_eq!(rb.DEEP_LEARNING[7][6][5][4][3][2][1][0].read(), 23); -} - -#[test] -fn modify_deep_array() { - let rb = register_block(); - ral::modify_reg!(periph, &rb, DEEP_LEARNING[7][6][5][4][3][2][1][0], GRADIENT: 42); - assert_eq!( - rb.DEEP_LEARNING[7][6][5][4][3][2][1][0].read(), - (42 & 0x1F) << 3 - ); -} - -#[test] -fn reset_deep_array() { - let rb = register_block(); - ral::reset_reg!(periph, &rb, INST, DEEP_LEARNING[7][6][5][4][3][2][1][0]); - assert_eq!(rb.DEEP_LEARNING[7][6][5][4][3][2][1][0].read(), 42); -} -- cgit v1.2.3