finished ext conv callback
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
@ -322,6 +322,7 @@ void SpiTestClass::performOneShotMax1227Test() {
|
||||
|
||||
adcCfg.plPcduAdcExtConv = true;
|
||||
adcCfg.plPcduAdcIntConv = false;
|
||||
adcCfg.plPcduAdcExtConvAsOne = false;
|
||||
performMax1227Test();
|
||||
}
|
||||
|
||||
@ -344,7 +345,7 @@ void SpiTestClass::performMax1227Test() {
|
||||
return;
|
||||
}
|
||||
uint32_t spiSpeed = 976'000;
|
||||
spi::SpiModes spiMode = spi::SpiModes::MODE_0;
|
||||
spi::SpiModes spiMode = spi::SpiModes::MODE_3;
|
||||
setSpiSpeedAndMode(fd, spiMode, spiSpeed);
|
||||
|
||||
max1227RadSensorTest(fd);
|
||||
@ -522,7 +523,8 @@ void SpiTestClass::max1227SusTest(int fd, SusTestCfg &cfg) {
|
||||
|
||||
void SpiTestClass::max1227PlPcduTest(int fd) {
|
||||
using namespace max1227;
|
||||
if ((adcCfg.plPcduAdcExtConv or adcCfg.plPcduAdcIntConv) and adcCfg.vbatSwitch) {
|
||||
if ((adcCfg.plPcduAdcExtConv or adcCfg.plPcduAdcIntConv or adcCfg.plPcduAdcExtConvAsOne) and
|
||||
adcCfg.vbatSwitch) {
|
||||
// This enables the ADC
|
||||
ReturnValue_t result = gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT0);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
@ -538,7 +540,6 @@ void SpiTestClass::max1227PlPcduTest(int fd) {
|
||||
sendBuffer[0] = max1227::buildResetByte(false);
|
||||
spiTransferStruct[0].len = 1;
|
||||
transfer(fd, gpioIds::PLPCDU_ADC_CS);
|
||||
|
||||
}
|
||||
if (adcCfg.plPcduAdcExtConv) {
|
||||
sendBuffer[0] = max1227::buildSetupByte(ClkSel::EXT_CONV_EXT_TIMED, RefSel::INT_REF_NO_WAKEUP,
|
||||
@ -547,20 +548,52 @@ void SpiTestClass::max1227PlPcduTest(int fd) {
|
||||
transfer(fd, gpioIds::PLPCDU_ADC_CS);
|
||||
uint8_t n = 11;
|
||||
max1227::prepareExternallyClockedRead0ToN(sendBuffer.data(), n, spiTransferStruct[0].len);
|
||||
size_t dummy = 0;
|
||||
max1227::prepareExternallyClockedTemperatureRead(sendBuffer.data() + spiTransferStruct[0].len,
|
||||
dummy);
|
||||
// + 1 to account for temp conversion byte
|
||||
spiTransferStruct[0].len += 1;
|
||||
transfer(fd, gpioIds::PLPCDU_ADC_CS);
|
||||
uint16_t adcRaw[n + 1] = {};
|
||||
for (uint8_t idx = 0; idx < n + 1; idx++) {
|
||||
adcRaw[idx] = (recvBuffer[idx * 2 + 1] << 8) | recvBuffer[idx * 2 + 2];
|
||||
}
|
||||
usleep(10);
|
||||
spiTransferStruct[0].len = 0;
|
||||
max1227::prepareExternallyClockedTemperatureRead(sendBuffer.data(), spiTransferStruct[0].len);
|
||||
spiTransferStruct[0].len = 24;
|
||||
// Shift out zeros
|
||||
shiftOutZeros();
|
||||
transfer(fd, gpioIds::PLPCDU_ADC_CS);
|
||||
int16_t tempRaw = ((recvBuffer[23] & 0x0f) << 8) | recvBuffer[24];
|
||||
setSendBuffer();
|
||||
int16_t tempRaw = ((recvBuffer[22] & 0x0f) << 8) | recvBuffer[23];
|
||||
sif::info << "PL PCDU ADC ext conv [" << std::hex << std::setfill('0');
|
||||
for (int idx = 0; idx < n + 1; idx++) {
|
||||
sif::info << std::setw(3) << adcRaw[idx];
|
||||
if(idx < n) {
|
||||
if (idx < n) {
|
||||
sif::info << ",";
|
||||
}
|
||||
}
|
||||
sif::info << "]" << std::endl;
|
||||
sif::info << "Temperature: " << max1227::getTemperature(tempRaw) << " C" << std::endl;
|
||||
}
|
||||
if (adcCfg.plPcduAdcExtConvAsOne) {
|
||||
sendBuffer[0] = max1227::buildSetupByte(ClkSel::EXT_CONV_EXT_TIMED, RefSel::INT_REF_NO_WAKEUP,
|
||||
DiffSel::NONE_0);
|
||||
spiTransferStruct[0].len = 1;
|
||||
transfer(fd, gpioIds::PLPCDU_ADC_CS);
|
||||
uint8_t n = 11;
|
||||
max1227::prepareExternallyClockedRead0ToN(sendBuffer.data(), n, spiTransferStruct[0].len);
|
||||
max1227::prepareExternallyClockedTemperatureRead(sendBuffer.data() + spiTransferStruct[0].len,
|
||||
spiTransferStruct[0].len);
|
||||
transfer(fd, gpioIds::PLPCDU_ADC_CS);
|
||||
uint16_t adcRaw[n + 1] = {};
|
||||
for (uint8_t idx = 0; idx < n + 1; idx++) {
|
||||
adcRaw[idx] = (recvBuffer[idx * 2 + 1] << 8) | recvBuffer[idx * 2 + 2];
|
||||
}
|
||||
int16_t tempRaw = ((recvBuffer[spiTransferStruct[0].len - 2] & 0x0f) << 8) |
|
||||
recvBuffer[spiTransferStruct[0].len - 1];
|
||||
sif::info << "PL PCDU ADC ext conv [" << std::hex << std::setfill('0');
|
||||
for (int idx = 0; idx < n + 1; idx++) {
|
||||
sif::info << std::setw(3) << adcRaw[idx];
|
||||
if (idx < n) {
|
||||
sif::info << ",";
|
||||
}
|
||||
}
|
||||
@ -594,7 +627,7 @@ void SpiTestClass::max1227PlPcduTest(int fd) {
|
||||
for (int idx = 0; idx < n + 1; idx++) {
|
||||
adcRaw[idx] = (recvBuffer[idx * 2 + 2] << 8) | recvBuffer[idx * 2 + 3];
|
||||
sif::info << std::setw(3) << adcRaw[idx];
|
||||
if(idx < n) {
|
||||
if (idx < n) {
|
||||
sif::info << ",";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user