From f6615b0fb8172e7b4d42f153d7a4f6afe6d8350c Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 10 Mar 2017 23:34:59 -0500 Subject: reformat --- src/ctxt.rs | 12 +++++++++--- src/macros.rs | 36 +++++++++++++++++++++++++++--------- src/peripheral/mod.rs | 30 ++++++++++++++++++++---------- src/register/mod.rs | 4 ++-- 4 files changed, 58 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/ctxt.rs b/src/ctxt.rs index 2fdd182..0a05ecb 100644 --- a/src/ctxt.rs +++ b/src/ctxt.rs @@ -5,14 +5,16 @@ use core::cell::UnsafeCell; /// Data local to a context pub struct Local - where Ctxt: Context +where + Ctxt: Context, { _ctxt: PhantomData, data: UnsafeCell, } impl Local - where Ctxt: Context +where + Ctxt: Context, { /// Initializes context local data pub const fn new(value: T) -> Self { @@ -28,7 +30,11 @@ impl Local } } -unsafe impl Sync for Local where Ctxt: Context {} +unsafe impl Sync for Local +where + Ctxt: Context, +{ +} /// A token unique to a context pub unsafe trait Context {} diff --git a/src/macros.rs b/src/macros.rs index 1c39f18..1ee2cf2 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1,31 +1,49 @@ /// Macro for printing to the **host's** standard stderr #[macro_export] macro_rules! ehprint { - ($s:expr) => ($crate::semihosting:::io:ewrite_str($s)); - ($($arg:tt)*) => ($crate::semihosting::io::ewrite_fmt(format_args!($($arg)*))); + ($s:expr) => { + $crate::semihosting:::io:ewrite_str($s); + }; + ($($arg:tt)*) => { + $crate::semihosting::io::ewrite_fmt(format_args!($($arg)*)); + }; } /// Macro for printing to the **host's** standard error, with a newline. #[macro_export] macro_rules! ehprintln { () => (ehprint!("\n")); - ($fmt:expr) => (ehprint!(concat!($fmt, "\n"))); - ($fmt:expr, $($arg:tt)*) => (ehprint!(concat!($fmt, "\n"), $($arg)*)); + ($fmt:expr) => { + ehprint!(concat!($fmt, "\n")); + }; + ($fmt:expr, $($arg:tt)*) => { + ehprint!(concat!($fmt, "\n"), $($arg)*); + }; } /// Macro for printing to the **host's** standard output #[macro_export] macro_rules! hprint { - ($s:expr) => ($crate::semihosting::io::write_str($s)); - ($($arg:tt)*) => ($crate::semihosting::io::write_fmt(format_args!($($arg)*))); + ($s:expr) => { + $crate::semihosting::io::write_str($s); + }; + ($($arg:tt)*) => { + $crate::semihosting::io::write_fmt(format_args!($($arg)*)); + }; } /// Macro for printing to the **host's** standard output, with a newline. #[macro_export] macro_rules! hprintln { - () => (hprint!("\n")); - ($fmt:expr) => (hprint!(concat!($fmt, "\n"))); - ($fmt:expr, $($arg:tt)*) => (hprint!(concat!($fmt, "\n"), $($arg)*)); + () => { + hprint!("\n"); + }; + ($fmt:expr) => { + hprint!(concat!($fmt, "\n")); + }; + ($fmt:expr, $($arg:tt)*) => { + hprint!(concat!($fmt, "\n"), $($arg)*); + }; } /// Macro for sending a formatted string through an ITM channel diff --git a/src/peripheral/mod.rs b/src/peripheral/mod.rs index f9ee217..1f9e147 100644 --- a/src/peripheral/mod.rs +++ b/src/peripheral/mod.rs @@ -52,7 +52,8 @@ pub const TPIU: Peripheral = unsafe { Peripheral::new(0xE004_0000) }; /// A peripheral pub struct Peripheral - where T: 'static +where + T: 'static, { address: usize, _marker: PhantomData<&'static mut T>, @@ -290,7 +291,8 @@ pub struct Nvic { impl Nvic { /// Clears `interrupt`'s pending state pub fn clear_pending(&self, interrupt: I) - where I: Nr + where + I: Nr, { let nr = interrupt.nr(); @@ -299,7 +301,8 @@ impl Nvic { /// Disables `interrupt` pub fn disable(&self, interrupt: I) - where I: Nr + where + I: Nr, { let nr = interrupt.nr(); @@ -308,7 +311,8 @@ impl Nvic { /// Enables `interrupt` pub fn enable(&self, interrupt: I) - where I: Nr + where + I: Nr, { let nr = interrupt.nr(); @@ -321,7 +325,8 @@ impl Nvic { /// `1` and `2` have the same priority. Also for NVIC priorities, a lower /// value (e.g. `16`) has higher priority than a larger value (e.g. `32`). pub fn get_priority(&self, interrupt: I) -> u8 - where I: Nr + where + I: Nr, { let nr = interrupt.nr(); @@ -330,7 +335,8 @@ impl Nvic { /// Is `interrupt` active or pre-empted and stacked pub fn is_active(&self, interrupt: I) -> bool - where I: Nr + where + I: Nr, { let nr = interrupt.nr(); let mask = 1 << (nr % 32); @@ -340,7 +346,8 @@ impl Nvic { /// Checks if `interrupt` is enabled pub fn is_enabled(&self, interrupt: I) -> bool - where I: Nr + where + I: Nr, { let nr = interrupt.nr(); let mask = 1 << (nr % 32); @@ -350,7 +357,8 @@ impl Nvic { /// Checks if `interrupt` is pending pub fn is_pending(&self, interrupt: I) -> bool - where I: Nr + where + I: Nr, { let nr = interrupt.nr(); let mask = 1 << (nr % 32); @@ -360,7 +368,8 @@ impl Nvic { /// Forces `interrupt` into pending state pub fn set_pending(&self, interrupt: I) - where I: Nr + where + I: Nr, { let nr = interrupt.nr(); @@ -372,7 +381,8 @@ impl Nvic { /// NOTE See `get_priority` method for an explanation of how NVIC priorities /// work. pub fn set_priority(&self, interrupt: I, prio: u8) - where I: Nr + where + I: Nr, { let nr = interrupt.nr(); diff --git a/src/register/mod.rs b/src/register/mod.rs index e3321a6..17f6fda 100644 --- a/src/register/mod.rs +++ b/src/register/mod.rs @@ -8,8 +8,8 @@ //! - MSP //! - PRIMASK //! -//! The rest of registers (see list below) can be accessed in either, PRIVILEGED or UNPRIVILEGED, -//! mode. +//! The rest of registers (see list below) can be accessed in either, PRIVILEGED +//! or UNPRIVILEGED, mode. //! //! - APSR //! - LR -- cgit v1.2.3