spi decoder callbacks wip
This commit is contained in:
parent
fef6cf4abe
commit
b708028c61
@ -266,7 +266,7 @@ To transfer files from the local machine to the Q7S, use port forwarding
|
|||||||
ssh -L 1535:192.168.133.10:22 eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5
|
ssh -L 1535:192.168.133.10:22 eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5
|
||||||
```
|
```
|
||||||
|
|
||||||
Then you can copy an `example` file like this
|
An `example` file can be copied like this
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
scp -P 1535 example root@localhost:/tmp
|
scp -P 1535 example root@localhost:/tmp
|
||||||
|
@ -20,16 +20,18 @@
|
|||||||
#include <mission/devices/Tmp1075Handler.h>
|
#include <mission/devices/Tmp1075Handler.h>
|
||||||
#include <mission/devices/Max31865PT1000Handler.h>
|
#include <mission/devices/Max31865PT1000Handler.h>
|
||||||
#include <mission/devices/IMTQHandler.h>
|
#include <mission/devices/IMTQHandler.h>
|
||||||
#include <mission/devices/devicedefinitions/Max31865Definitions.h>
|
|
||||||
#include <mission/devices/SyrlinksHkHandler.h>
|
#include <mission/devices/SyrlinksHkHandler.h>
|
||||||
#include <mission/devices/MGMHandlerLIS3MDL.h>
|
#include <mission/devices/MGMHandlerLIS3MDL.h>
|
||||||
#include <mission/devices/MGMHandlerRM3100.h>
|
#include <mission/devices/MGMHandlerRM3100.h>
|
||||||
#include <mission/devices/GyroL3GD20Handler.h>
|
#include <mission/devices/GyroL3GD20Handler.h>
|
||||||
#include <mission/devices/PlocHandler.h>
|
#include <mission/devices/PlocHandler.h>
|
||||||
|
#include <mission/devices/RadiationSensorHandler.h>
|
||||||
|
|
||||||
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
|
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
|
||||||
#include <mission/devices/devicedefinitions/SyrlinksDefinitions.h>
|
#include <mission/devices/devicedefinitions/SyrlinksDefinitions.h>
|
||||||
#include <mission/devices/devicedefinitions/PlocDefinitions.h>
|
#include <mission/devices/devicedefinitions/PlocDefinitions.h>
|
||||||
|
#include <mission/devices/devicedefinitions/RadSensorDefinitions.h>
|
||||||
|
#include <mission/devices/devicedefinitions/Max31865Definitions.h>
|
||||||
#include <mission/utility/TmFunnel.h>
|
#include <mission/utility/TmFunnel.h>
|
||||||
|
|
||||||
#include <linux/csp/CspCookie.h>
|
#include <linux/csp/CspCookie.h>
|
||||||
@ -428,12 +430,27 @@ void ObjectFactory::produce(){
|
|||||||
std::string("/dev/i2c-0"));
|
std::string("/dev/i2c-0"));
|
||||||
IMTQHandler* imtqHandler = new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie);
|
IMTQHandler* imtqHandler = new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie);
|
||||||
// imtqHandler->setStartUpImmediately();
|
// imtqHandler->setStartUpImmediately();
|
||||||
|
(void) imtqHandler;
|
||||||
|
|
||||||
UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyUL3"), 115200,
|
UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyUL3"), 115200,
|
||||||
PLOC::MAX_REPLY_SIZE);
|
PLOC::MAX_REPLY_SIZE);
|
||||||
PlocHandler* plocHandler = new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF,
|
PlocHandler* plocHandler = new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF,
|
||||||
plocUartCookie);
|
plocUartCookie);
|
||||||
// plocHandler->setStartUpImmediately();
|
// plocHandler->setStartUpImmediately();
|
||||||
|
(void) plocHandler;
|
||||||
|
|
||||||
|
GpioCookie* gpioCookieRadSensor = new GpioCookie;
|
||||||
|
GpiodRegular* chipSelectRadSensor = new GpiodRegular(std::string("gpiochip5"), 19,
|
||||||
|
std::string("Chip Select Radiation Sensor"), gpio::OUT, 1);
|
||||||
|
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);
|
||||||
|
RadiationSensorHandler* radSensor = new RadiationSensorHandler(objects::RAD_SENSOR,
|
||||||
|
objects::SPI_COM_IF, spiCookieRadSensor);
|
||||||
|
radSensor->setStartUpImmediately();
|
||||||
|
|
||||||
#endif /* TE0720 == 0 */
|
#endif /* TE0720 == 0 */
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
/* Only one of those 2 should be enabled! */
|
/* Only one of those 2 should be enabled! */
|
||||||
/* Add code for ACS board */
|
/* Add code for ACS board */
|
||||||
#define OBSW_ADD_ACS_BOARD 1
|
#define OBSW_ADD_ACS_BOARD 0
|
||||||
#define Q7S_ADD_SPI_TEST 0
|
#define Q7S_ADD_SPI_TEST 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,19 +22,20 @@ void initTcsBoardDecoder(GpioIF* gpioComIF) {
|
|||||||
gpioComInterface = gpioComIF;
|
gpioComInterface = gpioComIF;
|
||||||
|
|
||||||
GpioCookie* spiMuxGpios = new GpioCookie;
|
GpioCookie* spiMuxGpios = new GpioCookie;
|
||||||
/**
|
|
||||||
* Initial values of the spi mux gpios can all be set to an arbitrary value expect for spi mux
|
/** Setting mux bit 1 to low will disable IC21 on the interface board */
|
||||||
* bit 1. Setting spi mux bit 1 to high will pull all decoder outputs to high voltage level.
|
|
||||||
*/
|
|
||||||
GpiodRegular* spiMuxBit1 = new GpiodRegular(std::string("gpiochip7"), 13,
|
GpiodRegular* spiMuxBit1 = new GpiodRegular(std::string("gpiochip7"), 13,
|
||||||
std::string("SPI Mux Bit 1"), gpio::OUT, 1);
|
std::string("SPI Mux Bit 1"), gpio::OUT, 0);
|
||||||
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit1);
|
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit1);
|
||||||
|
/** Setting mux bit 2 to low disables IC1 on the TCS board */
|
||||||
GpiodRegular* spiMuxBit2 = new GpiodRegular(std::string("gpiochip7"), 14,
|
GpiodRegular* spiMuxBit2 = new GpiodRegular(std::string("gpiochip7"), 14,
|
||||||
std::string("SPI Mux Bit 2"), gpio::OUT, 0);
|
std::string("SPI Mux Bit 2"), gpio::OUT, 0);
|
||||||
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit2);
|
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit2);
|
||||||
|
/** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */
|
||||||
GpiodRegular* spiMuxBit3 = new GpiodRegular(std::string("gpiochip7"), 15,
|
GpiodRegular* spiMuxBit3 = new GpiodRegular(std::string("gpiochip7"), 15,
|
||||||
std::string("SPI Mux Bit 3"), gpio::OUT, 0);
|
std::string("SPI Mux Bit 3"), gpio::OUT, 0);
|
||||||
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit3);
|
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit3);
|
||||||
|
/** The following gpios can take arbitrary initial values */
|
||||||
GpiodRegular* spiMuxBit4 = new GpiodRegular(std::string("gpiochip7"), 16,
|
GpiodRegular* spiMuxBit4 = new GpiodRegular(std::string("gpiochip7"), 16,
|
||||||
std::string("SPI Mux Bit 4"), gpio::OUT, 0);
|
std::string("SPI Mux Bit 4"), gpio::OUT, 0);
|
||||||
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_4, spiMuxBit4);
|
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_4, spiMuxBit4);
|
||||||
@ -74,136 +75,93 @@ void tcsBoardDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, int va
|
|||||||
else if (value == 0) {
|
else if (value == 0) {
|
||||||
switch (gpioId) {
|
switch (gpioId) {
|
||||||
case(gpioIds::RTD_IC3): {
|
case(gpioIds::RTD_IC3): {
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
enableDecoderTcsIc1();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
selectY7();
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpioIds::RTD_IC4): {
|
case(gpioIds::RTD_IC4): {
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
enableDecoderTcsIc1();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
selectY6();
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpioIds::RTD_IC5): {
|
case(gpioIds::RTD_IC5): {
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
enableDecoderTcsIc1();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
selectY5();
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpioIds::RTD_IC6): {
|
case(gpioIds::RTD_IC6): {
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
enableDecoderTcsIc1();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
selectY4();
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpioIds::RTD_IC7): {
|
case(gpioIds::RTD_IC7): {
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
enableDecoderTcsIc1();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
selectY3();
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpioIds::RTD_IC8): {
|
case(gpioIds::RTD_IC8): {
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
enableDecoderTcsIc1();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
selectY2();
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpioIds::RTD_IC9): {
|
case(gpioIds::RTD_IC9): {
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
enableDecoderTcsIc1();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
selectY1();
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpioIds::RTD_IC10): {
|
case(gpioIds::RTD_IC10): {
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
enableDecoderTcsIc1();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
selectY0();
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpioIds::RTD_IC11): {
|
case(gpioIds::RTD_IC11): {
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
enableDecoderTcsIc2();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
selectY7();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpioIds::RTD_IC12): {
|
case(gpioIds::RTD_IC12): {
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
enableDecoderTcsIc2();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
selectY6();
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpioIds::RTD_IC13): {
|
case(gpioIds::RTD_IC13): {
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
enableDecoderTcsIc2();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
selectY5();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpioIds::RTD_IC14): {
|
case(gpioIds::RTD_IC14): {
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
enableDecoderTcsIc2();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
selectY4();
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpioIds::RTD_IC15): {
|
case(gpioIds::RTD_IC15): {
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
enableDecoderTcsIc2();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
selectY3();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpioIds::RTD_IC16): {
|
case(gpioIds::RTD_IC16): {
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
enableDecoderTcsIc2();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
selectY2();
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpioIds::RTD_IC17): {
|
case(gpioIds::RTD_IC17): {
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
enableDecoderTcsIc2();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
selectY1();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpioIds::RTD_IC18): {
|
case(gpioIds::RTD_IC18): {
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
enableDecoderTcsIc2();
|
||||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
selectY0();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(gpioIds::CS_SUS_1): {
|
||||||
|
enableDecoderInterfaceBoardIc21();
|
||||||
|
selectY0();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(gpioIds::CS_SUS_2): {
|
||||||
|
enableDecoderInterfaceBoardIc21();
|
||||||
|
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
|
||||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
|
||||||
@ -218,4 +176,70 @@ void tcsBoardDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, int va
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enableDecoderTcsIc1() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void enableDecoderTcsIc2() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void enableDecoderInterfaceBoardIc21() {
|
||||||
|
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||||
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||||
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void enableDecoderInterfaceBoardIc22() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void selectY0() {
|
||||||
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||||
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
|
||||||
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void selectY1() {
|
||||||
|
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
||||||
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
|
||||||
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void selectY2() {
|
||||||
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||||
|
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
||||||
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void selectY3() {
|
||||||
|
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
||||||
|
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
||||||
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void selectY4() {
|
||||||
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||||
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
|
||||||
|
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void selectY5() {
|
||||||
|
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
||||||
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
|
||||||
|
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void selectY6() {
|
||||||
|
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||||
|
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
||||||
|
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void selectY7() {
|
||||||
|
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
||||||
|
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
||||||
|
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,40 @@ namespace gpioCallbacks {
|
|||||||
* chips SN74LVC138APWR on the TCS board.
|
* chips SN74LVC138APWR on the TCS board.
|
||||||
*/
|
*/
|
||||||
void tcsBoardDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args);
|
void tcsBoardDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function sets mux bits 1-3 to a state which will only enable the decoder
|
||||||
|
* on the TCS board which is named to IC1 in the schematic.
|
||||||
|
*/
|
||||||
|
void enableDecoderTcsIc1();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function sets mux bits 1-3 to a state which will only enable the decoder
|
||||||
|
* on the TCS board which is named to IC2 in the schematic.
|
||||||
|
*/
|
||||||
|
void enableDecoderTcsIc2();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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();
|
||||||
|
|
||||||
|
/** The following functions enable the appropriate channel of the currently enabled decoder */
|
||||||
|
void selectY0();
|
||||||
|
void selectY1();
|
||||||
|
void selectY2();
|
||||||
|
void selectY3();
|
||||||
|
void selectY4();
|
||||||
|
void selectY5();
|
||||||
|
void selectY6();
|
||||||
|
void selectY7();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* LINUX_GPIO_GPIOCALLBACKS_H_ */
|
#endif /* LINUX_GPIO_GPIOCALLBACKS_H_ */
|
||||||
|
@ -29,7 +29,8 @@ debugging. */
|
|||||||
#define PDU2_DEBUG 0
|
#define PDU2_DEBUG 0
|
||||||
#define ACU_DEBUG 0
|
#define ACU_DEBUG 0
|
||||||
#define SYRLINKS_DEBUG 0
|
#define SYRLINKS_DEBUG 0
|
||||||
#define IMQT_DEBUG 1
|
#define IMQT_DEBUG 0
|
||||||
|
#define DEBUG_RAD_SENSOR 1
|
||||||
|
|
||||||
#include "OBSWVersion.h"
|
#include "OBSWVersion.h"
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ namespace addresses {
|
|||||||
GYRO_1_L3G = objects::GYRO_1_L3G_HANDLER,
|
GYRO_1_L3G = objects::GYRO_1_L3G_HANDLER,
|
||||||
GYRO_2_L3G = objects::GYRO_2_L3G_HANDLER,
|
GYRO_2_L3G = objects::GYRO_2_L3G_HANDLER,
|
||||||
|
|
||||||
|
RAD_SENSOR = objects::RAD_SENSOR,
|
||||||
|
|
||||||
/* Dummy and Test Addresses */
|
/* Dummy and Test Addresses */
|
||||||
DUMMY_ECHO = 129,
|
DUMMY_ECHO = 129,
|
||||||
DUMMY_GPS0 = 130,
|
DUMMY_GPS0 = 130,
|
||||||
|
@ -49,7 +49,9 @@ namespace gpioIds {
|
|||||||
SPI_MUX_BIT_3,
|
SPI_MUX_BIT_3,
|
||||||
SPI_MUX_BIT_4,
|
SPI_MUX_BIT_4,
|
||||||
SPI_MUX_BIT_5,
|
SPI_MUX_BIT_5,
|
||||||
SPI_MUX_BIT_6
|
SPI_MUX_BIT_6,
|
||||||
|
|
||||||
|
CS_RAD_SENSOR
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,9 @@ static constexpr spi::SpiModes DEFAULT_RM3100_MODE = spi::SpiModes::MODE_3;
|
|||||||
static constexpr uint32_t DEFAULT_L3G_SPEED = 3'900'000;
|
static constexpr uint32_t DEFAULT_L3G_SPEED = 3'900'000;
|
||||||
static constexpr spi::SpiModes DEFAULT_L3G_MODE = spi::SpiModes::MODE_3;
|
static constexpr spi::SpiModes DEFAULT_L3G_MODE = spi::SpiModes::MODE_3;
|
||||||
|
|
||||||
|
static constexpr uint32_t DEFAULT_MAX_1227_SPEED = 3'900'000;
|
||||||
|
static constexpr spi::SpiModes DEFAULT_MAX_1227_MODE = spi::SpiModes::MODE_3;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,6 +82,8 @@ namespace objects {
|
|||||||
RTD_IC17 = 0x5400003F,
|
RTD_IC17 = 0x5400003F,
|
||||||
RTD_IC18 = 0x5400004F,
|
RTD_IC18 = 0x5400004F,
|
||||||
|
|
||||||
|
RAD_SENSOR = 0x54000050,
|
||||||
|
|
||||||
/* 0x54 ('T') for test handlers */
|
/* 0x54 ('T') for test handlers */
|
||||||
TEST_TASK = 0x54694269,
|
TEST_TASK = 0x54694269,
|
||||||
LIBGPIOD_TEST = 0x54123456,
|
LIBGPIOD_TEST = 0x54123456,
|
||||||
|
@ -142,6 +142,14 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence)
|
|||||||
thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ);
|
thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ);
|
||||||
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ);
|
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ);
|
||||||
|
|
||||||
|
|
||||||
|
/* Radiation sensor */
|
||||||
|
thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||||
|
thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE);
|
||||||
|
thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE);
|
||||||
|
thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ);
|
||||||
|
thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ);
|
||||||
|
|
||||||
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
|
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ target_sources(${TARGET_NAME} PUBLIC
|
|||||||
Max31865PT1000Handler.cpp
|
Max31865PT1000Handler.cpp
|
||||||
IMTQHandler.cpp
|
IMTQHandler.cpp
|
||||||
PlocHandler.cpp
|
PlocHandler.cpp
|
||||||
|
RadiationSensorHandler.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,145 +0,0 @@
|
|||||||
#include <mission/devices/Max1227Handler.h>
|
|
||||||
#include <mission/devices/devicedefinitions/Tmp1075Definitions.h>
|
|
||||||
#include <OBSWConfig.h>
|
|
||||||
|
|
||||||
Max1227Handler::Max1227Handler(object_id_t objectId, object_id_t comIF,
|
|
||||||
CookieIF * comCookie) :
|
|
||||||
DeviceHandlerBase(objectId, comIF, comCookie), dataset(
|
|
||||||
this) {
|
|
||||||
if (comCookie == NULL) {
|
|
||||||
sif::error << "Max1227Handler: Invalid com cookie" << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Max1227Handler::~Max1227Handler() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Max1227Handler::doStartUp(){
|
|
||||||
if(mode == _MODE_START_UP){
|
|
||||||
setMode(MODE_ON);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Max1227Handler::doShutDown(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t Max1227Handler::buildNormalDeviceCommand(
|
|
||||||
DeviceCommandId_t * id) {
|
|
||||||
|
|
||||||
if(communicationStep == CommunicationStep::START_ADC_CONVERSION) {
|
|
||||||
*id = TMP1075::START_ADC_CONVERSION;
|
|
||||||
communicationStep = CommunicationStep::GET_TEMPERATURE;
|
|
||||||
return buildCommandFromCommand(*id, NULL, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
*id = TMP1075::GET_TEMP;
|
|
||||||
communicationStep = CommunicationStep::START_ADC_CONVERSION;
|
|
||||||
return buildCommandFromCommand(*id, NULL, 0);
|
|
||||||
}
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t Max1227Handler::buildTransitionDeviceCommand(
|
|
||||||
DeviceCommandId_t * id){
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t Max1227Handler::buildCommandFromCommand(
|
|
||||||
DeviceCommandId_t deviceCommand, const uint8_t * commandData,
|
|
||||||
size_t commandDataLen) {
|
|
||||||
switch(deviceCommand) {
|
|
||||||
case(TMP1075::START_ADC_CONVERSION): {
|
|
||||||
std::memset(cmdBuffer, 0, sizeof(cmdBuffer));
|
|
||||||
prepareAdcConversionCommand();
|
|
||||||
rawPacket = cmdBuffer;
|
|
||||||
rawPacketLen = TMP1075::CFGR_CMD_SIZE;
|
|
||||||
return RETURN_OK;
|
|
||||||
}
|
|
||||||
case(TMP1075::GET_TEMP): {
|
|
||||||
std::memset(cmdBuffer, 0, sizeof(cmdBuffer));
|
|
||||||
prepareGetTempCommand();
|
|
||||||
rawPacket = cmdBuffer;
|
|
||||||
rawPacketLen = TMP1075::POINTER_REG_SIZE;
|
|
||||||
rememberCommandId = TMP1075::GET_TEMP;
|
|
||||||
return RETURN_OK;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Max1227Handler::fillCommandAndReplyMap(){
|
|
||||||
this->insertInCommandMap(TMP1075::START_ADC_CONVERSION);
|
|
||||||
this->insertInCommandAndReplyMap(TMP1075::GET_TEMP, 1, &dataset,
|
|
||||||
TMP1075::GET_TEMP_REPLY_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t Max1227Handler::scanForReply(const uint8_t *start,
|
|
||||||
size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) {
|
|
||||||
switch(rememberCommandId) {
|
|
||||||
case(TMP1075::GET_TEMP):
|
|
||||||
*foundId = TMP1075::GET_TEMP;
|
|
||||||
*foundLen = TMP1075::GET_TEMP_REPLY_SIZE;
|
|
||||||
rememberCommandId = TMP1075::NONE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return IGNORE_REPLY_DATA;
|
|
||||||
}
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t Max1227Handler::interpretDeviceReply(DeviceCommandId_t id,
|
|
||||||
const uint8_t *packet) {
|
|
||||||
switch (id) {
|
|
||||||
case TMP1075::GET_TEMP: {
|
|
||||||
int16_t tempValueRaw = 0;
|
|
||||||
tempValueRaw = packet[0] << 4 | packet[1] >> 4;
|
|
||||||
float tempValue = ((static_cast<float>(tempValueRaw)) * 0.0625);
|
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
|
||||||
sif::info << "Tmp1075 with object id: 0x" << std::hex << getObjectId()
|
|
||||||
<< ": Temperature: " << tempValue<< " °C"
|
|
||||||
<< std::endl;
|
|
||||||
#endif
|
|
||||||
ReturnValue_t result = dataset.read();
|
|
||||||
if(result == HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
dataset.temperatureCelcius = tempValue;
|
|
||||||
dataset.commit();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Max1227Handler::setNormalDatapoolEntriesInvalid(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Max1227Handler::prepareAdcConversionCommand(){
|
|
||||||
cmdBuffer[0] = TMP1075::CFGR_ADDR;
|
|
||||||
cmdBuffer[1] = TMP1075::ONE_SHOT_MODE >> 8;
|
|
||||||
cmdBuffer[2] = TMP1075::ONE_SHOT_MODE & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Max1227Handler::prepareGetTempCommand(){
|
|
||||||
cmdBuffer[0] = TMP1075::TEMP_REG_ADDR;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t Max1227Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){
|
|
||||||
return 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t Max1227Handler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
|
||||||
LocalDataPoolManager& poolManager) {
|
|
||||||
localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075_1, new PoolEntry<float>( { 0.0 }));
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
158
mission/devices/RadiationSensorHandler.cpp
Normal file
158
mission/devices/RadiationSensorHandler.cpp
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
#include <fsfw/datapool/PoolReadGuard.h>
|
||||||
|
#include <mission/devices/RadiationSensorHandler.h>
|
||||||
|
#include <OBSWConfig.h>
|
||||||
|
|
||||||
|
RadiationSensorHandler::RadiationSensorHandler(object_id_t objectId, object_id_t comIF,
|
||||||
|
CookieIF * comCookie) :
|
||||||
|
DeviceHandlerBase(objectId, comIF, comCookie), dataset(
|
||||||
|
this) {
|
||||||
|
if (comCookie == NULL) {
|
||||||
|
sif::error << "RadiationSensorHandler: Invalid com cookie" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RadiationSensorHandler::~RadiationSensorHandler() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RadiationSensorHandler::doStartUp(){
|
||||||
|
if (internalState == InternalState::CONFIGURED) {
|
||||||
|
#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1
|
||||||
|
setMode(MODE_NORMAL);
|
||||||
|
#else
|
||||||
|
setMode(_MODE_TO_ON);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RadiationSensorHandler::doShutDown(){
|
||||||
|
setMode(_MODE_POWER_DOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand(
|
||||||
|
DeviceCommandId_t * id) {
|
||||||
|
|
||||||
|
switch (communicationStep) {
|
||||||
|
case CommunicationStep::START_CONVERSION: {
|
||||||
|
*id = RAD_SENSOR::START_CONVERSION;
|
||||||
|
communicationStep = CommunicationStep::READ_CONVERSIONS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CommunicationStep::READ_CONVERSIONS: {
|
||||||
|
*id = RAD_SENSOR::READ_CONVERSIONS;
|
||||||
|
// communicationStep = CommunicationStep::START_CONVERSION;
|
||||||
|
communicationStep = CommunicationStep::READ_CONVERSIONS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
sif::debug << "RadiationSensorHandler::buildNormalDeviceCommand: Unknwon communication "
|
||||||
|
<< "step" << std::endl;
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buildCommandFromCommand(*id, nullptr, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t RadiationSensorHandler::buildTransitionDeviceCommand(
|
||||||
|
DeviceCommandId_t * id){
|
||||||
|
if (internalState == InternalState::SETUP) {
|
||||||
|
*id = RAD_SENSOR::WRITE_SETUP;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
buildCommandFromCommand(*id, nullptr, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(
|
||||||
|
DeviceCommandId_t deviceCommand, const uint8_t * commandData,
|
||||||
|
size_t commandDataLen) {
|
||||||
|
switch(deviceCommand) {
|
||||||
|
case(RAD_SENSOR::WRITE_SETUP): {
|
||||||
|
cmdBuffer[0] = RAD_SENSOR::SETUP_DEFINITION;
|
||||||
|
rawPacket = cmdBuffer;
|
||||||
|
rawPacketLen = 1;
|
||||||
|
internalState = InternalState::CONFIGURED;
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
case(RAD_SENSOR::START_CONVERSION): {
|
||||||
|
cmdBuffer[0] = RAD_SENSOR::CONVERSION_DEFINITION;
|
||||||
|
rawPacket = cmdBuffer;
|
||||||
|
rawPacketLen = 1;
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
case(RAD_SENSOR::READ_CONVERSIONS): {
|
||||||
|
cmdBuffer[0] = RAD_SENSOR::DUMMY_BYTE;
|
||||||
|
cmdBuffer[1] = RAD_SENSOR::DUMMY_BYTE;
|
||||||
|
cmdBuffer[2] = RAD_SENSOR::DUMMY_BYTE;
|
||||||
|
cmdBuffer[3] = RAD_SENSOR::DUMMY_BYTE;
|
||||||
|
cmdBuffer[4] = RAD_SENSOR::DUMMY_BYTE;
|
||||||
|
cmdBuffer[5] = RAD_SENSOR::DUMMY_BYTE;
|
||||||
|
cmdBuffer[6] = RAD_SENSOR::DUMMY_BYTE;
|
||||||
|
rawPacket = cmdBuffer;
|
||||||
|
rawPacketLen = RAD_SENSOR::READ_SIZE;
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RadiationSensorHandler::fillCommandAndReplyMap() {
|
||||||
|
this->insertInCommandMap(RAD_SENSOR::WRITE_SETUP);
|
||||||
|
this->insertInCommandMap(RAD_SENSOR::START_CONVERSION);
|
||||||
|
this->insertInCommandAndReplyMap(RAD_SENSOR::READ_CONVERSIONS, 1, &dataset,
|
||||||
|
RAD_SENSOR::READ_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start,
|
||||||
|
size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) {
|
||||||
|
*foundId = this->getPendingCommand();
|
||||||
|
*foundLen = remainingSize;
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||||
|
const uint8_t *packet) {
|
||||||
|
switch (id) {
|
||||||
|
case RAD_SENSOR::READ_CONVERSIONS: {
|
||||||
|
PoolReadGuard readSet(&dataset);
|
||||||
|
dataset.temperatureCelcius = (*(packet) << 8 | *(packet + 1)) * 0.125;
|
||||||
|
dataset.channel0 = (*(packet + 2) << 8 | *(packet + 3));
|
||||||
|
dataset.channel1 = (*(packet + 4) << 8 | *(packet + 5));
|
||||||
|
#if OBSW_VERBOSE_LEVEL >= 1 && DEBUG_RAD_SENSOR
|
||||||
|
sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C"
|
||||||
|
<< std::endl;
|
||||||
|
sif::info << "Radiation sensor temperature ADC value channel 0: " << dataset.channel0
|
||||||
|
<< std::endl;
|
||||||
|
sif::info << "Radiation sensor temperature ADC value channel 1: " << dataset.channel1
|
||||||
|
<< std::endl;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
sif::debug << "RadiationSensorHandler::interpretDeviceReply: Unknown reply id" << std::endl;
|
||||||
|
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RadiationSensorHandler::setNormalDatapoolEntriesInvalid(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t RadiationSensorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){
|
||||||
|
return 5000;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||||
|
LocalDataPoolManager& poolManager) {
|
||||||
|
localDataPoolMap.emplace(RAD_SENSOR::TEMPERATURE_C, new PoolEntry<float>( { 0.0 }));
|
||||||
|
localDataPoolMap.emplace(RAD_SENSOR::CHANNEL_0, new PoolEntry<uint16_t>( { 0 }));
|
||||||
|
localDataPoolMap.emplace(RAD_SENSOR::CHANNEL_1, new PoolEntry<uint16_t>( { 0 }));
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
@ -1,22 +1,23 @@
|
|||||||
#ifndef MISSION_DEVICES_MAX1227HANDLER_H_
|
#ifndef MISSION_DEVICES_RADIATIONSENSORHANDLER_H_
|
||||||
#define MISSION_DEVICES_MAX1227HANDLER_H_
|
#define MISSION_DEVICES_RADIATIONSENSORHANDLER_H_
|
||||||
|
|
||||||
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||||
#include <mission/devices/devicedefinitions/Tmp1075Definitions.h>
|
#include <mission/devices/devicedefinitions/RadSensorDefinitions.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This is the device handler class for the MAX1227 ADC converter.
|
* @brief This is the device handler class for radiation sensor on the OBC IF Board. The sensor
|
||||||
|
* is based on the MAX1227 ADC converter.
|
||||||
*
|
*
|
||||||
* @details Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX1227-MAX1231.pdf
|
* @details Datasheet of MAX1227: https://datasheets.maximintegrated.com/en/ds/MAX1227-MAX1231.pdf
|
||||||
*
|
*
|
||||||
* @author J. Meier
|
* @author J. Meier
|
||||||
*/
|
*/
|
||||||
class Max1227Handler: public DeviceHandlerBase {
|
class RadiationSensorHandler: public DeviceHandlerBase {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Max1227Handler(object_id_t objectId, object_id_t comIF,
|
RadiationSensorHandler(object_id_t objectId, object_id_t comIF,
|
||||||
CookieIF * comCookie);
|
CookieIF * comCookie);
|
||||||
virtual ~Max1227Handler();
|
virtual ~RadiationSensorHandler();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void doStartUp() override;
|
void doStartUp() override;
|
||||||
@ -37,28 +38,23 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Function fills cmdBuffer with command to start the adc
|
|
||||||
* conversion for a new temperature value.
|
|
||||||
*/
|
|
||||||
void prepareAdcConversionCommand();
|
|
||||||
|
|
||||||
void prepareGetTempCommand();
|
|
||||||
|
|
||||||
enum class CommunicationStep {
|
enum class CommunicationStep {
|
||||||
START_ADC_CONVERSION,
|
START_CONVERSION,
|
||||||
GET_TEMPERATURE
|
READ_CONVERSIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
TMP1075::Tmp1075Dataset dataset;
|
enum class InternalState {
|
||||||
|
SETUP,
|
||||||
|
CONFIGURED
|
||||||
|
};
|
||||||
|
|
||||||
static const uint8_t MAX_CMD_LEN = 3;
|
RAD_SENSOR::RadSensorDataset dataset;
|
||||||
|
|
||||||
|
static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE;
|
||||||
|
|
||||||
uint8_t rememberRequestedSize = 0;
|
|
||||||
uint8_t rememberCommandId = TMP1075::NONE;
|
|
||||||
uint8_t cmdBuffer[MAX_CMD_LEN];
|
uint8_t cmdBuffer[MAX_CMD_LEN];
|
||||||
CommunicationStep communicationStep =
|
InternalState internalState = InternalState::SETUP;
|
||||||
CommunicationStep::START_ADC_CONVERSION;
|
CommunicationStep communicationStep = CommunicationStep::START_CONVERSION;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MISSION_DEVICES_MAX1227HANDLER_H_ */
|
#endif /* MISSION_DEVICES_RADIATIONSENSORHANDLER_H_ */
|
@ -1,47 +0,0 @@
|
|||||||
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_MAX1227_H_
|
|
||||||
#define MISSION_DEVICES_DEVICEDEFINITIONS_MAX1227_H_
|
|
||||||
|
|
||||||
namespace MAX1227 {
|
|
||||||
static const uint8_t TEMP_REG_ADDR = 0x0;
|
|
||||||
static const uint8_t CFGR_ADDR = 0x1;
|
|
||||||
|
|
||||||
/* Writing this information to the configuration register sets the tmp1075
|
|
||||||
* to shutdown mode and starts a single temperature conversion */
|
|
||||||
static const uint16_t ONE_SHOT_MODE = 0x8100;
|
|
||||||
|
|
||||||
static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending
|
|
||||||
static const DeviceCommandId_t GET_TEMP = 0x1;
|
|
||||||
static const DeviceCommandId_t START_ADC_CONVERSION = 0x2;
|
|
||||||
|
|
||||||
static const uint8_t GET_TEMP_REPLY_SIZE = 2;
|
|
||||||
static const uint8_t CFGR_CMD_SIZE = 3;
|
|
||||||
static const uint8_t POINTER_REG_SIZE = 1;
|
|
||||||
|
|
||||||
static const uint32_t TMP1075_DATA_SET_ID = GET_TEMP;
|
|
||||||
|
|
||||||
static const uint8_t MAX_REPLY_LENGTH = GET_TEMP_REPLY_SIZE;
|
|
||||||
|
|
||||||
enum Tmp1075PoolIds: lp_id_t {
|
|
||||||
TEMPERATURE_C_TMP1075_1,
|
|
||||||
TEMPERATURE_C_TMP1075_2
|
|
||||||
};
|
|
||||||
|
|
||||||
class Tmp1075Dataset:
|
|
||||||
public StaticLocalDataSet<sizeof(float)> {
|
|
||||||
public:
|
|
||||||
|
|
||||||
Tmp1075Dataset(HasLocalDataPoolIF* owner):
|
|
||||||
StaticLocalDataSet(owner, TMP1075_DATA_SET_ID) {
|
|
||||||
}
|
|
||||||
|
|
||||||
Tmp1075Dataset(object_id_t objectId):
|
|
||||||
StaticLocalDataSet(sid_t(objectId, TMP1075_DATA_SET_ID)) {
|
|
||||||
}
|
|
||||||
|
|
||||||
lp_var_t<float> temperatureCelcius = lp_var_t<float>(sid.objectId,
|
|
||||||
TEMPERATURE_C_TMP1075_1, this);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_MAX1227_H_ */
|
|
79
mission/devices/devicedefinitions/RadSensorDefinitions.h
Normal file
79
mission/devices/devicedefinitions/RadSensorDefinitions.h
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_RADSENSOR_H_
|
||||||
|
#define MISSION_DEVICES_DEVICEDEFINITIONS_RADSENSOR_H_
|
||||||
|
|
||||||
|
namespace RAD_SENSOR {
|
||||||
|
|
||||||
|
static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This command initiates the ADC conversion for all channels including the internal
|
||||||
|
* temperature sensor.
|
||||||
|
*/
|
||||||
|
static const DeviceCommandId_t WRITE_SETUP = 0x1;
|
||||||
|
static const DeviceCommandId_t START_CONVERSION = 0x2;
|
||||||
|
static const DeviceCommandId_t READ_CONVERSIONS = 0x3;
|
||||||
|
|
||||||
|
static const uint32_t MAX1227_DATA_SET_ID = READ_CONVERSIONS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This is the configuration byte which will be written to the setup register after
|
||||||
|
* power on.
|
||||||
|
*
|
||||||
|
* @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, no data follows the setup byte
|
||||||
|
* Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b01, external reference single ended
|
||||||
|
* Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, MAX1227 uses internal oscillator for timing
|
||||||
|
* Bit7 - Bit6: 0b01, tells MAX1227 that this is the setup register
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static const uint8_t SETUP_DEFINITION = 0b01101000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This value will always be written to the ADC conversion register to specify the
|
||||||
|
* conversions to perform.
|
||||||
|
* @details Bit0: 1 - Enables temperature conversion
|
||||||
|
* Bit2 (SCAN1) and Bit1 (SCAN0): 0b00 (channel conversion from 0 to N)
|
||||||
|
* Bit6 - Bit3 defines N: 0b0001 (N = 1)
|
||||||
|
* Bit7: Always 1. Tells the ADC that this is the conversion register.
|
||||||
|
*/
|
||||||
|
static const uint8_t CONVERSION_DEFINITION = 0b10001001;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unipolar only required for differential measurement. Unipolar or dipolar determines the
|
||||||
|
* voltage range.
|
||||||
|
*/
|
||||||
|
static const uint8_t UNIPOLAR_SETUP = 0b10000000;
|
||||||
|
|
||||||
|
static const uint8_t DUMMY_BYTE = 0xFF;
|
||||||
|
|
||||||
|
static const uint8_t RAD_SENSOR_DATA_SET_ID = READ_CONVERSIONS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One temperature value, conversion of channel 0 and conversion of channel 1
|
||||||
|
*/
|
||||||
|
static const uint8_t READ_SIZE = 6;
|
||||||
|
|
||||||
|
enum Max1227PoolIds: lp_id_t {
|
||||||
|
TEMPERATURE_C,
|
||||||
|
CHANNEL_0,
|
||||||
|
CHANNEL_1,
|
||||||
|
};
|
||||||
|
|
||||||
|
class RadSensorDataset: public StaticLocalDataSet<sizeof(float)> {
|
||||||
|
public:
|
||||||
|
|
||||||
|
RadSensorDataset(HasLocalDataPoolIF* owner) :
|
||||||
|
StaticLocalDataSet(owner, RAD_SENSOR_DATA_SET_ID) {
|
||||||
|
}
|
||||||
|
|
||||||
|
RadSensorDataset(object_id_t objectId) :
|
||||||
|
StaticLocalDataSet(sid_t(objectId, RAD_SENSOR_DATA_SET_ID)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
lp_var_t<float> temperatureCelcius = lp_var_t<float>(sid.objectId, TEMPERATURE_C, this);
|
||||||
|
lp_var_t<uint16_t> channel0 = lp_var_t<uint16_t>(sid.objectId, CHANNEL_0, this);
|
||||||
|
lp_var_t<uint16_t> channel1 = lp_var_t<uint16_t>(sid.objectId, CHANNEL_1, this);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RADSENSOR_H_ */
|
Loading…
Reference in New Issue
Block a user