issues with external pl pcdu conversion
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:
parent
9e3d7bccd9
commit
3f318afe2c
@ -320,8 +320,8 @@ void SpiTestClass::performOneShotMax1227Test() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
adcCfg.plPcduAdcExtConv = false;
|
adcCfg.plPcduAdcExtConv = true;
|
||||||
adcCfg.plPcduAdcIntConv = true;
|
adcCfg.plPcduAdcIntConv = false;
|
||||||
performMax1227Test();
|
performMax1227Test();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,8 +343,8 @@ void SpiTestClass::performMax1227Test() {
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint32_t spiSpeed = 1'000'000;
|
uint32_t spiSpeed = 976'000;
|
||||||
spi::SpiModes spiMode = spi::SpiModes::MODE_3;
|
spi::SpiModes spiMode = spi::SpiModes::MODE_0;
|
||||||
setSpiSpeedAndMode(fd, spiMode, spiSpeed);
|
setSpiSpeedAndMode(fd, spiMode, spiSpeed);
|
||||||
|
|
||||||
max1227RadSensorTest(fd);
|
max1227RadSensorTest(fd);
|
||||||
@ -535,11 +535,12 @@ void SpiTestClass::max1227PlPcduTest(int fd) {
|
|||||||
adcCfg.vbatSwitch = false;
|
adcCfg.vbatSwitch = false;
|
||||||
// Takes a bit of time until the ADC is usable
|
// Takes a bit of time until the ADC is usable
|
||||||
TaskFactory::delayTask(50);
|
TaskFactory::delayTask(50);
|
||||||
}
|
|
||||||
if (adcCfg.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);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (adcCfg.plPcduAdcExtConv) {
|
||||||
sendBuffer[0] = max1227::buildSetupByte(ClkSel::EXT_CONV_EXT_TIMED, RefSel::INT_REF_NO_WAKEUP,
|
sendBuffer[0] = max1227::buildSetupByte(ClkSel::EXT_CONV_EXT_TIMED, RefSel::INT_REF_NO_WAKEUP,
|
||||||
DiffSel::NONE_0);
|
DiffSel::NONE_0);
|
||||||
spiTransferStruct[0].len = 1;
|
spiTransferStruct[0].len = 1;
|
||||||
@ -551,16 +552,20 @@ void SpiTestClass::max1227PlPcduTest(int fd) {
|
|||||||
for (uint8_t idx = 0; idx < n + 1; idx++) {
|
for (uint8_t idx = 0; idx < n + 1; idx++) {
|
||||||
adcRaw[idx] = (recvBuffer[idx * 2 + 1] << 8) | recvBuffer[idx * 2 + 2];
|
adcRaw[idx] = (recvBuffer[idx * 2 + 1] << 8) | recvBuffer[idx * 2 + 2];
|
||||||
}
|
}
|
||||||
arrayprinter::print(recvBuffer.data(), spiTransferStruct[0].len, OutputType::HEX);
|
usleep(10);
|
||||||
sif::info << "PL PCDU ADC values:" << std::endl;
|
spiTransferStruct[0].len = 0;
|
||||||
for (int idx = 0; idx < n + 1; idx++) {
|
|
||||||
sif::info << "Raw Value " << idx << ": " << adcRaw[idx] << std::endl;
|
|
||||||
}
|
|
||||||
max1227::prepareExternallyClockedTemperatureRead(sendBuffer.data(), spiTransferStruct[0].len);
|
max1227::prepareExternallyClockedTemperatureRead(sendBuffer.data(), spiTransferStruct[0].len);
|
||||||
transfer(fd, gpioIds::PLPCDU_ADC_CS);
|
transfer(fd, gpioIds::PLPCDU_ADC_CS);
|
||||||
int16_t tempRaw = ((recvBuffer[23] & 0x0f) << 8) | recvBuffer[24];
|
int16_t tempRaw = ((recvBuffer[23] & 0x0f) << 8) | recvBuffer[24];
|
||||||
float temp = max1227::getTemperature(tempRaw);
|
sif::info << "PL PCDU ADC ext conv [" << std::hex << std::setfill('0');
|
||||||
sif::info << "Temperature: " << temp << std::endl;
|
for (int idx = 0; idx < n + 1; idx++) {
|
||||||
|
sif::info << std::setw(3) << adcRaw[idx];
|
||||||
|
if(idx < n) {
|
||||||
|
sif::info << ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sif::info << "]" << std::endl;
|
||||||
|
sif::info << "Temperature: " << max1227::getTemperature(tempRaw) << " C" << std::endl;
|
||||||
}
|
}
|
||||||
if (adcCfg.plPcduAdcIntConv) {
|
if (adcCfg.plPcduAdcIntConv) {
|
||||||
sendBuffer[0] = max1227::buildResetByte(true);
|
sendBuffer[0] = max1227::buildResetByte(true);
|
||||||
@ -583,7 +588,6 @@ void SpiTestClass::max1227PlPcduTest(int fd) {
|
|||||||
shiftOutZeros();
|
shiftOutZeros();
|
||||||
transfer(fd, gpioIds::PLPCDU_ADC_CS);
|
transfer(fd, gpioIds::PLPCDU_ADC_CS);
|
||||||
setSendBuffer();
|
setSendBuffer();
|
||||||
//arrayprinter::print(recvBuffer.data(), 26, OutputType::HEX);
|
|
||||||
uint16_t adcRaw[n + 1] = {};
|
uint16_t adcRaw[n + 1] = {};
|
||||||
int16_t tempRaw = ((recvBuffer[0] & 0x0f) << 8) | recvBuffer[1];
|
int16_t tempRaw = ((recvBuffer[0] & 0x0f) << 8) | recvBuffer[1];
|
||||||
sif::info << "PL PCDU ADC int conv [" << std::hex << std::setfill('0');
|
sif::info << "PL PCDU ADC int conv [" << std::hex << std::setfill('0');
|
||||||
@ -595,7 +599,7 @@ void SpiTestClass::max1227PlPcduTest(int fd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sif::info << "]" << std::endl;
|
sif::info << "]" << std::endl;
|
||||||
sif::info << "Temperature: " << tempRaw * 0.125 << " C" << std::endl;
|
sif::info << "Temperature: " << max1227::getTemperature(tempRaw) << " C" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ void prepareExternallyClockedSingleChannelRead(uint8_t* spiBuf, uint8_t channel,
|
|||||||
* the first byte (first conversion byte) the the rest of the SPI buffer.
|
* the first byte (first conversion byte) the the rest of the SPI buffer.
|
||||||
* @param spiBuf
|
* @param spiBuf
|
||||||
* @param n Channel number. Example: If the ADC has 6 channels, n will be 5
|
* @param n Channel number. Example: If the ADC has 6 channels, n will be 5
|
||||||
* @param sz
|
* @param sz Will be incremented by amount which should be sent
|
||||||
*/
|
*/
|
||||||
void prepareExternallyClockedRead0ToN(uint8_t* spiBuf, uint8_t n, size_t& sz);
|
void prepareExternallyClockedRead0ToN(uint8_t* spiBuf, uint8_t n, size_t& sz);
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ void prepareExternallyClockedRead0ToN(uint8_t* spiBuf, uint8_t n, size_t& sz);
|
|||||||
* Prepare an externally clocked temperature read. 25 bytes have to be sent
|
* Prepare an externally clocked temperature read. 25 bytes have to be sent
|
||||||
* and the raw temperature value will appear on the last 2 bytes of the reply.
|
* and the raw temperature value will appear on the last 2 bytes of the reply.
|
||||||
* @param spiBuf
|
* @param spiBuf
|
||||||
* @param sz
|
* @param sz Will be incremented by amount which should be sent
|
||||||
*/
|
*/
|
||||||
void prepareExternallyClockedTemperatureRead(uint8_t* spiBuf, size_t& sz);
|
void prepareExternallyClockedTemperatureRead(uint8_t* spiBuf, size_t& sz);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user