aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2017-05-25 16:39:26 -0500
committerGravatar Jorge Aparicio <jorge@japaric.io> 2017-05-25 16:39:26 -0500
commitb1e54883ac48e1a13df01648158eecd497f91d10 (patch)
tree52a300182d358e0832b39ad39e1b3018ebad4f8b /src
parentc1465b211704a0c993ceb9df511ebf6d085d683c (diff)
downloadrtic-b1e54883ac48e1a13df01648158eecd497f91d10.tar.gz
rtic-b1e54883ac48e1a13df01648158eecd497f91d10.tar.zst
rtic-b1e54883ac48e1a13df01648158eecd497f91d10.zip
make the register_block field optional in the peripherals! macro
with svd2rust 0.8.x peripheral types are written in UPPERCASE and match their names so specifying the type in the register_block field is no longer necessary.
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index de7fd194..81078d4e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -765,6 +765,9 @@ pub unsafe trait LessThanOrEqual<RHS> {}
///
/// # Example
///
+/// NOTE With device crates generated using svd2rust 0.8+ you can omit the
+/// register_block field.
+///
/// ``` ignore
/// #[macro_use]
/// extern crate cortex_m_rtfm;
@@ -797,6 +800,19 @@ macro_rules! peripherals {
$crate::Peripheral<::$device::$RegisterBlock, $crate::$C> =
unsafe { $crate::Peripheral::_new(::$device::$PERIPHERAL) };
)+
+ };
+ ($device:ident, {
+ $($PERIPHERAL:ident: Peripheral {
+ ceiling: $C:ident,
+ },)+
+ }) => {
+ $(
+ #[allow(private_no_mangle_statics)]
+ #[no_mangle]
+ static $PERIPHERAL:
+ $crate::Peripheral<::$device::$PERIPHERAL, $crate::$C> =
+ unsafe { $crate::Peripheral::_new(::$device::$PERIPHERAL) };
+ )+
}
}