mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-08-25 10:31:16 +02:00
wip. xilinx
This commit is contained in:
@@ -1433,16 +1433,18 @@ int setDAC(enum DACINDEX ind, int val, bool mV, char *mess) {
|
||||
int dacval = val;
|
||||
char dacName[20] = {0};
|
||||
snprintf(dacName, sizeof(dacName), "dac %d", ind);
|
||||
|
||||
if (mV) {
|
||||
if (validateDACValue(ind, val, mess) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
// vchip dac (dacname only())
|
||||
if (ind == D_PWR_CHIP) {
|
||||
if (ind == (int)D_PWR_CHIP) {
|
||||
snprintf(dacName, sizeof(dacName), "v_chip");
|
||||
}
|
||||
// power dacs (dacname and power should be disabled)
|
||||
else if (ind >= NDAC_ONLY) {
|
||||
// power dac name
|
||||
{
|
||||
enum PWRINDEX pwrIndex = PWR_IO;
|
||||
if (getPowerIndexFromDACIndex(ind, &pwrIndex, mess) == FAIL)
|
||||
@@ -1450,6 +1452,7 @@ int setDAC(enum DACINDEX ind, int val, bool mV, char *mess) {
|
||||
char *powerNames[] = {PWR_NAMES};
|
||||
snprintf(dacName, sizeof(dacName), "%s", powerNames[pwrIndex]);
|
||||
}
|
||||
|
||||
if (verifyPowerRailDisabled(ind, dacName, mess) == FAIL)
|
||||
return FAIL;
|
||||
}
|
||||
@@ -1627,24 +1630,15 @@ int setPowerRailEnabled(enum DACINDEX indices[], int count, bool enable,
|
||||
// get power indices for log messages and mask
|
||||
uint32_t mask = 0;
|
||||
enum PWRINDEX pwrIndices[count];
|
||||
char *powerNames[] = {PWR_NAMES};
|
||||
for (int i = 0; i != count; ++i) {
|
||||
if (getPowerIndexFromDACIndex(indices[i], &pwrIndices[i], mess) ==
|
||||
FAIL) {
|
||||
sprintf(mess,
|
||||
"Cannot set power rail for %s. Use powerlist to see whats "
|
||||
"available.\n",
|
||||
powerNames[pwrIndices[i]]);
|
||||
if (getPowerIndexFromDACIndex(indices[i], &pwrIndices[i], mess) == FAIL)
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
LOG(logDEBUG1,
|
||||
("Setting power rail for %s\n", powerNames[pwrIndices[i]]));
|
||||
if (getPowerRailMask(pwrIndices[i], &mask, mess) == FAIL)
|
||||
return FAIL;
|
||||
}
|
||||
// log message
|
||||
{
|
||||
char *powerNames[] = {PWR_NAMES};
|
||||
char message[256] = {0};
|
||||
sprintf(message, "Switching %s power for ", enable ? "on" : "off");
|
||||
for (int i = 0; i != count; ++i) {
|
||||
@@ -1674,14 +1668,8 @@ int setPowerRailEnabled(enum DACINDEX indices[], int count, bool enable,
|
||||
|
||||
int isPowerRailEnabled(enum DACINDEX ind, bool *retval, char *mess) {
|
||||
enum PWRINDEX pwrIndex = PWR_IO;
|
||||
if (getPowerIndexFromDACIndex(ind, &pwrIndex, mess) == FAIL) {
|
||||
char *powerNames[] = {PWR_NAMES};
|
||||
sprintf(mess,
|
||||
"Cannot set power rail for %s. Use powerlist to see whats "
|
||||
"available.\n",
|
||||
powerNames[pwrIndex]);
|
||||
if (getPowerIndexFromDACIndex(ind, &pwrIndex, mess) == FAIL)
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
uint32_t mask = 0;
|
||||
if (getPowerRailMask(pwrIndex, &mask, mess) == FAIL)
|
||||
@@ -1710,11 +1698,11 @@ int verifyPowerRailDisabled(enum DACINDEX ind, char *dacName, char *mess) {
|
||||
void powerChip(bool enable) {
|
||||
uint32_t addr = POWER_REG;
|
||||
if (enable) {
|
||||
LOG(logINFOBLUE, ("Powering on all voltage regulators\n"));
|
||||
LOG(logINFOBLUE, ("Powering ON all\n"));
|
||||
bus_w(addr, bus_r(addr) | POWER_ENBL_VLTG_RGLTR_MSK);
|
||||
return;
|
||||
} else {
|
||||
LOG(logINFOBLUE, ("Powering off all voltage regulators\n"));
|
||||
LOG(logINFOBLUE, ("Powering OFF all\n"));
|
||||
bus_w(addr, bus_r(addr) & (~POWER_ENBL_VLTG_RGLTR_MSK));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ int LTC2620_D_SetDacValue(int dacnum, int val, char *dacname, char *mess) {
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tSetting DAC %s [%d]: %d dac\n", dacname, dacnum, val));
|
||||
LOG(logINFOBLUE, ("\tSetting DAC %s [%d]: %d dac\n", dacname, dacnum, val));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
|
||||
@@ -590,14 +590,14 @@ int powerChip(bool on, char *mess) {
|
||||
uint32_t mask = POWER_VIO_MSK | POWER_VCC_A_MSK | POWER_VCC_B_MSK |
|
||||
POWER_VCC_C_MSK | POWER_VCC_D_MSK;
|
||||
if (on) {
|
||||
LOG(logINFOBLUE, ("Powering chip: on\n"));
|
||||
LOG(logINFOBLUE, ("Powering ON all\n"));
|
||||
bus_w(addr, bus_r(addr) | mask);
|
||||
|
||||
if (configureChip(mess) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
} else {
|
||||
LOG(logINFOBLUE, ("Powering chip: off\n"));
|
||||
LOG(logINFOBLUE, ("Powering OFF all\n"));
|
||||
bus_w(addr, bus_r(addr) & ~mask);
|
||||
chipConfigured = 0;
|
||||
if (FAIL == XILINX_FMC_disable_all(mess, MAX_STR_LENGTH)) {
|
||||
@@ -1306,25 +1306,38 @@ int setDAC(enum DACINDEX ind, int val, bool mV, char *mess) {
|
||||
return FAIL;
|
||||
|
||||
int dacval = val;
|
||||
char dacName[20] = {0};
|
||||
snprintf(dacName, sizeof(dacName), "dac %d", ind);
|
||||
|
||||
if (mV) {
|
||||
if (validateDACValue(ind, val, mess) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
if (ind == (int)D_PWR_EMPTY) {
|
||||
snprintf(mess, MAX_STR_LENGTH, "Invalid dac index %d\n", (int)ind);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
// power dacs (power should be disabled)
|
||||
if (ind >= NDAC_ONLY && ind != (int)D_PWR_EMPTY) {
|
||||
if (verifyPowerRailDisabled(ind, mess) == FAIL)
|
||||
// power dac name
|
||||
{
|
||||
enum PWRINDEX pwrIndex = PWR_IO;
|
||||
if (getPowerIndexFromDACIndex(ind, &pwrIndex, mess) == FAIL)
|
||||
return FAIL;
|
||||
char *powerNames[] = {PWR_NAMES};
|
||||
snprintf(dacName, sizeof(dacName), "%s", powerNames[pwrIndex]);
|
||||
}
|
||||
|
||||
if (verifyPowerRailDisabled(ind, dacName, mess) == FAIL)
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (convertVoltageToDACValue(ind, val, &dacval, mess) == FAIL)
|
||||
return FAIL;
|
||||
}
|
||||
{
|
||||
char dacName[20] = {0};
|
||||
snprintf(dacName, sizeof(dacName), "dac %d", ind);
|
||||
if (LTC2620_D_SetDacValue((int)ind, dacval, dacName, mess) == FAIL)
|
||||
return FAIL;
|
||||
}
|
||||
if (LTC2620_D_SetDacValue((int)ind, dacval, dacName, mess) == FAIL)
|
||||
return FAIL;
|
||||
dacValues[ind] = dacval;
|
||||
return OK;
|
||||
}
|
||||
@@ -1471,23 +1484,20 @@ int isPowerRailEnabled(enum DACINDEX ind, bool *retval, char *mess) {
|
||||
return FAIL;
|
||||
|
||||
*retval = (bus_r(CTRL_REG) & mask) != 0;
|
||||
LOG(logDEBUG1, ("get power %d:%d\n", pwrIndex, *retval));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int verifyPowerRailDisabled(enum DACINDEX ind, char *mess) {
|
||||
int verifyPowerRailDisabled(enum DACINDEX ind, char *dacName, char *mess) {
|
||||
bool isEnabled = false;
|
||||
if (isPowerRailEnabled(ind, &isEnabled, mess) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
if (isEnabled) {
|
||||
enum PWRINDEX pwrIndex = PWR_IO;
|
||||
if (getPowerIndexFromDACIndex(ind, &pwrIndex, mess) == FAIL)
|
||||
return FAIL;
|
||||
char *powerNames[] = {PWR_NAMES};
|
||||
sprintf(mess,
|
||||
"Could not set dac for %s. Please disable the power rail "
|
||||
"before setting the dac value.\n",
|
||||
powerNames[pwrIndex]);
|
||||
dacName);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ int getPowerRailMask(enum PWRINDEX ind, uint32_t *mask, char *mess);
|
||||
int setPowerRailEnabled(enum DACINDEX indices[], int count, bool enable,
|
||||
char *mess);
|
||||
int isPowerRailEnabled(enum DACINDEX ind, bool *retval, char *mess);
|
||||
int verifyPowerRailDisabled(enum DACINDEX ind, char *mess);
|
||||
int verifyPowerRailDisabled(enum DACINDEX ind, char *dacName, char *mess);
|
||||
|
||||
int getADC(enum ADCINDEX ind, int *value, char *mess);
|
||||
int getSlowADC(int ichan, int *retval, char *mess);
|
||||
|
||||
Reference in New Issue
Block a user