save before making change in spicomif
This commit is contained in:
parent
931c17e971
commit
f4eb5d81ba
@ -156,16 +156,12 @@ void ObjectFactory::produce(){
|
||||
gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, chipSelectRadSensor);
|
||||
gpioComIF->addGpios(gpioCookieRadSensor);
|
||||
|
||||
// SpiCookie* spiCookieRadSensor = new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR,
|
||||
// std::string("/dev/spidev2.0"), RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
// spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieRadSensor = new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR,
|
||||
std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
std::string("/dev/spidev2.0"), RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
// RadiationSensorHandler* radSensor = new RadiationSensorHandler(objects::RAD_SENSOR,
|
||||
// objects::SPI_COM_IF, spiCookieRadSensor);
|
||||
// (void) radSensor;
|
||||
// radSensor->setStartUpImmediately();
|
||||
RadiationSensorHandler* radSensor = new RadiationSensorHandler(objects::RAD_SENSOR,
|
||||
objects::SPI_COM_IF, spiCookieRadSensor);
|
||||
(void) radSensor;
|
||||
|
||||
GpioCookie* gpioCookieSus = new GpioCookie();
|
||||
|
||||
@ -251,33 +247,45 @@ void ObjectFactory::produce(){
|
||||
std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
|
||||
SusHandler* sus1 = new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus1);
|
||||
SusHandler* sus1 = new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus1, gpioComIF,
|
||||
gpioIds::CS_SUS_1);
|
||||
// sus1->setStartUpImmediately();
|
||||
(void) sus1;
|
||||
|
||||
SusHandler* sus2 = new SusHandler(objects::SUS_2, objects::SPI_COM_IF, spiCookieSus2);
|
||||
// sus2->setStartUpImmediately();
|
||||
SusHandler* sus2 = new SusHandler(objects::SUS_2, objects::SPI_COM_IF, spiCookieSus2, gpioComIF,
|
||||
gpioIds::CS_SUS_2);
|
||||
sus2->setStartUpImmediately();
|
||||
(void) sus2;
|
||||
|
||||
SusHandler* sus3 = new SusHandler(objects::SUS_3, objects::SPI_COM_IF, spiCookieSus3);
|
||||
SusHandler* sus3 = new SusHandler(objects::SUS_3, objects::SPI_COM_IF, spiCookieSus3, gpioComIF,
|
||||
gpioIds::CS_SUS_3);
|
||||
sus3->setStartUpImmediately();
|
||||
(void) sus3;
|
||||
|
||||
new SusHandler(objects::SUS_4, objects::SPI_COM_IF, spiCookieSus4);
|
||||
new SusHandler(objects::SUS_5, objects::SPI_COM_IF, spiCookieSus5);
|
||||
new SusHandler(objects::SUS_6, objects::SPI_COM_IF, spiCookieSus6);
|
||||
new SusHandler(objects::SUS_7, objects::SPI_COM_IF, spiCookieSus7);
|
||||
SusHandler* sus8 = new SusHandler(objects::SUS_8, objects::SPI_COM_IF, spiCookieSus8);
|
||||
// sus8->setStartUpImmediately();
|
||||
(void) sus8;
|
||||
new SusHandler(objects::SUS_4, objects::SPI_COM_IF, spiCookieSus4, gpioComIF,
|
||||
gpioIds::CS_SUS_4);
|
||||
new SusHandler(objects::SUS_5, objects::SPI_COM_IF, spiCookieSus5, gpioComIF,
|
||||
gpioIds::CS_SUS_5);
|
||||
new SusHandler(objects::SUS_6, objects::SPI_COM_IF, spiCookieSus6, gpioComIF,
|
||||
gpioIds::CS_SUS_6);
|
||||
new SusHandler(objects::SUS_7, objects::SPI_COM_IF, spiCookieSus7, gpioComIF,
|
||||
gpioIds::CS_SUS_7);
|
||||
SusHandler* sus8 = new SusHandler(objects::SUS_8, objects::SPI_COM_IF, spiCookieSus8, gpioComIF,
|
||||
gpioIds::CS_SUS_8);
|
||||
sus8->setStartUpImmediately();
|
||||
|
||||
new SusHandler(objects::SUS_9, objects::SPI_COM_IF, spiCookieSus9);
|
||||
new SusHandler(objects::SUS_10, objects::SPI_COM_IF, spiCookieSus10);
|
||||
SusHandler* sus11 = new SusHandler(objects::SUS_11, objects::SPI_COM_IF, spiCookieRadSensor);
|
||||
new SusHandler(objects::SUS_9, objects::SPI_COM_IF, spiCookieSus9, gpioComIF,
|
||||
gpioIds::CS_SUS_9);
|
||||
new SusHandler(objects::SUS_10, objects::SPI_COM_IF, spiCookieSus10, gpioComIF,
|
||||
gpioIds::CS_SUS_10);
|
||||
SusHandler* sus11 = new SusHandler(objects::SUS_11, objects::SPI_COM_IF, spiCookieSus11,
|
||||
gpioComIF, gpioIds::CS_SUS_11);
|
||||
sus11->setStartUpImmediately();
|
||||
|
||||
new SusHandler(objects::SUS_12, objects::SPI_COM_IF, spiCookieSus12);
|
||||
new SusHandler(objects::SUS_13, objects::SPI_COM_IF, spiCookieSus13);
|
||||
new SusHandler(objects::SUS_12, objects::SPI_COM_IF, spiCookieSus12, gpioComIF,
|
||||
gpioIds::CS_SUS_12);
|
||||
new SusHandler(objects::SUS_13, objects::SPI_COM_IF, spiCookieSus13, gpioComIF,
|
||||
gpioIds::CS_SUS_13);
|
||||
|
||||
#if OBSW_ADD_ACS_BOARD == 1
|
||||
GpioCookie* gpioCookieAcsBoard = new GpioCookie();
|
||||
@ -592,7 +600,8 @@ void ObjectFactory::produce(){
|
||||
std::string("/dev/spidev1.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
|
||||
SusHandler* sus1 = new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus);
|
||||
SusHandler* sus1 = new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus, gpioComIF,
|
||||
gpioIds::CS_SUS_1);
|
||||
sus1->setStartUpImmediately();
|
||||
#endif
|
||||
|
||||
|
@ -58,19 +58,18 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value
|
||||
void* args) {
|
||||
|
||||
if (gpioComInterface == nullptr) {
|
||||
sif::debug << "tcsBoardDecoderCallback: No gpioComIF specified. Call initTcsBoardDecoder "
|
||||
sif::debug << "spiCsDecoderCallback: No gpioComIF specified. Call initSpiCsDecoder "
|
||||
<< "to specify gpioComIF" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Read is not supported by the callback function */
|
||||
/* Reading is not supported by the callback function */
|
||||
if (gpioOp == gpio::GpioOperation::READ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == 1) {
|
||||
/* This will pull all 16 decoder outputs to high */
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
disableAllDecoder();
|
||||
}
|
||||
else if (value == 0) {
|
||||
switch (gpioId) {
|
||||
@ -155,70 +154,70 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_1): {
|
||||
enableDecoderInterfaceBoardIc21();
|
||||
enableDecoderInterfaceBoardIc1();
|
||||
selectY0();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_2): {
|
||||
enableDecoderInterfaceBoardIc21();
|
||||
enableDecoderInterfaceBoardIc1();
|
||||
selectY1();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_3): {
|
||||
enableDecoderInterfaceBoardIc21();
|
||||
selectY2();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_4): {
|
||||
enableDecoderInterfaceBoardIc21();
|
||||
selectY3();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_5): {
|
||||
enableDecoderInterfaceBoardIc21();
|
||||
selectY4();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_6): {
|
||||
enableDecoderInterfaceBoardIc21();
|
||||
selectY5();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_7): {
|
||||
enableDecoderInterfaceBoardIc21();
|
||||
selectY6();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_8): {
|
||||
enableDecoderInterfaceBoardIc22();
|
||||
enableDecoderInterfaceBoardIc2();
|
||||
selectY0();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_9): {
|
||||
enableDecoderInterfaceBoardIc22();
|
||||
case(gpioIds::CS_SUS_4): {
|
||||
enableDecoderInterfaceBoardIc2();
|
||||
selectY1();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_10): {
|
||||
enableDecoderInterfaceBoardIc22();
|
||||
case(gpioIds::CS_SUS_5): {
|
||||
enableDecoderInterfaceBoardIc2();
|
||||
selectY2();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_11): {
|
||||
enableDecoderInterfaceBoardIc22();
|
||||
case(gpioIds::CS_SUS_6): {
|
||||
enableDecoderInterfaceBoardIc1();
|
||||
selectY2();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_7): {
|
||||
enableDecoderInterfaceBoardIc1();
|
||||
selectY3();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_12): {
|
||||
enableDecoderInterfaceBoardIc22();
|
||||
case(gpioIds::CS_SUS_8): {
|
||||
enableDecoderInterfaceBoardIc2();
|
||||
selectY3();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_9): {
|
||||
enableDecoderInterfaceBoardIc1();
|
||||
selectY4();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_13): {
|
||||
enableDecoderInterfaceBoardIc22();
|
||||
case(gpioIds::CS_SUS_10): {
|
||||
enableDecoderInterfaceBoardIc1();
|
||||
selectY5();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_11): {
|
||||
enableDecoderInterfaceBoardIc2();
|
||||
selectY4();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_12): {
|
||||
enableDecoderInterfaceBoardIc2();
|
||||
selectY5();
|
||||
break;
|
||||
}
|
||||
case(gpioIds::CS_SUS_13): {
|
||||
enableDecoderInterfaceBoardIc1();
|
||||
selectY6();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl;
|
||||
}
|
||||
@ -240,13 +239,13 @@ void enableDecoderTcsIc2() {
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
||||
}
|
||||
|
||||
void enableDecoderInterfaceBoardIc21() {
|
||||
void enableDecoderInterfaceBoardIc1() {
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
}
|
||||
|
||||
void enableDecoderInterfaceBoardIc22() {
|
||||
void enableDecoderInterfaceBoardIc2() {
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
||||
@ -300,4 +299,10 @@ void selectY7() {
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
|
||||
}
|
||||
|
||||
void disableAllDecoder() {
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,13 +35,18 @@ namespace gpioCallbacks {
|
||||
* @brief This function sets mux bits 1-3 to a state which will only enable the decoder
|
||||
* on the inteface board board which is named to IC21 in the schematic.
|
||||
*/
|
||||
void enableDecoderInterfaceBoardIc21();
|
||||
void enableDecoderInterfaceBoardIc1();
|
||||
|
||||
/**
|
||||
* @brief This function sets mux bits 1-3 to a state which will only enable the decoder
|
||||
* on the inteface board board which is named to IC22 in the schematic.
|
||||
*/
|
||||
void enableDecoderInterfaceBoardIc22();
|
||||
void enableDecoderInterfaceBoardIc2();
|
||||
|
||||
/**
|
||||
* @brief This function disables all decoder.
|
||||
*/
|
||||
void disableAllDecoder();
|
||||
|
||||
/** The following functions enable the appropriate channel of the currently enabled decoder */
|
||||
void selectY0();
|
||||
|
@ -24,7 +24,7 @@ debugging. */
|
||||
#define TEST_SUS_HANDLER 1
|
||||
#define TEST_PLOC_HANDLER 0
|
||||
|
||||
#define TE0720 1
|
||||
#define TE0720 0
|
||||
#define TE0720_HEATER_TEST 0
|
||||
|
||||
#define P60DOCK_DEBUG 0
|
||||
|
@ -21,8 +21,8 @@ static constexpr uint32_t DEFAULT_L3G_SPEED = 3'900'000;
|
||||
static constexpr spi::SpiModes DEFAULT_L3G_MODE = spi::SpiModes::MODE_3;
|
||||
|
||||
//static constexpr uint32_t DEFAULT_MAX_1227_SPEED = 3'900'000;
|
||||
static constexpr uint32_t DEFAULT_MAX_1227_SPEED = 2'900'000;
|
||||
static constexpr spi::SpiModes DEFAULT_MAX_1227_MODE = spi::SpiModes::MODE_3;
|
||||
static constexpr uint32_t DEFAULT_MAX_1227_SPEED = 1'000'000;
|
||||
static constexpr spi::SpiModes DEFAULT_MAX_1227_MODE = spi::SpiModes::MODE_0;
|
||||
|
||||
}
|
||||
|
||||
|
@ -151,17 +151,17 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence)
|
||||
// thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ);
|
||||
|
||||
/* Sun sensor 1 */
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.2, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.4, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.6, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.8, DeviceHandlerIF::GET_READ);
|
||||
// thisSequence->addSlot(objects::SUS_1, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
// thisSequence->addSlot(objects::SUS_1, length * 0.2, DeviceHandlerIF::SEND_WRITE);
|
||||
// thisSequence->addSlot(objects::SUS_1, length * 0.4, DeviceHandlerIF::GET_WRITE);
|
||||
// thisSequence->addSlot(objects::SUS_1, length * 0.6, DeviceHandlerIF::SEND_READ);
|
||||
// thisSequence->addSlot(objects::SUS_1, length * 0.8, DeviceHandlerIF::GET_READ);
|
||||
|
||||
// thisSequence->addSlot(objects::SUS_2, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
// thisSequence->addSlot(objects::SUS_2, length * 0.2, DeviceHandlerIF::SEND_WRITE);
|
||||
// thisSequence->addSlot(objects::SUS_2, length * 0.4, DeviceHandlerIF::GET_WRITE);
|
||||
// thisSequence->addSlot(objects::SUS_2, length * 0.6, DeviceHandlerIF::SEND_READ);
|
||||
// thisSequence->addSlot(objects::SUS_2, length * 0.8, DeviceHandlerIF::GET_READ);
|
||||
thisSequence->addSlot(objects::SUS_8, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::SUS_8, length * 0.2, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_8, length * 0.4, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_8, length * 0.6, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::SUS_8, length * 0.8, DeviceHandlerIF::GET_READ);
|
||||
|
||||
// thisSequence->addSlot(objects::SUS_11, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
// thisSequence->addSlot(objects::SUS_11, length * 0.2, DeviceHandlerIF::SEND_WRITE);
|
||||
|
@ -1,15 +1,14 @@
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include <mission/devices/SusHandler.h>
|
||||
#include <OBSWConfig.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
SusHandler::SusHandler(object_id_t objectId, object_id_t comIF,
|
||||
CookieIF * comCookie) :
|
||||
DeviceHandlerBase(objectId, comIF, comCookie), dataset(
|
||||
this) {
|
||||
if (comCookie == NULL) {
|
||||
sif::error << "SusHandler: Invalid com cookie" << std::endl;
|
||||
}
|
||||
SusHandler::SusHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie,
|
||||
LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId) :
|
||||
DeviceHandlerBase(objectId, comIF, comCookie), gpioComIF(gpioComIF), chipSelectId(
|
||||
chipSelectId), dataset(this) {
|
||||
if (comCookie == NULL) {
|
||||
sif::error << "SusHandler: Invalid com cookie" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
SusHandler::~SusHandler() {
|
||||
@ -34,8 +33,8 @@ ReturnValue_t SusHandler::buildNormalDeviceCommand(
|
||||
DeviceCommandId_t * id) {
|
||||
if (communicationStep == CommunicationStep::PERFORM_CONVERSIONS) {
|
||||
*id = SUS::PERFORM_CONVERSIONS;
|
||||
// communicationStep = CommunicationStep::READ_TEMP;
|
||||
communicationStep = CommunicationStep::PERFORM_CONVERSIONS;
|
||||
communicationStep = CommunicationStep::READ_TEMP;
|
||||
// communicationStep = CommunicationStep::PERFORM_CONVERSIONS;
|
||||
}
|
||||
else if (communicationStep == CommunicationStep::READ_TEMP) {
|
||||
*id = SUS::READ_TEMP;
|
||||
@ -61,23 +60,23 @@ ReturnValue_t SusHandler::buildCommandFromCommand(
|
||||
switch(deviceCommand) {
|
||||
case(SUS::WRITE_SETUP): {
|
||||
cmdBuffer[0] = SUS::SETUP_DEFINITION;
|
||||
cmdBuffer[1] = SUS::UNIPOLAR_CONFIG;
|
||||
rawPacket = cmdBuffer;
|
||||
rawPacketLen = 2;
|
||||
rawPacketLen = 0;
|
||||
internalState = InternalState::CONFIGURED;
|
||||
return RETURN_OK;
|
||||
}
|
||||
case(SUS::PERFORM_CONVERSIONS): {
|
||||
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
|
||||
* measurement the setup has to be rewritten
|
||||
*/
|
||||
cmdBuffer[0] = SUS::SETUP_DEFINITION;
|
||||
cmdBuffer[1] = SUS::UNIPOLAR_CONFIG;
|
||||
cmdBuffer[0] = SUS::RESET_FIFO;
|
||||
cmdBuffer[1] = SUS::SETUP_DEFINITION;
|
||||
// wirte one dummy byte here
|
||||
// cmdBuffer[2] = SUS::CONVERT_TEMPERATURE;
|
||||
cmdBuffer[2] = SUS::CONVERT_TEMPERATURE;
|
||||
cmdBuffer[2] = SUS::CONVERT_DIFF_CHANNEL_0_1;
|
||||
// struct timeval startOfDelay;
|
||||
// gettimeofday(&startOfDelay, NULL);
|
||||
// struct timeval currentTime;
|
||||
@ -98,13 +97,16 @@ ReturnValue_t SusHandler::buildCommandFromCommand(
|
||||
// cmdBuffer[30] = SUS::CONVERT_DIFF_CHANNEL_4_5;
|
||||
rawPacket = cmdBuffer;
|
||||
// rawPacketLen = SUS::SIZE_PERFORM_CONVERSIONS;
|
||||
rawPacketLen = 7;
|
||||
rawPacketLen = 5;
|
||||
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 = 26;
|
||||
rawPacketLen = 27;
|
||||
return RETURN_OK;
|
||||
}
|
||||
default:
|
||||
@ -115,7 +117,9 @@ ReturnValue_t SusHandler::buildCommandFromCommand(
|
||||
|
||||
void SusHandler::fillCommandAndReplyMap() {
|
||||
this->insertInCommandMap(SUS::WRITE_SETUP);
|
||||
this->insertInCommandAndReplyMap(SUS::READ_TEMP, 1, &dataset, SUS::SIZE_PERFORM_CONVERSIONS);
|
||||
// this->insertInCommandAndReplyMap(SUS::READ_TEMP, 1, &dataset, SUS::SIZE_PERFORM_CONVERSIONS);
|
||||
this->insertInCommandAndReplyMap(SUS::PERFORM_CONVERSIONS, 1, &dataset, SUS::SIZE_PERFORM_CONVERSIONS);
|
||||
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);
|
||||
@ -149,6 +153,10 @@ ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case SUS::READ_TEMP: {
|
||||
gpioComIF->pullHigh(chipSelectId);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
sif::debug << "SusHandler::interpretDeviceReply: Unknown reply id" << std::endl;
|
||||
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||
#include <mission/devices/devicedefinitions/SusDefinitions.h>
|
||||
#include <fsfw_hal/linux/gpio/LinuxLibgpioIF.h>
|
||||
|
||||
/**
|
||||
* @brief This is the device handler class for the SUS sensor. The sensor is
|
||||
@ -17,7 +18,7 @@ class SusHandler: public DeviceHandlerBase {
|
||||
public:
|
||||
|
||||
SusHandler(object_id_t objectId, object_id_t comIF,
|
||||
CookieIF * comCookie);
|
||||
CookieIF * comCookie, LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId);
|
||||
virtual ~SusHandler();
|
||||
|
||||
protected:
|
||||
@ -49,6 +50,10 @@ private:
|
||||
CONFIGURED
|
||||
};
|
||||
|
||||
LinuxLibgpioIF* gpioComIF = nullptr;
|
||||
|
||||
gpioId_t chipSelectId = gpio::NO_GPIO;
|
||||
|
||||
SUS::SusDataset dataset;
|
||||
|
||||
uint8_t cmdBuffer[SUS::MAX_CMD_SIZE];
|
||||
|
@ -17,25 +17,13 @@ namespace SUS {
|
||||
* @brief This is the configuration byte which will be written to the setup register after
|
||||
* power on.
|
||||
*
|
||||
* @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b10, following byte will be written to the
|
||||
* unipolar register to perform differential conversion
|
||||
* Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, internal reference differential (AIN6 is REF-)
|
||||
* @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, No byte is following the setup byte
|
||||
* Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b00, internal reference, needs wake-up delay
|
||||
* Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b11, MAX1227 clocked through SPI SCLK
|
||||
* Bit7 - Bit6: 0b01, tells MAX1227 that this is the setup register
|
||||
*
|
||||
*/
|
||||
// static const uint8_t SETUP_DEFINITION = 0b0111110;
|
||||
|
||||
// Internal reference 0b10
|
||||
static const uint8_t SETUP_DEFINITION = 0b0111010;
|
||||
|
||||
/**
|
||||
* @brief This byte will be written to the unipolar register
|
||||
*
|
||||
* @details Setting bits 7 - 5 to will configure channels 0/1, 2/3 and 4/5 as differential
|
||||
* pairs.
|
||||
*/
|
||||
static const uint8_t UNIPOLAR_CONFIG = 0b11100000;
|
||||
static const uint8_t SETUP_DEFINITION = 0b01110000;
|
||||
|
||||
/**
|
||||
* @brief This value will always be written to the ADC conversion register to specify the
|
||||
@ -46,12 +34,13 @@ namespace SUS {
|
||||
* Bit6 - Bit3 defines N: 0b0001 (N = 4)
|
||||
* Bit7: Always 1. Tells the ADC that this is the conversion register.
|
||||
*/
|
||||
// static const uint8_t CONVERT_TEMPERATURE = 0b10000111;
|
||||
static const uint8_t CONVERT_TEMPERATURE = 0b10000110;
|
||||
static const uint8_t CONVERT_TEMPERATURE = 0b10000001;
|
||||
static const uint8_t CONVERT_DIFF_CHANNEL_0_1 = 0b10000110;
|
||||
static const uint8_t CONVERT_DIFF_CHANNEL_2_3 = 0b10010110;
|
||||
static const uint8_t CONVERT_DIFF_CHANNEL_4_5 = 0b10100110;
|
||||
|
||||
static const uint8_t RESET_FIFO = 0b00011000;
|
||||
|
||||
static const uint8_t DUMMY_BYTE = 0x0;
|
||||
|
||||
static const uint8_t SUS_DATA_SET_ID = PERFORM_CONVERSIONS;
|
||||
@ -60,6 +49,7 @@ namespace SUS {
|
||||
|
||||
static const uint8_t MAX_CMD_SIZE = SIZE_PERFORM_CONVERSIONS;
|
||||
|
||||
|
||||
enum Max1227PoolIds: lp_id_t {
|
||||
TEMPERATURE_C,
|
||||
DIFF_SCAN_CHANNEL_0_1,
|
||||
|
Loading…
Reference in New Issue
Block a user