1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
|
/**
* \file headless.c
*
* \brief Contains example code for user integration with their application
*
* All data structures required for operation have been initialized with values which reflect
* these settings:
*
* Device Clock:
* 125MHz
*
* Profiles:
* Rx 100MHz, IQrate 125MSPS, Dec5
* Tx 20/100MHz, IQrate 125MSPS, Dec5
* ORX 100MHz, IQrate 125MSPS, Dec5
* SRx 20MHz, IQrate 31.25MSPS, Dec5
*
*/
#include <stdlib.h>
#include "headless.h"
#include "t_mykonos.h"
#include "mykonos.h"
#include "mykonos_gpio.h"
#include "mykonos_config.h"
//#include "mykonos_static_config.h"
/****< Action: Insert rest of required Includes Here >***/
int oldmain()
{
const char* errorString;
uint8_t mcsStatus = 0;
uint8_t pllLockStatus = 0;
uint8_t binary[98304] = {0}; /*** < Action: binary should contain ARM binary file as array > ***/
uint32_t count = sizeof(binary);
uint8_t errorFlag = 0;
uint8_t errorCode = 0;
uint32_t initCalsCompleted = 0;
uint16_t errorWord = 0;
uint16_t statusWord = 0;
uint8_t status = 0;
mykonosInitCalStatus_t initCalStatus = {0};
uint8_t deframerStatus = 0;
uint8_t obsFramerStatus = 0;
uint8_t framerStatus = 0;
uint32_t initCalMask = TX_BB_FILTER | ADC_TUNER | TIA_3DB_CORNER | DC_OFFSET |
TX_ATTENUATION_DELAY | RX_GAIN_DELAY | FLASH_CAL |
PATH_DELAY | TX_LO_LEAKAGE_INTERNAL | TX_QEC_INIT |
LOOPBACK_RX_LO_DELAY | LOOPBACK_RX_RX_QEC_INIT |
RX_LO_DELAY | RX_QEC_INIT;
uint32_t trackingCalMask = TRACK_RX1_QEC |
TRACK_RX2_QEC |
TRACK_TX1_QEC |
TRACK_TX2_QEC |
TRACK_ORX1_QEC|
TRACK_ORX2_QEC;
mykonosErr_t mykError = MYKONOS_ERR_OK;
mykonosGpioErr_t mykGpioErr = MYKONOS_ERR_GPIO_OK;
/* Allocating memory for the errorString */
errorString = (const char*) malloc(sizeof(char) * 200);
/*** < Action: Insert System Clock(s) Initialization Code Here > ***/
/*** < Action: Insert BBIC Initialization Code Here > ***/
/*************************************************************************/
/***** Mykonos Initialization Sequence *****/
/*************************************************************************/
// TODO: change to unique ptr
mykonos_config config();
mykonosDevice_t *mykDevice = &config.device;
/*** < Action: Toggle RESETB pin on Mykonos device > ***/
if ((mykError = MYKONOS_resetDevice(&mykDevice)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_initialize(&mykDevice)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
/*************************************************************************/
/***** Mykonos CLKPLL Status Check *****/
/*************************************************************************/
if ((mykError = MYKONOS_checkPllsLockStatus(&mykDevice, &pllLockStatus)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if (pllLockStatus & 0x01)
{
/*** < User: code here for actions once CLKPLL locked > ***/
}
else
{
/*** < User: code here here for actions since CLKPLL not locked
* ensure lock before proceeding - > ***/
}
/*************************************************************************/
/***** Mykonos Perform MultiChip Sync *****/
/*************************************************************************/
if ((mykError = MYKONOS_enableMultichipSync(&mykDevice, 1, &mcsStatus)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
/*** < Action: minimum 3 SYSREF pulses from Clock Device has to be produced
* for MulticChip Sync > ***/
/*************************************************************************/
/***** Mykonos Verify MultiChip Sync *****/
/*************************************************************************/
if ((mykError = MYKONOS_enableMultichipSync(&mykDevice, 0, &mcsStatus)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mcsStatus & 0x0B) == 0x0B)
{
/*** < Info: MCS successful > ***/
/*** < Action: extra User code > ***/
}
else
{
/*** < Info: MCS failed > ***/
/*** < Action: ensure MCS before proceeding > ***/
}
/*************************************************************************/
/***** Mykonos Load ARM file *****/
/*************************************************************************/
if (pllLockStatus & 0x01)
{
if ((mykError = MYKONOS_initArm(&mykDevice)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
/*** < Action: User must load ARM binary byte array into variable binary[98304] before calling next command > ***/
if ((mykError = MYKONOS_loadArmFromBinary(&mykDevice, &binary[0], count)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug why
* ARM did not load properly - check binary and device settings > ***/
/*** < Action: User code > ***/
errorString = getMykonosErrorMessage(mykError);
}
}
else
{
/*** < Action: check settings for proper CLKPLL lock > ***/
}
/*************************************************************************/
/***** Mykonos Set RF PLL Frequencies *****/
/*************************************************************************/
if ((mykError = MYKONOS_setRfPllFrequency(&mykDevice, RX_PLL, mykDevice.rx->rxPllLoFrequency_Hz)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_setRfPllFrequency(&mykDevice, TX_PLL, mykDevice.tx->txPllLoFrequency_Hz)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_setRfPllFrequency(&mykDevice, SNIFFER_PLL, mykDevice.obsRx->snifferPllLoFrequency_Hz)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
/*** < Action: wait 200ms for PLLs to lock > ***/
if ((mykError = MYKONOS_checkPllsLockStatus(&mykDevice, &pllLockStatus)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((pllLockStatus & 0x0F) == 0x0F)
{
/*** < Info: All PLLs locked > ***/
}
else
{
/*** < Info: PLLs not locked > ***/
/*** < Action: Ensure lock before proceeding - User code here > ***/
}
/*************************************************************************/
/***** Mykonos Set GPIOs *****/
/*************************************************************************/
if ((mykGpioErr = MYKONOS_setRx1GainCtrlPin(&mykDevice, 0, 0, 0, 0, 0)) != MYKONOS_ERR_GPIO_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getGpioMykonosErrorMessage(mykGpioErr);
}
if ((mykGpioErr = MYKONOS_setRx2GainCtrlPin(&mykDevice, 0, 0, 0, 0, 0)) != MYKONOS_ERR_GPIO_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getGpioMykonosErrorMessage(mykGpioErr);
}
if ((mykGpioErr = MYKONOS_setTx1AttenCtrlPin(&mykDevice, 0, 0, 0, 0, 0)) != MYKONOS_ERR_GPIO_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getGpioMykonosErrorMessage(mykGpioErr);
}
if ((mykGpioErr = MYKONOS_setTx2AttenCtrlPin(&mykDevice, 0, 0, 0, 0)) != MYKONOS_ERR_GPIO_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getGpioMykonosErrorMessage(mykGpioErr);
}
if ((mykGpioErr = MYKONOS_setupGpio(&mykDevice)) != MYKONOS_ERR_GPIO_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getGpioMykonosErrorMessage(mykGpioErr);
}
/*************************************************************************/
/***** Mykonos Set manual gains values *****/
/*************************************************************************/
if ((mykError = MYKONOS_setRx1ManualGain(&mykDevice, 255)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_setRx2ManualGain(&mykDevice, 255)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_setObsRxManualGain(&mykDevice, OBS_RX1_TXLO, 255)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_setObsRxManualGain(&mykDevice, OBS_RX2_TXLO, 255)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_setObsRxManualGain(&mykDevice, OBS_SNIFFER_A, 255)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_setObsRxManualGain(&mykDevice, OBS_SNIFFER_B, 255)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_setObsRxManualGain(&mykDevice, OBS_SNIFFER_C, 255)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
/*************************************************************************/
/***** Mykonos Initialize attenuations *****/
/*************************************************************************/
if ((mykError = MYKONOS_setTx1Attenuation(&mykDevice, 0)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_setTx2Attenuation(&mykDevice, 0)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
/*************************************************************************/
/***** Mykonos ARM Initialization Calibrations *****/
/*************************************************************************/
if ((mykError = MYKONOS_runInitCals(&mykDevice, (initCalMask & ~TX_LO_LEAKAGE_EXTERNAL))) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_waitInitCals(&mykDevice, 60000, &errorFlag, &errorCode)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((errorFlag != 0) || (errorCode != 0))
{
if ((mykError = MYKONOS_getInitCalStatus(&mykDevice, &initCalStatus)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
/*** < Info: abort init cals > ***/
if ((mykError = MYKONOS_abortInitCals(&mykDevice, &initCalsCompleted)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if (initCalsCompleted)
{
/*** < Info: which calls had completed, per the mask > ***/
}
if ((mykError = MYKONOS_readArmCmdStatus(&mykDevice, &errorWord, &statusWord)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_readArmCmdStatusByte(&mykDevice, 2, &status)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug why failed > ***/
errorString = getMykonosErrorMessage(mykError);
}
if (status != 0)
{
/*** < Info: Arm Mailbox Status Error errorWord > ***/
/*** < Info: Pending Flag per opcode statusWord, this follows the mask > ***/
}
}
else
{
/*** < Info: Calibrations completed successfully > ***/
}
/*************************************************************************/
/***** Mykonos ARM Initialization External LOL Calibrations with PA *****/
/*************************************************************************/
/*** < Action: Please ensure PA is enabled operational at this time > ***/
if (initCalMask & TX_LO_LEAKAGE_EXTERNAL)
{
if ((mykError = MYKONOS_runInitCals(&mykDevice, TX_LO_LEAKAGE_EXTERNAL)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_waitInitCals(&mykDevice, 60000, &errorFlag, &errorCode)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((errorFlag != 0) || (errorCode != 0))
{
if ((mykError = MYKONOS_getInitCalStatus(&mykDevice, &initCalStatus)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
/*** < Info: abort init cals > ***/
if ((mykError = MYKONOS_abortInitCals(&mykDevice, &initCalsCompleted)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if (initCalsCompleted)
{
/*** < Info: which calls had completed, per the mask > ***/
}
if ((mykError = MYKONOS_readArmCmdStatus(&mykDevice, &errorWord, &statusWord)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_readArmCmdStatusByte(&mykDevice, 2, &status)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if (status != 0)
{
/*** < Info: Arm Mailbox Status Error errorWord > ***/
/*** < Info: Pending Flag per opcode statusWord, this follows the mask > ***/
}
}
else
{
/*** < Info: Calibrations completed successfully > ***/
}
}
/*************************************************************************/
/***** SYSTEM JESD bring up procedure *****/
/*************************************************************************/
/*** < Action: Make sure SYSREF is stopped/disabled > ***/
/*** < Action: Make sure BBIC JESD is reset and ready to recieve CGS chars> ***/
if ((mykError = MYKONOS_enableSysrefToRxFramer(&mykDevice, 1)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
/*** < Info: Mykonos is waiting for sysref in order to start
* transmitting CGS from the RxFramer> ***/
if ((mykError = MYKONOS_enableSysrefToObsRxFramer(&mykDevice, 1)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
/*** < Info: Mykonos is waiting for sysref in order to start
* transmitting CGS from the ObsRxFramer> ***/
/*** < User: Make sure SYSREF is stopped/disabled > ***/
if ((mykError = MYKONOS_enableSysrefToDeframer(&mykDevice, 0)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_resetDeframer(&mykDevice)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
/*** < User: make sure BBIC JESD framer is actively transmitting CGS> ***/
if ((mykError = MYKONOS_enableSysrefToDeframer(&mykDevice, 1)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
/*************************************************************************/
/***** Enable SYSREF to Mykonos and BBIC *****/
/*************************************************************************/
/*** < Action: Sends SYSREF Here > ***/
/*** < Info: Mykonos is actively transmitting CGS from the RxFramer> ***/
/*** < Info: Mykonos is actively transmitting CGS from the ObsRxFramer> ***/
/*** < Action: Insert User: BBIC JESD Sync Verification Code Here > ***/
/*************************************************************************/
/***** Check Mykonos Framer Status *****/
/*************************************************************************/
if ((mykError = MYKONOS_readRxFramerStatus(&mykDevice, &framerStatus)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_readOrxFramerStatus(&mykDevice, &obsFramerStatus)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
/*************************************************************************/
/***** Check Mykonos Deframer Status *****/
/*************************************************************************/
if ((mykError = MYKONOS_readDeframerStatus(&mykDevice, &deframerStatus)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
/*** < Action: When links have been verified, proceed > ***/
/*************************************************************************/
/***** Mykonos enable tracking calibrations *****/
/*************************************************************************/
if ((mykError = MYKONOS_enableTrackingCals(&mykDevice, trackingCalMask)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug why enableTrackingCals failed > ***/
errorString = getMykonosErrorMessage(mykError);
}
/*** < Info: Allow Rx1/2 QEC tracking and Tx1/2 QEC tracking to run when in the radioOn state
* Tx calibrations will only run if radioOn and the obsRx path is set to OBS_INTERNAL_CALS > ***/
/*** < Info: Function to turn radio on, Enables transmitters and receivers
* that were setup during MYKONOS_initialize() > ***/
if ((mykError = MYKONOS_radioOn(&mykDevice)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
/*** < Info: Allow TxQEC to run when User: is not actively using ORx receive path > ***/
if ((mykError = MYKONOS_setObsRxPathSource(&mykDevice, OBS_RXOFF)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
if ((mykError = MYKONOS_setObsRxPathSource(&mykDevice, OBS_INTERNALCALS)) != MYKONOS_ERR_OK)
{
/*** < Info: errorString will contain log error string in order to debug failure > ***/
errorString = getMykonosErrorMessage(mykError);
}
return 0;
}
|