some tries to get data from max1227 in externally clocked mode
This commit is contained in:
@ -33,9 +33,13 @@ ReturnValue_t SusHandler::buildNormalDeviceCommand(
|
||||
DeviceCommandId_t * id) {
|
||||
if (communicationStep == CommunicationStep::PERFORM_CONVERSIONS) {
|
||||
*id = SUS::PERFORM_CONVERSIONS;
|
||||
communicationStep = CommunicationStep::READ_TEMP;
|
||||
communicationStep = CommunicationStep::REQUEST_TEMP;
|
||||
// communicationStep = CommunicationStep::PERFORM_CONVERSIONS;
|
||||
}
|
||||
else if (communicationStep == CommunicationStep::REQUEST_TEMP) {
|
||||
*id = SUS::RQUEST_TEMP;
|
||||
communicationStep = CommunicationStep::PERFORM_CONVERSIONS;
|
||||
}
|
||||
else if (communicationStep == CommunicationStep::READ_TEMP) {
|
||||
*id = SUS::READ_TEMP;
|
||||
communicationStep = CommunicationStep::PERFORM_CONVERSIONS;
|
||||
@ -66,7 +70,7 @@ ReturnValue_t SusHandler::buildCommandFromCommand(
|
||||
return RETURN_OK;
|
||||
}
|
||||
case(SUS::PERFORM_CONVERSIONS): {
|
||||
gpioComIF->pullLow(chipSelectId);
|
||||
// gpioComIF->pullLow(chipSelectId);
|
||||
std::memset(cmdBuffer, 0, sizeof(cmdBuffer));
|
||||
/**
|
||||
* The sun sensor ADC is shutdown when CS is pulled high so each time requesting a
|
||||
@ -76,18 +80,7 @@ ReturnValue_t SusHandler::buildCommandFromCommand(
|
||||
cmdBuffer[1] = SUS::SETUP_DEFINITION;
|
||||
// wirte one dummy byte here
|
||||
// cmdBuffer[2] = SUS::CONVERT_TEMPERATURE;
|
||||
cmdBuffer[2] = SUS::CONVERT_DIFF_CHANNEL_0_1;
|
||||
// struct timeval startOfDelay;
|
||||
// gettimeofday(&startOfDelay, NULL);
|
||||
// struct timeval currentTime;
|
||||
// gettimeofday(¤tTime, NULL);
|
||||
// while (currentTime.tv_usec - startOfDelay.tv_usec < 1000) {
|
||||
// gettimeofday(¤tTime, NULL);
|
||||
// }
|
||||
|
||||
// cmdBuffer[27] = SUS::CONVERT_DIFF_CHANNEL_0_1;
|
||||
// cmdBuffer[29] = SUS::CONVERT_DIFF_CHANNEL_2_3;
|
||||
// cmdBuffer[31] = SUS::CONVERT_DIFF_CHANNEL_4_5;
|
||||
cmdBuffer[2] = SUS::CONVERT_DIFF_CHANNEL_2;
|
||||
|
||||
// cmdBuffer[0] = SUS::SETUP_DEFINITION;
|
||||
// cmdBuffer[1] = SUS::UNIPOLAR_CONFIG;
|
||||
@ -100,13 +93,20 @@ ReturnValue_t SusHandler::buildCommandFromCommand(
|
||||
rawPacketLen = 5;
|
||||
return RETURN_OK;
|
||||
}
|
||||
case(SUS::RQUEST_TEMP): {
|
||||
// gpioComIF->pullLow(chipSelectId);
|
||||
std::memset(cmdBuffer, 0, sizeof(cmdBuffer));
|
||||
// cmdBuffer[0] = SUS::RESET_FIFO;
|
||||
// cmdBuffer[1] = SUS::SETUP_DEFINITION;
|
||||
cmdBuffer[0] = SUS::CONVERT_TEMPERATURE;
|
||||
rawPacket = cmdBuffer;
|
||||
rawPacketLen = 25;
|
||||
return RETURN_OK;
|
||||
}
|
||||
case(SUS::READ_TEMP): {
|
||||
std::memset(cmdBuffer, 0, sizeof(cmdBuffer));
|
||||
cmdBuffer[0] = SUS::RESET_FIFO;
|
||||
cmdBuffer[1] = SUS::SETUP_DEFINITION;
|
||||
cmdBuffer[2] = SUS::CONVERT_TEMPERATURE;
|
||||
rawPacket = cmdBuffer;
|
||||
rawPacketLen = 27;
|
||||
rawPacketLen = 0;
|
||||
return RETURN_OK;
|
||||
}
|
||||
default:
|
||||
@ -122,7 +122,7 @@ void SusHandler::fillCommandAndReplyMap() {
|
||||
this->insertInCommandAndReplyMap(SUS::READ_TEMP, 1, nullptr, SUS::SIZE_PERFORM_CONVERSIONS);
|
||||
// this->insertInCommandAndReplyMap(SUS::PERFORM_CONVERSIONS, 1, &dataset,
|
||||
// SUS::SIZE_PERFORM_CONVERSIONS);
|
||||
this->insertInCommandMap(SUS::PERFORM_CONVERSIONS);
|
||||
this->insertInCommandMap(SUS::RQUEST_TEMP);
|
||||
}
|
||||
|
||||
ReturnValue_t SusHandler::scanForReply(const uint8_t *start,
|
||||
@ -136,6 +136,7 @@ ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
const uint8_t *packet) {
|
||||
switch (id) {
|
||||
case SUS::PERFORM_CONVERSIONS: {
|
||||
// gpioComIF->pullHigh(chipSelectId);
|
||||
PoolReadGuard readSet(&dataset);
|
||||
dataset.temperatureCelcius = (*(packet + 25) << 8 | *(packet + 26)) * 0.125;
|
||||
dataset.diffScanChannel0_1 = (*(packet + 29) << 8 | *(packet + 30));
|
||||
@ -154,7 +155,7 @@ ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
break;
|
||||
}
|
||||
case SUS::READ_TEMP: {
|
||||
gpioComIF->pullHigh(chipSelectId);
|
||||
// gpioComIF->pullHigh(chipSelectId);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
Reference in New Issue
Block a user