From b577c8b715bc70e4f06f94ab4fe0bdea9ccde220 Mon Sep 17 00:00:00 2001 From: occheung Date: Wed, 30 Sep 2020 15:57:06 +0800 Subject: [PATCH] dds: strictly enforce ~lsb_first and sdio_input_only --- src/dds.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/dds.rs b/src/dds.rs index ec398ea..f55ce91 100644 --- a/src/dds.rs +++ b/src/dds.rs @@ -335,7 +335,7 @@ where pub fn set_configurations(&mut self, mask_pairs: &mut[(DDSCFRMask, u32)]) -> Result<(), Error> { let mut data_array = self.get_all_configurations()?; for index in 0..mask_pairs.len() { - // Reject any attempt to rewrite LSB_FIRST and SBIO_INPUT_ONLY + // Reject any attempt to rewrite LSB_FIRST and SDIO_INPUT_ONLY if mask_pairs[index].0 == DDSCFRMask::LSB_FIRST || mask_pairs[index].0 == DDSCFRMask::SDIO_IN_ONLY { continue; } @@ -346,6 +346,9 @@ where _ => panic!("Invalid DDSCFRMask!"), }; } + // Deterministically maintain LSB_FIRST and SDIO_INPUT_ONLY + DDSCFRMask::LSB_FIRST.set_data_by_arg(&mut data_array[0], 0); + DDSCFRMask::SDIO_IN_ONLY.set_data_by_arg(&mut data_array[0], 1); self.set_all_configurations(data_array.clone()) } @@ -862,7 +865,9 @@ macro_rules! impl_register_io { } self.spi.transfer(&mut arr) .map(|_| ()) - .map_err(Error::SPI) + .map_err(Error::SPI)?; + debug!("Write register: {:X}, Bytes: {:X?}", addr, bytes); + Ok(()) }, )* _ => panic!("Bad address for DDS writing.") @@ -885,7 +890,9 @@ macro_rules! impl_register_io { Ok(bytes) }, Err(e) => Err(e), - } + }; + debug!("Read register: {:X}, Bytes: {:X?}", addr, bytes); + Ok(bytes) }, )* _ => panic!("Bad address for DDS reading.")