ngc 1.4.0
 
Loading...
Searching...
No Matches
ngcdcsSLX.hpp
Go to the documentation of this file.
1
7#ifndef ngcdcsSLX_H
8#define ngcdcsSLX_H
9
10
11#ifndef __cplusplus
12#error This is a C++ include file and cannot be used from plain C
13#endif
14
15/*
16 * System Headers
17 */
18#include <stdio.h>
19#include <stdlib.h>
20#include <string.h>
21#include <unistd.h>
22#include <errno.h>
23
24/*
25 * Local Headers
26 */
27#include <ngc/core/ngcb.h>
28#include <ngc/core/ngcbAddr.h>
29
33#define ngcdcsSLX_MAX_WIN 48
34
35/*
36 * Multiplexer control register (MCR)
37 */
38#define ngcdcsSLX_MCR_CHAN 0x03 //< channel selection mask
39#define ngcdcsSLX_MCR_CHAN4 0x00 //< 4 channels
40#define ngcdcsSLX_MCR_CHAN8 0x01 //< 8 channels
41#define ngcdcsSLX_MCR_CHAN16 0x02 //< 16 channels
42#define ngcdcsSLX_MCR_CHAN32 0x03 //< 32 channels
43#define ngcdcsSLX_MCR_EXTRST 0x04 //< external reset
44#define ngcdcsSLX_MCR_NO_REF 0x08 //< disable reference pixels
45#define ngcdcsSLX_MCR_CB_REF_EN 0x10 //< enable ballast capacitors (reference)
46#define ngcdcsSLX_MCR_CB_EN 0x20 //< enable ballast capacitors (33-288)
47#define ngcdcsSLX_MCR_LSP_EN 0x40 //< enable LSP output
48#define ngcdcsSLX_MCR_NO_CLAMP 0x80 //< disable clamp function
49
50/*
51 * Read-out modes
52 */
53#define ngcdcsSLX_RM_ITR 0x00 //< integrate-then-read
54#define ngcdcsSLX_RM_RR 0x01 //< rolling reset
55#define ngcdcsSLX_RM_RDRSTRD 0x02 //< read-reset-read
56
57/*
58 * Detector control register (DCR)
59 */
60#define ngcdcsSLX_DCR_RM 0x0f //< read-out mode mask
61#define ngcdcsSLX_DCR_SELECT 0xf0 //< register selection mask
62#define ngcdcsSLX_DCR_MCR 0x10 //< program MCR
63#define ngcdcsSLX_DCR_WDR 0x20 //< program WDR
64#define ngcdcsSLX_DCR_WRR 0x40 //< program WRR
65
69#define ngcdcsSLX_NROW 256
70
74#define ngcdcsSLX_NCOL 320
75
79#define ngcdcsSLX_NCOL_NO_REF 256
80
87
90
93
95 void Init() {numBits = 0; memset(array, 0, sizeof(array));}
96
98 int TxSize() {
99 int n;
100 int numBytes = numBits / 8;
101 if ((numBits % 8) > 0) numBytes++;
102 n = numBytes / 4;
103 if ((numBytes % 4) > 0) n++;
104 return (n);
105 }
106};
107
113 int start;
114
116 int size;
117
120
122 void Clear() {start = 0; size = 0;}
123
125 int Valid() {return ((start > 0) && (size > 0));}
126
128 friend int operator==(const ngcdcs_slxrow_t &a, const ngcdcs_slxrow_t &b) {
129 return ((a.size == b.size) && (a.start == b.start));
130 }
131};
132
138 short colRst;
139
141 short colData;
142
145
148
151
153 int mcr;
154
157
160
163
165 int valid;
166
169 ClearWin();
172 fullFrame = 1;
173 newCfg = 0;
174 enabled = 0;
175 valid = 0;
176 }
177
179 void ClearWin() {
180 int i;
181
182 for (i=0;i<ngcdcsSLX_MAX_WIN;i++)
183 {
184 rowRst[i].Clear();
185 rowData[i].Clear();
186 }
187
188 colRst = 0x0;
189 colData = 0x0;
190 }
191
193 void ClearRstWin() {
194 int i;
195 for (i=0;i<ngcdcsSLX_MAX_WIN;i++) rowRst[i].Clear();
196 colRst = 0x0;
197 }
198
201 int i;
202 for (i=0;i<ngcdcsSLX_MAX_WIN;i++) rowData[i].Clear();
203 colData = 0x0;
204 }
205
207 int ValidWin() {
208 if (colData != 0)
209 {
210 int i;
211 for (i=0;i<ngcdcsSLX_MAX_WIN;i++)
212 {
213 if (rowData[i].Valid())
214 {
215 return (1);
216 }
217 }
218 }
219 return (0);
220 }
221};
222
226#define ngcdcsSHIFT_MAX 32
227
232public:
235
238
241
244 erms_[0] = '\0';
245
246 /*
247 * Interface enabled
248 */
249 enabled = 1;
250
251 /*
252 * Clear control registers
253 */
254 mcr_ = 0x0;
255 dcr_ = 0x0;
256
257 /*
258 * Clear configuration flags
259 */
260 ClearCfg();
261
262 /*
263 * We only support 32-channel mode
264 */
266
267 /*
268 * Default read-out mode
269 */
271
272 /*
273 * Full frame
274 */
275 FullFrame();
276 fullFrame = 1;
277
278 /*
279 * Clear shift register
280 */
281 memset(shiftReg, 0, sizeof(shiftReg));
282 shiftRegSize = 0;
283 }
284
285 // Destructor
286 virtual ~ngcdcsSLX() {}
287
289 char *ErrMsg() {return (erms_);}
290
292 void ReadMode(int mode) {
293 readMode_ = mode & ngcdcsSLX_DCR_RM;
294 dcr_ &= ~ngcdcsSLX_DCR_RM;
295 dcr_ |= (char)readMode_;
296 rmX_ = 1;
297 }
298
300 int ReadMode() {return (readMode_);}
301
303 char DCR() {return (dcr_);}
304
306 void MCR(int value) {
307 mcr_ = (char)(value & 0xff);
308
309 /*
310 * We only support 32-channel mode
311 */
312 mcr_ &= ~ngcdcsSLX_MCR_CHAN;
313 mcr_ |= ngcdcsSLX_MCR_CHAN32;
314
315 mcrX_ = 1;
316 }
317
319 char MCR() {return (mcr_);}
320
322 void FullFrame() {WDRALL(); WRRALL();}
323
325 void ClearWin() {WDRCLR(); WRRCLR(); }
326
328 void ClearCfg() {rmX_ = 0; wdrX_ = 0; wrrX_ = 0; mcrX_ = 0;}
329
331 void Configure() {
332 int n;
333
334 /*
335 * Clear pending shift register instructions
336 */
337 for (n=0;n<ngcdcsSHIFT_MAX;n++) shift[n].numBits = 0;
338
339 if (fullFrame)
340 {
341 /*
342 * Override window requests
343 */
344 FullFrame();
345 }
346
347 n = 0;
348 if (rmX_)
349 {
350 int next;
351 if (mcrX_) next = ngcdcsSLX_DCR_MCR;
352 else if (wdrX_) next = ngcdcsSLX_DCR_WDR;
353 else if (wrrX_) next = ngcdcsSLX_DCR_WRR;
354 else next = 0;
355
356 RM2REG(next);
357 shift[n].Init();
358 shift[n].array[0] = DCR() & 0xff;
359 shift[n].numBits = 8;
360 n++;
361 rmX_ = 0;
362 }
363 if (mcrX_)
364 {
365 int next;
366 if (wdrX_) next = ngcdcsSLX_DCR_WDR;
367 else if (wrrX_) next = ngcdcsSLX_DCR_WRR;
368 else next = 0;
369 MCR2REG(next);
370 if (n == 0)
371 {
372 shift[n].Init();
373 shift[n].array[0] = DCR() & 0xff;
374 shift[n].numBits = 8;
375 n++;
376 }
377 shift[n].Init();
378 shift[n].array[0] = shiftReg[0];
379 shift[n].numBits = shiftRegSize;
380 n++;
381 mcrX_ = 0;
382 }
383 if (wdrX_)
384 {
385 int next;
386 if (wrrX_) next = ngcdcsSLX_DCR_WRR;
387 else next = 0;
388 WDR2REG(next);
389 if (n == 0)
390 {
391 shift[n].Init();
392 shift[n].array[0] = DCR() & 0xff;
393 shift[n].numBits = 8;
394 n++;
395 }
396 shift[n].Init();
397 memcpy(shift[n].array, shiftReg, sizeof(shiftReg));
398 shift[n].numBits = shiftRegSize;
399 n++;
400 wdrX_ = 0;
401 }
402 if (wrrX_)
403 {
404 WRR2REG();
405 if (n == 0)
406 {
407 shift[n].Init();
408 shift[n].array[0] = DCR() & 0xff;
409 shift[n].numBits = 8;
410 n++;
411 }
412 shift[n].Init();
413 memcpy(shift[n].array, shiftReg, sizeof(shiftReg));
414 shift[n].numBits = shiftRegSize;
415 wrrX_ = 0;
416 }
417 }
418
420 int Key(const char *name, const char *value) {
421 char tmp[128];
422 char ermsLoc[128];
423 int keyIdx[8];
424 int n;
425 char v[256];
426 int idx;
427
428 strcpy(v, value);
429 for (n=0;n<(int)strlen(v);n++)
430 {
431 if ((v[n] == '_') || (v[n] == ',') || (v[n] == '|')) v[n] = ' ';
432 }
433
434 strcpy(tmp, name);
435 if (ngcbKeyIdx(tmp, &n, keyIdx, ermsLoc) != ngcbSUCCESS)
436 {
437 sprintf(ErrMsg(), "invalid keyword <%s> - %s", name,
438 ermsLoc);
439 return (ngcbFAILURE);
440 }
441 idx = keyIdx[1];
442
443 if (strcmp(tmp, "SLX.ENA") == 0)
444 {
445 if (strcmp(v, "T") == 0) enabled = 1;
446 else if (strcmp(v, "F") == 0) enabled = 0;
447 else
448 {
449 sprintf(ErrMsg(), "invalid keyword value <%s>", name);
450 return (ngcbFAILURE);
451 }
452 }
453 else if (strcmp(tmp, "SLX.MCR") == 0)
454 {
455 int intVal;
456 if (!ngcbFmt2Int(v, &intVal))
457 {
458 sprintf(ErrMsg(), "invalid keyword value <%s>", name);
459 return (ngcbFAILURE);
460 }
461 MCR(intVal);
462 }
463 else if (strcmp(tmp, "SLX.REFPIX") == 0)
464 {
465 int intVal = MCR();
466 if (strcmp(v, "T") == 0) intVal &= ~ngcdcsSLX_MCR_NO_REF;
467 else if (strcmp(v, "F") == 0) intVal |= ngcdcsSLX_MCR_NO_REF;
468 else
469 {
470 sprintf(ErrMsg(), "invalid keyword value <%s>", name);
471 return (ngcbFAILURE);
472 }
473 MCR(intVal);
474 }
475 else if (strcmp(tmp, "SLX.EXTRST") == 0)
476 {
477 int intVal = MCR();
478 if (strcmp(v, "T") == 0) intVal |= ngcdcsSLX_MCR_EXTRST;
479 else if (strcmp(v, "F") == 0) intVal &= ~ngcdcsSLX_MCR_EXTRST;
480 else
481 {
482 sprintf(ErrMsg(), "invalid keyword value <%s>", name);
483 return (ngcbFAILURE);
484 }
485 MCR(intVal);
486 }
487 else if (strcmp(tmp, "SLX.CBENA") == 0)
488 {
489 int intVal = MCR();
490 if (strcmp(v, "T") == 0) intVal |= ngcdcsSLX_MCR_CB_EN;
491 else if (strcmp(v, "F") == 0) intVal &= ~ngcdcsSLX_MCR_CB_EN;
492 else
493 {
494 sprintf(ErrMsg(), "invalid keyword value <%s>", name);
495 return (ngcbFAILURE);
496 }
497 MCR(intVal);
498 }
499 else if (strcmp(tmp, "SLX.CBREFENA") == 0)
500 {
501 int intVal = MCR();
502 if (strcmp(v, "T") == 0) intVal |= ngcdcsSLX_MCR_CB_REF_EN;
503 else if (strcmp(v, "F") == 0) intVal &= ~ngcdcsSLX_MCR_CB_REF_EN;
504 else
505 {
506 sprintf(ErrMsg(), "invalid keyword value <%s>", name);
507 return (ngcbFAILURE);
508 }
509 MCR(intVal);
510 }
511 else if (strcmp(tmp, "SLX.LSPENA") == 0)
512 {
513 int intVal = MCR();
514 if (strcmp(v, "T") == 0) intVal |= ngcdcsSLX_MCR_LSP_EN;
515 else if (strcmp(v, "F") == 0) intVal &= ~ngcdcsSLX_MCR_LSP_EN;
516 else
517 {
518 sprintf(ErrMsg(), "invalid keyword value <%s>", name);
519 return (ngcbFAILURE);
520 }
521 MCR(intVal);
522 }
523 else if (strcmp(tmp, "SLX.CLAMP") == 0)
524 {
525 int intVal = MCR();
526 if (strcmp(v, "T") == 0) intVal &= ~ngcdcsSLX_MCR_NO_CLAMP;
527 else if (strcmp(v, "F") == 0) intVal |= ngcdcsSLX_MCR_NO_CLAMP;
528 else
529 {
530 sprintf(ErrMsg(), "invalid keyword value <%s>", name);
531 return (ngcbFAILURE);
532 }
533 MCR(intVal);
534 }
535 else if (strcmp(tmp, "SLX.MODE") == 0)
536 {
537 ngcbToLower(v);
538 if (strcmp(v, "itr") == 0) ReadMode(ngcdcsSLX_RM_ITR);
539 else if (strcmp(v, "rolling") == 0) ReadMode(ngcdcsSLX_RM_RR);
540 else if (strcmp(v, "rdrstrd") == 0) ReadMode(ngcdcsSLX_RM_RDRSTRD);
541 else
542 {
543 sprintf(ErrMsg(), "invalid keyword value <%s>", name);
544 return (ngcbFAILURE);
545 }
546 }
547 else if (strcmp(tmp, "SLX.WIN") == 0)
548 {
549 if (strcmp(v, "F") == 0) fullFrame = 1;
550 else if (strcmp(v, "T") == 0) fullFrame = 0;
551 else
552 {
553 int intVal;
554 if (sscanf(v, "%10d", &intVal) < 1)
555 {
556 sprintf(ErrMsg(), "invalid keyword value <%s>", name);
557 return (ngcbFAILURE);
558 }
559 if (intVal) fullFrame = 1;
560 else fullFrame = 0;
561 }
562 }
563 else if (strcmp(tmp, "SLX.DCOL") == 0)
564 {
565 if (idx > 10)
566 {
567 sprintf(ErrMsg(), "column index out of range [1,10]");
568 return (ngcbFAILURE);
569 }
570 if (strcmp(v, "T") == 0)
571 {
572 if (!wdrX_) WDRCLR();
573 if (idx <= 0) WDRCOL_ON();
574 else WDRCOL_ON(idx - 1);
575 }
576 else if (strcmp(v, "F") == 0)
577 {
578 if (!wdrX_) WDRCLR();
579 if (idx <= 0) WDRCOL_OFF();
580 else WDRCOL_OFF(idx - 1);
581 }
582 else
583 {
584 sprintf(ErrMsg(), "invalid keyword value <%s>", name);
585 return (ngcbFAILURE);
586 }
587 }
588 else if (strcmp(tmp, "SLX.RCOL") == 0)
589 {
590 if (idx > 10)
591 {
592 sprintf(ErrMsg(), "column index out of range [1,10]");
593 return (ngcbFAILURE);
594 }
595 if (strcmp(v, "T") == 0)
596 {
597 if (!wrrX_) WRRCLR();
598 if (idx <= 0) WRRCOL_ON();
599 else WRRCOL_ON(idx - 1);
600 }
601 else if (strcmp(v, "F") == 0)
602 {
603 if (!wrrX_) WRRCLR();
604 if (idx <= 0) WRRCOL_OFF();
605 else WRRCOL_OFF(idx - 1);
606 }
607 else
608 {
609 sprintf(ErrMsg(), "invalid keyword value <%s>", name);
610 return (ngcbFAILURE);
611 }
612 }
613 else if (strcmp(tmp, "SLX.COL") == 0)
614 {
615 if (idx > 10)
616 {
617 sprintf(ErrMsg(), "column index out of range [1,10]");
618 return (ngcbFAILURE);
619 }
620 if (strcmp(v, "T") == 0)
621 {
622 if (!wdrX_) WDRCLR();
623 if (!wrrX_) WRRCLR();
624 if (idx <= 0)
625 {
626 WDRCOL_ON();
627 WRRCOL_ON();
628 }
629 else
630 {
631 WDRCOL_ON(idx - 1);
632 WRRCOL_ON(idx - 1);
633 }
634 }
635 else if (strcmp(v, "F") == 0)
636 {
637 if (!wdrX_) WDRCLR();
638 if (!wrrX_) WRRCLR();
639 if (idx <= 0)
640 {
641 WDRCOL_OFF();
642 WRRCOL_OFF();
643 }
644 else
645 {
646 WDRCOL_OFF(idx - 1);
647 WRRCOL_OFF(idx - 1);
648 }
649 }
650 else
651 {
652 sprintf(ErrMsg(), "invalid keyword value <%s>", name);
653 return (ngcbFAILURE);
654 }
655 }
656 else if (strcmp(tmp, "SLX.ROW") == 0)
657 {
658 int sy, ny;
659 if (sscanf(v, "%10d %10d", &sy, &ny) < 2)
660 {
661 sprintf(ErrMsg(), "invalid keyword value <%s>", name);
662 return (ngcbFAILURE);
663 }
664 if (!wdrX_) WDRCLR();
665 if (!wrrX_) WRRCLR();
666 WDRROW(sy - 1, ny);
667 WRRROW(sy - 1, ny);
668 }
669 else if (strcmp(tmp, "SLX.DROW") == 0)
670 {
671 int sy, ny;
672 if (sscanf(v, "%10d %10d", &sy, &ny) < 2)
673 {
674 sprintf(ErrMsg(), "invalid keyword value <%s>", name);
675 return (ngcbFAILURE);
676 }
677 if (!wdrX_) WDRCLR();
678 WDRROW(sy - 1, ny);
679 }
680 else if (strcmp(tmp, "SLX.RROW") == 0)
681 {
682 int sy, ny;
683 if (sscanf(v, "%10d %10d", &sy, &ny) < 2)
684 {
685 sprintf(ErrMsg(), "invalid keyword value <%s>", name);
686 return (ngcbFAILURE);
687 }
688 if (!wrrX_) WRRCLR();
689 WRRROW(sy - 1, ny);
690 }
691
692 return (ngcbSUCCESS);
693 }
694
697 /*
698 * Read-out mode
699 */
700 ReadMode(cfg.readMode);
701
702 /*
703 * Multiplexer control register
704 */
705 MCR(cfg.mcr);
706
707 if (cfg.fullFrame || !cfg.ValidWin())
708 {
709 /*
710 * Full frame read-out
711 */
712 FullFrame(); fullFrame = 1;
713 }
714 else
715 {
716 int i;
717
718 /*
719 * Clear window mappings
720 */
721 ClearWin(); fullFrame = 0;
722
723 /*
724 * Program column register
725 */
726 for (i=0;i<10;i++)
727 {
728 if (cfg.colData & (1 << i)) WDRCOL_ON(i);
729 if (cfg.colRst & (1 << i)) WRRCOL_ON(i);
730 }
731
732 /*
733 * Program row registers
734 */
735 for (i=0;i<ngcdcsSLX_MAX_WIN;i++)
736 {
737 if (cfg.rowData[i].Valid())
738 {
739 WDRROW(cfg.rowData[i].start - 1, cfg.rowData[i].size);
740 }
741 if (cfg.rowRst[i].Valid())
742 {
743 WRRROW(cfg.rowRst[i].start - 1, cfg.rowRst[i].size);
744 }
745 }
746 }
747 }
748
749 void GetDim(int *sx, int *sy, int *nx, int *ny) {
750 int i, j;
751
752 *sx = 1; *sy = 1; *nx = 0; *ny = 0;
753 if (mcr_ & ngcdcsSLX_MCR_NO_REF)
754 {
755 for (j=1;j<8;j++)
756 {
757 if (wdrCol_[0] & (1 << j)) (*nx) += 32;
758 else if (*nx == 0) (*sx) += 32;
759 }
760 if (wdrCol_[1] & 0x1) (*nx) += 32;
761 else if (*nx == 0) (*sx) += 32;
762 }
763 else
764 {
765 for (j=0;j<8;j++)
766 {
767 if (wdrCol_[0] & (1 << j)) (*nx) += 32;
768 else if (*nx == 0) (*sx) += 32;
769 }
770 for (j=0;j<2;j++)
771 {
772 if (wdrCol_[1] & (1 << j)) (*nx) += 32;
773 else if (*nx == 0) (*sx) += 32;
774 }
775 }
776
777 for (i=0;i<32;i++)
778 {
779 for (j=0;j<8;j++)
780 {
781 if (wdrRow_[i] & (1 << j)) (*ny)++;
782 else if (*ny == 0) (*sy)++;
783 }
784 }
785 }
786
787 // Return data column configuration
788 int DCOL() {return (wdrCol_[0] | wdrCol_[1] << 8);}
789
790 // Return reset column configuration
791 int RCOL() {return (wrrCol_[0] | wrrCol_[1] << 8);}
792
793 // Return data row configuration
794 void DROW(ngcdcs_slxrow_t *w) {Reg2Row_(wdrRow_, w);}
795
796 // Return reset row configuration
797 void RROW(ngcdcs_slxrow_t *w) {Reg2Row_(wrrRow_, w);}
798
799protected:
802
805
807 void RM2REG(int nextSelect = 0) {
808 dcr_ &= (char)~ngcdcsSLX_DCR_SELECT;
809 dcr_ |= (char)(nextSelect & ngcdcsSLX_DCR_SELECT);
810 shiftRegSize = 0;
811 }
812
814 void MCR2REG(int nextSelect = 0) {
815 /*
816 * We only support 32-channel mode
817 */
818 mcr_ &= ~ngcdcsSLX_MCR_CHAN;
819 mcr_ |= ngcdcsSLX_MCR_CHAN32;
820
821 dcr_ &= (char)~ngcdcsSLX_DCR_SELECT;
822 dcr_ |= (char)(nextSelect & ngcdcsSLX_DCR_SELECT);
823 shiftReg[0] = (dcr_ & 0xff) | (mcr_ & 0xff) << 8;
824 shiftRegSize = 16;
825 dcr_ &= (char)~ngcdcsSLX_DCR_SELECT;
826 dcr_ |= ngcdcsSLX_DCR_MCR;
827 }
828
830 void WDR2REG(int nextSelect = 0) {
831 dcr_ &= (char)~ngcdcsSLX_DCR_SELECT;
832 dcr_ |= (char)(nextSelect & ngcdcsSLX_DCR_SELECT);
833 Win2Shift_(wdrRow_, wdrCol_);
834 dcr_ &= (char)~ngcdcsSLX_DCR_SELECT;
835 dcr_ |= ngcdcsSLX_DCR_WDR;
836 }
837
839 void WRR2REG(int nextSelect = 0) {
840 dcr_ &= (char)~ngcdcsSLX_DCR_SELECT;
841 dcr_ |= (char)(nextSelect & ngcdcsSLX_DCR_SELECT);
842 Win2Shift_(wrrRow_, wrrCol_);
843 dcr_ &= (char)~ngcdcsSLX_DCR_SELECT;
844 dcr_ |= ngcdcsSLX_DCR_WRR;
845 }
846
848 void WDRALL() {
849 wdrCol_[0] = (char)0xff; wdrCol_[1] = (char)0x3;
850 memset(wdrRow_, 0xff, sizeof(wdrRow_));
851 wdrX_ = 1;
852 }
853
855 void WRRALL() {
856 wrrCol_[0] = (char)0xff; wrrCol_[1] = (char)0x3;
857 memset(wrrRow_, 0xff, sizeof(wdrRow_));
858 wrrX_ = 1;
859 }
860
862 void WDRCLR() {
863 memset(wdrCol_, 0x00, sizeof(wdrCol_));
864 memset(wdrRow_, 0x00, sizeof(wdrRow_));
865 wdrX_ = 1;
866 }
867
869 void WRRCLR() {
870 memset(wrrCol_, 0x00, sizeof(wdrCol_));
871 memset(wrrRow_, 0x00, sizeof(wdrRow_));
872 wrrX_ = 1;
873 }
874
876 void WDRROW(int sy, int ny) {
877 AdjustRow_(&sy, &ny);
878 Row2Reg_(sy, ny, wdrRow_);
879 }
880
882 void WRRROW(int sy, int ny) {
883 AdjustRow_(&sy, &ny);
884 Row2Reg_(sy, ny, wrrRow_);
885 }
886
888 void WDRCOL_ON() {wdrCol_[0] = (char)0xff; wdrCol_[1] = (char)0x3;}
889
891 void WRRCOL_ON() {wrrCol_[0] = (char)0xff; wrrCol_[1] = (char)0x3;}
892
894 void WDRCOL_OFF() {wdrCol_[0] = (char)0x0; wdrCol_[1] = (char)0x0;}
895
897 void WRRCOL_OFF() {wrrCol_[0] = (char)0x0; wrrCol_[1] = (char)0x0;}
898
900 void WDRCOL_ON(int n) {Col2Reg_(n, wdrCol_);}
901
903 void WRRCOL_ON(int n) {Col2Reg_(n, wrrCol_);}
904
906 void WDRCOL_OFF(int n) {ColRemove_(n, wdrCol_);}
907
909 void WRRCOL_OFF(int n) {ColRemove_(n, wrrCol_);}
910
911private:
913 char erms_[256];
914
916 int readMode_;
917
919 char dcr_;
920
922 char mcr_;
923
925 char wdrCol_[2];
926
928 char wdrRow_[32];
929
931 char wrrCol_[2];
932
934 char wrrRow_[32];
935
937 int rmX_;
938
940 int mcrX_;
941
943 int wrrX_;
944
946 int wdrX_;
947
949 void AdjustRow_(int *sy, int *ny) {
950 if (*sy < 0) *sy = 0;
951 if (*sy >= ngcdcsSLX_NROW) *sy = ngcdcsSLX_NROW - 1;
952 if ((*sy + *ny) > ngcdcsSLX_NROW) *ny = ngcdcsSLX_NROW - *sy;
953 }
954
956 void Col2Reg_(int n, char *reg) {
957 if (n < 0) n = 0;
958 if (n > 9) n = 9;
959 if (n > 7) reg[1] |= (char)(1 << (n - 8));
960 else reg[0] |= (char)(1 << n);
961 }
962
964 void ColRemove_(int n, char *reg) {
965 if ((n < 0) || (n > 9)) return;
966 if (n > 7) reg[1] &= (char)~(1 << (n - 8));
967 else reg[0] &= (char)~(1 << n);
968 }
969
971 void Row2Reg_(int start, int n, char *reg) {
972 int i, s;
973 char *r;
974
975 s = start % 8;
976 r = reg + (start / 8);
977 for (i=start;i<(start+n);i++)
978 {
979 *r |= (char)(1 << s);
980 s = (s + 1) % 8;
981 if (s == 0) r++;
982 }
983 }
984
986 void Reg2Row_(char *reg, ngcdcs_slxrow_t *w) {
987 int n = 0;
988 int sy = 1;
989 int ny = 0;
990 int i, j;
991
992 for (i=0;i<32;i++)
993 {
994 for (j=0;j<8;j++)
995 {
996 if (reg[i] & (1 << j)) ny++;
997 else if (ny == 0) sy++;
998 else
999 {
1000 w[n].start = sy;
1001 w[n++].size = ny;
1002 sy += ny + 1;
1003 ny = 0;
1004 }
1005 }
1006 }
1007 }
1008
1010 void Win2Shift_(char *wr, char *wc) {
1011 int *r = &shiftReg[0];
1012 int i;
1013 int s = 8;
1014
1015 *r = dcr_ & 0xff;
1016
1017 for (i=0;i<32;i++)
1018 {
1019 *r |= (wr[i] & 0xff) << s;
1020 s = (s + 8) % 32;
1021 if (s == 0) r++;
1022 }
1023
1024 if (mcr_ & ngcdcsSLX_MCR_NO_REF)
1025 {
1026 char b = (char)(((wc[0] >> 1) & 0x7f) | ((wc[1] & 0x1) << 7));
1027 *r |= (b & 0xff) << s;
1028 shiftRegSize = 272;
1029 }
1030 else
1031 {
1032 *r |= (wc[0] & 0xff) << s;
1033 s = (s + 8) % 32;
1034 if (s == 0) r++;
1035 *r |= (wc[1] & 0xff) << s;
1036 shiftRegSize = 274;
1037 }
1038 }
1039
1040};
1041
1042#endif
int fullFrame
Full frame readout.
Definition ngcdcsSLX.hpp:237
void WDRROW(int sy, int ny)
Map window to row data registers.
Definition ngcdcsSLX.hpp:876
void WDRALL()
Enable all pixels in WDR.
Definition ngcdcsSLX.hpp:848
int RCOL()
Definition ngcdcsSLX.hpp:791
void WRRCLR()
Clear all pixels in WRR.
Definition ngcdcsSLX.hpp:869
void ClearCfg()
Clear configuration flags.
Definition ngcdcsSLX.hpp:328
void WRRROW(int sy, int ny)
Map window to row reset registers.
Definition ngcdcsSLX.hpp:882
int DCOL()
Definition ngcdcsSLX.hpp:788
void WRRCOL_ON()
Enable all reset-columns in WDR.
Definition ngcdcsSLX.hpp:891
void MCR(int value)
Preset MCR value.
Definition ngcdcsSLX.hpp:306
char DCR()
Return detector control register.
Definition ngcdcsSLX.hpp:303
char MCR()
Return multiplexer control register.
Definition ngcdcsSLX.hpp:319
void WRRALL()
Enable all pixels in WRR.
Definition ngcdcsSLX.hpp:855
void WDRCOL_ON(int n)
Enable data-column in WDR.
Definition ngcdcsSLX.hpp:900
void WDRCLR()
Clear all pixels in WDR.
Definition ngcdcsSLX.hpp:862
int shiftReg[ngcbSEQ_SHRAM_SIZE]
Shift register.
Definition ngcdcsSLX.hpp:801
ngcdcs_shift_t shift[ngcdcsSHIFT_MAX]
Pennding shift register instructions.
Definition ngcdcsSLX.hpp:234
void RM2REG(int nextSelect=0)
Push read-out mode to shift register.
Definition ngcdcsSLX.hpp:807
void Preset(ngcdcs_slxcfg_t &cfg)
Preset with external configuration.
Definition ngcdcsSLX.hpp:696
ngcdcsSLX()
Constructor.
Definition ngcdcsSLX.hpp:243
void WRRCOL_OFF()
Disable all reset-columns in WDR.
Definition ngcdcsSLX.hpp:897
void WRRCOL_OFF(int n)
Disable reset-column in WDR.
Definition ngcdcsSLX.hpp:909
void WRRCOL_ON(int n)
Enable reset-column in WDR.
Definition ngcdcsSLX.hpp:903
virtual ~ngcdcsSLX()
Definition ngcdcsSLX.hpp:286
void WDR2REG(int nextSelect=0)
Push WDR to shift register.
Definition ngcdcsSLX.hpp:830
void RROW(ngcdcs_slxrow_t *w)
Definition ngcdcsSLX.hpp:797
void DROW(ngcdcs_slxrow_t *w)
Definition ngcdcsSLX.hpp:794
void WDRCOL_OFF(int n)
Disable data-column in WDR.
Definition ngcdcsSLX.hpp:906
void ClearWin()
Clear window mappings.
Definition ngcdcsSLX.hpp:325
char * ErrMsg()
Return global error message.
Definition ngcdcsSLX.hpp:289
int shiftRegSize
Number of bits in shift register.
Definition ngcdcsSLX.hpp:804
void FullFrame()
Full frame read-out.
Definition ngcdcsSLX.hpp:322
void GetDim(int *sx, int *sy, int *nx, int *ny)
Definition ngcdcsSLX.hpp:749
void Configure()
Configure shift register instructions.
Definition ngcdcsSLX.hpp:331
void ReadMode(int mode)
Preset read-out mode.
Definition ngcdcsSLX.hpp:292
void MCR2REG(int nextSelect=0)
Push MCR to shift register.
Definition ngcdcsSLX.hpp:814
int ReadMode()
Return read-out mode.
Definition ngcdcsSLX.hpp:300
void WDRCOL_OFF()
Disable all data-columns in WDR.
Definition ngcdcsSLX.hpp:894
int Key(const char *name, const char *value)
Parse setup key.
Definition ngcdcsSLX.hpp:420
int enabled
SELEX interface enabled.
Definition ngcdcsSLX.hpp:240
void WDRCOL_ON()
Enable all data-columns in WDR.
Definition ngcdcsSLX.hpp:888
void WRR2REG(int nextSelect=0)
Push WRR to shift register.
Definition ngcdcsSLX.hpp:839
#define ngcbSEQ_SHRAM_SIZE
Definition ngcbAddr.h:180
int ngcbFmt2Int(const char *s, int *value)
Definition ngcbString.c:235
int ngcbKeyIdx(char *key, int *nsplit, int *kval, char *erms)
Definition ngcbKey.c:375
#define ngcbSUCCESS
Definition ngcb.h:137
void ngcbToLower(char *s)
Definition ngcbString.c:27
#define ngcbFAILURE
Definition ngcb.h:139
#define ngcdcsSLX_MCR_NO_REF
Definition ngcdcsSLX.hpp:44
#define ngcdcsSLX_MCR_CHAN
Definition ngcdcsSLX.hpp:38
#define ngcdcsSLX_RM_RR
Definition ngcdcsSLX.hpp:54
#define ngcdcsSLX_DCR_WDR
Definition ngcdcsSLX.hpp:63
#define ngcdcsSLX_DCR_WRR
Definition ngcdcsSLX.hpp:64
#define ngcdcsSLX_MCR_CB_REF_EN
Definition ngcdcsSLX.hpp:45
#define ngcdcsSLX_MCR_NO_CLAMP
Definition ngcdcsSLX.hpp:48
#define ngcdcsSLX_MCR_LSP_EN
Definition ngcdcsSLX.hpp:47
#define ngcdcsSLX_MCR_CB_EN
Definition ngcdcsSLX.hpp:46
#define ngcdcsSLX_DCR_RM
Definition ngcdcsSLX.hpp:60
#define ngcdcsSLX_RM_ITR
Definition ngcdcsSLX.hpp:53
#define ngcdcsSLX_MCR_CHAN32
Definition ngcdcsSLX.hpp:42
#define ngcdcsSHIFT_MAX
Definition ngcdcsSLX.hpp:226
#define ngcdcsSLX_MAX_WIN
Definition ngcdcsSLX.hpp:33
#define ngcdcsSLX_MCR_EXTRST
Definition ngcdcsSLX.hpp:43
#define ngcdcsSLX_NROW
Definition ngcdcsSLX.hpp:69
#define ngcdcsSLX_DCR_SELECT
Definition ngcdcsSLX.hpp:61
#define ngcdcsSLX_RM_RDRSTRD
Definition ngcdcsSLX.hpp:55
#define ngcdcsSLX_DCR_MCR
Definition ngcdcsSLX.hpp:62
Definition ngcdcsSLX.hpp:84
ngcdcs_shift_t()
Constructor.
Definition ngcdcsSLX.hpp:92
int array[ngcbSEQ_SHRAM_SIZE]
Shift RAM (32-bit word array)
Definition ngcdcsSLX.hpp:89
int numBits
Number of bits to transfer.
Definition ngcdcsSLX.hpp:86
int TxSize()
Return number of words to transfer.
Definition ngcdcsSLX.hpp:98
void Init()
Initialize.
Definition ngcdcsSLX.hpp:95
Definition ngcdcsSLX.hpp:136
int newCfg
Flag indicating a new configuration.
Definition ngcdcsSLX.hpp:159
void ClearWin()
Clear.
Definition ngcdcsSLX.hpp:179
int ValidWin()
Valid window.
Definition ngcdcsSLX.hpp:207
void ClearRstWin()
Clear reset windows.
Definition ngcdcsSLX.hpp:193
short colRst
Columns (reset)
Definition ngcdcsSLX.hpp:138
short colData
Columns (data)
Definition ngcdcsSLX.hpp:141
int valid
Configuration is valid.
Definition ngcdcsSLX.hpp:165
int enabled
SELEX interface enabled.
Definition ngcdcsSLX.hpp:162
int readMode
Read-out mode.
Definition ngcdcsSLX.hpp:150
ngcdcs_slxrow_t rowData[ngcdcsSLX_MAX_WIN]
Rows (data)
Definition ngcdcsSLX.hpp:147
ngcdcs_slxrow_t rowRst[ngcdcsSLX_MAX_WIN]
Rows (reset)
Definition ngcdcsSLX.hpp:144
int mcr
MCR.
Definition ngcdcsSLX.hpp:153
ngcdcs_slxcfg_t()
Constructor.
Definition ngcdcsSLX.hpp:168
void ClearDataWin()
Clear data windows.
Definition ngcdcsSLX.hpp:200
int fullFrame
Full frame read-out.
Definition ngcdcsSLX.hpp:156
Definition ngcdcsSLX.hpp:111
int start
Start coordinate.
Definition ngcdcsSLX.hpp:113
void Clear()
Clear.
Definition ngcdcsSLX.hpp:122
int Valid()
Validity check.
Definition ngcdcsSLX.hpp:125
friend int operator==(const ngcdcs_slxrow_t &a, const ngcdcs_slxrow_t &b)
Operator ==.
Definition ngcdcsSLX.hpp:128
ngcdcs_slxrow_t()
Constructor.
Definition ngcdcsSLX.hpp:119
int size
Size.
Definition ngcdcsSLX.hpp:116