From 765cd1d51349124de8749f34ee46dc13492478e3 Mon Sep 17 00:00:00 2001 From: occheung Date: Wed, 12 Aug 2020 12:28:33 +0800 Subject: [PATCH] cfg_reg: split enum into status and cfg --- src/config_register.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/config_register.rs b/src/config_register.rs index 5b40b3e..c2f72da 100644 --- a/src/config_register.rs +++ b/src/config_register.rs @@ -46,9 +46,9 @@ macro_rules! construct_bitmask { } } +// Bitmasks for CFG construct_bitmask!(CFGMask; - // Bitmasks for CFG write - RF_SW, 0, 4, // Reuse RF_SW for Status register + RF_SW, 0, 4, LED, 4, 4, PROFILE, 8, 3, IO_UPDATE, 12, 1, @@ -58,8 +58,12 @@ construct_bitmask!(CFGMask; RST, 19, 1, IO_RST, 20, 1, CLK_SEL1, 21, 1, - DIV, 22, 2, - // BitMasks for CFG read + DIV, 22, 2 +); + +// BitMasks for CFG read +construct_bitmask!(StatusMask; + RF_SW, 0, 4, SMP_ERR, 4, 4, PLL_LOCK, 8, 4, IFC_MODE, 12, 4, @@ -129,7 +133,7 @@ where /* * Return status */ - pub fn get_status(&mut self, status_type: CFGMask) -> Result> { + pub fn get_status(&mut self, status_type: StatusMask) -> Result> { match self.set_all_configurations() { Ok(val) => Ok(((val & status_type.get_bitmask()) >> status_type.get_shift()) as u8), Err(e) => Err(e),