MAX31865 clear fault byte #116
2
fsfw
2
fsfw
@ -1 +1 @@
|
|||||||
Subproject commit bda02b464a2ad00b1a8e373d4c6b80b0a7c8de95
|
Subproject commit 54e56ec522f485525de7b17458b22132003c5047
|
@ -115,8 +115,8 @@ debugging. */
|
|||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
/** Hardcoded */
|
/** Hardcoded */
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
// Leave at one as the BSP is linux. Used by the ADIS16507 device handler
|
// Leave at one as the BSP is linux. Used by the ADIS1650X device handler
|
||||||
#define OBSW_ADIS16507_LINUX_COM_IF 1
|
#define OBSW_ADIS1650X_LINUX_COM_IF 1
|
||||||
|
|
||||||
#include "OBSWVersion.h"
|
#include "OBSWVersion.h"
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ void GyroADIS1650XHandler::fillCommandAndReplyMap() {
|
|||||||
|
|
||||||
ReturnValue_t GyroADIS1650XHandler::scanForReply(const uint8_t *start, size_t remainingSize,
|
ReturnValue_t GyroADIS1650XHandler::scanForReply(const uint8_t *start, size_t remainingSize,
|
||||||
DeviceCommandId_t *foundId, size_t *foundLen) {
|
DeviceCommandId_t *foundId, size_t *foundLen) {
|
||||||
/* For SPI, the ID will always be the one of the last sent command. */
|
// For SPI, the ID will always be the one of the last sent command
|
||||||
*foundId = this->getPendingCommand();
|
*foundId = this->getPendingCommand();
|
||||||
*foundLen = this->rawPacketLen;
|
*foundLen = this->rawPacketLen;
|
||||||
|
|
||||||
@ -196,18 +196,19 @@ ReturnValue_t GyroADIS1650XHandler::interpretDeviceReply(DeviceCommandId_t id,
|
|||||||
const uint8_t *packet) {
|
const uint8_t *packet) {
|
||||||
switch(id) {
|
switch(id) {
|
||||||
case(ADIS1650X::READ_OUT_CONFIG): {
|
case(ADIS1650X::READ_OUT_CONFIG): {
|
||||||
PoolReadGuard rg(&configDataset);
|
|
||||||
uint16_t readProdId = packet[10] << 8 | packet[11];
|
uint16_t readProdId = packet[10] << 8 | packet[11];
|
||||||
if(((adisType == ADIS1650X::Type::ADIS16507) and
|
if(((adisType == ADIS1650X::Type::ADIS16507) and
|
||||||
(readProdId != ADIS1650X::PROD_ID_16507)) or
|
(readProdId != ADIS1650X::PROD_ID_16507)) or
|
||||||
((adisType == ADIS1650X::Type::ADIS16505) and
|
((adisType == ADIS1650X::Type::ADIS16505) and
|
||||||
(readProdId != ADIS1650X::PROD_ID_16505))) {
|
(readProdId != ADIS1650X::PROD_ID_16505))) {
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
sif::warning << "GyroADIS16507Handler::interpretDeviceReply: Invalid product ID "
|
sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID "
|
||||||
<< readProdId << std::endl;
|
<< readProdId << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
PoolReadGuard rg(&configDataset);
|
||||||
configDataset.diagStatReg.value = packet[2] << 8 | packet[3];
|
configDataset.diagStatReg.value = packet[2] << 8 | packet[3];
|
||||||
configDataset.filterSetting.value = packet[4] << 8 | packet[5];
|
configDataset.filterSetting.value = packet[4] << 8 | packet[5];
|
||||||
configDataset.mscCtrlReg.value = packet[6] << 8 | packet[7];
|
configDataset.mscCtrlReg.value = packet[6] << 8 | packet[7];
|
||||||
@ -232,21 +233,20 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) {
|
|||||||
switch(burstMode) {
|
switch(burstMode) {
|
||||||
case(BurstModes::BURST_16_BURST_SEL_1):
|
case(BurstModes::BURST_16_BURST_SEL_1):
|
||||||
case(BurstModes::BURST_32_BURST_SEL_1): {
|
case(BurstModes::BURST_32_BURST_SEL_1): {
|
||||||
sif::warning << "GyroADIS16507Handler::interpretDeviceReply: Analysis with BURST_SEL1"
|
sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Analysis with BURST_SEL1"
|
||||||
" not implemented!" << std::endl;
|
" not implemented!" << std::endl;
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
case(BurstModes::BURST_16_BURST_SEL_0): {
|
case(BurstModes::BURST_16_BURST_SEL_0): {
|
||||||
uint16_t checksum = packet[20] << 8 | packet[21];
|
uint16_t checksum = packet[20] << 8 | packet[21];
|
||||||
/* Now verify the read checksum with the expected checksum
|
// Now verify the read checksum with the expected checksum according to datasheet p. 20
|
||||||
according to datasheet p. 20 */
|
|
||||||
uint16_t calcChecksum = 0;
|
uint16_t calcChecksum = 0;
|
||||||
for(size_t idx = 2; idx < 20; idx ++) {
|
for(size_t idx = 2; idx < 20; idx ++) {
|
||||||
calcChecksum += packet[idx];
|
calcChecksum += packet[idx];
|
||||||
}
|
}
|
||||||
if(checksum != calcChecksum) {
|
if(checksum != calcChecksum) {
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
sif::warning << "GyroADIS16507Handler::interpretDeviceReply: "
|
sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: "
|
||||||
"Invalid checksum detected!" << std::endl;
|
"Invalid checksum detected!" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
@ -277,7 +277,7 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) {
|
|||||||
} else if(adisType == ADIS1650X::Type::ADIS16505) {
|
} else if(adisType == ADIS1650X::Type::ADIS16505) {
|
||||||
accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16505;
|
accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16505;
|
||||||
} else {
|
} else {
|
||||||
sif::warning << "GyroADIS16507Handler::handleSensorData: "
|
sif::warning << "GyroADIS1650XHandler::handleSensorData: "
|
||||||
"Unknown ADIS type" << std::endl;
|
"Unknown ADIS type" << std::endl;
|
||||||
}
|
}
|
||||||
int16_t accelXRaw = packet[10] << 8 | packet[11];
|
int16_t accelXRaw = packet[10] << 8 | packet[11];
|
||||||
@ -298,11 +298,11 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) {
|
|||||||
|
|
||||||
#if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1
|
#if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1
|
||||||
if(debugDivider->checkAndIncrement()) {
|
if(debugDivider->checkAndIncrement()) {
|
||||||
sif::info << "GyroADIS16507Handler: Angular velocities in deg / s" << std::endl;
|
sif::info << "GyroADIS1650XHandler: Angular velocities in deg / s" << std::endl;
|
||||||
sif::info << "X: " << primaryDataset.angVelocX.value << std::endl;
|
sif::info << "X: " << primaryDataset.angVelocX.value << std::endl;
|
||||||
sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl;
|
sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl;
|
||||||
sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl;
|
sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl;
|
||||||
sif::info << "GyroADIS16507Handler: Accelerations in m / s^2: " << std::endl;
|
sif::info << "GyroADIS1650XHandler: Accelerations in m / s^2: " << std::endl;
|
||||||
sif::info << "X: " << primaryDataset.accelX.value << std::endl;
|
sif::info << "X: " << primaryDataset.accelX.value << std::endl;
|
||||||
sif::info << "Y: " << primaryDataset.accelY.value << std::endl;
|
sif::info << "Y: " << primaryDataset.accelY.value << std::endl;
|
||||||
sif::info << "Z: " << primaryDataset.accelZ.value << std::endl;
|
sif::info << "Z: " << primaryDataset.accelZ.value << std::endl;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
|
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
|
||||||
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
||||||
|
|
||||||
#if OBSW_ADIS16507_LINUX_COM_IF == 1
|
#if OBSW_ADIS1650X_LINUX_COM_IF == 1
|
||||||
class SpiComIF;
|
class SpiComIF;
|
||||||
class SpiCookie;
|
class SpiCookie;
|
||||||
#endif
|
#endif
|
||||||
@ -24,7 +24,7 @@ public:
|
|||||||
GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication,
|
GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication,
|
||||||
CookieIF* comCookie, ADIS1650X::Type type);
|
CookieIF* comCookie, ADIS1650X::Type type);
|
||||||
|
|
||||||
/* DeviceHandlerBase abstract function implementation */
|
// DeviceHandlerBase abstract function implementation
|
||||||
void doStartUp() override;
|
void doStartUp() override;
|
||||||
void doShutDown() override;
|
void doShutDown() override;
|
||||||
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override;
|
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override;
|
||||||
@ -66,7 +66,7 @@ private:
|
|||||||
|
|
||||||
BurstModes getBurstMode();
|
BurstModes getBurstMode();
|
||||||
|
|
||||||
#if OBSW_ADIS16507_LINUX_COM_IF == 1
|
#if OBSW_ADIS1650X_LINUX_COM_IF == 1
|
||||||
static ReturnValue_t spiSendCallback(SpiComIF* comIf, SpiCookie *cookie,
|
static ReturnValue_t spiSendCallback(SpiComIF* comIf, SpiCookie *cookie,
|
||||||
const uint8_t *sendData, size_t sendLen, void* args);
|
const uint8_t *sendData, size_t sendLen, void* args);
|
||||||
#endif
|
#endif
|
||||||
|
@ -91,6 +91,10 @@ ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand(
|
|||||||
*id = Max31865Definitions::REQUEST_FAULT_BYTE;
|
*id = Max31865Definitions::REQUEST_FAULT_BYTE;
|
||||||
return buildCommandFromCommand(*id, nullptr, 0);
|
return buildCommandFromCommand(*id, nullptr, 0);
|
||||||
}
|
}
|
||||||
|
else if(internalState == InternalState::CLEAR_FAULT_BYTE) {
|
||||||
|
*id = Max31865Definitions::CLEAR_FAULT_BYTE;
|
||||||
|
return buildCommandFromCommand(*id, nullptr, 0);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return DeviceHandlerBase::NOTHING_TO_SEND;
|
return DeviceHandlerBase::NOTHING_TO_SEND;
|
||||||
}
|
}
|
||||||
@ -155,6 +159,13 @@ ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand(
|
|||||||
return DeviceHandlerIF::NO_COMMAND_DATA;
|
return DeviceHandlerIF::NO_COMMAND_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case(Max31865Definitions::CLEAR_FAULT_BYTE): {
|
||||||
|
commandBuffer[0] = static_cast<uint8_t>(Max31865Definitions::CONFIG_CMD);
|
||||||
|
commandBuffer[1] = Max31865Definitions::CLEAR_FAULT_BIT_VAL;
|
||||||
|
DeviceHandlerBase::rawPacketLen = 2;
|
||||||
|
DeviceHandlerBase::rawPacket = commandBuffer.data();
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
case(Max31865Definitions::REQUEST_CONFIG): {
|
case(Max31865Definitions::REQUEST_CONFIG): {
|
||||||
commandBuffer[0] = static_cast<uint8_t>(
|
commandBuffer[0] = static_cast<uint8_t>(
|
||||||
Max31865Definitions::REQUEST_CONFIG);
|
Max31865Definitions::REQUEST_CONFIG);
|
||||||
@ -233,6 +244,7 @@ void Max31865PT1000Handler::fillCommandAndReplyMap() {
|
|||||||
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3,
|
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3,
|
||||||
&sensorDataset);
|
&sensorDataset);
|
||||||
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3);
|
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3);
|
||||||
|
insertInCommandAndReplyMap(Max31865Definitions::CLEAR_FAULT_BYTE, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start,
|
ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start,
|
||||||
@ -290,6 +302,11 @@ ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start,
|
|||||||
*foundLen = 2;
|
*foundLen = 2;
|
||||||
internalState = InternalState::RUNNING;
|
internalState = InternalState::RUNNING;
|
||||||
}
|
}
|
||||||
|
else if(internalState == InternalState::CLEAR_FAULT_BYTE) {
|
||||||
|
*foundId = Max31865Definitions::CLEAR_FAULT_BYTE;
|
||||||
|
*foundLen = 2;
|
||||||
|
internalState = InternalState::RUNNING;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
*foundId = Max31865Definitions::REQUEST_CONFIG;
|
*foundId = Max31865Definitions::REQUEST_CONFIG;
|
||||||
*foundLen = configReplySize;
|
*foundLen = configReplySize;
|
||||||
@ -360,9 +377,14 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(
|
|||||||
case(Max31865Definitions::REQUEST_RTD): {
|
case(Max31865Definitions::REQUEST_RTD): {
|
||||||
// first bit of LSB reply byte is the fault bit
|
// first bit of LSB reply byte is the fault bit
|
||||||
uint8_t faultBit = packet[2] & 0b0000'0001;
|
uint8_t faultBit = packet[2] & 0b0000'0001;
|
||||||
if(faultBit == 1) {
|
if(resetFaultBit) {
|
||||||
|
internalState = InternalState::CLEAR_FAULT_BYTE;
|
||||||
|
resetFaultBit = false;
|
||||||
|
}
|
||||||
|
else if(faultBit == 1) {
|
||||||
// Maybe we should attempt to restart it?
|
// Maybe we should attempt to restart it?
|
||||||
internalState = InternalState::REQUEST_FAULT_BYTE;
|
internalState = InternalState::REQUEST_FAULT_BYTE;
|
||||||
|
resetFaultBit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// RTD value consists of last seven bits of the LSB reply byte and
|
// RTD value consists of last seven bits of the LSB reply byte and
|
||||||
|
@ -96,12 +96,14 @@ private:
|
|||||||
REQUEST_LOW_THRESHOLD,
|
REQUEST_LOW_THRESHOLD,
|
||||||
REQUEST_CONFIG,
|
REQUEST_CONFIG,
|
||||||
RUNNING,
|
RUNNING,
|
||||||
REQUEST_FAULT_BYTE
|
REQUEST_FAULT_BYTE,
|
||||||
|
CLEAR_FAULT_BYTE
|
||||||
};
|
};
|
||||||
|
|
||||||
InternalState internalState = InternalState::NONE;
|
InternalState internalState = InternalState::NONE;
|
||||||
bool commandExecuted = false;
|
bool commandExecuted = false;
|
||||||
|
|
||||||
|
bool resetFaultBit = false;
|
||||||
dur_millis_t startTime = 0;
|
dur_millis_t startTime = 0;
|
||||||
uint8_t faultByte = 0;
|
uint8_t faultByte = 0;
|
||||||
std::array<uint8_t, 3> commandBuffer { 0 };
|
std::array<uint8_t, 3> commandBuffer { 0 };
|
||||||
|
@ -17,13 +17,17 @@ enum PoolIds: lp_id_t {
|
|||||||
static constexpr DeviceCommandId_t CONFIG_CMD = 0x80;
|
static constexpr DeviceCommandId_t CONFIG_CMD = 0x80;
|
||||||
static constexpr DeviceCommandId_t WRITE_HIGH_THRESHOLD = 0x83;
|
static constexpr DeviceCommandId_t WRITE_HIGH_THRESHOLD = 0x83;
|
||||||
static constexpr DeviceCommandId_t WRITE_LOW_THRESHOLD = 0x85;
|
static constexpr DeviceCommandId_t WRITE_LOW_THRESHOLD = 0x85;
|
||||||
|
|
||||||
static constexpr DeviceCommandId_t REQUEST_CONFIG = 0x00;
|
static constexpr DeviceCommandId_t REQUEST_CONFIG = 0x00;
|
||||||
static constexpr DeviceCommandId_t REQUEST_RTD = 0x01;
|
static constexpr DeviceCommandId_t REQUEST_RTD = 0x01;
|
||||||
static constexpr DeviceCommandId_t REQUEST_HIGH_THRESHOLD = 0x03;
|
static constexpr DeviceCommandId_t REQUEST_HIGH_THRESHOLD = 0x03;
|
||||||
static constexpr DeviceCommandId_t REQUEST_LOW_THRESHOLD = 0x05;
|
static constexpr DeviceCommandId_t REQUEST_LOW_THRESHOLD = 0x05;
|
||||||
static constexpr DeviceCommandId_t REQUEST_FAULT_BYTE = 0x07;
|
static constexpr DeviceCommandId_t REQUEST_FAULT_BYTE = 0x07;
|
||||||
|
|
||||||
|
static constexpr DeviceCommandId_t CLEAR_FAULT_BYTE = 0x08;
|
||||||
|
|
||||||
static constexpr uint32_t MAX31865_SET_ID = REQUEST_RTD;
|
static constexpr uint32_t MAX31865_SET_ID = REQUEST_RTD;
|
||||||
|
static constexpr uint8_t CLEAR_FAULT_BIT_VAL = 0b0000'0010;
|
||||||
|
|
||||||
static constexpr size_t MAX_REPLY_SIZE = 5;
|
static constexpr size_t MAX_REPLY_SIZE = 5;
|
||||||
|
|
||||||
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
|||||||
Subproject commit 1d374230b34606d8b6aa4df1335befec316a1e35
|
Subproject commit eca5bba1d8df6576a19547d356e676b0fb164d87
|
Loading…
Reference in New Issue
Block a user