Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

SnConstants.h

Committer:
uci1
Date:
2015-02-10
Revision:
72:40be8d36d2b0
Parent:
71:2e8f7d01dea6
Child:
73:5ba0a26eff94

File content as of revision 72:40be8d36d2b0:

#ifndef SN_SnConstants
#define SN_SnConstants

// available CHIPBOARDs -- these values should never change!
#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

//#define DEBUG

//#define USE_INTERFACE_CHIP


#include "SnBitUtils.h"
#include "SnCommConstants.h"

//
// constants
//

// 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, 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
//static const char kDefaultMacAdress[] = {0x00, 0x02, 0xF7, 0xF2, 0x1A, 0x8A}; // STN 18 (SST 111)   0002F7F21A8A
//static const char kDefaultMacAdress[] = {0x00, 0x02, 0xF7, 0xF0, 0xC6, 0x1A}; // STN 10 (ATWD MB 8) 0002F7F0C61A
  static const char kDefaultMacAdress[] = {0x00, 0x02, 0xF7, 0xF2, 0x0A, 0x9C}; // STN 14 (SST 104)   0002F7F20A9C

// if these change, it is likely that some i/o version (config, event, etc) will need to change
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

// 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 uint32_t kAbsMaxTimer      = 1800u; // timers use integers counting us and can't go longer than ~ this many secs

// NOTE: these times (in sec) must be less than kAbsMaxTimer (this is not checked, however)
static const uint8_t  kDefTimeoutMin    = 3u;    // minutes. used in case a clock error is detected or range needs enforcing
static const uint32_t kCommWinLongPrdTk = 300u;  // seconds. check if it's time for a comm win every X sec. this way comm per can be longer than Timer allows

static const uint16_t kMaxConsecCommFails = 4;    // (exclusive) number of times a comm win can fail before the mbed resets

// safety nets
static const uint16_t kMaxFirstSeq      = 25000;  // max specifiable seq number -- leave room to grow
static const float    kMinForcePer      = 0.05;   // seconds -- safety net for max force trigger rate
static const uint16_t kMaxThrottlePerMs = 60000;  // ms -- max time between thermal triggers
static const uint16_t kMaxBatVoltLowPwr = 25000;  // ADCs -- probably futile, but try to prevent it from being in low power mode always
static const uint32_t kMinCommWinPeriod = 120;    // seconds -- min time between communication windows
static const uint32_t kMaxCommWinPeriod = 259200; // seconds -- max time between communication windows
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 uint16_t kTotSamps         = kNchans*kNsamps;
static const uint16_t kTotDacs          = kNchans*kNchanDacs;


enum ESnTrgTypes {
    kThmTrg=0,
    kFrcTrg=1,
    kExtTrg=2,
    kAdcToMBflag=3,
    
    kNumTrgs
};
                                          // order must match ESnTrgTypes
static const uint8_t kTrgBW[kNumTrgs] = { BIT(0), BIT(1), BIT(2), BIT(7) };



#endif // SN_SnConstants