aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml3
-rw-r--r--src/lib.rs2
-rw-r--r--src/macros.rs5
3 files changed, 7 insertions, 3 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 5885c6b..82712ee 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,6 +13,7 @@ version = "0.4.2"
aligned = "0.1.1"
bare-metal = "0.1.0"
volatile-register = "0.2.0"
+untagged-option = "0.1.1"
[features]
-cm7-r0p1 = [] \ No newline at end of file
+cm7-r0p1 = []
diff --git a/src/lib.rs b/src/lib.rs
index 694d1b2..6af60d7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -15,6 +15,7 @@
extern crate aligned;
extern crate bare_metal;
+extern crate untagged_option;
extern crate volatile_register;
#[macro_use]
@@ -31,3 +32,4 @@ pub mod peripheral;
pub mod register;
pub use peripheral::Peripherals;
+pub use untagged_option::UntaggedOption;
diff --git a/src/macros.rs b/src/macros.rs
index c9a32c2..c5799bf 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -54,13 +54,14 @@ macro_rules! singleton {
(: $ty:ty = $expr:expr) => {
$crate::interrupt::free(|_| unsafe {
static mut USED: bool = false;
- static mut VAR: $ty = $expr;
+ static mut VAR: $crate::UntaggedOption<$ty> = $crate::UntaggedOption { none: () };
if USED {
None
} else {
USED = true;
- let var: &'static mut _ = &mut VAR;
+ VAR.some = $expr;
+ let var: &'static mut _ = &mut VAR.some;
Some(var)
}
})