From c7a9b9f3d4b9e71303c7b988d2bd916c2e4df9bc Mon Sep 17 00:00:00 2001 From: Ian McIntyre Date: Tue, 2 Aug 2022 06:21:12 -0400 Subject: First commit --- board/src/teensy4.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 board/src/teensy4.rs (limited to 'board/src/teensy4.rs') diff --git a/board/src/teensy4.rs b/board/src/teensy4.rs new file mode 100644 index 0000000..28587cd --- /dev/null +++ b/board/src/teensy4.rs @@ -0,0 +1,37 @@ +//! Teensy4 support. + +use crate::ral; + +#[cfg(target_arch = "arm")] +use teensy4_fcb as _; +#[cfg(target_arch = "arm")] +use teensy4_panic as _; + +const LED_OFFSET: u32 = 3; + +pub mod rtic_support { + pub use crate::ral::*; +} + +/// Prepare the board for the examples. +/// +/// Call this first. Panics if something went wrong. +pub fn prepare(timer_delay_microseconds: u32) -> Option { + let iomuxc = unsafe { ral::iomuxc::IOMUXC::instance() }; + // Set the GPIO pad to a GPIO function (ALT 5) + ral::write_reg!(ral::iomuxc, iomuxc, SW_MUX_CTL_PAD_GPIO_B0_03, 5); + // Increase drive strength, but leave other fields at their current value... + ral::modify_reg!( + ral::iomuxc, + iomuxc, + SW_PAD_CTL_PAD_GPIO_B0_03, + DSE: DSE_7_R0_7 + ); + + let pit = crate::prepare_pit(timer_delay_microseconds)?; + let gpio2 = unsafe { ral::gpio::GPIO2::instance() }; + Some(crate::Resources { + led: crate::Led::new(LED_OFFSET, &gpio2), + pit, + }) +} -- cgit v1.2.3