diff options
author | 2017-03-10 23:34:59 -0500 | |
---|---|---|
committer | 2017-03-10 23:34:59 -0500 | |
commit | f6615b0fb8172e7b4d42f153d7a4f6afe6d8350c (patch) | |
tree | 2bfd9e278d2dcfa70a132c9b7bc5d6ede640c97c | |
parent | 81c9d39ebc8e73baa396a60eb8d9f717a74b96f0 (diff) | |
download | cortex-m-f6615b0fb8172e7b4d42f153d7a4f6afe6d8350c.tar.gz cortex-m-f6615b0fb8172e7b4d42f153d7a4f6afe6d8350c.tar.zst cortex-m-f6615b0fb8172e7b4d42f153d7a4f6afe6d8350c.zip |
reformat
-rw-r--r-- | src/ctxt.rs | 12 | ||||
-rw-r--r-- | src/macros.rs | 36 | ||||
-rw-r--r-- | src/peripheral/mod.rs | 30 | ||||
-rw-r--r-- | src/register/mod.rs | 4 |
4 files changed, 58 insertions, 24 deletions
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<T, Ctxt> - where Ctxt: Context +where + Ctxt: Context, { _ctxt: PhantomData<Ctxt>, data: UnsafeCell<T>, } impl<T, Ctxt> Local<T, Ctxt> - where Ctxt: Context +where + Ctxt: Context, { /// Initializes context local data pub const fn new(value: T) -> Self { @@ -28,7 +30,11 @@ impl<T, Ctxt> Local<T, Ctxt> } } -unsafe impl<T, Ctxt> Sync for Local<T, Ctxt> where Ctxt: Context {} +unsafe impl<T, Ctxt> Sync for Local<T, Ctxt> +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<Tpiu> = unsafe { Peripheral::new(0xE004_0000) }; /// A peripheral pub struct Peripheral<T> - 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<I>(&self, interrupt: I) - where I: Nr + where + I: Nr, { let nr = interrupt.nr(); @@ -299,7 +301,8 @@ impl Nvic { /// Disables `interrupt` pub fn disable<I>(&self, interrupt: I) - where I: Nr + where + I: Nr, { let nr = interrupt.nr(); @@ -308,7 +311,8 @@ impl Nvic { /// Enables `interrupt` pub fn enable<I>(&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<I>(&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<I>(&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<I>(&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<I>(&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<I>(&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<I>(&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 |