diff options
Diffstat (limited to 'board')
| -rw-r--r-- | board/Cargo.toml | 5 | ||||
| -rw-r--r-- | board/build.rs | 17 | ||||
| -rw-r--r-- | board/src/imxrt1170evk_cm4.rs | 36 | ||||
| -rw-r--r-- | board/src/lib.rs | 6 |
4 files changed, 64 insertions, 0 deletions
diff --git a/board/Cargo.toml b/board/Cargo.toml index 5ac029c..03ec25f 100644 --- a/board/Cargo.toml +++ b/board/Cargo.toml @@ -55,6 +55,11 @@ imxrt1170evk-cm7 = [ "dep:rtt-target", "dep:panic-rtt-target", ] +imxrt1170evk-cm4 = [ + "imxrt-ral/imxrt1176_cm4", + "dep:rtt-target", + "dep:panic-rtt-target", +] imxrt1170evk-cm7-ram = [ "ram", "imxrt1170evk-cm7", diff --git a/board/build.rs b/board/build.rs index 1f4e207..8709852 100644 --- a/board/build.rs +++ b/board/build.rs @@ -79,6 +79,23 @@ fn main() { .build() .unwrap() } + "imxrt1170evk_cm4" => imxrt_rt::RuntimeBuilder::in_flash( + imxrt_rt::Family::Imxrt1170, + 256 * 1024, + 87 * 1024, + ) + .core(imxrt_rt::Core::Secondary) + .text(imxrt_rt::Memory::Itcm) + .rodata(imxrt_rt::Memory::Dtcm) + .data(imxrt_rt::Memory::Dtcm) + .vectors(imxrt_rt::Memory::Dtcm) + .bss(imxrt_rt::Memory::Dtcm) + .uninit(imxrt_rt::Memory::Dtcm) + .stack(imxrt_rt::Memory::Dtcm) + .heap(imxrt_rt::Memory::Ocram) + .heap_size(2 * 1024) + .build() + .unwrap(), _ => continue, } break; diff --git a/board/src/imxrt1170evk_cm4.rs b/board/src/imxrt1170evk_cm4.rs new file mode 100644 index 0000000..0f6057c --- /dev/null +++ b/board/src/imxrt1170evk_cm4.rs @@ -0,0 +1,36 @@ +//! Support for booting the Cortex M4 on the i.MX RT 1170 EVK. + +use crate::ral; + +#[cfg(target_arch = "arm")] +use panic_rtt_target as _; + +const LED_OFFSET: u32 = 3; + +pub mod rtic_support { + pub use crate::ral::NVIC_PRIO_BITS; + #[allow(non_snake_case)] // For RTIC trickery... + pub mod Interrupt { + pub const PIT: crate::ral::Interrupt = crate::ral::Interrupt::PIT1; + } + pub use Interrupt as interrupt; +} + +pub fn prepare(timer_delay_microseconds: u32) -> Option<crate::Resources> { + #[cfg(target_arch = "arm")] + rtt_target::rtt_init_print!(); + + let iomuxc = unsafe { ral::iomuxc::IOMUXC::instance() }; + ral::modify_reg!(ral::iomuxc, iomuxc, SW_MUX_CTL_PAD_GPIO_AD_04, MUX_MODE: 5); + + let ccm = unsafe { ral::ccm::CCM::instance() }; + // Enable LPCG for GPIOs. + ral::write_reg!(ral::ccm, ccm, LPCG51_DIRECT, 1); + + let gpio = unsafe { ral::gpio::GPIO3::instance() }; + let pit = crate::prepare_pit(timer_delay_microseconds)?; + Some(crate::Resources { + pit, + led: crate::Led::new(LED_OFFSET, &gpio), + }) +} diff --git a/board/src/lib.rs b/board/src/lib.rs index fa2afcd..0f60c66 100644 --- a/board/src/lib.rs +++ b/board/src/lib.rs @@ -22,6 +22,12 @@ cfg_if::cfg_if! { mod imxrt1170evk_cm7; pub use imxrt1170evk_cm7::*; + } else if #[cfg(feature = "imxrt1170evk-cm4")] { + mod shared { pub mod imxrt11xx; } + use shared::imxrt11xx::prepare_pit; + + mod imxrt1170evk_cm4; + pub use imxrt1170evk_cm4::*; } else { compile_error!("No board feature selected!"); } |
