this delay seems to do the job
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2022-02-18 11:29:51 +01:00
parent 151621b49a
commit 6326ac71ca
2 changed files with 10 additions and 15 deletions

View File

@ -310,8 +310,8 @@ void SpiTestClass::performPeriodicMax1227Test() {
susExtConversion = false; susExtConversion = false;
susIntConversion = false; susIntConversion = false;
plPcduAdcExtConv = false; plPcduAdcExtConv = true;
plPcduAdcIntConv = true; plPcduAdcIntConv = false;
performMax1227Test(); performMax1227Test();
} }
@ -487,7 +487,7 @@ void SpiTestClass::max1227SusTest(int fd) {
void SpiTestClass::max1227PlPcduTest(int fd) { void SpiTestClass::max1227PlPcduTest(int fd) {
using namespace max1227; using namespace max1227;
if (plPcduAdcExtConv) { if ((plPcduAdcExtConv or plPcduAdcIntConv) and vbatSwitch) {
// This enables the ADC // This enables the ADC
ReturnValue_t result = gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT0); ReturnValue_t result = gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT0);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
@ -497,7 +497,11 @@ void SpiTestClass::max1227PlPcduTest(int fd) {
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return; return;
} }
usleep(1000); vbatSwitch = false;
// Takes a bit of time until the ADC is usable
TaskFactory::delayTask(50);
}
if (plPcduAdcExtConv) {
sendBuffer[0] = max1227::buildResetByte(false); sendBuffer[0] = max1227::buildResetByte(false);
spiTransferStruct[0].len = 1; spiTransferStruct[0].len = 1;
transfer(fd, gpioIds::PLPCDU_ADC_CS); transfer(fd, gpioIds::PLPCDU_ADC_CS);
@ -524,17 +528,7 @@ void SpiTestClass::max1227PlPcduTest(int fd) {
sif::info << "Temperature: " << temp << std::endl; sif::info << "Temperature: " << temp << std::endl;
} }
if (plPcduAdcIntConv) { if (plPcduAdcIntConv) {
// This enables the ADC sendBuffer[0] = max1227::buildResetByte(true);
ReturnValue_t result = gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT0);
if (result != HasReturnvaluesIF::RETURN_OK) {
return;
}
result = gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT1);
if (result != HasReturnvaluesIF::RETURN_OK) {
return;
}
usleep(1000);
sendBuffer[0] = max1227::buildResetByte(false);
spiTransferStruct[0].len = 1; spiTransferStruct[0].len = 1;
transfer(fd, gpioIds::PLPCDU_ADC_CS); transfer(fd, gpioIds::PLPCDU_ADC_CS);
// Now use internal conversion // Now use internal conversion

View File

@ -61,6 +61,7 @@ class SpiTestClass : public TestTask {
bool plPcduAdcExtConv = false; bool plPcduAdcExtConv = false;
bool plPcduAdcIntConv = false; bool plPcduAdcIntConv = false;
bool vbatSwitch = true;
uint8_t mgm0Lis3mdlChipSelect = 0; uint8_t mgm0Lis3mdlChipSelect = 0;
uint8_t mgm1Rm3100ChipSelect = 0; uint8_t mgm1Rm3100ChipSelect = 0;