// $Header: https://oberon.oapd.inaf.it/shins/trunk/shins/src/tiptilt_ctrl/bcu/util/bcuMemoryMap.h 3809 2022-01-28 16:24:34Z depa $

#pragma once

// to some of the following addresses has to be added an offset,
// some refers to DSP memory, some to SRAM
// memory and some to camera memory, here noted the camera name
// For reference, the name used for the camera in original Microgate MATLAB code is OCAM
// The memory to which the address refers is reported aside is as comment for reference
namespace Sharknir
{
  namespace Bcu
  {
    enum memoryMap
    {
     ResetDevice = 0,
     BANK_0 = 0,
     BANK_1 = 0x80000,
     BANK_2 = 0x100000,
     DSPstart = 0x180730,
     DummyArea = 0x1000,        /* DSP */
     SoftwareRelease = 0x1021,  /* DSP */
     FramesCounter = 0x1022,    /* DSP */
     ResetLoop = 0x1023,        /* DSP */
     FramesCounterIrq = 0x1024, /* DSP */
     ParamSelectorIrq = 0x1025, /* DSP */
     DMNumActuatorsIrq = 0x1026, /* DSP */
     DMOutputVector = 0x1028,    /* DSP */
     ParamSelector = 0x1128,     /* DSP */
     CCDInterfaceEnable = 0x1129, /* DSP */
     CCDWaitForReset = 0x112A,    /* DSP */
     CCDSubFrameCnt = 0x112B,     /* DSP */
     CCDTotalFlux = 0x112C,       /* DSP */
     NewModeVectorUpd = 0x112D,   /* DSP */
     ModesVectorLen = 0x112E,     /* DSP */
     TTControlLoopEna = 0x112F,   /* DSP */
     DMOutputEnable = 0x1130,     /* DSP */
     DMNumActuators = 0x1131,     /* DSP */
     DMInuseNumAct = 0x1132,      /* DSP */
     enableRTCommands = 0x1133,   /* DSP */
     HSDLVectorLen = 0x1134,      /* DSP */
     HSDLCmdStart = 0x1135,       /* DSP */
     HSDLCmdNotReadyCnt = 0x1136, /* DSP */
     HSDLCommandScale = 0x1137,   /* DSP */
     HSDLToSkipFrameCnt = 0x1138, /* DSP */
     DMUpdateStart = 0x1139,      /* DSP */
     NumCentroidPixels = 0x113A,  /* DSP */
     TimeHistoryAct = 0x113B,     /* DSP */
     SubapIntensityThres = 0x113C, /* DSP */
     DiagnosticFrameDec = 0x113D,  /* DSP */
     PixelFrameDec = 0x113E,       /* DSP */
     NiosIrqDelay = 0x113F,        /* DSP */
     PixelMinThreshold = 0x1140,   /* DSP */
     MinCentroidValue = 0x1141,    /* DSP */
     MaxCentroidValue = 0x1142,    /* DSP */
     MinTTCommandValue = 0x1143,   /* DSP */
     MaxTTCommandValue = 0x1144,   /* DSP */
     MaxAbsDMCommand = 0x1145,     /* DSP */
     MaxAbsDMCommandSkip = 0x1146, /* DSP */
     DMCommandToSkip = 0x1147,     /* DSP */
     DMm2bitConversion = 0x1148,   /* DSP */
     DMBitOffset = 0x1149,         /* DSP */
     MaxDMPower = 0x114A,          /* DSP */
     DMTotalPower = 0x114B,        /* DSP */
     DMCmdSkippedCnt = 0x114C,     /* DSP */
     CentroidGain = 0x114E,        /* DSP */
     CentroidOrigin = 0x1150,      /* DSP */
     TimeHistoryGain = 0x1152,     /* DSP */
     CentroidOut = 0x1154,         /* DSP */
     PIDDelayLine = 0x1156,        /* DSP */
     PIDFilterCoeff = 0x1162,      /* DSP */
     NewModeVectorPtr = 0x116C,    /* DSP */
     HSDLInputVectorPtr = 0x116D,  /* DSP */
     HSDLReplyVectorPtr = 0x116E,  /* DSP */
     NumPixelsToDoPtr = 0x116F,    /* DSP */
     CentroidPixelAreaPtr = 0x1170, /* DSP */
     DiagBuffHeaderPtr = 0x1171,    /* DSP */
     DMCommandVectPtr = 0x1172,     /* DSP */
     DiagBuffDataPtr = 0x1173,      /* DSP */
     DiagBuffFooterPtr = 0x1174,    /* DSP */
     ModeVector0Ptr = 0x1175,       /* DSP */
     DMInfluenceMatrix0Ptr = 0x1176, /* DSP */
     TimeHistoryPtr = 0x1177,        /* DSP */
     TimeHistoryEndPtr = 0x1178,     /* DSP */
     PixelOffsetPtr = 0x1179,   /* DSP */
     PixelGainPtr = 0x117A,     /* DSP */
     CentroidFactPtr = 0x117B,  /* DSP */
     PreviousPixelAreaPtr = 0x117C, /* DSP */
     ModeVector1Ptr = 0x117D,       /* DSP */
     DMInfluenceMatrix1Ptr = 0x117E, /* DSP */
     DMBiasVectorPtr = 0x117F,       /* DSP */
     DMActuatorSignPtr = 0x1180,     /* DSP */
     DMTmpOutputVectorPtr = 0x1181,  /* DSP */
     DMActuatorMapPtr = 0x1182,      /* DSP */
     NullValue = 0x1185,             /* DSP */
     SaveRegs = 0x1188,              /* DSP */ // according to matlab example
//   TimeHistory = 0x11A1,           /* DSP */ Time history pointer is 0x11A1 on memory map xml file but is 0x11A0 in matlab example
     TimeHistory = 0x11A0,           /* DSP */
     NewModeVector = 0xF000,         /* DSP */
     HSDLInputVector = 0xF068,        /* DSP */
     HSDLReplyVector = 0xF068,        /* DSP */

     CamFramesCounter = 0x3800C,     /* SRAM */
     EnablePosAccumulation = 0x38011, /* SRAM */
     DiagRecordPtr = 0x38012,         /* SRAM */
     DiagRecordLen = 0x38013,         /* SRAM */
     DiagRecordDecFactorEna = 0x38014, /* SRAM */
     DiagRecordRemoteAddr = 0x38015,   /* SRAM */
     DiagRecordReadPtr =  0x38018,     /* SRAM */
     DiagRecordWritePtr = 0x38019,     /* SRAM */
     ContrlReg = 0x0,                  /* CRED2 */
     EnaRAMStorage = 0x00000001,       /* CRED2 */
     SDRAMStartAddr = 0x00000002,      /* CRED2 */
     // camera setup
     OcamType = 0x00000003,     /* CRED2 */
     OcamFrameRate = 0x00000004, /* CRED2 */
     Ocam2RamPixelCnt = 0x00000005, /* CRED2 */
     Ocam2DspPixelCnt = 0x00000006, /* CRED2 */
     OcamInUsePixelMap = 0x00000800, /* CRED2 */
     OcamInUsePixelMapSize = 2048,   /* CRED2 */
     OcamNumSlopeToDo = 0x00001000,  /* CRED2 */
     OcamNumSlopeToDoSize = 512,
     OcamToSavePixelMap = 0x00001800, /* CRED2 */
     OcamToSavePixelMapSize = 2048,
     OcamSlopePixelsMap = 0x00002000, /* CRED2 */
     OcamSlopePixelsMapSize = 8192,
     // camera commands locations
     UartControlRegs = 0x3801A,  /* SRAM */
     UartRxControlReg = 0x3801A, // SRAM - correct as per Matlab struct aoVariables
     UartTxControlReg = 0x3801B, /* SRAM */
     UartTxBufferArea = 0x38800, /* SRAM */
     UartRxBufferArea = 0x38C00  /* SRAM */
    };
  }
}
