[4330] | 1 | %------------------------------------------------------------------------- |
---|
[4332] | 2 | % WARPLab Framework |
---|
[4330] | 3 | % |
---|
| 4 | % Copyright 2013, Mango Communications. All rights reserved. |
---|
| 5 | % Distributed under the WARP license (http://warpproject.org/license) |
---|
| 6 | % |
---|
| 7 | % Chris Hunter (chunter [at] mangocomm.com) |
---|
| 8 | % Patrick Murphy (murphpo [at] mangocomm.com) |
---|
| 9 | % Erik Welsh (welsh [at] mangocomm.com) |
---|
| 10 | %------------------------------------------------------------------------- |
---|
| 11 | |
---|
[1973] | 12 | classdef wl_interface_group_X245 < wl_interface_group |
---|
[4330] | 13 | % Interface group object for the X245 transceivers |
---|
| 14 | % User code should not use this object directly -- the parent wl_node will |
---|
| 15 | % instantiate the appropriate interface group object for the hardware in use |
---|
[1975] | 16 | properties (SetAccess = protected) |
---|
[4330] | 17 | num_interface; % number of interfaces in this group |
---|
| 18 | ID; % vector of IDs for all interfaces in this group |
---|
| 19 | label; % cell vector of labels for the interfaces |
---|
| 20 | description; % description of this object |
---|
[1915] | 21 | end |
---|
[4330] | 22 | |
---|
[4687] | 23 | properties (SetAccess = public, Hidden = false, Constant = true) |
---|
| 24 | % Buffer State |
---|
| 25 | STANDBY = 0; |
---|
| 26 | RX = 1; |
---|
| 27 | TX = 2; |
---|
| 28 | end |
---|
| 29 | |
---|
[1948] | 30 | properties(Hidden = true,Constant = true) |
---|
[4330] | 31 | % These constants define specific command IDs used by this object. |
---|
| 32 | % Their C counterparts are found in wl_interface.h |
---|
| 33 | GRP = 'interface'; |
---|
| 34 | CMD_TX_EN = 1; % 0x000001 |
---|
| 35 | CMD_RX_EN = 2; % 0x000002 |
---|
| 36 | CMD_TX_RX_DIS = 3; % 0x000003 |
---|
[4686] | 37 | CMD_TX_RX_STATE = 4; % 0x000004 |
---|
| 38 | CMD_CHANNEL = 5; % 0x000005 |
---|
| 39 | CMD_TX_GAINS = 6; % 0x000006 |
---|
| 40 | CMD_RX_GAINS = 7; % 0x000007 |
---|
| 41 | CMD_TX_LPF_CORN_FREQ = 8; % 0x000008 |
---|
| 42 | CMD_RX_LPF_CORN_FREQ = 9; % 0x000009 |
---|
| 43 | CMD_RX_HPF_CORN_FREQ = 10; % 0x00000A |
---|
| 44 | CMD_RX_GAINCTRL_SRC = 11; % 0x00000B |
---|
| 45 | CMD_RX_RXHP_CTRL = 12; % 0x00000C |
---|
[4989] | 46 | CMD_RX_LPF_CORN_FREQ_FINE = 13; % 0x00000D |
---|
[1948] | 47 | end |
---|
[4330] | 48 | |
---|
[1915] | 49 | methods |
---|
[1973] | 50 | function obj = wl_interface_group_X245(varargin) |
---|
[4330] | 51 | obj.description = '2.4/5GHz RF Interface Group'; |
---|
| 52 | |
---|
[1915] | 53 | radioSel = varargin{1}; |
---|
[4330] | 54 | FMCMode = 0; |
---|
[1915] | 55 | |
---|
| 56 | if (nargin == 2) |
---|
| 57 | FMCMode = strcmpi(varargin{2},'w3'); |
---|
| 58 | end |
---|
| 59 | |
---|
[4330] | 60 | obj.ID = []; |
---|
[1915] | 61 | obj.label = {}; |
---|
| 62 | |
---|
| 63 | for n = radioSel |
---|
[4330] | 64 | obj.ID = [obj.ID, uint32(2.^((n - 1) + 28))]; |
---|
[1915] | 65 | if (FMCMode == 0 || n < 3) |
---|
[4330] | 66 | obj.label = [obj.label, {sprintf('RF%c',n+64)}]; |
---|
[1915] | 67 | else |
---|
[4330] | 68 | obj.label = [obj.label, {sprintf('RF%c (FMC RF%c)', (n + 64), (n + 62))}]; |
---|
[1915] | 69 | end |
---|
| 70 | end |
---|
| 71 | end |
---|
[4330] | 72 | |
---|
[1915] | 73 | function out = wl_ifcValid(obj,rfSel) |
---|
| 74 | rfSel = repmat(rfSel,size(obj.ID)); |
---|
[4330] | 75 | out = max(bitand(rfSel,obj.ID)>1); |
---|
[1915] | 76 | end |
---|
| 77 | |
---|
| 78 | function out = procCmd(obj, nodeInd, node, rfSel, cmdStr, varargin) |
---|
[4330] | 79 | % wl_interface procCmd(obj, nodeInd, node, rfSel, cmdStr, varargin) |
---|
| 80 | % obj: Node object (when called using dot notation) |
---|
| 81 | % nodeInd: Index of the current node, when wl_node is iterating over nodes |
---|
| 82 | % node: Current node object (the owner of this baseband) |
---|
| 83 | % rfSel: RF interface(s) to apply the interface command |
---|
| 84 | % cmdStr: Command string of the interface command |
---|
| 85 | % varargin: |
---|
| 86 | % [1:N} Command arguments |
---|
| 87 | % |
---|
[1915] | 88 | out = []; |
---|
[4330] | 89 | |
---|
[4686] | 90 | % Process the rfSel argument |
---|
[4330] | 91 | if(strcmp(rfSel, 'RF_ALL')) |
---|
[4686] | 92 | |
---|
| 93 | % If rfSel is the "magic string" 'RF_ALL', then select all RF interfaces |
---|
[4687] | 94 | rfSel = sum(obj.ID); |
---|
| 95 | num_interfaces = 1; |
---|
[4686] | 96 | |
---|
[1959] | 97 | else |
---|
[4686] | 98 | |
---|
[4687] | 99 | % RF interfaces specified by RF interface IDs |
---|
| 100 | num_interfaces = length(rfSel); |
---|
[1959] | 101 | end |
---|
[4687] | 102 | |
---|
[4330] | 103 | % Check to make sure this rfSel actually applies to me |
---|
[4687] | 104 | if(bitand(rfSel, sum(obj.ID)) ~= rfSel) |
---|
[2865] | 105 | error('Invalid interface selection'); |
---|
[1959] | 106 | end |
---|
| 107 | |
---|
[1915] | 108 | switch(lower(cmdStr)) |
---|
[4330] | 109 | %--------------------------------------------------------- |
---|
[1915] | 110 | case 'tx_en' |
---|
| 111 | % Enable transmit mode for selected interfaces |
---|
| 112 | % |
---|
| 113 | % Arguments: none |
---|
| 114 | % Returns: none |
---|
[4330] | 115 | % |
---|
[4687] | 116 | |
---|
| 117 | % Check interface selection |
---|
| 118 | if(num_interfaces ~= 1) |
---|
| 119 | error('%s: Requires scalar interface selection. If trying to enable multiple interfaces, use bitwise addition of interfaces: RFA + RFB.', cmdStr); |
---|
| 120 | end |
---|
| 121 | |
---|
[4330] | 122 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_TX_EN), rfSel); |
---|
[1975] | 123 | node.sendCmd(myCmd); |
---|
[4330] | 124 | |
---|
| 125 | %--------------------------------------------------------- |
---|
[1915] | 126 | case 'rx_en' |
---|
| 127 | % Enable receive mode for selected interfaces |
---|
| 128 | % |
---|
| 129 | % Arguments: none |
---|
| 130 | % Returns: none |
---|
[4330] | 131 | % |
---|
[4687] | 132 | |
---|
| 133 | % Check interface selection |
---|
| 134 | if(num_interfaces ~= 1) |
---|
| 135 | error('%s: Requires scalar interface selection. If trying to enable multiple interfaces, use bitwise addition of interfaces: RFA + RFB.', cmdStr); |
---|
| 136 | end |
---|
| 137 | |
---|
[4330] | 138 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_RX_EN), rfSel); |
---|
[1975] | 139 | node.sendCmd(myCmd); |
---|
[4330] | 140 | |
---|
| 141 | %--------------------------------------------------------- |
---|
[1915] | 142 | case 'tx_rx_dis' |
---|
[4330] | 143 | % Disable transmit and receive for selected interfaces (standby mode) |
---|
[1915] | 144 | % |
---|
| 145 | % Arguments: none |
---|
| 146 | % Returns: none |
---|
[4330] | 147 | % |
---|
[4687] | 148 | |
---|
| 149 | % Check interface selection |
---|
| 150 | if(num_interfaces ~= 1) |
---|
| 151 | error('%s: Requires scalar interface selection. If trying to disable multiple interfaces, use bitwise addition of interfaces: RFA + RFB.', cmdStr); |
---|
| 152 | end |
---|
| 153 | |
---|
[4330] | 154 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_TX_RX_DIS), rfSel); |
---|
[1975] | 155 | node.sendCmd(myCmd); |
---|
[4330] | 156 | |
---|
| 157 | %--------------------------------------------------------- |
---|
[4687] | 158 | case 'read_tx_rx_state' |
---|
| 159 | % Read the current state of the interface |
---|
| 160 | % |
---|
| 161 | % Requires BUFF_SEL: Yes |
---|
| 162 | % Arguments: none |
---|
| 163 | % Returns: Current state of the buffer: TX, RX or STANDBY |
---|
| 164 | % |
---|
| 165 | |
---|
| 166 | for ifc_index = 1:num_interfaces |
---|
| 167 | |
---|
| 168 | if(isSingleBuffer(rfSel(ifc_index)) == 0) |
---|
| 169 | error('%s: Buffer selection must be singular. Use vector notation for reading from multiple buffers e.g. [RFA, RFB]', cmdStr); |
---|
| 170 | end |
---|
| 171 | |
---|
| 172 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_TX_RX_STATE)); |
---|
| 173 | myCmd.addArgs(rfSel(ifc_index)); |
---|
| 174 | |
---|
| 175 | resp = node.sendCmd(myCmd); |
---|
| 176 | ret = resp.getArgs(); |
---|
| 177 | |
---|
[5617] | 178 | if(ret(1) == 0) |
---|
| 179 | out(ifc_index) = obj.STANDBY; |
---|
| 180 | elseif(ret(1) == 1) |
---|
| 181 | out(ifc_index) = obj.RX; |
---|
| 182 | elseif(ret(1) == 2) |
---|
| 183 | out(ifc_index) = obj.TX; |
---|
| 184 | else |
---|
| 185 | error('%s: Node returned an unknown buffer state.', cmdStr); |
---|
| 186 | end |
---|
[4687] | 187 | end |
---|
| 188 | |
---|
| 189 | %--------------------------------------------------------- |
---|
[1915] | 190 | case 'channel' |
---|
| 191 | % Tune selected interfaces to the specified band and channel |
---|
| 192 | % |
---|
| 193 | % Arguments: (float BAND, int CHAN) |
---|
[4330] | 194 | % BAND: Must be 2.4 or 5, to select 2.4GHz or 5GHz channels |
---|
[5616] | 195 | % CHAN: Must be integer in [1,14] for BAND=2.4, [1,44] for BAND=5 |
---|
[1915] | 196 | % Returns: none |
---|
| 197 | % |
---|
| 198 | % BAND and CHAN must be scalars (same values for all specified interfaces) or |
---|
[4330] | 199 | % 1-D vectors (one value per interface) with length equal to the length of the interface ID vector |
---|
[1915] | 200 | % |
---|
| 201 | % Band/Channel - Center Frequency Map: |
---|
[5619] | 202 | % ||||= 2.4GHz =||||= 5GHz =|| |
---|
| 203 | % || Chan || Freq || Chan || Freq || |
---|
| 204 | % || 1 || 2412 || 1 || 5180 || |
---|
| 205 | % || 2 || 2417 || 2 || 5190 || |
---|
| 206 | % || 3 || 2422 || 3 || 5200 || |
---|
| 207 | % || 4 || 2427 || 4 || 5220 || |
---|
| 208 | % || 5 || 2432 || 5 || 5230 || |
---|
| 209 | % || 6 || 2437 || 6 || 5240 || |
---|
| 210 | % || 7 || 2442 || 7 || 5260 || |
---|
| 211 | % || 8 || 2447 || 8 || 5270 || |
---|
| 212 | % || 9 || 2452 || 9 || 5280 || |
---|
| 213 | % || 10 || 2457 || 10 || 5300 || |
---|
| 214 | % || 11 || 2462 || 11 || 5310 || |
---|
| 215 | % || 12 || 2467 || 12 || 5320 || |
---|
| 216 | % || 13 || 2472 || 13 || 5500 || |
---|
| 217 | % || 14 || 2484 || 14 || 5510 || |
---|
| 218 | % || || || 15 || 5520 || |
---|
| 219 | % || || || 16 || 5540 || |
---|
| 220 | % || || || 17 || 5550 || |
---|
| 221 | % || || || 18 || 5560 || |
---|
| 222 | % || || || 19 || 5580 || |
---|
| 223 | % || || || 20 || 5590 || |
---|
| 224 | % || || || 21 || 5600 || |
---|
| 225 | % || || || 22 || 5620 || |
---|
| 226 | % || || || 23 || 5630 || |
---|
| 227 | % || || || 24 || 5640 || |
---|
| 228 | % || || || 25 || 5660 || |
---|
| 229 | % || || || 26 || 5670 || |
---|
| 230 | % || || || 27 || 5680 || |
---|
| 231 | % || || || 28 || 5700 || |
---|
| 232 | % || || || 29 || 5710 || |
---|
| 233 | % || || || 30 || 5720 || |
---|
| 234 | % || || || 31 || 5745 || |
---|
| 235 | % || || || 32 || 5755 || |
---|
| 236 | % || || || 33 || 5765 || |
---|
| 237 | % || || || 34 || 5785 || |
---|
| 238 | % || || || 35 || 5795 || |
---|
| 239 | % || || || 36 || 5805 || |
---|
| 240 | % || || || 37 || 5825 || |
---|
| 241 | % || || || 38 || 5860 || |
---|
| 242 | % || || || 39 || 5870 || |
---|
| 243 | % || || || 40 || 5875 || |
---|
| 244 | % || || || 41 || 5880 || |
---|
| 245 | % || || || 42 || 5885 || |
---|
| 246 | % || || || 43 || 5890 || |
---|
| 247 | % || || || 44 || 5865 || |
---|
[4330] | 248 | % |
---|
| 249 | if(isempty(varargin)) % read-back mode |
---|
[4687] | 250 | error('%s: Channel read back not implemented.', cmdStr); |
---|
[4330] | 251 | |
---|
| 252 | elseif(length(varargin) == 2) % write mode |
---|
[4687] | 253 | |
---|
| 254 | band = varargin{1}; |
---|
[1915] | 255 | channel = varargin{2}; |
---|
| 256 | |
---|
[4687] | 257 | for n = 1:num_interfaces |
---|
| 258 | |
---|
| 259 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_CHANNEL), rfSel(n)); |
---|
[1915] | 260 | |
---|
[4687] | 261 | % Check arguments |
---|
| 262 | if(length(band) == num_interfaces) |
---|
| 263 | node_band = band(n); |
---|
| 264 | else |
---|
| 265 | error('%s: Expects band selection to be a vector of length equal to the number of interfaces.', cmdStr); |
---|
[1915] | 266 | end |
---|
[4687] | 267 | |
---|
| 268 | if(length(channel) == num_interfaces) |
---|
| 269 | node_channel = channel(n); |
---|
| 270 | else |
---|
| 271 | error('%s: Expects channel selection to be a vector of length equal to the number of interfaces.', cmdStr); |
---|
[1915] | 272 | end |
---|
[4687] | 273 | |
---|
| 274 | if(node_band == 2.4) |
---|
| 275 | node_band = 0; |
---|
| 276 | if((node_channel < 1) || (node_channel > 14)) |
---|
| 277 | error('%s: Expects channel selection to be between [1,14] for the 2.4GHz band', cmdStr); |
---|
| 278 | end |
---|
| 279 | elseif(node_band == 5) |
---|
| 280 | node_band = 1; |
---|
[5613] | 281 | if((node_channel < 1) || (node_channel > 44)) |
---|
| 282 | error('%s: Expects channel selection to be between [1,44] for the 5GHz band', cmdStr); |
---|
[4687] | 283 | end |
---|
| 284 | else |
---|
| 285 | error('%s: Expects band selection 2.4 or 5', cmdStr); |
---|
| 286 | end |
---|
| 287 | |
---|
| 288 | myCmd.addArgs(node_band, node_channel); |
---|
| 289 | node.sendCmd(myCmd); |
---|
[1915] | 290 | end |
---|
| 291 | else |
---|
[4687] | 292 | error('%s: Expects two arguments: a band and a channel', cmdStr); |
---|
[1915] | 293 | end |
---|
[4330] | 294 | |
---|
| 295 | %--------------------------------------------------------- |
---|
[1915] | 296 | case 'tx_gains' |
---|
| 297 | % Sets the gains for the variable gain amplifiers in the MAX2829 Tx path |
---|
| 298 | % Refer to MAX2829 datasheet for curves of gain value vs actual gain at 2.4 and 5GHz |
---|
| 299 | % |
---|
| 300 | % Arguments: (int BB_GAIN, int RF_GAIN) |
---|
| 301 | % BB_GAIN: Must be integer in [0,1,2,3] for approx [-5, -3, -1.5, 0]dB baseband gain |
---|
| 302 | % RF_GAIN: Must be integer in [0:63] for approx [0:31]dB RF gain |
---|
| 303 | % Returns: none |
---|
| 304 | % |
---|
| 305 | % BB_GAIN and RF_GAIN must be scalars (same values for all specified interfaces) or |
---|
| 306 | % 1-D vectors (one value per interface) with length equal to the length of the interface ID vector |
---|
[3589] | 307 | % |
---|
| 308 | % NOTE: The parameters are in the order in which they are applied to the signal (ie baseband gain, then RF gain) |
---|
[4330] | 309 | % |
---|
| 310 | if(isempty(varargin)) % read-back mode |
---|
[4687] | 311 | error('%s: Tx gain read back not implemented.', cmdStr); |
---|
[4330] | 312 | |
---|
| 313 | elseif(length(varargin) == 2) % write mode |
---|
[4687] | 314 | |
---|
[1915] | 315 | bbGain = varargin{1}; |
---|
| 316 | rfGain = varargin{2}; |
---|
[4330] | 317 | |
---|
[4687] | 318 | for n = 1:num_interfaces |
---|
| 319 | |
---|
| 320 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_TX_GAINS), rfSel(n)); |
---|
| 321 | |
---|
| 322 | % Check arguments |
---|
| 323 | if(length(bbGain) == num_interfaces) |
---|
| 324 | node_bb_gain = bbGain(n); |
---|
| 325 | else |
---|
| 326 | error('%s: Expects baseband gain selection to be a vector of length equal to the number of interfaces.', cmdStr); |
---|
| 327 | end |
---|
| 328 | |
---|
| 329 | if(length(rfGain) == num_interfaces) |
---|
| 330 | node_rf_gain = rfGain(n); |
---|
| 331 | else |
---|
| 332 | error('%s: Expects rf gain selection to be a vector of length equal to the number of interfaces.', cmdStr); |
---|
| 333 | end |
---|
| 334 | |
---|
| 335 | if((node_bb_gain > 3) || (node_rf_gain > 63)) |
---|
| 336 | error('%s: Baseband gain must be in [0,3] and RF gain must be in [0,63]', cmdStr); |
---|
| 337 | end |
---|
[1915] | 338 | |
---|
[4687] | 339 | myCmd.addArgs(node_bb_gain, node_rf_gain); |
---|
| 340 | node.sendCmd(myCmd); |
---|
[1915] | 341 | end |
---|
| 342 | else |
---|
[4687] | 343 | error('%s: Expects two arguments: a baseband gain and an RF gain', cmdStr); |
---|
[1915] | 344 | end |
---|
| 345 | |
---|
[4330] | 346 | %--------------------------------------------------------- |
---|
[1915] | 347 | case 'rx_gains' |
---|
| 348 | % Sets the gains for the variable gain amplifiers in the MAX2829 Rx path |
---|
| 349 | % Refer to MAX2829 datasheet for curves of gain value vs actual gain at 2.4 and 5GHz |
---|
| 350 | % |
---|
[3589] | 351 | % Arguments: (int RF_GAIN, int BB_GAIN) |
---|
| 352 | % RF_GAIN: Must be integer in [1,2,3] for approx [0,15,30]dB RF gain |
---|
[1915] | 353 | % BB_GAIN: Must be integer in [0:31] for approx [0:63]dB baseband gain |
---|
| 354 | % Returns: none |
---|
| 355 | % |
---|
| 356 | % BB_GAIN and RF_GAIN must be scalars (same values for all specified interfaces) or |
---|
| 357 | % 1-D vectors (one value per interface) with length equal to the length of the interface ID vector |
---|
[3589] | 358 | % |
---|
| 359 | % NOTE: The parameters are in the order in which they are applied to the signal (ie RF gain, then baseband gain) |
---|
[4330] | 360 | % |
---|
| 361 | if(isempty(varargin)) % read-back mode |
---|
[4687] | 362 | error('%s: Rx gain read back not implemented.', cmdStr); |
---|
| 363 | |
---|
[4330] | 364 | elseif(length(varargin) == 2) % write mode |
---|
[4687] | 365 | |
---|
[1915] | 366 | rfGain = varargin{1}; |
---|
| 367 | bbGain = varargin{2}; |
---|
[4330] | 368 | |
---|
[4687] | 369 | for n = 1:num_interfaces |
---|
| 370 | |
---|
| 371 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_RX_GAINS), rfSel(n)); |
---|
| 372 | |
---|
| 373 | % Check arguments |
---|
| 374 | if(length(bbGain) == num_interfaces) |
---|
| 375 | node_bb_gain = bbGain(n); |
---|
| 376 | else |
---|
| 377 | error('%s: Expects baseband gain selection to be a vector of length equal to the number of interfaces.', cmdStr); |
---|
| 378 | end |
---|
| 379 | |
---|
| 380 | if(length(rfGain) == num_interfaces) |
---|
| 381 | node_rf_gain = rfGain(n); |
---|
| 382 | else |
---|
| 383 | error('%s: Expects rf gain selection to be a vector of length equal to the number of interfaces.', cmdStr); |
---|
| 384 | end |
---|
| 385 | |
---|
| 386 | if((node_bb_gain > 31) || (node_rf_gain > 3)) |
---|
| 387 | error('%s: RF gain must be in [0,3] and baseband gain must be in [0,31]', cmdStr); |
---|
| 388 | end |
---|
[1915] | 389 | |
---|
[4687] | 390 | myCmd.addArgs(node_rf_gain, node_bb_gain); |
---|
| 391 | node.sendCmd(myCmd); |
---|
[1915] | 392 | end |
---|
| 393 | else |
---|
[4687] | 394 | error('%s: Expects two arguments: an RF gain and a baseband gain', cmdStr); |
---|
[1915] | 395 | end |
---|
[4330] | 396 | |
---|
| 397 | %--------------------------------------------------------- |
---|
[1915] | 398 | case 'tx_lpf_corn_freq' |
---|
| 399 | % Sets the corner frequency for the MAX2829 Tx path low pass filter |
---|
| 400 | % Refer to MAX2829 datasheet for curves of the frequency response with each setting |
---|
| 401 | % |
---|
| 402 | % Arguments: (int FILT) |
---|
[4330] | 403 | % FILT: Must be integer in [1,2,3] for approx [12,18,24]MHz corner frequencies ([24,36,48]MHz bandwidths) |
---|
[1915] | 404 | % Returns: none |
---|
| 405 | % |
---|
| 406 | % FILT must be scalar (same value for all specified interfaces) or 1-D vector (one value per interface) |
---|
[4330] | 407 | % with length equal to the length of the interface ID vector |
---|
| 408 | % |
---|
| 409 | if(isempty(varargin)) % read-back mode |
---|
[4687] | 410 | error('%s: Tx LPF corner frequency read back not implemented.', cmdStr); |
---|
[4330] | 411 | |
---|
| 412 | elseif(length(varargin) == 1) % write mode |
---|
[4687] | 413 | |
---|
[4330] | 414 | cornFreq = varargin{1}; |
---|
| 415 | |
---|
[4687] | 416 | for n = 1:num_interfaces |
---|
| 417 | |
---|
| 418 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_TX_LPF_CORN_FREQ), rfSel(n)); |
---|
| 419 | |
---|
| 420 | % Check arguments |
---|
| 421 | if(length(cornFreq) == num_interfaces) |
---|
| 422 | node_corn_freq = cornFreq(n); |
---|
| 423 | else |
---|
| 424 | error('%s: Expects corner frequency selection to be a vector of length equal to the number of interfaces.', cmdStr); |
---|
| 425 | end |
---|
| 426 | |
---|
| 427 | if((node_corn_freq == 0) || (node_corn_freq > 3)) |
---|
| 428 | error('%s: Corner frequency filter must be in [1, 3]', cmdStr); |
---|
| 429 | end |
---|
| 430 | |
---|
| 431 | myCmd.addArgs(node_corn_freq); |
---|
| 432 | node.sendCmd(myCmd); |
---|
[1915] | 433 | end |
---|
| 434 | else |
---|
[4687] | 435 | error('%s: Expects one argument', cmdStr); |
---|
[4330] | 436 | end |
---|
| 437 | |
---|
| 438 | %--------------------------------------------------------- |
---|
[4989] | 439 | case 'rx_lpf_corn_freq_fine' |
---|
| 440 | % Sets the fine corner frequency for the MAX2829 Rx path low pass filter |
---|
| 441 | % Refer to MAX2829 datasheet for curves of the frequency response with each setting |
---|
| 442 | % |
---|
| 443 | % Arguments: (int FILT) |
---|
| 444 | % FILT: Must be integer in [0,1,2,3,4,5] for |
---|
| 445 | % [90,95,100,105,110]% scaling to LPF corner frequency |
---|
| 446 | % |
---|
| 447 | % Returns: none |
---|
| 448 | % |
---|
| 449 | % FILT must be scalar (same value for all specified interfaces) or 1-D vector (one value per interface) |
---|
| 450 | % with length equal to the length of the interface ID vector |
---|
| 451 | % |
---|
| 452 | if(isempty(varargin)) % read-back mode |
---|
| 453 | error('%s: Rx LPF fine corner frequency read back not implemented.', cmdStr); |
---|
| 454 | |
---|
| 455 | elseif(length(varargin) == 1) % write mode |
---|
| 456 | |
---|
| 457 | cornFreq = varargin{1}; |
---|
| 458 | |
---|
| 459 | for n = 1:num_interfaces |
---|
| 460 | |
---|
| 461 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_RX_LPF_CORN_FREQ_FINE), rfSel(n)); |
---|
| 462 | |
---|
| 463 | % Check arguments |
---|
| 464 | if(length(cornFreq) == num_interfaces) |
---|
| 465 | node_corn_freq = cornFreq(n); |
---|
| 466 | else |
---|
| 467 | error('%s: Expects corner frequency selection to be a vector of length equal to the number of interfaces.', cmdStr); |
---|
| 468 | end |
---|
| 469 | |
---|
| 470 | if((node_corn_freq < 0) || (node_corn_freq > 5)) |
---|
| 471 | error('%s: Corner frequency filter must be in [0, 5]', cmdStr); |
---|
| 472 | end |
---|
| 473 | |
---|
| 474 | myCmd.addArgs(node_corn_freq); |
---|
| 475 | node.sendCmd(myCmd); |
---|
| 476 | end |
---|
| 477 | else |
---|
| 478 | error('%s: Expects one argument', cmdStr); |
---|
| 479 | end |
---|
| 480 | |
---|
| 481 | %--------------------------------------------------------- |
---|
[1915] | 482 | case 'rx_lpf_corn_freq' |
---|
| 483 | % Sets the corner frequency for the MAX2829 Rx path low pass filter |
---|
| 484 | % Refer to MAX2829 datasheet for curves of the frequency response with each setting |
---|
| 485 | % |
---|
| 486 | % Arguments: (int FILT) |
---|
[4330] | 487 | % FILT: Must be integer in [0,1,2,3] for approx [7.5,9.5,14,18]MHz corner |
---|
| 488 | % frequencies ([15,19,28,36]MHz bandwidths) |
---|
[1915] | 489 | % Returns: none |
---|
| 490 | % |
---|
| 491 | % FILT must be scalar (same value for all specified interfaces) or 1-D vector (one value per interface) |
---|
[4330] | 492 | % with length equal to the length of the interface ID vector |
---|
| 493 | % |
---|
| 494 | if(isempty(varargin)) % read-back mode |
---|
[4687] | 495 | error('%s: Rx LPF corner frequency read back not implemented.', cmdStr); |
---|
| 496 | |
---|
[4330] | 497 | elseif(length(varargin) == 1) % write mode |
---|
[4687] | 498 | |
---|
| 499 | cornFreq = varargin{1}; |
---|
| 500 | |
---|
| 501 | for n = 1:num_interfaces |
---|
| 502 | |
---|
| 503 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_RX_LPF_CORN_FREQ), rfSel(n)); |
---|
| 504 | |
---|
| 505 | % Check arguments |
---|
| 506 | if(length(cornFreq) == num_interfaces) |
---|
| 507 | node_corn_freq = cornFreq(n); |
---|
| 508 | else |
---|
| 509 | error('%s: Expects corner frequency selection to be a vector of length equal to the number of interfaces.', cmdStr); |
---|
| 510 | end |
---|
| 511 | |
---|
| 512 | if((node_corn_freq < 0) || (node_corn_freq > 3)) |
---|
| 513 | error('%s: Corner frequency filter must be in [0, 3]', cmdStr); |
---|
| 514 | end |
---|
[4330] | 515 | |
---|
[4687] | 516 | myCmd.addArgs(node_corn_freq); |
---|
| 517 | node.sendCmd(myCmd); |
---|
[1915] | 518 | end |
---|
| 519 | else |
---|
[4687] | 520 | error('%s: Expects one argument', cmdStr); |
---|
| 521 | end |
---|
| 522 | |
---|
[4330] | 523 | %--------------------------------------------------------- |
---|
[4674] | 524 | case 'rx_hpf_corn_freq' |
---|
| 525 | % Sets the corner frequency for the MAX2829 Rx path high pass filter when RXHP = 'disable' (ie 0) |
---|
| 526 | % |
---|
| 527 | % Arguments: (int MODE) |
---|
| 528 | % MODE: Must be 0 (HPF corner of 100 Hz) or 1 (default; HPF corner of 30 kHz) |
---|
| 529 | % Returns: none |
---|
| 530 | % |
---|
| 531 | % MODE must be scalar (same value for all specified interfaces) or 1-D vector (one value per interface) |
---|
| 532 | % with length equal to the length of the interface ID vector |
---|
| 533 | % |
---|
| 534 | % The MAX2829 default setting is 1 (30 kHz corner frequency). This is the better setting for most |
---|
| 535 | % applications. The lower cutoff frequency (100 Hz) should only be used when the Rx waveform has |
---|
| 536 | % energy in the 60 kHz around DC. |
---|
| 537 | % |
---|
| 538 | % This filter setting is only used when RXHP is 'disable' (ie 0). |
---|
| 539 | % |
---|
| 540 | if(isempty(varargin)) % read-back mode |
---|
[4687] | 541 | error('%s: Rx HPF corner frequency read back not implemented.', cmdStr); |
---|
| 542 | |
---|
[4674] | 543 | elseif(length(varargin) == 1) % write mode |
---|
[4687] | 544 | |
---|
| 545 | cornFreq = varargin{1}; |
---|
| 546 | |
---|
| 547 | for n = 1:num_interfaces |
---|
| 548 | |
---|
| 549 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_RX_HPF_CORN_FREQ), rfSel(n)); |
---|
| 550 | |
---|
| 551 | % Check arguments |
---|
| 552 | if(length(cornFreq) == num_interfaces) |
---|
| 553 | node_corn_freq = cornFreq(n); |
---|
| 554 | else |
---|
| 555 | error('%s: Expects corner frequency selection to be a vector of length equal to the number of interfaces.', cmdStr); |
---|
| 556 | end |
---|
| 557 | |
---|
| 558 | if((node_corn_freq < 0) || (node_corn_freq > 1)) |
---|
| 559 | error('%s: Corner frequency mode must be in [0, 1]', cmdStr); |
---|
| 560 | end |
---|
[4674] | 561 | |
---|
[4687] | 562 | myCmd.addArgs(node_corn_freq); |
---|
| 563 | node.sendCmd(myCmd); |
---|
[4674] | 564 | end |
---|
| 565 | else |
---|
[4687] | 566 | error('%s: Expects one argument', cmdStr); |
---|
| 567 | end |
---|
[4674] | 568 | |
---|
| 569 | %--------------------------------------------------------- |
---|
[1915] | 570 | case 'rx_gain_mode' |
---|
[1975] | 571 | % Sets the gain selection mode |
---|
| 572 | % |
---|
| 573 | % Arguments: (string MODE) |
---|
[4330] | 574 | % MODE: 'automatic' for AGC, or 'manual' for manual gain control |
---|
[1975] | 575 | % Returns: none |
---|
[4330] | 576 | % |
---|
[4687] | 577 | |
---|
| 578 | % Check interface selection |
---|
| 579 | if(num_interfaces ~= 1) |
---|
| 580 | error('%s: Requires scalar interface selection. If trying to set multiple interfaces, use bitwise addition of interfaces: RFA + RFB.', cmdStr); |
---|
| 581 | end |
---|
| 582 | |
---|
| 583 | if(length(varargin) ~= 1) |
---|
| 584 | error('%s: Requires one argument', cmdStr); |
---|
| 585 | end |
---|
| 586 | |
---|
[4330] | 587 | if(strcmp(lower(varargin{1}) , 'automatic')) |
---|
| 588 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_RX_GAINCTRL_SRC), rfSel, 1); |
---|
| 589 | elseif(strcmp(lower(varargin{1}) , 'manual')) |
---|
| 590 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_RX_GAINCTRL_SRC), rfSel, 0); |
---|
| 591 | else |
---|
| 592 | error( 'Invalid rx_gain_mode: %s (must be ''automatic'' or ''manual'')', varargin{1}); |
---|
| 593 | end |
---|
[1989] | 594 | |
---|
[1975] | 595 | node.sendCmd(myCmd); |
---|
[4330] | 596 | |
---|
| 597 | %--------------------------------------------------------- |
---|
| 598 | case 'rx_rxhp' |
---|
| 599 | % Sets the RXHP mode on the node when in manual gain control |
---|
| 600 | % |
---|
[4930] | 601 | % Arguments: (boolean MODE) |
---|
| 602 | % MODE: true enables RXHP on the node when in manual gain control |
---|
| 603 | % false disables RXHP on the node when in manual gain control |
---|
| 604 | % |
---|
[4330] | 605 | % Returns: none |
---|
| 606 | % |
---|
[4687] | 607 | |
---|
| 608 | % Check interface selection |
---|
| 609 | if(num_interfaces ~= 1) |
---|
| 610 | error('%s: Requires scalar interface selection. If trying to set multiple interfaces, use bitwise addition of interfaces: RFA + RFB.', cmdStr); |
---|
| 611 | end |
---|
| 612 | |
---|
| 613 | if(length(varargin) ~= 1) |
---|
| 614 | error('%s: Requires one argument', cmdStr); |
---|
| 615 | end |
---|
| 616 | |
---|
[4930] | 617 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_RX_RXHP_CTRL), rfSel); |
---|
| 618 | mode = varargin{1}; |
---|
| 619 | |
---|
| 620 | if (ischar(mode)) |
---|
| 621 | % Print warning that this syntax will be deprecated |
---|
| 622 | try |
---|
| 623 | temp = evalin('base', 'wl_rx_rxhp_did_warn'); |
---|
| 624 | catch |
---|
| 625 | fprintf('WARNING: This syntax for rx_rxhp() is being deprecated.\n'); |
---|
| 626 | fprintf('WARNING: Please use: wl_interfaceCmd(node, RF_SEL, ''rx_rxhp'', <true, false>);\n'); |
---|
| 627 | fprintf('WARNING: See WARPLab documentation for more information\n\n'); |
---|
| 628 | |
---|
| 629 | assignin('base', 'wl_rx_rxhp_did_warn', 1) |
---|
| 630 | end |
---|
| 631 | |
---|
| 632 | if(strcmp(lower(mode),'enable')) |
---|
| 633 | mode = 1; |
---|
| 634 | elseif(strcmp(lower(mode),'disable')) |
---|
| 635 | mode = 0; |
---|
| 636 | else |
---|
| 637 | error('mode selection must be ''enable'' or ''disable''') |
---|
| 638 | end |
---|
| 639 | elseif (islogical(mode)) |
---|
| 640 | if(mode) |
---|
| 641 | mode = 1; |
---|
| 642 | else |
---|
| 643 | mode = 0; |
---|
| 644 | end |
---|
| 645 | else |
---|
| 646 | error('mode selection must be true or false') |
---|
[4330] | 647 | end |
---|
[4930] | 648 | |
---|
| 649 | myCmd.addArgs(mode); |
---|
[4330] | 650 | node.sendCmd(myCmd); |
---|
| 651 | |
---|
| 652 | %--------------------------------------------------------- |
---|
[1915] | 653 | otherwise |
---|
[2865] | 654 | error('unknown command ''%s''', cmdStr); |
---|
[1915] | 655 | end |
---|
| 656 | |
---|
| 657 | if(iscell(out)==0 && numel(out)~=1) |
---|
| 658 | out = {out}; |
---|
| 659 | end |
---|
| 660 | end |
---|
[4330] | 661 | end % methods |
---|
| 662 | end % classdef |
---|
[4687] | 663 | |
---|
| 664 | |
---|
| 665 | function out = isSingleBuffer(sel) |
---|
| 666 | out = (length(strfind(dec2bin(sel), '1')) == 1); |
---|
| 667 | end |
---|