Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Revision:
116:8099b754fbb4
Parent:
115:29f46e4b65d4
Child:
119:b3d7699d0eb0
--- a/SnConstants.h	Fri Dec 04 02:57:12 2015 +0000
+++ b/SnConstants.h	Tue May 03 02:01:35 2016 +0000
@@ -13,7 +13,7 @@
 //
 
 // this should be updated for each and every mbed board (ugh!)
-//static const char kDefaultMacAdress[] = {0x00, 0x02, 0xAA, 0xAA, 0xAA, 0xAA}; // for testing SST
+static const char kDefaultMacAdress[] = {0x00, 0x02, 0xAA, 0xAA, 0xAA, 0xAA}; // for testing SST
 //static const char kDefaultMacAdress[] = {0x00, 0x02, 0xBB, 0xBB, 0xBB, 0xBB}; // for testing ATWD
 //static const char kDefaultMacAdress[] = {0x00, 0x02, 0xF7, 0xF0, 0xAE, 0xE0}; // STN 20 (ATWD MB 1) 0002F7F0AEE0
 //static const char kDefaultMacAdress[] = {0x00, 0x02, 0xF7, 0xF0, 0xC3, 0xB6}; // STN  3 (ATWD MB 5) 0002F7F0C3B6
@@ -25,7 +25,7 @@
 //static const char kDefaultMacAdress[] = {0x00, 0x02, 0xF7, 0xF1, 0xF7, 0xA8}; // STN 15 (SST 110)   0002F7F1F7A8
 //static const char kDefaultMacAdress[] = {0x00, 0x02, 0xF7, 0xF2, 0x24, 0x4B}; // STN 13 (SST 102)   0002F7F2244B
 //static const char kDefaultMacAdress[] = {0x00, 0x02, 0xF7, 0xF1, 0xF6, 0x34}; // STN 31 (SST 107)   0002F7F1F634
-static const char kDefaultMacAdress[] = {0x00, 0x02, 0xF7, 0xF1, 0xF2, 0x1A}; // STN 32 (SST 112)   0002F7F1F21A (slow)
+//static const char kDefaultMacAdress[] = {0x00, 0x02, 0xF7, 0xF1, 0xF2, 0x1A}; // STN 32 (SST 112)   0002F7F1F21A (slow)
 //static const char kDefaultMacAdress[] = {0x00, 0x02, 0xF7, 0xF1, 0xF2, 0x12}; // STN 30 (SST 113)   0002F7F1F212
 
 // if these change, it is likely that some i/o version (config, event, etc) will need to change
@@ -38,14 +38,17 @@
 static const uint8_t  kNplasV1          = 5u; // to preserve i/o version sizes
 static const uint16_t kNsampsAtwd       = 128u;
 static const uint16_t kNsampsSst        = 256u;
+static const uint16_t kNsampsSst512     = 512u;
 static const uint8_t  kNchanDacsAtwd    = 4u;
 static const uint8_t  kNchanDacsSst     = 2u;
 static const uint8_t  kNchansFourAnt    = 4u;
 static const uint16_t kTotSampsAtwd4ch  = kNchansFourAnt*kNsampsAtwd;
 static const uint16_t kTotDacsAtwd4ch   = kNchansFourAnt*kNchanDacsAtwd;
 static const uint16_t kTotSampsSst4ch   = kNchansFourAnt*kNsampsSst;
+static const uint16_t kTotSampsSst4ch512= kNchansFourAnt*kNsampsSst512;
 static const uint16_t kTotDacsSst4ch    = kNchansFourAnt*kNchanDacsSst;
-static const uint16_t kNstopBytesSst4ch = kNsampsSst / BITS_IN_CHAR; // if the values change, may need to round this numebr
+static const uint16_t kNstopBytesSst4ch    = kNsampsSst / BITS_IN_CHAR; // if the values change, may need to round this numebr
+static const uint16_t kNstopBytesSst4ch512 = kNsampsSst512 / BITS_IN_CHAR; // if the values change, may need to round this numebr
 
 // these are the station config sizes, and may change. they should not be used in i/o functions. i/o versions need updating as these change!
 #if CHIPBOARD==ATWD4CH
@@ -64,9 +67,17 @@
 static const uint8_t  kAllLTC2657       = 0x73u << 1; // slave address that every LTC2657 DAC chip will respond to
 static const uint8_t  kUpdateDacCmd     = 0x3u;       // LTC2657 DAC chip command bits that write to & update DAC value
 static const uint8_t  kMaxDacSetTries   = 3u;         // how many times to retry setting a dac in case no ACK is received from the DAC chip
+#elif (CHIPBOARD==SST4CH512) || (CHIPBOARD==SST4CH512_1GHz)
+static const uint8_t  kNchans           = kNchansFourAnt;
+static const uint16_t kNsamps           = kNsampsSst512;
+static const uint8_t  kNchanDacs        = kNchanDacsSst;
+static const uint16_t kNstopBytes       = kNstopBytesSst4ch512;
+static const uint8_t  kAllLTC2657       = 0x73u << 1; // slave address that every LTC2657 DAC chip will respond to
+static const uint8_t  kUpdateDacCmd     = 0x3u;       // LTC2657 DAC chip command bits that write to & update DAC value
+static const uint8_t  kMaxDacSetTries   = 3u;         // how many times to retry setting a dac in case no ACK is received from the DAC chip
 #endif
 static const uint8_t  kNcomms           = 2u;   // must match the number of comms enabled in SnPreCompOptions
-static const uint16_t kNvoltsAve        = 500u; // must be greater than ~10 (but not checked. <2 will result in a divide by 0)
+static const uint16_t kNvoltsAve        = 500u; // must be greater than ~10 (but value is not checked, so <2 will result in a divide by 0)
 
 static const uint32_t kAbsMaxTimer      = 1800u; // timers use integers counting us and can't go longer than ~ this many secs
 
@@ -88,36 +99,26 @@
 static const uint32_t kMinCommWinDur    = 600;    // seconds -- min communication window duration -- must be >= Ncomms*listen/connect timeout
 static const uint32_t kMaxWatchDogPer   = 3600;   // seconds -- max time before watchdog reset on idle
 static const uint32_t kMinWatchDogPer   = 300;    // seconds -- min time before watchdog reset on idle
+static const uint8_t  kMinSingleFreqSuppRatio = 26; // L1>0.1 is the min cut value (avoid rejecting absolutely all events)
+static const uint8_t  kMaxSingleFreqSuppRatio =255; // L1>1.0 is the max cut value
+static const uint8_t  kDefSingleFreqSuppRatio = 77; // L1=0.3 is the default
 
 static const uint16_t kTotSamps         = kNchans*kNsamps;
 static const uint16_t kTotDacs          = kNchans*kNchanDacs;
 
 
 enum ETrgBit_t {
+      // see SnEventFrame::fTrgBits for number of available bits
       kThermal     = BIT(0),  // thermal trigger
       kForced      = BIT(1),  // forced trigger
       kExternal    = BIT(2),  // reserved for external, but impossible to set with current DAQ
       kSingleFreqSupp = BIT(3), // the L1 trigger to cut away events with a large fraction of power in a single frequency
-      // bits 4,5 not yet used
+      // bit 4 not yet used
+      kL1Scaledown  = BIT(5), // whether the event is written thanks to the L1 scaledown
       kL1TrgApplied = BIT(6), // whether to throw away events based on L1 triggers
       kAdcToMBflag = BIT(7)  // flag events that took too long to get data from dCards to MB
 };
 
-/*
-    kThmTrg=
-    kFrcTrg=1,         // BIT 1
-    kExtTrg=2,         // BIT 2
-    kAdcToMBflag=3,    // BIT 7 **note order** (not BIT(3))
-    // L1 triggers
-    kSingleFreqSupp=4, // BIT 3 **note order** (not BIT(4))
-    k
-    
-    kNumTrgs
-};
-                                          // order must match ESnTrgTypes
-static const uint8_t kTrgBW[kNumTrgs] = { BIT(0), BIT(1), BIT(2), BIT(7), BIT(3) };
-*/
-
 enum EL1TrigStatus {
     kL1Fail=0,
     kL1Pass=1,