From d9b1667cea09e9ecf9958ee7f43ca20c8b918dcf Mon Sep 17 00:00:00 2001 From: Pagadarai Date: Wed, 9 Oct 2024 13:59:54 -0500 Subject: [PATCH 1/8] ADRV9002: Added properties to access Rx interface gains available Signed-off-by: Pagadarai --- +adi/+ADRV9002/Rx.m | 32 ++++++++++++++++++++++++-------- test/ADRV9002Tests.m | 4 ++-- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/+adi/+ADRV9002/Rx.m b/+adi/+ADRV9002/Rx.m index aacd599c..88b0e153 100644 --- a/+adi/+ADRV9002/Rx.m +++ b/+adi/+ADRV9002/Rx.m @@ -200,7 +200,7 @@ % hardware RSSIChannel1 end - + properties(Constant, Hidden) ENSMModeChannel0Set = matlab.system.StringSet({ ... 'calibrated','primed','rf_enabled'}); @@ -221,15 +221,13 @@ 'automatic','spi'}); DigitalGainControlModeChannel1Set = matlab.system.StringSet({ ... 'automatic','spi'}); - - InterfaceGainChannel0Set = matlab.system.StringSet({... - '18dB', '12dB', '6dB', '0dB', '-6dB', '-12dB', '-18dB',... - '-24dB', '-30dB','-36dB'}); - InterfaceGainChannel1Set = matlab.system.StringSet({... - '18dB', '12dB', '6dB', '0dB', '-6dB', '-12dB', '-18dB',... - '-24dB', '-30dB','-36dB'}); end + properties(Hidden) + InterfaceGainAvailableChannel0 + InterfaceGainAvailableChannel1 + end + properties (Hidden, Nontunable, Access = protected) isOutput = false; end @@ -264,6 +262,22 @@ value = NaN; end end + function values = get.InterfaceGainAvailableChannel0(obj) + if obj.ConnectedToDevice + values = obj.getAttributeRAW('voltage0','interface_gain_available',false); + values = strsplit(values); + else + values = NaN; + end + end + function values = get.InterfaceGainAvailableChannel1(obj) + if obj.ConnectedToDevice + values = obj.getAttributeRAW('voltage0','interface_gain_available',false); + values = strsplit(values); + else + values = NaN; + end + end % Check ENSMModeChannel0 function set.ENSMModeChannel0(obj, value) @@ -352,6 +366,7 @@ % Check InterfaceGainChannel0 function set.InterfaceGainChannel0(obj, value) + mustBeMember(value,obj.InterfaceGainAvailableChannel0); obj.InterfaceGainChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; @@ -363,6 +378,7 @@ end % Check InterfaceGainChannel1 function set.InterfaceGainChannel1(obj, value) + mustBeMember(value,obj.InterfaceGainAvailableChannel1); obj.InterfaceGainChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; diff --git a/test/ADRV9002Tests.m b/test/ADRV9002Tests.m index b0f04853..3dba5825 100644 --- a/test/ADRV9002Tests.m +++ b/test/ADRV9002Tests.m @@ -321,7 +321,7 @@ function testADRV9002ManualGainControlError(testCase) rx.CustomStreamFileName = which('lte_5_cmos_api_68_0_6.stream'); rx.DigitalGainControlModeChannel0 = 'spi'; - rx.InterfaceGainChannel0 = '6dB'; + rx.InterfaceGainChannel0 = rx.InterfaceGainAvailableChannel0{1}; verifyError(testCase, @() rx(), ?MException); end @@ -335,7 +335,7 @@ function testADRV9002ManualGainControl(testCase) rx.CustomStreamFileName = which('lte_5_cmos_api_68_0_6.stream'); rx.DigitalGainControlModeChannel0 = 'spi'; - rx.InterfaceGainChannel0 = '6dB'; + rx.InterfaceGainChannel0 = rx.InterfaceGainAvailableChannel0{1}; [~,valid] = rx(); testCase.assertTrue(valid); end From ee6d0d999b4b88faeb725158288d0830760e5842 Mon Sep 17 00:00:00 2001 From: Pagadarai Date: Wed, 9 Oct 2024 14:27:41 -0500 Subject: [PATCH 2/8] ADRV9002: Update to check interface gain available only when connected to device Signed-off-by: Pagadarai --- +adi/+ADRV9002/Rx.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/+adi/+ADRV9002/Rx.m b/+adi/+ADRV9002/Rx.m index 88b0e153..4542dcc6 100644 --- a/+adi/+ADRV9002/Rx.m +++ b/+adi/+ADRV9002/Rx.m @@ -366,9 +366,9 @@ % Check InterfaceGainChannel0 function set.InterfaceGainChannel0(obj, value) - mustBeMember(value,obj.InterfaceGainAvailableChannel0); obj.InterfaceGainChannel0 = value; if obj.ConnectedToDevice + mustBeMember(value,obj.InterfaceGainAvailableChannel0); id = 'voltage0'; if strcmpi(obj.DigitalGainControlModeChannel0,'spi') &&... strcmpi(obj.ENSMModeChannel0,'rf_enabled') @@ -378,9 +378,9 @@ end % Check InterfaceGainChannel1 function set.InterfaceGainChannel1(obj, value) - mustBeMember(value,obj.InterfaceGainAvailableChannel1); obj.InterfaceGainChannel1 = value; if obj.ConnectedToDevice + mustBeMember(value,obj.InterfaceGainAvailableChannel1); id = 'voltage1'; if strcmpi(obj.DigitalGainControlModeChannel1,'spi') &&... strcmpi(obj.ENSMModeChannel1,'rf_enabled') From 36acae04463adff865b560833ec53d818475ddc0 Mon Sep 17 00:00:00 2001 From: Pagadarai Date: Wed, 9 Oct 2024 14:38:14 -0500 Subject: [PATCH 3/8] ADRV9002: Updated tests since InterfaceGainAvailable isnt filled until connected to device Signed-off-by: Pagadarai --- test/ADRV9002Tests.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/ADRV9002Tests.m b/test/ADRV9002Tests.m index 3dba5825..7042ecd8 100644 --- a/test/ADRV9002Tests.m +++ b/test/ADRV9002Tests.m @@ -321,7 +321,7 @@ function testADRV9002ManualGainControlError(testCase) rx.CustomStreamFileName = which('lte_5_cmos_api_68_0_6.stream'); rx.DigitalGainControlModeChannel0 = 'spi'; - rx.InterfaceGainChannel0 = rx.InterfaceGainAvailableChannel0{1}; + rx.InterfaceGainChannel0 = '0dB'; verifyError(testCase, @() rx(), ?MException); end @@ -335,8 +335,9 @@ function testADRV9002ManualGainControl(testCase) rx.CustomStreamFileName = which('lte_5_cmos_api_68_0_6.stream'); rx.DigitalGainControlModeChannel0 = 'spi'; - rx.InterfaceGainChannel0 = rx.InterfaceGainAvailableChannel0{1}; + rx.InterfaceGainChannel0 = '0dB'; [~,valid] = rx(); + rx.InterfaceGainChannel0 = rx.InterfaceGainAvailableChannel0{1}; testCase.assertTrue(valid); end From ffdf2638de1871e3661d5dfbed4a4c2741e23281 Mon Sep 17 00:00:00 2001 From: Pagadarai Date: Fri, 18 Oct 2024 11:09:16 -0500 Subject: [PATCH 4/8] ADRV9002: Added back string sets for interface gains Signed-off-by: Pagadarai --- +adi/+ADRV9002/Rx.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/+adi/+ADRV9002/Rx.m b/+adi/+ADRV9002/Rx.m index 4542dcc6..c5b94460 100644 --- a/+adi/+ADRV9002/Rx.m +++ b/+adi/+ADRV9002/Rx.m @@ -221,6 +221,13 @@ 'automatic','spi'}); DigitalGainControlModeChannel1Set = matlab.system.StringSet({ ... 'automatic','spi'}); + + InterfaceGainChannel0Set = matlab.system.StringSet({... + '18dB', '12dB', '6dB', '0dB', '-6dB', '-12dB', '-18dB',... + '-24dB', '-30dB','-36dB'}); + InterfaceGainChannel1Set = matlab.system.StringSet({... + '18dB', '12dB', '6dB', '0dB', '-6dB', '-12dB', '-18dB',... + '-24dB', '-30dB','-36dB'}); end properties(Hidden) From ee6b158b722d1403bcecd9eaf7a5b9962c77f4e8 Mon Sep 17 00:00:00 2001 From: Pagadarai Date: Fri, 18 Oct 2024 11:11:48 -0500 Subject: [PATCH 5/8] ADRV9002 Rx: Updated docstrings to indicate that interface gain setting depends on the profile loaded Signed-off-by: Pagadarai --- +adi/+ADRV9002/Rx.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/+adi/+ADRV9002/Rx.m b/+adi/+ADRV9002/Rx.m index c5b94460..61071e79 100644 --- a/+adi/+ADRV9002/Rx.m +++ b/+adi/+ADRV9002/Rx.m @@ -28,7 +28,10 @@ % For narrowband applications higher levels of interface gain % should be used (0:18) to allow signal level and analog noise to % dominate. For wideband applications this gain should be reduced - % or disabled since quantization noise is minimal. + % or disabled since quantization noise is minimal. Note that the + % available options for this gain depend on the profile loaded + % and picking an option outside of those options generates an + % error. InterfaceGainChannel0 = '0dB'; %InterfaceGainChannel1 Interface Gain Channel 1 % This is the final gain in the digital path with possible @@ -37,7 +40,10 @@ % For narrowband applications higher levels of interface gain % should be used (0:18) to allow signal level and analog noise to % dominate. For wideband applications this gain should be reduced - % or disabled since quantization noise is minimal. + % or disabled since quantization noise is minimal. Note that the + % available options for this gain depend on the profile loaded + % and picking an option outside of those options generates an + % error. InterfaceGainChannel1 = '0dB'; %DigitalGainControlModeChannel0 Digital Gain Control Mode Channel 0 From 0845b78c1472684b9191de1fa137205262bb17c2 Mon Sep 17 00:00:00 2001 From: Pagadarai Date: Fri, 18 Oct 2024 11:15:56 -0500 Subject: [PATCH 6/8] ADRV9002 Test: Updated RxInterfaceGain to test for verifyGreaterThanOrEqual instead of verifyGreaterThan Signed-off-by: Pagadarai --- test/ADRV9002Tests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ADRV9002Tests.m b/test/ADRV9002Tests.m index 7042ecd8..0ec95809 100644 --- a/test/ADRV9002Tests.m +++ b/test/ADRV9002Tests.m @@ -122,7 +122,7 @@ function testADRV9002RxInterfaceGain(testCase,InterfaceGain) [out, valid] = rx(); rx.release(); testCase.verifyTrue(valid); - testCase.verifyGreaterThan(sum(abs(double(out))),0); + testCase.verifyGreaterThanOrEqual(sum(abs(double(out))),0); end function testADRV9002RxTracking(testCase,Tracking) From cb3e1fe32a191d299071b988423a84f8ff555aad Mon Sep 17 00:00:00 2001 From: Pagadarai Date: Fri, 18 Oct 2024 11:21:48 -0500 Subject: [PATCH 7/8] ADRV9002 Rx: Updated setupinit to set interface gains after checking available gains Signed-off-by: Pagadarai --- +adi/+ADRV9002/Rx.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/+adi/+ADRV9002/Rx.m b/+adi/+ADRV9002/Rx.m index 61071e79..ccd699d6 100644 --- a/+adi/+ADRV9002/Rx.m +++ b/+adi/+ADRV9002/Rx.m @@ -596,10 +596,12 @@ function setupInit(obj) end if strcmpi(obj.DigitalGainControlModeChannel0,'spi') && strcmpi(obj.ENSMModeChannel0,'rf_enabled') + mustBeMember(obj.InterfaceGainChannel0,obj.InterfaceGainAvailableChannel0); obj.setAttributeRAW('voltage0','interface_gain',obj.InterfaceGainChannel0,false); end if strcmpi(obj.DigitalGainControlModeChannel1,'spi') && strcmpi(obj.ENSMModeChannel1,'rf_enabled') && channelsAval == 2 + mustBeMember(obj.InterfaceGainChannel1,obj.InterfaceGainAvailableChannel1); obj.setAttributeRAW('voltage1','interface_gain',obj.InterfaceGainChannel1,false); end From f199b28bc1c93cc97e91023570a99cd62627043c Mon Sep 17 00:00:00 2001 From: Pagadarai Date: Fri, 18 Oct 2024 11:57:18 -0500 Subject: [PATCH 8/8] ADRV9002 tests: Reverted gain setting in ManualGainControlError to cause the test to fail Signed-off-by: Pagadarai --- test/ADRV9002Tests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ADRV9002Tests.m b/test/ADRV9002Tests.m index 0ec95809..3cb21d31 100644 --- a/test/ADRV9002Tests.m +++ b/test/ADRV9002Tests.m @@ -321,7 +321,7 @@ function testADRV9002ManualGainControlError(testCase) rx.CustomStreamFileName = which('lte_5_cmos_api_68_0_6.stream'); rx.DigitalGainControlModeChannel0 = 'spi'; - rx.InterfaceGainChannel0 = '0dB'; + rx.InterfaceGainChannel0 = '6dB'; verifyError(testCase, @() rx(), ?MException); end