aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Greig <adam@adamgreig.com>2021-09-23 23:26:57 +0100
committerGitHub <noreply@github.com>2021-09-23 23:26:57 +0100
commit587e8bd658da6bdfe4da99416b4fa31b93575f77 (patch)
tree67690bbff6c2d8a1a05f651e0096fa384141022a /src
parent55168100e1fe885587e2a4f7ad555139a396a720 (diff)
parente65acf5ccf64563b4fc91320dd1075c520ef931a (diff)
Merge pull request #4 from Disasm/prevent-masking
Prevent masking value variables with imports
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 6122f01..52401d6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -280,7 +280,11 @@ macro_rules! write_reg {
use $periph::{*};
#[allow(unused_imports)]
(*$instance).$reg.write(
- $({ use $periph::{$reg::$field::{mask, offset, W::*, RW::*}}; ($value << offset) & mask }) | *
+ $({
+ use $periph::{$reg::$field::{W::*, RW::*}};
+ ($value << { use $periph::{$reg::$field::offset}; offset })
+ & { use $periph::{$reg::$field::mask}; mask }
+ }) | *
);
}};
( $periph:path, $instance:expr, $reg:ident, $value:expr ) => {{
@@ -410,7 +414,12 @@ macro_rules! modify_reg {
#[allow(unused_imports)]
(*$instance).$reg.write(
((*$instance).$reg.read() & !( $({ use $periph::{$reg::$field::mask}; mask }) | * ))
- | $({ use $periph::{$reg::$field::{mask, offset, W::*, RW::*}}; ($value << offset) & mask }) | *);
+ | $({
+ use $periph::{$reg::$field::{W::*, RW::*}};
+ ($value << { use $periph::{$reg::$field::offset}; offset })
+ & { use $periph::{$reg::$field::mask}; mask }
+ }) | *
+ );
}};
( $periph:path, $instance:expr, $reg:ident, $fn:expr ) => {{
#[allow(unused_imports)]