aboutsummaryrefslogtreecommitdiff
path: root/crates/imxrt/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/imxrt/src/lib.rs')
-rw-r--r--crates/imxrt/src/lib.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/crates/imxrt/src/lib.rs b/crates/imxrt/src/lib.rs
new file mode 100644
index 0000000..781fc50
--- /dev/null
+++ b/crates/imxrt/src/lib.rs
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: MPL-2.0
+// SPDX-FileCopyrightText: Copyright 2025 Ian McIntyre
+
+#![no_std]
+#![feature(rustc_private)]
+extern crate fusible;
+
+pub use ral_registers::{Instance, modify_reg, read_reg, write_reg};
+
+pub mod ral {
+ pub use imxrt_drivers_enet as enet;
+ pub use imxrt_drivers_gpio as gpio;
+}
+
+pub mod drivers {
+ pub mod enet;
+ pub mod gpio;
+
+ /// TODO: remove this, use embedded-hal or something else.
+ pub trait ToggleOutput: Send + 'static {
+ fn toggle(&self);
+ }
+
+ /// TODO: remove this, use embedded-hal or something else.
+ pub trait BlockingInput: Send + 'static {
+ fn block_on_interrupt(&self);
+ }
+}
+
+/// TODO: A REAL RANDOM NUMBER GENERATOR.
+///
+/// This is needed by NetX Duo for port allocation.
+/// I'm being very lazy and spoofing the required
+/// implementation.
+#[unsafe(no_mangle)]
+pub extern "C" fn rand() -> core::ffi::c_int {
+ use core::sync::atomic::{AtomicI32, Ordering};
+ static SOME_RANDOM_NUMBER: AtomicI32 = AtomicI32::new(0);
+ SOME_RANDOM_NUMBER.fetch_add(1, Ordering::Relaxed)
+}