Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/ad9361/sw/console_commands/command.c

raw symbols SCIP
1 /**************************************************************************//**
2 * @file command.c
3 * @brief Implementation of AD9361 Command Driver.
4 * @author DBogdan ([email protected])
5 *******************************************************************************
6 * Copyright 2013(c) Analog Devices, Inc.
7 *
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 * - Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * - Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * - Neither the name of Analog Devices, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 * - The use of this software may or may not infringe the patent rights
22 * of one or more patent holders. This license does not release you
23 * from the requirement that you obtain separate licenses from these
24 * patent holders to use this software.
25 * - Use of the software either in source or binary form, must be run
26 * on or directly connected to an Analog Devices Inc. component.
27 *
28 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
29 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
30 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
31 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 *******************************************************************************/
39
40 /******************************************************************************/
41 /***************************** Include Files **********************************/
42 /******************************************************************************/
43 #include "command.h"
44 #include "console.h"
45 #include "../ad9361_api.h"
46 #include "dac_core.h"
47
48 /******************************************************************************/
49 /************************ Constants Definitions *******************************/
50 /******************************************************************************/
51 command cmd_list[] = {
52 {"help?", "Displays all available commands.", "", get_help},
53 {"register?", "Gets the specified register value.", "", get_register},
54 {"tx_lo_freq?", "Gets current TX LO frequency [MHz].", "", get_tx_lo_freq},
55 {"tx_lo_freq=", "Sets the TX LO frequency [MHz].", "", set_tx_lo_freq},
56 {"tx_samp_freq?", "Gets current TX sampling frequency [Hz].", "", get_tx_samp_freq},
57 {"tx_samp_freq=", "Sets the TX sampling frequency [Hz].", "", set_tx_samp_freq},
58 {"tx_rf_bandwidth?", "Gets current TX RF bandwidth [Hz].", "", get_tx_rf_bandwidth},
59 {"tx_rf_bandwidth=", "Sets the TX RF bandwidth [Hz].", "", set_tx_rf_bandwidth},
60 {"tx1_attenuation?", "Gets current TX1 attenuation [mdB].", "", get_tx1_attenuation},
61 {"tx1_attenuation=", "Sets the TX1 attenuation [mdB].", "", set_tx1_attenuation},
62 {"tx2_attenuation?", "Gets current TX2 attenuation [mdB].", "", get_tx2_attenuation},
63 {"tx2_attenuation=", "Sets the TX2 attenuation [mdB].", "", set_tx2_attenuation},
64 {"tx_fir_en?", "Gets current TX FIR state.", "", get_tx_fir_en},
65 {"tx_fir_en=", "Sets the TX FIR state.", "", set_tx_fir_en},
66 {"rx_lo_freq?", "Gets current RX LO frequency [MHz].", "", get_rx_lo_freq},
67 {"rx_lo_freq=", "Sets the RX LO frequency [MHz].", "", set_rx_lo_freq},
68 {"rx_samp_freq?", "Gets current RX sampling frequency [Hz].", "", get_rx_samp_freq},
69 {"rx_samp_freq=", "Sets the RX sampling frequency [Hz].", "", set_rx_samp_freq},
70 {"rx_rf_bandwidth?", "Gets current RX RF bandwidth [Hz].", "", get_rx_rf_bandwidth},
71 {"rx_rf_bandwidth=", "Sets the RX RF bandwidth [Hz].", "", set_rx_rf_bandwidth},
72 {"rx1_gc_mode?", "Gets current RX1 GC mode.", "", get_rx1_gc_mode},
73 {"rx1_gc_mode=", "Sets the RX1 GC mode.", "", set_rx1_gc_mode},
74 {"rx2_gc_mode?", "Gets current RX2 GC mode.", "", get_rx2_gc_mode},
75 {"rx2_gc_mode=", "Sets the RX2 GC mode.", "", set_rx2_gc_mode},
76 {"rx1_rf_gain?", "Gets current RX1 RF gain.", "", get_rx1_rf_gain},
77 {"rx1_rf_gain=", "Sets the RX1 RF gain.", "", set_rx1_rf_gain},
78 {"rx2_rf_gain?", "Gets current RX2 RF gain.", "", get_rx2_rf_gain},
79 {"rx2_rf_gain=", "Sets the RX2 RF gain.", "", set_rx2_rf_gain},
80 {"rx_fir_en?", "Gets current RX FIR state.", "", get_rx_fir_en},
81 {"rx_fir_en=", "Sets the RX FIR state.", "", set_rx_fir_en},
82 {"dds_tx1_tone1_freq?", "Gets current DDS TX1 Tone 1 frequency [Hz].", "", get_dds_tx1_tone1_freq},
83 {"dds_tx1_tone1_freq=", "Sets the DDS TX1 Tone 1 frequency [Hz].", "", set_dds_tx1_tone1_freq},
84 {"dds_tx1_tone2_freq?", "Gets current DDS TX1 Tone 2 frequency [Hz].", "", get_dds_tx1_tone2_freq},
85 {"dds_tx1_tone2_freq=", "Sets the DDS TX1 Tone 2 frequency [Hz].", "", set_dds_tx1_tone2_freq},
86 {"dds_tx1_tone1_phase?", "Gets current DDS TX1 Tone 1 phase [degrees].", "", get_dds_tx1_tone1_phase},
87 {"dds_tx1_tone1_phase=", "Sets the DDS TX1 Tone 1 phase [degrees].", "", set_dds_tx1_tone1_phase},
88 {"dds_tx1_tone2_phase?", "Gets current DDS TX1 Tone 2 phase [degrees].", "", get_dds_tx1_tone2_phase},
89 {"dds_tx1_tone2_phase=", "Sets the DDS TX1 Tone 2 phase [degrees].", "", set_dds_tx1_tone2_phase},
90 {"dds_tx1_tone1_scale?", "Gets current DDS TX1 Tone 1 scale.", "", get_dds_tx1_tone1_scale},
91 {"dds_tx1_tone1_scale=", "Sets the DDS TX1 Tone 1 scale.", "", set_dds_tx1_tone1_scale},
92 {"dds_tx1_tone2_scale?", "Gets current DDS TX1 Tone 2 scale.", "", get_dds_tx1_tone2_scale},
93 {"dds_tx1_tone2_scale=", "Sets the DDS TX1 Tone 2 scale.", "", set_dds_tx1_tone2_scale},
94 {"dds_tx2_tone1_freq?", "Gets current DDS TX2 Tone 1 frequency [Hz].", "", get_dds_tx2_tone1_freq},
95 {"dds_tx2_tone1_freq=", "Sets the DDS TX2 Tone 1 frequency [Hz].", "", set_dds_tx2_tone1_freq},
96 {"dds_tx2_tone2_freq?", "Gets current DDS TX2 Tone 2 frequency [Hz].", "", get_dds_tx2_tone2_freq},
97 {"dds_tx2_tone2_freq=", "Sets the DDS TX2 Tone 2 frequency [Hz].", "", set_dds_tx2_tone2_freq},
98 {"dds_tx2_tone1_phase?", "Gets current DDS TX2 Tone 1 phase [degrees].", "", get_dds_tx2_tone1_phase},
99 {"dds_tx2_tone1_phase=", "Sets the DDS TX2 Tone 1 phase [degrees].", "", set_dds_tx2_tone1_phase},
100 {"dds_tx2_tone2_phase?", "Gets current DDS TX2 Tone 2 phase [degrees].", "", get_dds_tx2_tone2_phase},
101 {"dds_tx2_tone2_phase=", "Sets the DDS TX2 Tone 2 phase [degrees].", "", set_dds_tx2_tone2_phase},
102 {"dds_tx2_tone1_scale?", "Gets current DDS TX2 Tone 1 scale.", "", get_dds_tx2_tone1_scale},
103 {"dds_tx2_tone1_scale=", "Sets the DDS TX2 Tone 1 scale.", "", set_dds_tx2_tone1_scale},
104 {"dds_tx2_tone2_scale?", "Gets current DDS TX2 Tone 2 scale.", "", dds_tx2_tone2_scale},
105 {"dds_tx2_tone2_scale=", "Sets the DDS TX2 Tone 2 scale.", "", set_dds_tx2_tone2_scale},
106 };
107 const char cmd_no = (sizeof(cmd_list) / sizeof(command));
108
109 /******************************************************************************/
110 /************************ Variables Definitions *******************************/
111 /******************************************************************************/
112 extern struct dds_state dds_st;
113 extern struct ad9361_rf_phy *ad9361_phy;
114
115 /**************************************************************************//***
116 * @brief Show the invalid parameter message.
117 *
118 * @return None.
119 *******************************************************************************/
120 void show_invalid_param_message(unsigned char cmd_no)
121 {
122 console_print("Invalid parameter!\n");
123 console_print("%s - %s\n", (char*)cmd_list[cmd_no].name, (char*)cmd_list[cmd_no].description);
124 console_print("Example: %s\n", (char*)cmd_list[cmd_no].example);
125 }
126
127 /**************************************************************************//***
128 * @brief Displays all available commands.
129 *
130 * @return None.
131 *******************************************************************************/
132 void get_help(double* param, char param_no) // "help?" command
133 {
134 unsigned char display_cmd;
135
136 console_print("Available commands:\n");
137 for(display_cmd = 0; display_cmd < cmd_no; display_cmd++)
138 {
139 console_print("%s - %s\n", (char*)cmd_list[display_cmd].name,
140 (char*)cmd_list[display_cmd].description);
141 }
142 }
143
144 /**************************************************************************//***
145 * @brief Displays all available commands.
146 *
147 * @return None.
148 *******************************************************************************/
149 void get_register(double* param, char param_no) // "register?" command
150 {
151 uint16_t reg_addr;
152 uint8_t reg_val;
153 struct spi_device spi;
154
155 if(param_no >= 1)
156 {
157 spi.id_no = 0;
158 reg_addr = param[0];
159 reg_val = ad9361_spi_read(&spi, reg_addr);
160 console_print("register[0x%x]=0x%x\n", reg_addr, reg_val);
161 }
162 else
163 show_invalid_param_message(1);
164 }
165
166 /**************************************************************************//***
167 * @brief Gets current TX LO frequency [MHz].
168 *
169 * @return None.
170 *******************************************************************************/
171 void get_tx_lo_freq(double* param, char param_no) // "tx_lo_freq?" command
172 {
173 uint64_t lo_freq_hz;
174
175 ad9361_get_tx_lo_freq(ad9361_phy, &lo_freq_hz);
176 lo_freq_hz /= 1000000;
177 console_print("tx_lo_freq=%d\n", (uint32_t)lo_freq_hz);
178 }
179
180 /**************************************************************************//***
181 * @brief Sets the TX LO frequency [MHz].
182 *
183 * @return None.
184 *******************************************************************************/
185 void set_tx_lo_freq(double* param, char param_no) // "tx_lo_freq=" command
186 {
187 uint64_t lo_freq_hz;
188
189 if(param_no >= 1)
190 {
191 lo_freq_hz = param[0];
192 lo_freq_hz *= 1000000;
193 ad9361_set_tx_lo_freq(ad9361_phy, lo_freq_hz);
194 lo_freq_hz /= 1000000;
195 console_print("tx_lo_freq=%d\n", (uint32_t)lo_freq_hz);
196 }
197 }
198
199 /**************************************************************************//***
200 * @brief Gets current sampling frequency [Hz].
201 *
202 * @return None.
203 *******************************************************************************/
204 void get_tx_samp_freq(double* param, char param_no) // "tx_samp_freq?" command
205 {
206 uint32_t sampling_freq_hz;
207
208 ad9361_get_tx_sampling_freq(ad9361_phy, &sampling_freq_hz);
209 console_print("tx_samp_freq=%d\n", sampling_freq_hz);
210 }
211
212 /**************************************************************************//***
213 * @brief Sets the sampling frequency [Hz].
214 *
215 * @return None.
216 *******************************************************************************/
217 void set_tx_samp_freq(double* param, char param_no) // "tx_samp_freq=" command
218 {
219 uint32_t sampling_freq_hz;
220
221 if(param_no >= 1)
222 {
223 sampling_freq_hz = (uint32_t)param[0];
224 ad9361_set_tx_sampling_freq(ad9361_phy, sampling_freq_hz);
225 ad9361_get_tx_sampling_freq(ad9361_phy, &sampling_freq_hz);
226 dds_update(ad9361_phy);
227 console_print("tx_samp_freq=%d\n", sampling_freq_hz);
228 }
229 else
230 show_invalid_param_message(1);
231 }
232
233 /**************************************************************************//***
234 * @brief Gets current TX RF bandwidth [Hz].
235 *
236 * @return None.
237 *******************************************************************************/
238 void get_tx_rf_bandwidth(double* param, char param_no) // "tx_rf_bandwidth?" command
239 {
240 uint32_t bandwidth_hz;
241
242 ad9361_get_tx_rf_bandwidth(ad9361_phy, &bandwidth_hz);
243 console_print("tx_rf_bandwidth=%d\n", bandwidth_hz);
244 }
245
246 /**************************************************************************//***
247 * @brief Sets the TX RF bandwidth [Hz].
248 *
249 * @return None.
250 *******************************************************************************/
251 void set_tx_rf_bandwidth(double* param, char param_no) // "tx_rf_bandwidth=" command
252 {
253 uint32_t bandwidth_hz;
254
255 if(param_no >= 1)
256 {
257 bandwidth_hz = param[0];
258 ad9361_set_tx_rf_bandwidth(ad9361_phy, bandwidth_hz);
259 }
260 else
261 show_invalid_param_message(1);
262 }
263
264 /**************************************************************************//***
265 * @brief Gets current TX1 attenuation [mdB].
266 *
267 * @return None.
268 *******************************************************************************/
269 void get_tx1_attenuation(double* param, char param_no) // "tx1_attenuation?" command
270 {
271 uint32_t attenuation_mdb;
272
273 ad9361_get_tx_attenuation(ad9361_phy, 0, &attenuation_mdb);
274 console_print("tx1_attenuation=%d\n", attenuation_mdb);
275 }
276
277 /**************************************************************************//***
278 * @brief Sets the TX1 attenuation [mdB].
279 *
280 * @return None.
281 *******************************************************************************/
282 void set_tx1_attenuation(double* param, char param_no) // "tx1_attenuation=" command
283 {
284 uint32_t attenuation_mdb;
285
286 if(param_no >= 1)
287 {
288 attenuation_mdb = param[0];
289 ad9361_set_tx_attenuation(ad9361_phy, 0, attenuation_mdb);
290 console_print("tx1_attenuation=%d\n", attenuation_mdb);
291 }
292 else
293 show_invalid_param_message(1);
294 }
295
296 /**************************************************************************//***
297 * @brief Gets current TX2 attenuation [mdB].
298 *
299 * @return None.
300 *******************************************************************************/
301 void get_tx2_attenuation(double* param, char param_no) // "tx1_attenuation?" command
302 {
303 uint32_t attenuation_mdb;
304
305 ad9361_get_tx_attenuation(ad9361_phy, 1, &attenuation_mdb);
306 console_print("tx2_attenuation=%d\n", attenuation_mdb);
307 }
308
309 /**************************************************************************//***
310 * @brief Sets the TX2 attenuation [mdB].
311 *
312 * @return None.
313 *******************************************************************************/
314 void set_tx2_attenuation(double* param, char param_no) // "tx1_attenuation=" command
315 {
316 uint32_t attenuation_mdb;
317
318 if(param_no >= 1)
319 {
320 attenuation_mdb = param[0];
321 ad9361_set_tx_attenuation(ad9361_phy, 1, attenuation_mdb);
322 console_print("tx2_attenuation=%d\n", attenuation_mdb);
323 }
324 else
325 show_invalid_param_message(1);
326 }
327
328 /**************************************************************************//***
329 * @brief Gets current TX FIR state.
330 *
331 * @return None.
332 *******************************************************************************/
333 void get_tx_fir_en(double* param, char param_no) // "tx_fir_en?" command
334 {
335 uint8_t en_dis;
336
337 ad9361_get_tx_fir_en_dis(ad9361_phy, &en_dis);
338 console_print("tx_fir_en=%d\n", en_dis);
339 }
340
341 /**************************************************************************//***
342 * @brief Sets the TX FIR state.
343 *
344 * @return None.
345 *******************************************************************************/
346 void set_tx_fir_en(double* param, char param_no) // "tx_fir_en=" command
347 {
348 uint8_t en_dis;
349
350 if(param_no >= 1)
351 {
352 en_dis = param[0];
353 ad9361_set_tx_fir_en_dis(ad9361_phy, en_dis);
354 console_print("tx_fir_en=%d\n", en_dis);
355 }
356 else
357 show_invalid_param_message(1);
358 }
359
360 /**************************************************************************//***
361 * @brief Gets current RX LO frequency [MHz].
362 *
363 * @return None.
364 *******************************************************************************/
365 void get_rx_lo_freq(double* param, char param_no) // "rx_lo_freq?" command
366 {
367 uint64_t lo_freq_hz;
368
369 ad9361_get_rx_lo_freq(ad9361_phy, &lo_freq_hz);
370 lo_freq_hz /= 1000000;
371 console_print("rx_lo_freq=%d\n", (uint32_t)lo_freq_hz);
372 }
373
374 /**************************************************************************//***
375 * @brief Sets the RX LO frequency [MHz].
376 *
377 * @return None.
378 *******************************************************************************/
379 void set_rx_lo_freq(double* param, char param_no) // "rx_lo_freq=" command
380 {
381 uint64_t lo_freq_hz;
382
383 if(param_no >= 1)
384 {
385 lo_freq_hz = param[0];
386 lo_freq_hz *= 1000000;
387 ad9361_set_rx_lo_freq(ad9361_phy, lo_freq_hz);
388 lo_freq_hz /= 1000000;
389 console_print("rx_lo_freq=%d\n", (uint32_t)lo_freq_hz);
390 }
391 }
392
393 /**************************************************************************//***
394 * @brief Gets current RX sampling frequency [Hz].
395 *
396 * @return None.
397 *******************************************************************************/
398 void get_rx_samp_freq(double* param, char param_no) // "rx_samp_freq?" command
399 {
400 uint32_t sampling_freq_hz;
401
402 ad9361_get_rx_sampling_freq(ad9361_phy, &sampling_freq_hz);
403 console_print("rx_samp_freq=%d\n", sampling_freq_hz);
404 }
405
406 /**************************************************************************//***
407 * @brief Sets the RX sampling frequency [Hz].
408 *
409 * @return None.
410 *******************************************************************************/
411 void set_rx_samp_freq(double* param, char param_no) // "rx_samp_freq=" command
412 {
413 uint32_t sampling_freq_hz;
414
415 if(param_no >= 1)
416 {
417 sampling_freq_hz = (uint32_t)param[0];
418 ad9361_set_rx_sampling_freq(ad9361_phy, sampling_freq_hz);
419 ad9361_get_rx_sampling_freq(ad9361_phy, &sampling_freq_hz);
420 dds_update(ad9361_phy);
421 console_print("rx_samp_freq=%d\n", sampling_freq_hz);
422 }
423 else
424 show_invalid_param_message(1);
425 }
426
427 /**************************************************************************//***
428 * @brief Gets current RX RF bandwidth [Hz].
429 *
430 * @return None.
431 *******************************************************************************/
432 void get_rx_rf_bandwidth(double* param, char param_no) // "rx_rf_bandwidth?" command
433 {
434 uint32_t bandwidth_hz;
435
436 ad9361_get_rx_rf_bandwidth(ad9361_phy, &bandwidth_hz);
437 console_print("rx_rf_bandwidth=%d\n", bandwidth_hz);
438 }
439
440 /**************************************************************************//***
441 * @brief Sets the RX RF bandwidth [Hz].
442 *
443 * @return None.
444 *******************************************************************************/
445 void set_rx_rf_bandwidth(double* param, char param_no) // "rx_rf_bandwidth=" command
446 {
447 uint32_t bandwidth_hz;
448
449 if(param_no >= 1)
450 {
451 bandwidth_hz = param[0];
452 ad9361_set_rx_rf_bandwidth(ad9361_phy, bandwidth_hz);
453 console_print("rx_rf_bandwidth=%d\n", bandwidth_hz);
454 }
455 else
456 show_invalid_param_message(1);
457 }
458
459 /**************************************************************************//***
460 * @brief Gets current RX1 GC mode.
461 *
462 * @return None.
463 *******************************************************************************/
464 void get_rx1_gc_mode(double* param, char param_no) // "rx1_gc_mode?" command
465 {
466 uint8_t gc_mode;
467
468 ad9361_get_rx_gain_control_mode(ad9361_phy, 0, &gc_mode);
469 console_print("rx1_gc_mode=%d\n", gc_mode);
470 }
471
472 /**************************************************************************//***
473 * @brief Sets the RX1 GC mode.
474 *
475 * @return None.
476 *******************************************************************************/
477 void set_rx1_gc_mode(double* param, char param_no) // "rx1_gc_mode=" command
478 {
479 uint8_t gc_mode;
480
481 if(param_no >= 1)
482 {
483 gc_mode = param[0];
484 ad9361_set_rx_gain_control_mode(ad9361_phy, 0, gc_mode);
485 console_print("rx1_gc_mode=%d\n", gc_mode);
486 }
487 else
488 show_invalid_param_message(1);
489 }
490
491 /**************************************************************************//***
492 * @brief Gets current RX2 GC mode.
493 *
494 * @return None.
495 *******************************************************************************/
496 void get_rx2_gc_mode(double* param, char param_no) // "rx2_gc_mode?" command
497 {
498 uint8_t gc_mode;
499
500 ad9361_get_rx_gain_control_mode(ad9361_phy, 1, &gc_mode);
501 console_print("rx2_gc_mode=%d\n", gc_mode);
502 }
503
504 /**************************************************************************//***
505 * @brief Sets the RX2 GC mode.
506 *
507 * @return None.
508 *******************************************************************************/
509 void set_rx2_gc_mode(double* param, char param_no) // "rx2_gc_mode=" command
510 {
511 uint8_t gc_mode;
512
513 if(param_no >= 1)
514 {
515 gc_mode = param[0];
516 ad9361_set_rx_gain_control_mode(ad9361_phy, 1, gc_mode);
517 console_print("rx2_gc_mode=%d\n", gc_mode);
518 }
519 else
520 show_invalid_param_message(1);
521 }
522
523 /**************************************************************************//***
524 * @brief Gets current RX1 RF gain.
525 *
526 * @return None.
527 *******************************************************************************/
528 void get_rx1_rf_gain(double* param, char param_no) // "rx1_rf_gain?" command
529 {
530 int32_t gain_db;
531
532 ad9361_get_rx_rf_gain (ad9361_phy, 0, &gain_db);
533 console_print("rx1_rf_gain=%d\n", gain_db);
534 }
535
536 /**************************************************************************//***
537 * @brief Sets the RX1 RF gain.
538 *
539 * @return None.
540 *******************************************************************************/
541 void set_rx1_rf_gain(double* param, char param_no) // "rx1_rf_gain=" command
542 {
543 int32_t gain_db;
544
545 if(param_no >= 1)
546 {
547 gain_db = param[0];
548 ad9361_set_rx_rf_gain (ad9361_phy, 0, gain_db);
549 console_print("rx1_rf_gain=%d\n", gain_db);
550 }
551 else
552 show_invalid_param_message(1);
553 }
554
555 /**************************************************************************//***
556 * @brief Gets current RX2 RF gain.
557 *
558 * @return None.
559 *******************************************************************************/
560 void get_rx2_rf_gain(double* param, char param_no) // "rx2_rf_gain?" command
561 {
562 int32_t gain_db;
563
564 ad9361_get_rx_rf_gain (ad9361_phy, 1, &gain_db);
565 console_print("rx2_rf_gain=%d\n", gain_db);
566 }
567
568 /**************************************************************************//***
569 * @brief Sets the RX2 RF gain.
570 *
571 * @return None.
572 *******************************************************************************/
573 void set_rx2_rf_gain(double* param, char param_no) // "rx2_rf_gain=" command
574 {
575 int32_t gain_db;
576
577 if(param_no >= 1)
578 {
579 gain_db = param[0];
580 ad9361_set_rx_rf_gain (ad9361_phy, 1, gain_db);
581 console_print("rx2_rf_gain=%d\n", gain_db);
582 }
583 else
584 show_invalid_param_message(1);
585 }
586
587 /**************************************************************************//***
588 * @brief Gets current RX FIR state.
589 *
590 * @return None.
591 *******************************************************************************/
592 void get_rx_fir_en(double* param, char param_no) // "rx_fir_en?" command
593 {
594 uint8_t en_dis;
595
596 ad9361_get_rx_fir_en_dis(ad9361_phy, &en_dis);
597 console_print("rx_fir_en=%d\n", en_dis);
598 }
599
600 /**************************************************************************//***
601 * @brief Sets the RX FIR state.
602 *
603 * @return None.
604 *******************************************************************************/
605 void set_rx_fir_en(double* param, char param_no) // "rx_fir_en=" command
606 {
607 uint8_t en_dis;
608
609 if(param_no >= 1)
610 {
611 en_dis = param[0];
612 ad9361_set_rx_fir_en_dis(ad9361_phy, en_dis);
613 console_print("rx_fir_en=%d\n", en_dis);
614 }
615 else
616 show_invalid_param_message(1);
617 }
618
619 /**************************************************************************//***
620 * @brief Gets current DDS TX1 Tone 1 frequency [Hz].
621 *
622 * @return None.
623 *******************************************************************************/
624 void get_dds_tx1_tone1_freq(double* param, char param_no) // dds_tx1_tone1_freq?
625 {
626 uint32_t freq = dds_st.cached_freq[DDS_CHAN_TX1_I_F1];
627
628 console_print("dds_tx1_tone1_freq=%d\n", freq);
629 }
630
631 /**************************************************************************//***
632 * @brief Sets the DDS TX1 Tone 1 frequency [Hz].
633 *
634 * @return None.
635 *******************************************************************************/
636 void set_dds_tx1_tone1_freq(double* param, char param_no) // dds_tx1_tone1_freq=
637 {
638 uint32_t freq = (uint32_t)param[0];
639
640 if(param_no >= 1)
641 {
642 dds_set_frequency(ad9361_phy, DDS_CHAN_TX1_I_F1, freq);
643 dds_set_frequency(ad9361_phy, DDS_CHAN_TX1_Q_F1, freq);
644 console_print("dds_tx1_tone1_freq=%d\n", freq);
645 }
646 else
647 show_invalid_param_message(1);
648 }
649
650 /**************************************************************************//***
651 * @brief Gets current DDS TX1 Tone 2 frequency [Hz].
652 *
653 * @return None.
654 *******************************************************************************/
655 void get_dds_tx1_tone2_freq(double* param, char param_no) // dds_tx1_tone2_freq?
656 {
657 uint32_t freq = dds_st.cached_freq[DDS_CHAN_TX1_I_F2];
658
659 console_print("dds_tx1_tone2_freq=%d\n", freq);
660 }
661
662 /**************************************************************************//***
663 * @brief Sets the DDS TX1 Tone 2 frequency [Hz].
664 *
665 * @return None.
666 *******************************************************************************/
667 void set_dds_tx1_tone2_freq(double* param, char param_no) // dds_tx1_tone2_freq=
668 {
669 uint32_t freq = (uint32_t)param[0];
670
671 if(param_no >= 1)
672 {
673 dds_set_frequency(ad9361_phy, DDS_CHAN_TX1_I_F2, freq);
674 dds_set_frequency(ad9361_phy, DDS_CHAN_TX1_Q_F2, freq);
675 console_print("dds_tx1_tone2_freq=%d\n", freq);
676 }
677 else
678 show_invalid_param_message(1);
679 }
680
681 /**************************************************************************//***
682 * @brief Gets current DDS TX1 Tone 1 phase [degrees].
683 *
684 * @return None.
685 *******************************************************************************/
686 void get_dds_tx1_tone1_phase(double* param, char param_no) // dds_tx1_tone1_phase?
687 {
688 uint32_t phase = dds_st.cached_phase[DDS_CHAN_TX1_I_F1];
689
690 phase /= 1000;
691 console_print("dds_tx1_tone1_phase=%d\n", phase);
692 }
693
694 /**************************************************************************//***
695 * @brief Sets the DDS TX1 Tone 1 phase [degrees].
696 *
697 * @return None.
698 *******************************************************************************/
699 void set_dds_tx1_tone1_phase(double* param, char param_no) // dds_tx1_tone1_phase=
700 {
701 int32_t phase = (uint32_t)param[0];
702
703 if(param_no >= 1)
704 {
705 dds_set_phase(ad9361_phy, DDS_CHAN_TX1_I_F1, (uint32_t)(phase * 1000));
706 if ((phase - 90) < 0)
707 phase += 360;
708 dds_set_phase(ad9361_phy, DDS_CHAN_TX1_Q_F1, (uint32_t)((phase - 90) * 1000));
709 phase = dds_st.cached_phase[DDS_CHAN_TX1_I_F1] / 1000;
710 console_print("dds_tx1_tone1_phase=%d\n", phase);
711 }
712 else
713 show_invalid_param_message(1);
714 }
715
716 /**************************************************************************//***
717 * @brief Gets current DDS TX1 Tone 2 phase [degrees].
718 *
719 * @return None.
720 *******************************************************************************/
721 void get_dds_tx1_tone2_phase(double* param, char param_no) // dds_tx1_tone2_phase?
722 {
723 uint32_t phase = dds_st.cached_phase[DDS_CHAN_TX1_I_F2];
724
725 phase /= 1000;
726 console_print("dds_tx1_tone2_phase=%d\n", phase);
727 }
728
729 /**************************************************************************//***
730 * @brief Sets the DDS TX1 Tone 2 phase [degrees].
731 *
732 * @return None.
733 *******************************************************************************/
734 void set_dds_tx1_tone2_phase(double* param, char param_no) // dds_tx1_tone2_phase=
735 {
736 int32_t phase = (uint32_t)param[0];
737
738 if(param_no >= 1)
739 {
740 dds_set_phase(ad9361_phy, DDS_CHAN_TX1_I_F2, (uint32_t)(phase * 1000));
741 if ((phase - 90) < 0)
742 phase += 360;
743 dds_set_phase(ad9361_phy, DDS_CHAN_TX1_Q_F2, (uint32_t)((phase - 90) * 1000));
744 phase = dds_st.cached_phase[DDS_CHAN_TX1_I_F2] / 1000;
745 console_print("dds_tx1_tone2_phase=%d\n", phase);
746 }
747 else
748 show_invalid_param_message(1);
749 }
750
751 /**************************************************************************//***
752 * @brief Gets current DDS TX1 Tone 1 scale.
753 *
754 * @return None.
755 *******************************************************************************/
756 void get_dds_tx1_tone1_scale(double* param, char param_no) // dds_tx1_tone1_scale?
757 {
758 int32_t scale = dds_st.cached_scale[DDS_CHAN_TX1_I_F1];
759
760 console_print("dds_tx1_tone1_scale=%d\n", scale);
761 }
762
763 /**************************************************************************//***
764 * @brief Sets the DDS TX1 Tone 1 scale.
765 *
766 * @return None.
767 *******************************************************************************/
768 void set_dds_tx1_tone1_scale(double* param, char param_no) // dds_tx1_tone1_scale=
769 {
770 int32_t scale = (int32_t)param[0];
771
772 if(param_no >= 1)
773 {
774 dds_set_scale(ad9361_phy, DDS_CHAN_TX1_I_F1, scale);
775 dds_set_scale(ad9361_phy, DDS_CHAN_TX1_Q_F1, scale);
776 scale = dds_st.cached_scale[DDS_CHAN_TX1_I_F1];
777 console_print("dds_tx1_tone1_scale=%d\n", scale);
778 }
779 else
780 show_invalid_param_message(1);
781 }
782
783 /**************************************************************************//***
784 * @brief Gets current DDS TX1 Tone 2 scale.
785 *
786 * @return None.
787 *******************************************************************************/
788 void get_dds_tx1_tone2_scale(double* param, char param_no) // dds_tx1_tone2_scale?
789 {
790 int32_t scale = dds_st.cached_scale[DDS_CHAN_TX1_I_F2];
791
792 console_print("dds_tx1_tone2_scale=%d\n", scale);
793 }
794
795 /**************************************************************************//***
796 * @brief Sets the DDS TX1 Tone 2 scale.
797 *
798 * @return None.
799 *******************************************************************************/
800 void set_dds_tx1_tone2_scale(double* param, char param_no) // dds_tx1_tone2_scale=
801 {
802 int32_t scale = (int32_t)param[0];
803
804 if(param_no >= 1)
805 {
806 dds_set_scale(ad9361_phy, DDS_CHAN_TX1_I_F2, scale);
807 dds_set_scale(ad9361_phy, DDS_CHAN_TX1_Q_F2, scale);
808 scale = dds_st.cached_scale[DDS_CHAN_TX1_I_F2];
809 console_print("dds_tx1_tone2_scale=%d\n", scale);
810 }
811 else
812 show_invalid_param_message(1);
813 }
814
815 /**************************************************************************//***
816 * @brief Gets current DDS TX2 Tone 1 frequency [Hz].
817 *
818 * @return None.
819 *******************************************************************************/
820 void get_dds_tx2_tone1_freq(double* param, char param_no) // dds_tx2_tone1_freq?
821 {
822 uint32_t freq = dds_st.cached_freq[DDS_CHAN_TX2_I_F1];
823
824 console_print("dds_tx2_tone1_freq=%d\n", freq);
825 }
826
827 /**************************************************************************//***
828 * @brief Sets the DDS TX2 Tone 1 frequency [Hz].
829 *
830 * @return None.
831 *******************************************************************************/
832 void set_dds_tx2_tone1_freq(double* param, char param_no) // dds_tx2_tone1_freq=
833 {
834 uint32_t freq = (uint32_t)param[0];
835
836 if(param_no >= 1)
837 {
838 dds_set_frequency(ad9361_phy, DDS_CHAN_TX2_I_F1, freq);
839 dds_set_frequency(ad9361_phy, DDS_CHAN_TX2_Q_F1, freq);
840 console_print("dds_tx2_tone1_freq=%d\n", freq);
841 }
842 else
843 show_invalid_param_message(1);
844 }
845
846 /**************************************************************************//***
847 * @brief Gets current DDS TX2 Tone 2 frequency [Hz].
848 *
849 * @return None.
850 *******************************************************************************/
851 void get_dds_tx2_tone2_freq(double* param, char param_no) // dds_tx2_tone2_freq?
852 {
853 uint32_t freq = dds_st.cached_freq[DDS_CHAN_TX2_I_F2];
854
855 console_print("dds_tx2_tone2_freq=%d\n", freq);
856 }
857
858 /**************************************************************************//***
859 * @brief Sets the DDS TX2 Tone 2 frequency [Hz].
860 *
861 * @return None.
862 *******************************************************************************/
863 void set_dds_tx2_tone2_freq(double* param, char param_no) // dds_tx2_tone2_freq=
864 {
865 uint32_t freq = (uint32_t)param[0];
866
867 if(param_no >= 1)
868 {
869 dds_set_frequency(ad9361_phy, DDS_CHAN_TX2_I_F2, freq);
870 dds_set_frequency(ad9361_phy, DDS_CHAN_TX2_Q_F2, freq);
871 console_print("dds_tx2_tone2_freq=%d\n", freq);
872 }
873 else
874 show_invalid_param_message(1);
875 }
876
877 /**************************************************************************//***
878 * @brief Gets current DDS TX2 Tone 1 phase [degrees].
879 *
880 * @return None.
881 *******************************************************************************/
882 void get_dds_tx2_tone1_phase(double* param, char param_no) // dds_tx2_tone1_phase?
883 {
884 uint32_t phase = dds_st.cached_phase[DDS_CHAN_TX2_I_F1];
885
886 phase /= 1000;
887 console_print("dds_tx2_tone1_phase=%d\n", phase);
888 }
889
890 /**************************************************************************//***
891 * @brief Sets the DDS TX2 Tone 1 phase [degrees].
892 *
893 * @return None.
894 *******************************************************************************/
895 void set_dds_tx2_tone1_phase(double* param, char param_no) // dds_tx2_tone1_phase=
896 {
897 int32_t phase = (uint32_t)param[0];
898
899 if(param_no >= 1)
900 {
901 dds_set_phase(ad9361_phy, DDS_CHAN_TX2_I_F1, (uint32_t)(phase * 1000));
902 if ((phase - 90) < 0)
903 phase += 360;
904 dds_set_phase(ad9361_phy, DDS_CHAN_TX2_Q_F1, (uint32_t)((phase - 90) * 1000));
905 phase = dds_st.cached_phase[DDS_CHAN_TX2_I_F1] / 1000;
906 console_print("dds_tx2_tone1_phase=%d\n", phase);
907 }
908 else
909 show_invalid_param_message(1);
910 }
911
912 /**************************************************************************//***
913 * @brief Gets current DDS TX2 Tone 2 phase [degrees].
914 *
915 * @return None.
916 *******************************************************************************/
917 void get_dds_tx2_tone2_phase(double* param, char param_no) // dds_tx2_tone2_phase?
918 {
919 uint32_t phase = dds_st.cached_phase[DDS_CHAN_TX2_I_F2];
920
921 phase /= 1000;
922 console_print("dds_tx2_f2_phase=%d\n", phase);
923 }
924
925 /**************************************************************************//***
926 * @brief Sets the DDS TX2 Tone 2 phase [degrees].
927 *
928 * @return None.
929 *******************************************************************************/
930 void set_dds_tx2_tone2_phase(double* param, char param_no) // dds_tx2_tone2_phase=
931 {
932 int32_t phase = (uint32_t)param[0];
933
934 if(param_no >= 1)
935 {
936 dds_set_phase(ad9361_phy, DDS_CHAN_TX2_I_F2, (uint32_t)(phase * 1000));
937 if ((phase - 90) < 0)
938 phase += 360;
939 dds_set_phase(ad9361_phy, DDS_CHAN_TX2_Q_F2, (uint32_t)((phase - 90) * 1000));
940 phase = dds_st.cached_phase[DDS_CHAN_TX2_I_F2] / 1000;
941 console_print("dds_tx2_tone2_phase=%d\n", phase);
942 }
943 else
944 show_invalid_param_message(1);
945 }
946
947 /**************************************************************************//***
948 * @brief Gets current DDS TX2 Tone 1 scale.
949 *
950 * @return None.
951 *******************************************************************************/
952 void get_dds_tx2_tone1_scale(double* param, char param_no) // dds_tx2_tone1_scale?
953 {
954 int32_t scale = dds_st.cached_scale[DDS_CHAN_TX2_I_F1];
955
956 console_print("dds_tx2_tone1_scale=%d\n", scale);
957 }
958
959 /**************************************************************************//***
960 * @brief Sets the DDS TX2 Tone 1 scale.
961 *
962 * @return None.
963 *******************************************************************************/
964 void set_dds_tx2_tone1_scale(double* param, char param_no) // dds_tx2_tone1_scale=
965 {
966 int32_t scale = (int32_t)param[0];
967
968 if(param_no >= 1)
969 {
970 dds_set_scale(ad9361_phy, DDS_CHAN_TX2_I_F1, scale);
971 dds_set_scale(ad9361_phy, DDS_CHAN_TX2_Q_F1, scale);
972 scale = dds_st.cached_scale[DDS_CHAN_TX2_I_F1];
973 console_print("dds_tx2_tone1_scale=%d\n", scale);
974 }
975 else
976 show_invalid_param_message(1);
977 }
978
979 /**************************************************************************//***
980 * @brief Gets current DDS TX2 Tone 2 scale.
981 *
982 * @return None.
983 *******************************************************************************/
984 void dds_tx2_tone2_scale(double* param, char param_no) // dds_tx2_tone2_scale?
985 {
986 int32_t scale = dds_st.cached_scale[DDS_CHAN_TX2_I_F2];
987
988 console_print("dds_tx2_tone2_scale=%d\n", scale);
989 }
990
991 /**************************************************************************//***
992 * @brief Sets the DDS TX2 Tone 2 scale.
993 *
994 * @return None.
995 *******************************************************************************/
996 void set_dds_tx2_tone2_scale(double* param, char param_no) // dds_tx2_tone2_scale=
997 {
998 int32_t scale = (int32_t)param[0];
999
1000 if(param_no >= 1)
1001 {
1002 dds_set_scale(ad9361_phy, DDS_CHAN_TX2_I_F2, scale);
1003 dds_set_scale(ad9361_phy, DDS_CHAN_TX2_Q_F2, scale);
1004 scale = dds_st.cached_scale[DDS_CHAN_TX2_I_F2];
1005 console_print("dds_tx2_tone2_scale=%d\n", scale);
1006 }
1007 else
1008 show_invalid_param_message(1);
1009 }