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