diff --git a/+adi/+ADRV9002/Rx.m b/+adi/+ADRV9002/Rx.m index aacd599c..ccd699d6 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 @@ -200,7 +206,7 @@ % hardware RSSIChannel1 end - + properties(Constant, Hidden) ENSMModeChannel0Set = matlab.system.StringSet({ ... 'calibrated','primed','rf_enabled'}); @@ -221,7 +227,7 @@ 'automatic','spi'}); DigitalGainControlModeChannel1Set = matlab.system.StringSet({ ... 'automatic','spi'}); - + InterfaceGainChannel0Set = matlab.system.StringSet({... '18dB', '12dB', '6dB', '0dB', '-6dB', '-12dB', '-18dB',... '-24dB', '-30dB','-36dB'}); @@ -230,6 +236,11 @@ '-24dB', '-30dB','-36dB'}); end + properties(Hidden) + InterfaceGainAvailableChannel0 + InterfaceGainAvailableChannel1 + end + properties (Hidden, Nontunable, Access = protected) isOutput = false; end @@ -264,6 +275,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) @@ -354,6 +381,7 @@ function set.InterfaceGainChannel0(obj, value) obj.InterfaceGainChannel0 = value; if obj.ConnectedToDevice + mustBeMember(value,obj.InterfaceGainAvailableChannel0); id = 'voltage0'; if strcmpi(obj.DigitalGainControlModeChannel0,'spi') &&... strcmpi(obj.ENSMModeChannel0,'rf_enabled') @@ -365,6 +393,7 @@ function set.InterfaceGainChannel1(obj, value) obj.InterfaceGainChannel1 = value; if obj.ConnectedToDevice + mustBeMember(value,obj.InterfaceGainAvailableChannel1); id = 'voltage1'; if strcmpi(obj.DigitalGainControlModeChannel1,'spi') &&... strcmpi(obj.ENSMModeChannel1,'rf_enabled') @@ -567,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 diff --git a/test/ADRV9002Tests.m b/test/ADRV9002Tests.m index b0f04853..3cb21d31 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) @@ -335,8 +335,9 @@ function testADRV9002ManualGainControl(testCase) rx.CustomStreamFileName = which('lte_5_cmos_api_68_0_6.stream'); rx.DigitalGainControlModeChannel0 = 'spi'; - rx.InterfaceGainChannel0 = '6dB'; + rx.InterfaceGainChannel0 = '0dB'; [~,valid] = rx(); + rx.InterfaceGainChannel0 = rx.InterfaceGainAvailableChannel0{1}; testCase.assertTrue(valid); end