Commit 6e3a7fe5 authored by Laurent Claustre's avatar Laurent Claustre

Merge branch 'add_frelon16' into 'master'

Frelon16: add getSPBStatus with both SPB2/SPB8 support

See merge request !9
parents 8176a7fd f501ccc0
Pipeline #7716 passed with stages
in 8 minutes and 35 seconds
......@@ -49,6 +49,7 @@ enum Reg {
SingleVertXfer, SingleHorzXfer, AllVertXfer, AllHorzXfer,
ReadoutTime, TransferTime, CcdModesAvail, StatusSeqA,
StatusAMTA, StatusAMTB, StatusAMTC, StatusAMTD,
StatusAMTE,
LookUpTable, ImagesPerEOF, WeightValDFl, WeightValSig,
SeqClockFreq, CamChar,
};
......@@ -200,26 +201,61 @@ enum Status {
StatusMask = 0x3ff,
};
enum StatusSPB2 {
SPB2_GBitFifoPixEmpty = 0x8000,
SPB2_FifoOutEmpty = 0x4000,
SPB2_FifoInEmpty = 0x2000,
SPB2_FifoLUTEmpty = 0x1000,
SPB2_FifoChan4Empty = 0x0800,
SPB2_FifoChan3Empty = 0x0400,
SPB2_FifoChan2Empty = 0x0200,
SPB2_FifoChan1Empty = 0x0100,
SPB2_FifoEmptyMask = 0xff00,
SPB2_TstEnvFrmOut = 0x0040,
SPB2_TstEnvFrmIn = 0x0020,
SPB2_TstEnvMask = 0x0060,
SPB2_TstFlashUsrReady = 0x0010,
SPB2_EndInitRam = 0x0008,
SPB2_EndFlashRead = 0x0004,
SPB2_AuroraChanUp = 0x0002,
SPB2_DcmLocked = 0x0001,
SPB2_TstInitMask = 0x001f,
SPB2_TstInitGood = 0x001f,
enum StatusSPB2_SAA {
SPB2_SAA_GBitFifoPixEmpty = 0x8000,
SPB2_SAA_FifoOutEmpty = 0x4000,
SPB2_SAA_FifoInEmpty = 0x2000,
SPB2_SAA_FifoLUTEmpty = 0x1000,
SPB2_SAA_FifoChan4Empty = 0x0800,
SPB2_SAA_FifoChan3Empty = 0x0400,
SPB2_SAA_FifoChan2Empty = 0x0200,
SPB2_SAA_FifoChan1Empty = 0x0100,
SPB2_SAA_FifoEmptyMask = 0xff00,
SPB2_SAA_TstEnvFrmOut = 0x0040,
SPB2_SAA_TstEnvFrmIn = 0x0020,
SPB2_SAA_TstEnvMask = 0x0060,
SPB2_SAA_TstFlashUsrReady = 0x0010,
SPB2_SAA_EndInitRam = 0x0008,
SPB2_SAA_EndFlashRead = 0x0004,
SPB2_SAA_AuroraChanUp = 0x0002,
SPB2_SAA_DcmLocked = 0x0001,
SPB2_SAA_TstInitMask = 0x001f,
SPB2_SAA_TstInitGood = 0x001f,
};
enum StatusSPB8_SAA {
SPB8_SAA_PLL8Locked = 0x8000,
SPB8_SAA_PLL7Locked = 0x4000,
SPB8_SAA_PLL6Locked = 0x2000,
SPB8_SAA_PLL5Locked = 0x1000,
SPB8_SAA_PLL4Locked = 0x0800,
SPB8_SAA_PLL3Locked = 0x0400,
SPB8_SAA_PLL2Locked = 0x0200,
SPB8_SAA_PLL1Locked = 0x0100,
SPB8_SAA_DCMLocked = 0x0020,
SPB8_SAA_AuroraChanUp = 0x0010,
SPB8_SAA_DDR1CalDone = 0x0002,
SPB8_SAA_DDR0CalDone = 0x0001,
SPB8_SAA_TstInitMask = 0xff33,
SPB8_SAA_TstInitGood = 0xff33,
};
enum StatusSPB8_SAE {
SPB8_SAE_TstEnvFrmOut = 0x8000,
SPB8_SAE_TstEnvFrmIn = 0x4000,
SPB8_SAE_TstEnvMask = 0xc000,
SPB8_SAE_FifoTXAEmpty = 0x0800,
SPB8_SAE_FifoOutEmpty = 0x0400,
SPB8_SAE_FifoInEmpty = 0x0200,
SPB8_SAE_FifoMuxEmpty = 0x0100,
SPB8_SAE_FifoChan8Empty = 0x0080,
SPB8_SAE_FifoChan7Empty = 0x0040,
SPB8_SAE_FifoChan6Empty = 0x0020,
SPB8_SAE_FifoChan5Empty = 0x0010,
SPB8_SAE_FifoChan4Empty = 0x0008,
SPB8_SAE_FifoChan3Empty = 0x0004,
SPB8_SAE_FifoChan2Empty = 0x0002,
SPB8_SAE_FifoChan1Empty = 0x0001,
};
enum ShutMode {
......
......@@ -120,9 +120,9 @@ class Camera
void getExtSyncEnable(ExtSync& ext_sync_ena);
void getStatus(Status& status, bool use_ser_line=false,
bool read_spb2=false);
bool read_spb=false);
bool waitStatus(Status& status, Status mask, double timeout,
bool use_ser_line=false, bool read_spb2=false);
bool use_ser_line=false, bool read_spb=false);
void getImageCount(unsigned int& img_count, bool only_lsw=false);
......@@ -157,7 +157,9 @@ class Camera
double getMaxIdleWaitTime();
bool waitIdleStatus(Status& status, bool use_ser_line=false,
bool read_spb2=false);
bool read_spb=false);
Status getSPBStatus();
AutoMutex lock();
......@@ -177,11 +179,11 @@ inline AutoMutex Camera::lock()
}
inline bool Camera::waitIdleStatus(Status& status, bool use_ser_line,
bool read_spb2)
bool read_spb)
{
status = Wait;
return waitStatus(status, StatusMask, getMaxIdleWaitTime(),
use_ser_line, read_spb2);
use_ser_line, read_spb);
}
......
......@@ -174,7 +174,7 @@ inline bool Geometry::isFrelon16(SPBType spb_type)
GeomType geom_type = m_model.getGeomType();
return (((geom_type == SPB2_F16) && (spb_type == SPBType2)) ||
(((geom_type == SPB8_F16_Half) ||
(geom_type == SPB8_F16_Half)) && (spb_type == SPBType8)));
(geom_type == SPB8_F16_Dual)) && (spb_type == SPBType8)));
}
......
......@@ -48,6 +48,7 @@ enum Reg {
SingleVertXfer, SingleHorzXfer, AllVertXfer, AllHorzXfer,
ReadoutTime, TransferTime, CcdModesAvail, StatusSeqA,
StatusAMTA, StatusAMTB, StatusAMTC, StatusAMTD,
StatusAMTE,
LookUpTable, ImagesPerEOF, WeightValDFl, WeightValSig,
SeqClockFreq, CamChar,
};
......@@ -208,25 +209,60 @@ enum Status {
StatusMask = 0x3ff,
};
enum StatusSPB2 {
SPB2_GBitFifoPixEmpty = 0x8000,
SPB2_FifoOutEmpty = 0x4000,
SPB2_FifoInEmpty = 0x2000,
SPB2_FifoLUTEmpty = 0x1000,
SPB2_FifoChan4Empty = 0x0800,
SPB2_FifoChan3Empty = 0x0400,
SPB2_FifoChan2Empty = 0x0200,
SPB2_FifoChan1Empty = 0x0100,
SPB2_TstEnvFrmOut = 0x0040,
SPB2_TstEnvFrmIn = 0x0020,
SPB2_TstEnvMask = 0x0060,
SPB2_TstFlashUsrReady = 0x0010,
SPB2_EndInitRam = 0x0008,
SPB2_EndFlashRead = 0x0004,
SPB2_AuroraChanUp = 0x0002,
SPB2_DcmLocked = 0x0001,
SPB2_TstInitMask = 0x001f,
SPB2_TstInitGood = 0x001f,
enum StatusSPB2_SAA {
SPB2_SAA_GBitFifoPixEmpty = 0x8000,
SPB2_SAA_FifoOutEmpty = 0x4000,
SPB2_SAA_FifoInEmpty = 0x2000,
SPB2_SAA_FifoLUTEmpty = 0x1000,
SPB2_SAA_FifoChan4Empty = 0x0800,
SPB2_SAA_FifoChan3Empty = 0x0400,
SPB2_SAA_FifoChan2Empty = 0x0200,
SPB2_SAA_FifoChan1Empty = 0x0100,
SPB2_SAA_TstEnvFrmOut = 0x0040,
SPB2_SAA_TstEnvFrmIn = 0x0020,
SPB2_SAA_TstEnvMask = 0x0060,
SPB2_SAA_TstFlashUsrReady = 0x0010,
SPB2_SAA_EndInitRam = 0x0008,
SPB2_SAA_EndFlashRead = 0x0004,
SPB2_SAA_AuroraChanUp = 0x0002,
SPB2_SAA_DcmLocked = 0x0001,
SPB2_SAA_TstInitMask = 0x001f,
SPB2_SAA_TstInitGood = 0x001f,
};
enum StatusSPB8_SAA {
SPB8_SAA_PLL8Locked = 0x8000,
SPB8_SAA_PLL7Locked = 0x4000,
SPB8_SAA_PLL6Locked = 0x2000,
SPB8_SAA_PLL5Locked = 0x1000,
SPB8_SAA_PLL4Locked = 0x0800,
SPB8_SAA_PLL3Locked = 0x0400,
SPB8_SAA_PLL2Locked = 0x0200,
SPB8_SAA_PLL1Locked = 0x0100,
SPB8_SAA_DCMLocked = 0x0020,
SPB8_SAA_AuroraChanUp = 0x0010,
SPB8_SAA_DDR1CalDone = 0x0002,
SPB8_SAA_DDR0CalDone = 0x0001,
SPB8_SAA_TstInitMask = 0xff33,
SPB8_SAA_TstInitGood = 0xff33,
};
enum StatusSPB8_SAE {
SPB8_SAE_TstEnvFrmOut = 0x8000,
SPB8_SAE_TstEnvFrmIn = 0x4000,
SPB8_SAE_TstEnvMask = 0xc000,
SPB8_SAE_FifoTXAEmpty = 0x0800,
SPB8_SAE_FifoOutEmpty = 0x0400,
SPB8_SAE_FifoInEmpty = 0x0200,
SPB8_SAE_FifoMuxEmpty = 0x0100,
SPB8_SAE_FifoChan8Empty = 0x0080,
SPB8_SAE_FifoChan7Empty = 0x0040,
SPB8_SAE_FifoChan6Empty = 0x0020,
SPB8_SAE_FifoChan5Empty = 0x0010,
SPB8_SAE_FifoChan4Empty = 0x0008,
SPB8_SAE_FifoChan3Empty = 0x0004,
SPB8_SAE_FifoChan2Empty = 0x0002,
SPB8_SAE_FifoChan1Empty = 0x0001,
};
enum ShutMode {
......
......@@ -92,6 +92,7 @@ static const RegPair RegStrCList[] = {
RegPair(StatusAMTB, "SAB"),
RegPair(StatusAMTC, "SAC"),
RegPair(StatusAMTD, "SAD"),
RegPair(StatusAMTE, "SAE"),
RegPair(LookUpTable, "LUT"),
RegPair(ImagesPerEOF, "NEF"),
......
......@@ -112,10 +112,9 @@ void Camera::syncRegs()
case Hamamatsu:
case SPB2_F16:
case SPB8_F16_Half:
case SPB8_F16_Dual:
m_geom = new Geometry(*this);
break;
case SPB8_F16_Dual:
THROW_HW_ERROR(NotSupported) << DEB_VAR1(geom_type);
}
}
......@@ -143,17 +142,17 @@ void Camera::syncRegsGoodHTD()
DEB_MEMBER_FUNCT();
Status status;
bool use_ser_line, read_spb2;
use_ser_line = read_spb2 = true;
getStatus(status, use_ser_line, read_spb2);
bool use_ser_line, read_spb;
use_ser_line = read_spb = true;
getStatus(status, use_ser_line, read_spb);
if (status != Wait)
DEB_WARNING() << "Camera not IDLE: "
DEB_WARNING() << "Camera not IDLE/READY: "
<< DEB_VAR1(DEB_HEX(status));
int retry = 0;
do {
setExtSyncEnable(ExtSyncNone);
sendCmd(Stop);
bool ok = waitIdleStatus(status, use_ser_line, read_spb2);
bool ok = waitIdleStatus(status, use_ser_line, read_spb);
if (ok) {
if (retry > 0)
DEB_TRACE() << "Succeeded after " << retry
......@@ -166,7 +165,7 @@ void Camera::syncRegsGoodHTD()
} while (++retry < 2);
if (status != Wait)
THROW_HW_ERROR(Error) << "Wrong camera BUSY status: "
THROW_HW_ERROR(Error) << "Wrong camera status: BAD_INIT/BUSY: "
<< DEB_VAR1(DEB_HEX(status));
}
......@@ -723,26 +722,18 @@ void Camera::getExtSyncEnable(ExtSync& ext_sync_ena)
DEB_RETURN() << DEB_VAR1(ext_sync_ena);
}
void Camera::getStatus(Status& status, bool use_ser_line, bool read_spb2)
void Camera::getStatus(Status& status, bool use_ser_line, bool read_spb)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR2(use_ser_line, read_spb2);
bool isSPB8 = (m_model.getSPBType() == SPBType8);
if (isSPB8 && read_spb2) {
DEB_TRACE() << "SPB8: Ignoring " << DEB_VAR1(read_spb2);
read_spb2 = false;
}
DEB_PARAM() << DEB_VAR2(use_ser_line, read_spb);
bool has_good_htd = m_model.has(Model::GoodHTD);
if ((use_ser_line || read_spb2) && !has_good_htd)
if ((use_ser_line || read_spb) && !has_good_htd)
THROW_HW_ERROR(NotSupported) << "SPB2/ser. line status "
"not supported: must upgrade to good HTD firmware";
int spb2_status = 0;
if (read_spb2)
readRegister(StatusAMTA, spb2_status);
int spb_status = read_spb ? getSPBStatus() : 0;
int ccd_status;
if (use_ser_line) {
readRegister(StatusSeqA, ccd_status);
......@@ -751,23 +742,65 @@ void Camera::getStatus(Status& status, bool use_ser_line, bool read_spb2)
dev.getCcdStatus(ccd_status);
}
if (read_spb2) {
if ((spb2_status & SPB2_TstEnvMask) != 0)
ccd_status |= EspiaXfer;
if ((spb2_status & SPB2_TstInitMask) != SPB2_TstInitGood)
ccd_status |= InInit;
}
ccd_status |= spb_status;
status = Status(ccd_status);
DEB_RETURN() << DEB_VAR1(DEB_HEX(status));
}
Status Camera::getSPBStatus()
{
DEB_MEMBER_FUNCT();
bool in_init = false;
bool in_xfer = false;
bool isSPB8 = (m_model.getSPBType() == SPBType8);
if (isSPB8) {
int spb_con_type = m_model.getSPBConType();
for (int i = 0; i < 2; ++i) {
bool present = ((spb_con_type & (1 << i)) != 0);
if (!present)
continue;
int chan = i ? 8 : 0;
writeRegister(ChanControl, chan);
int spb_status, mask, good;
readRegister(StatusAMTA, spb_status);
mask = SPB8_SAA_TstInitMask;
good = SPB8_SAA_TstInitGood;
in_init |= ((spb_status & mask) != good);
readRegister(StatusAMTE, spb_status);
mask = SPB8_SAE_TstEnvMask;
good = 0;
in_xfer |= ((spb_status & mask) != good);
}
} else {
int spb_status, mask, good;
readRegister(StatusAMTA, spb_status);
mask = SPB2_SAA_TstInitMask;
good = SPB2_SAA_TstInitGood;
in_init |= ((spb_status & mask) != good);
mask = SPB2_SAA_TstEnvMask;
good = 0;
in_xfer |= ((spb_status & mask) != good);
}
DEB_TRACE() << DEB_VAR2(in_init, in_xfer);
int spb_status = 0;
if (in_init)
spb_status |= InInit;
if (in_xfer)
spb_status |= EspiaXfer;
DEB_RETURN() << DEB_VAR1(spb_status);
return Status(spb_status);
}
bool Camera::waitStatus(Status& status, Status mask, double timeout,
bool use_ser_line, bool read_spb2)
bool use_ser_line, bool read_spb)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR5(DEB_HEX(status), DEB_HEX(mask), timeout,
use_ser_line, read_spb2);
use_ser_line, read_spb);
Timestamp end;
if (timeout > 0)
......@@ -783,7 +816,7 @@ bool Camera::waitStatus(Status& status, Status mask, double timeout,
break;
}
getStatus(curr_status, use_ser_line, read_spb2);
getStatus(curr_status, use_ser_line, read_spb);
good_status = ((curr_status & mask) == status);
}
......
......@@ -31,7 +31,7 @@ using namespace std;
const double SerialLine::TimeoutSingle = 0.5;
const double SerialLine::TimeoutNormal = 2.0;
const double SerialLine::TimeoutMultiLine = 3.0;
const double SerialLine::TimeoutReset = 5.0;
const double SerialLine::TimeoutReset = 10.0;
SerialLine::SerialLine(Espia::SerialLine& espia_ser_line)
......@@ -231,7 +231,9 @@ void SerialLine::readSingleLine(string& buffer, int max_len, double timeout)
if ((m_curr_op == DoReset) && (timeout == TimeoutDefault))
timeout = TimeoutReset;
m_espia_ser_line.readLine(buffer, max_len, timeout);
do {
m_espia_ser_line.readLine(buffer, max_len, timeout);
} while ((m_curr_op == DoReset) && (buffer != "!OK\r\n"));
decodeFmtResp(buffer, m_curr_fmt_resp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment