Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Revision:
56:0bba0ef15697
Parent:
55:6767c08111c0
Child:
67:ec999336fcd1
--- a/SnConstants.h	Fri Jan 03 13:03:01 2014 +0000
+++ b/SnConstants.h	Thu Oct 30 06:42:17 2014 +0000
@@ -1,6 +1,14 @@
 #ifndef SN_SnConstants
 #define SN_SnConstants
 
+// available CHIPBOARDs
+#define ATWD4CH 0  // set CHIPBOARD to this to get firmware for the 2012-2013 stations (value is arbitrary but unique)
+#define SST4CH  1  // set CHIPBOARD to this to get firmware for the 2014 stations with a single SST chip (value is arbitrary but unique)
+
+// which chip/board combination to build this firmware for
+//#define CHIPBOARD ATWD4CH
+#define CHIPBOARD SST4CH
+
 #include "SnBitUtils.h"
 #include "SnCommConstants.h"
 
@@ -8,17 +16,44 @@
 // constants
 //
 // if these change, it is likely that some i/o version (config, event, etc) will need to change
-static const bool     kIridPwrFromAfar  = true; // true if Iridium & Afar are on the same relay, false if not
+static const bool     kIridPwrFromAfar  = false; // true if Iridium & Afar are on the same relay, false if not
 static const uint32_t kBStime           = 946684800u; // 1/1/2000 00:00:00 UTC
-static const uint8_t  kNchans           = 4u;
-static const uint8_t  kNsamps           = 128u;
-static const uint8_t  kNfpgaDacs        = 4u;
-static const uint8_t  kNplasV1          = 5u;//72;  // update config i/o version if this changes
+
+// these constants are used to specify the size of a specific i/o version of a frame, even if e.g. the number of samples changes for later i/o versions
+// these values should NEVER be changed!!
+// these values should be used in i/o functions
+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 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 kTotDacsSst4ch    = kNchansFourAnt*kNchanDacsSst;
+static const uint16_t kNstopBytesSst4ch = kNsampsSst / 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
+static const uint8_t  kNchans           = kNchansFourAnt;
+static const uint16_t kNsamps           = kNsampsAtwd;
 static const uint8_t  kNplas            = kNplasV1; // update config i/o version if this changes
+static const uint8_t  kNchanDacs        = kNchanDacsAtwd;
 static const uint16_t kNoTrigPla        = 0x0000u;
+static const float    kAsfClkPrdUs      = 8.535; // us -- change kAdcToMBtimeCut if this is <=2us
+static const float    kAdcToMBtimeCut   = (kNsamps*kAsfClkPrdUs)+(kAsfClkPrdUs/2.0);
+#elif CHIPBOARD==SST4CH
+static const uint8_t  kNchans           = kNchansFourAnt;
+static const uint16_t kNsamps           = kNsampsSst;
+static const uint8_t  kNchanDacs        = kNchanDacsSst;
+static const uint16_t kNstopBytes       = kNstopBytesSst4ch;
+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;
 static const uint16_t kNvoltsAve        = 500u; // must be greater than ~10 (but not checked. <2 will result in divide by 0)
-static const float    kAsfClkPrdUs      = 8.535; // us -- change kAdcToMBtimeCut if this is <=2us
 
 static const uint32_t kAbsMaxTimer      = 1800u; // timers use integers counting us and can't go longer than ~ this many secs
 
@@ -40,15 +75,14 @@
 static const uint32_t kMinWatchDogPer   = 300;    // seconds -- min time before watchdog reset on idle
 
 static const uint16_t kTotSamps         = kNchans*kNsamps;
-static const uint16_t kTotDacs          = kNchans*kNfpgaDacs;
+static const uint16_t kTotDacs          = kNchans*kNchanDacs;
 
-static const float    kAdcToMBtimeCut   = (kNsamps*kAsfClkPrdUs)+(kAsfClkPrdUs/2.0);
 
 enum ESnTrgTypes {
     kThmTrg=0,
-    kFrcTrg,
-    kExtTrg,
-    kAdcToMBflag,
+    kFrcTrg=1,
+    kExtTrg=2,
+    kAdcToMBflag=3,
     
     kNumTrgs
 };