1 | %------------------------------------------------------------------------- |
---|
2 | % WARPLab Framework |
---|
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 | |
---|
12 | classdef wl_interface_group_X245 < wl_interface_group |
---|
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 |
---|
16 | properties (SetAccess = protected) |
---|
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 |
---|
21 | end |
---|
22 | |
---|
23 | properties (SetAccess = public, Hidden = false, Constant = true) |
---|
24 | % Buffer State |
---|
25 | STANDBY = 0; |
---|
26 | RX = 1; |
---|
27 | TX = 2; |
---|
28 | end |
---|
29 | |
---|
30 | properties(Hidden = true,Constant = true) |
---|
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 |
---|
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 |
---|
46 | CMD_RX_LPF_CORN_FREQ_FINE = 13; % 0x00000D |
---|
47 | end |
---|
48 | |
---|
49 | methods |
---|
50 | function obj = wl_interface_group_X245(varargin) |
---|
51 | obj.description = '2.4/5GHz RF Interface Group'; |
---|
52 | |
---|
53 | radioSel = varargin{1}; |
---|
54 | FMCMode = 0; |
---|
55 | |
---|
56 | if (nargin == 2) |
---|
57 | FMCMode = strcmpi(varargin{2},'w3'); |
---|
58 | end |
---|
59 | |
---|
60 | obj.ID = []; |
---|
61 | obj.label = {}; |
---|
62 | |
---|
63 | for n = radioSel |
---|
64 | obj.ID = [obj.ID, uint32(2.^((n - 1) + 28))]; |
---|
65 | if (FMCMode == 0 || n < 3) |
---|
66 | obj.label = [obj.label, {sprintf('RF%c',n+64)}]; |
---|
67 | else |
---|
68 | obj.label = [obj.label, {sprintf('RF%c (FMC RF%c)', (n + 64), (n + 62))}]; |
---|
69 | end |
---|
70 | end |
---|
71 | end |
---|
72 | |
---|
73 | function out = wl_ifcValid(obj,rfSel) |
---|
74 | rfSel = repmat(rfSel,size(obj.ID)); |
---|
75 | out = max(bitand(rfSel,obj.ID)>1); |
---|
76 | end |
---|
77 | |
---|
78 | function out = procCmd(obj, nodeInd, node, rfSel, cmdStr, varargin) |
---|
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 | % |
---|
88 | out = []; |
---|
89 | |
---|
90 | % Process the rfSel argument |
---|
91 | if(strcmp(rfSel, 'RF_ALL')) |
---|
92 | |
---|
93 | % If rfSel is the "magic string" 'RF_ALL', then select all RF interfaces |
---|
94 | rfSel = sum(obj.ID); |
---|
95 | num_interfaces = 1; |
---|
96 | |
---|
97 | else |
---|
98 | |
---|
99 | % RF interfaces specified by RF interface IDs |
---|
100 | num_interfaces = length(rfSel); |
---|
101 | end |
---|
102 | |
---|
103 | % Check to make sure this rfSel actually applies to me |
---|
104 | if(bitand(rfSel, sum(obj.ID)) ~= rfSel) |
---|
105 | error('Invalid interface selection'); |
---|
106 | end |
---|
107 | |
---|
108 | switch(lower(cmdStr)) |
---|
109 | %--------------------------------------------------------- |
---|
110 | case 'tx_en' |
---|
111 | % Enable transmit mode for selected interfaces |
---|
112 | % |
---|
113 | % Arguments: none |
---|
114 | % Returns: none |
---|
115 | % |
---|
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 | |
---|
122 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_TX_EN), rfSel); |
---|
123 | node.sendCmd(myCmd); |
---|
124 | |
---|
125 | %--------------------------------------------------------- |
---|
126 | case 'rx_en' |
---|
127 | % Enable receive mode for selected interfaces |
---|
128 | % |
---|
129 | % Arguments: none |
---|
130 | % Returns: none |
---|
131 | % |
---|
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 | |
---|
138 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_RX_EN), rfSel); |
---|
139 | node.sendCmd(myCmd); |
---|
140 | |
---|
141 | %--------------------------------------------------------- |
---|
142 | case 'tx_rx_dis' |
---|
143 | % Disable transmit and receive for selected interfaces (standby mode) |
---|
144 | % |
---|
145 | % Arguments: none |
---|
146 | % Returns: none |
---|
147 | % |
---|
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 | |
---|
154 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_TX_RX_DIS), rfSel); |
---|
155 | node.sendCmd(myCmd); |
---|
156 | |
---|
157 | %--------------------------------------------------------- |
---|
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 | |
---|
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 |
---|
187 | end |
---|
188 | |
---|
189 | %--------------------------------------------------------- |
---|
190 | case 'channel' |
---|
191 | % Tune selected interfaces to the specified band and channel |
---|
192 | % |
---|
193 | % Arguments: (float BAND, int CHAN) |
---|
194 | % BAND: Must be 2.4 or 5, to select 2.4GHz or 5GHz channels |
---|
195 | % CHAN: Must be integer in [1,14] for BAND=2.4, [1,44] for BAND=5 |
---|
196 | % Returns: none |
---|
197 | % |
---|
198 | % BAND and CHAN must be scalars (same values for all specified interfaces) or |
---|
199 | % 1-D vectors (one value per interface) with length equal to the length of the interface ID vector |
---|
200 | % |
---|
201 | % Band/Channel - Center Frequency Map: |
---|
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 || |
---|
248 | % |
---|
249 | if(isempty(varargin)) % read-back mode |
---|
250 | error('%s: Channel read back not implemented.', cmdStr); |
---|
251 | |
---|
252 | elseif(length(varargin) == 2) % write mode |
---|
253 | |
---|
254 | band = varargin{1}; |
---|
255 | channel = varargin{2}; |
---|
256 | |
---|
257 | for n = 1:num_interfaces |
---|
258 | |
---|
259 | myCmd = wl_cmd(node.calcCmd(obj.GRP, obj.CMD_CHANNEL), rfSel(n)); |
---|
260 | |
---|
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); |
---|
266 | end |
---|
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); |
---|
272 | end |
---|
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; |
---|
281 | if((node_channel < 1) || (node_channel > 44)) |
---|
282 | error('%s: Expects channel selection to be between [1,44] for the 5GHz band', cmdStr); |
---|
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); |
---|
290 | end |
---|
291 | else |
---|
292 | error('%s: Expects two arguments: a band and a channel', cmdStr); |
---|
293 | end |
---|
294 | |
---|
295 | %--------------------------------------------------------- |
---|
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 |
---|
307 | % |
---|
308 | % NOTE: The parameters are in the order in which they are applied to the signal (ie baseband gain, then RF gain) |
---|
309 | % |
---|
310 | if(isempty(varargin)) % read-back mode |
---|
311 | error('%s: Tx gain read back not implemented.', cmdStr); |
---|
312 | |
---|
313 | elseif(length(varargin) == 2) % write mode |
---|
314 | |
---|
315 | bbGain = varargin{1}; |
---|
316 | rfGain = varargin{2}; |
---|
317 | |
---|
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 |
---|
338 | |
---|
339 | myCmd.addArgs(node_bb_gain, node_rf_gain); |
---|
340 | node.sendCmd(myCmd); |
---|
341 | end |
---|
342 | else |
---|
343 | error('%s: Expects two arguments: a baseband gain and an RF gain', cmdStr); |
---|
344 | end |
---|
345 | |
---|
346 | %--------------------------------------------------------- |
---|
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 | % |
---|
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 |
---|
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 |
---|
358 | % |
---|
359 | % NOTE: The parameters are in the order in which they are applied to the signal (ie RF gain, then baseband gain) |
---|
360 | % |
---|
361 | if(isempty(varargin)) % read-back mode |
---|
362 | error('%s: Rx gain read back not implemented.', cmdStr); |
---|
363 | |
---|
364 | elseif(length(varargin) == 2) % write mode |
---|
365 | |
---|
366 | rfGain = varargin{1}; |
---|
367 | bbGain = varargin{2}; |
---|
368 | |
---|
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 |
---|
389 | |
---|
390 | myCmd.addArgs(node_rf_gain, node_bb_gain); |
---|
391 | node.sendCmd(myCmd); |
---|
392 | end |
---|
393 | else |
---|
394 | error('%s: Expects two arguments: an RF gain and a baseband gain', cmdStr); |
---|
395 | end |
---|
396 | |
---|
397 | %--------------------------------------------------------- |
---|
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) |
---|
403 | % FILT: Must be integer in [1,2,3] for approx [12,18,24]MHz corner frequencies ([24,36,48]MHz bandwidths) |
---|
404 | % Returns: none |
---|
405 | % |
---|
406 | % FILT must be scalar (same value for all specified interfaces) or 1-D vector (one value per interface) |
---|
407 | % with length equal to the length of the interface ID vector |
---|
408 | % |
---|
409 | if(isempty(varargin)) % read-back mode |
---|
410 | error('%s: Tx LPF corner frequency read back not implemented.', cmdStr); |
---|
411 | |
---|
412 | elseif(length(varargin) == 1) % write mode |
---|
413 | |
---|
414 | cornFreq = varargin{1}; |
---|
415 | |
---|
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); |
---|
433 | end |
---|
434 | else |
---|
435 | error('%s: Expects one argument', cmdStr); |
---|
436 | end |
---|
437 | |
---|
438 | %--------------------------------------------------------- |
---|
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 | %--------------------------------------------------------- |
---|
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) |
---|
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) |
---|
489 | % Returns: none |
---|
490 | % |
---|
491 | % FILT must be scalar (same value for all specified interfaces) or 1-D vector (one value per interface) |
---|
492 | % with length equal to the length of the interface ID vector |
---|
493 | % |
---|
494 | if(isempty(varargin)) % read-back mode |
---|
495 | error('%s: Rx LPF corner frequency read back not implemented.', cmdStr); |
---|
496 | |
---|
497 | elseif(length(varargin) == 1) % write mode |
---|
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 |
---|
515 | |
---|
516 | myCmd.addArgs(node_corn_freq); |
---|
517 | node.sendCmd(myCmd); |
---|
518 | end |
---|
519 | else |
---|
520 | error('%s: Expects one argument', cmdStr); |
---|
521 | end |
---|
522 | |
---|
523 | %--------------------------------------------------------- |
---|
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 |
---|
541 | error('%s: Rx HPF corner frequency read back not implemented.', cmdStr); |
---|
542 | |
---|
543 | elseif(length(varargin) == 1) % write mode |
---|
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 |
---|
561 | |
---|
562 | myCmd.addArgs(node_corn_freq); |
---|
563 | node.sendCmd(myCmd); |
---|
564 | end |
---|
565 | else |
---|
566 | error('%s: Expects one argument', cmdStr); |
---|
567 | end |
---|
568 | |
---|
569 | %--------------------------------------------------------- |
---|
570 | case 'rx_gain_mode' |
---|
571 | % Sets the gain selection mode |
---|
572 | % |
---|
573 | % Arguments: (string MODE) |
---|
574 | % MODE: 'automatic' for AGC, or 'manual' for manual gain control |
---|
575 | % Returns: none |
---|
576 | % |
---|
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 | |
---|
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 |
---|
594 | |
---|
595 | node.sendCmd(myCmd); |
---|
596 | |
---|
597 | %--------------------------------------------------------- |
---|
598 | case 'rx_rxhp' |
---|
599 | % Sets the RXHP mode on the node when in manual gain control |
---|
600 | % |
---|
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 | % |
---|
605 | % Returns: none |
---|
606 | % |
---|
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 | |
---|
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') |
---|
647 | end |
---|
648 | |
---|
649 | myCmd.addArgs(mode); |
---|
650 | node.sendCmd(myCmd); |
---|
651 | |
---|
652 | %--------------------------------------------------------- |
---|
653 | otherwise |
---|
654 | error('unknown command ''%s''', cmdStr); |
---|
655 | end |
---|
656 | |
---|
657 | if(iscell(out)==0 && numel(out)~=1) |
---|
658 | out = {out}; |
---|
659 | end |
---|
660 | end |
---|
661 | end % methods |
---|
662 | end % classdef |
---|
663 | |
---|
664 | |
---|
665 | function out = isSingleBuffer(sel) |
---|
666 | out = (length(strfind(dec2bin(sel), '1')) == 1); |
---|
667 | end |
---|