meier/master #33
@ -150,6 +150,23 @@ void ObjectFactory::produce(){
|
||||
/* Adding gpios for chip select decoding to the gpioComIf */
|
||||
gpioCallbacks::initSpiCsDecoder(gpioComIF);
|
||||
|
||||
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);
|
||||
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,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
// RadiationSensorHandler* radSensor = new RadiationSensorHandler(objects::RAD_SENSOR,
|
||||
// objects::SPI_COM_IF, spiCookieRadSensor);
|
||||
// (void) radSensor;
|
||||
// radSensor->setStartUpImmediately();
|
||||
|
||||
GpioCookie* gpioCookieSus = new GpioCookie();
|
||||
|
||||
GpioCallback* susgpio = new GpioCallback(std::string("Chip select SUS 1"), gpio::OUT, 1,
|
||||
@ -195,47 +212,70 @@ void ObjectFactory::produce(){
|
||||
gpioComIF->addGpios(gpioCookieSus);
|
||||
|
||||
SpiCookie* spiCookieSus1 = new SpiCookie(addresses::SUS_1, gpioIds::CS_SUS_1,
|
||||
std::string("/dev/spidev2.0"), SUS::READ_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus2 = new SpiCookie(addresses::SUS_2, gpioIds::CS_SUS_2,
|
||||
std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus3 = new SpiCookie(addresses::SUS_3, gpioIds::CS_SUS_3,
|
||||
std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus4 = new SpiCookie(addresses::SUS_4, gpioIds::CS_SUS_4,
|
||||
std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus5 = new SpiCookie(addresses::SUS_5, gpioIds::CS_SUS_5,
|
||||
std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus6 = new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6,
|
||||
std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus7 = new SpiCookie(addresses::SUS_7, gpioIds::CS_SUS_7,
|
||||
std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus8 = new SpiCookie(addresses::SUS_8, gpioIds::CS_SUS_8,
|
||||
std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus9 = new SpiCookie(addresses::SUS_9, gpioIds::CS_SUS_9,
|
||||
std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus10 = new SpiCookie(addresses::SUS_10, gpioIds::CS_SUS_10,
|
||||
std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus11 = new SpiCookie(addresses::SUS_11, gpioIds::CS_SUS_11,
|
||||
std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus12 = new SpiCookie(addresses::SUS_12, gpioIds::CS_SUS_12,
|
||||
std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus13 = new SpiCookie(addresses::SUS_13, gpioIds::CS_SUS_13,
|
||||
std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus2 = new SpiCookie(addresses::SUS_2, gpioIds::CS_SUS_2, std::string("/dev/spidev2.0"),
|
||||
SUS::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus3 = new SpiCookie(addresses::SUS_3, gpioIds::CS_SUS_3, std::string("/dev/spidev2.0"),
|
||||
SUS::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus4 = new SpiCookie(addresses::SUS_4, gpioIds::CS_SUS_4, std::string("/dev/spidev2.0"),
|
||||
SUS::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus5 = new SpiCookie(addresses::SUS_5, gpioIds::CS_SUS_5, std::string("/dev/spidev2.0"),
|
||||
SUS::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus6 = new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, std::string("/dev/spidev2.0"),
|
||||
SUS::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus7 = new SpiCookie(addresses::SUS_7, gpioIds::CS_SUS_7, std::string("/dev/spidev2.0"),
|
||||
SUS::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus8 = new SpiCookie(addresses::SUS_8, gpioIds::CS_SUS_8, std::string("/dev/spidev2.0"),
|
||||
SUS::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus9 = new SpiCookie(addresses::SUS_9, gpioIds::CS_SUS_9, std::string("/dev/spidev2.0"),
|
||||
SUS::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus10 = new SpiCookie(addresses::SUS_10, gpioIds::CS_SUS_10, std::string("/dev/spidev2.0"),
|
||||
SUS::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus11 = new SpiCookie(addresses::SUS_11, gpioIds::CS_SUS_11, std::string("/dev/spidev2.0"),
|
||||
SUS::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus12 = new SpiCookie(addresses::SUS_12, gpioIds::CS_SUS_12, std::string("/dev/spidev2.0"),
|
||||
SUS::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus13 = new SpiCookie(addresses::SUS_13, gpioIds::CS_SUS_13, std::string("/dev/spidev2.0"),
|
||||
SUS::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
|
||||
SusHandler* sus1 = new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus1);
|
||||
(void) sus1;
|
||||
// sus1->setStartUpImmediately();
|
||||
(void) sus1;
|
||||
|
||||
SusHandler* sus2 = new SusHandler(objects::SUS_2, objects::SPI_COM_IF, spiCookieSus2);
|
||||
// sus2->setStartUpImmediately();
|
||||
(void) sus2;
|
||||
|
||||
SusHandler* sus3 = new SusHandler(objects::SUS_3, objects::SPI_COM_IF, spiCookieSus3);
|
||||
sus3->setStartUpImmediately();
|
||||
(void) sus3;
|
||||
|
||||
new SusHandler(objects::SUS_2, objects::SPI_COM_IF, spiCookieSus2);
|
||||
new SusHandler(objects::SUS_3, objects::SPI_COM_IF, spiCookieSus3);
|
||||
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);
|
||||
new SusHandler(objects::SUS_8, objects::SPI_COM_IF, spiCookieSus8);
|
||||
SusHandler* sus8 = new SusHandler(objects::SUS_8, objects::SPI_COM_IF, spiCookieSus8);
|
||||
// sus8->setStartUpImmediately();
|
||||
(void) sus8;
|
||||
|
||||
new SusHandler(objects::SUS_9, objects::SPI_COM_IF, spiCookieSus9);
|
||||
new SusHandler(objects::SUS_10, objects::SPI_COM_IF, spiCookieSus10);
|
||||
new SusHandler(objects::SUS_11, objects::SPI_COM_IF, spiCookieSus11);
|
||||
SusHandler* sus11 = new SusHandler(objects::SUS_11, objects::SPI_COM_IF, spiCookieRadSensor);
|
||||
sus11->setStartUpImmediately();
|
||||
|
||||
new SusHandler(objects::SUS_12, objects::SPI_COM_IF, spiCookieSus12);
|
||||
new SusHandler(objects::SUS_13, objects::SPI_COM_IF, spiCookieSus13);
|
||||
|
||||
@ -526,19 +566,6 @@ void ObjectFactory::produce(){
|
||||
// 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 */
|
||||
|
||||
new UdpTmTcBridge(objects::UDP_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR, objects::TM_STORE,
|
||||
@ -552,8 +579,40 @@ void ObjectFactory::produce(){
|
||||
GpioCookie* gpioCookie = new GpioCookie;
|
||||
gpioCookie->addGpio(gpioIds::TEST_ID_0, gpioConfigMio0);
|
||||
new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie);
|
||||
#elif TE0720 == 1
|
||||
#endif
|
||||
|
||||
#if TE0720 == 1 && TEST_SUS_HANDLER == 1
|
||||
GpioCookie* gpioCookieSus = new GpioCookie;
|
||||
GpiodRegular* chipSelectSus = new GpiodRegular(std::string("gpiochip0"), 9,
|
||||
std::string("Chip Select Sus Sensor"), gpio::OUT, 1);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_1, chipSelectSus);
|
||||
gpioComIF->addGpios(gpioCookieSus);
|
||||
|
||||
SpiCookie* spiCookieSus = new SpiCookie(addresses::SUS_1, gpioIds::CS_SUS_1,
|
||||
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);
|
||||
sus1->setStartUpImmediately();
|
||||
#endif
|
||||
|
||||
#if TE0720 == 1 && TEST_RADIATION_SENSOR_HANDLER == 1
|
||||
GpioCookie* gpioCookieRadSensor = new GpioCookie;
|
||||
GpiodRegular* chipSelectRadSensor = new GpiodRegular(std::string("gpiochip0"), 9,
|
||||
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/spidev1.0"), SUS::MAX_CMD_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
|
||||
|
||||
#if TE0720 == 1 && TEST_PLOC_HANDLER == 1
|
||||
UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyPS1"), 115200,
|
||||
PLOC::MAX_REPLY_SIZE);
|
||||
/* Testing PlocHandler on TE0720-03-1CFA */
|
||||
|
@ -16,12 +16,15 @@
|
||||
|
||||
/* These defines should be disabled for mission code but are useful for
|
||||
debugging. */
|
||||
#define OBSW_VERBOSE_LEVEL 1
|
||||
#define OBSW_PRINT_MISSED_DEADLINES 1
|
||||
#define OBSW_ADD_TEST_CODE 1
|
||||
#define TEST_LIBGPIOD 0
|
||||
#define OBSW_VERBOSE_LEVEL 1
|
||||
#define OBSW_PRINT_MISSED_DEADLINES 1
|
||||
#define OBSW_ADD_TEST_CODE 1
|
||||
#define TEST_LIBGPIOD 0
|
||||
#define TEST_RADIATION_SENSOR_HANDLER 0
|
||||
#define TEST_SUS_HANDLER 1
|
||||
#define TEST_PLOC_HANDLER 0
|
||||
|
||||
#define TE0720 0
|
||||
#define TE0720 1
|
||||
#define TE0720_HEATER_TEST 0
|
||||
|
||||
#define P60DOCK_DEBUG 0
|
||||
|
@ -20,7 +20,8 @@ static constexpr spi::SpiModes DEFAULT_RM3100_MODE = spi::SpiModes::MODE_3;
|
||||
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 = 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;
|
||||
|
||||
}
|
||||
|
@ -54,6 +54,21 @@ namespace objects {
|
||||
IMTQ_HANDLER = 0x44000014,
|
||||
PLOC_HANDLER = 0x44000015,
|
||||
|
||||
|
||||
SUS_1 = 0x44000016,
|
||||
SUS_2 = 0x44000017,
|
||||
SUS_3 = 0x44000018,
|
||||
SUS_4 = 0x44000019,
|
||||
SUS_5 = 0x4400001A,
|
||||
SUS_6 = 0x4400001B,
|
||||
SUS_7 = 0x4400001C,
|
||||
SUS_8 = 0x4400001D,
|
||||
SUS_9 = 0x4400001E,
|
||||
SUS_10 = 0x4400001F,
|
||||
SUS_11 = 0x44000021,
|
||||
SUS_12 = 0x44000022,
|
||||
SUS_13 = 0x44000023,
|
||||
|
||||
/* Custom device handler */
|
||||
PCDU_HANDLER = 0x44001000,
|
||||
SOLAR_ARRAY_DEPL_HANDLER = 0x44001001,
|
||||
@ -84,20 +99,6 @@ namespace objects {
|
||||
|
||||
RAD_SENSOR = 0x54000050,
|
||||
|
||||
SUS_1 = 0x54000051,
|
||||
SUS_2 = 0x54000052,
|
||||
SUS_3 = 0x54000053,
|
||||
SUS_4 = 0x54000054,
|
||||
SUS_5 = 0x54000055,
|
||||
SUS_6 = 0x54000056,
|
||||
SUS_7 = 0x54000057,
|
||||
SUS_8 = 0x54000058,
|
||||
SUS_9 = 0x54000059,
|
||||
SUS_10 = 0x5400005A,
|
||||
SUS_11 = 0x5400005B,
|
||||
SUS_12 = 0x5400005C,
|
||||
SUS_13 = 0x5400005D,
|
||||
|
||||
/* 0x54 ('T') for test handlers */
|
||||
TEST_TASK = 0x54694269,
|
||||
LIBGPIOD_TEST = 0x54123456,
|
||||
|
@ -144,11 +144,11 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence)
|
||||
|
||||
|
||||
/* 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);
|
||||
// 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);
|
||||
|
||||
/* Sun sensor 1 */
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
@ -157,6 +157,18 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence)
|
||||
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_11, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
// thisSequence->addSlot(objects::SUS_11, length * 0.2, DeviceHandlerIF::SEND_WRITE);
|
||||
// thisSequence->addSlot(objects::SUS_11, length * 0.4, DeviceHandlerIF::GET_WRITE);
|
||||
// thisSequence->addSlot(objects::SUS_11, length * 0.6, DeviceHandlerIF::SEND_READ);
|
||||
// thisSequence->addSlot(objects::SUS_11, length * 0.8, DeviceHandlerIF::GET_READ);
|
||||
|
||||
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
@ -340,16 +352,30 @@ ReturnValue_t pst::pollingSequenceAcsTest(FixedTimeslotTaskIF *thisSequence) {
|
||||
ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) {
|
||||
uint32_t length = thisSequence->getPeriodMs();
|
||||
|
||||
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0,
|
||||
DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.2,
|
||||
DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.4,
|
||||
DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.6,
|
||||
DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.8,
|
||||
DeviceHandlerIF::GET_READ);
|
||||
#if TEST_PLOC_HANDLER == 1
|
||||
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ);
|
||||
#endif
|
||||
|
||||
#if TEST_SUS_HANDLER == 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);
|
||||
#endif
|
||||
|
||||
#if TEST_RADIATION_SENSOR_HANDLER == 1
|
||||
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);
|
||||
#endif
|
||||
|
||||
|
||||
if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "Initialization of TE0720 PST failed" << std::endl;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#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) :
|
||||
@ -31,26 +32,16 @@ void SusHandler::doShutDown(){
|
||||
|
||||
ReturnValue_t SusHandler::buildNormalDeviceCommand(
|
||||
DeviceCommandId_t * id) {
|
||||
|
||||
switch (communicationStep) {
|
||||
case CommunicationStep::START_CONVERSION: {
|
||||
*id = SUS::START_CONVERSION;
|
||||
communicationStep = CommunicationStep::READ_CONVERSIONS;
|
||||
break;
|
||||
if (communicationStep == CommunicationStep::PERFORM_CONVERSIONS) {
|
||||
*id = SUS::PERFORM_CONVERSIONS;
|
||||
// communicationStep = CommunicationStep::READ_TEMP;
|
||||
communicationStep = CommunicationStep::PERFORM_CONVERSIONS;
|
||||
}
|
||||
case CommunicationStep::READ_CONVERSIONS: {
|
||||
*id = SUS::READ_CONVERSIONS;
|
||||
// communicationStep = CommunicationStep::START_CONVERSION;
|
||||
communicationStep = CommunicationStep::READ_CONVERSIONS;
|
||||
break;
|
||||
else if (communicationStep == CommunicationStep::READ_TEMP) {
|
||||
*id = SUS::READ_TEMP;
|
||||
communicationStep = CommunicationStep::PERFORM_CONVERSIONS;
|
||||
}
|
||||
default: {
|
||||
sif::debug << "SusHandler::buildNormalDeviceCommand: Unknwon communication "
|
||||
<< "step" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
}
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
|
||||
ReturnValue_t SusHandler::buildTransitionDeviceCommand(
|
||||
@ -76,24 +67,44 @@ ReturnValue_t SusHandler::buildCommandFromCommand(
|
||||
internalState = InternalState::CONFIGURED;
|
||||
return RETURN_OK;
|
||||
}
|
||||
case(SUS::START_CONVERSION): {
|
||||
cmdBuffer[0] = SUS::CONVERSION_DEFINITION;
|
||||
case(SUS::PERFORM_CONVERSIONS): {
|
||||
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;
|
||||
// wirte one dummy byte here
|
||||
// cmdBuffer[2] = SUS::CONVERT_TEMPERATURE;
|
||||
cmdBuffer[2] = SUS::CONVERT_TEMPERATURE;
|
||||
// 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[0] = SUS::SETUP_DEFINITION;
|
||||
// cmdBuffer[1] = SUS::UNIPOLAR_CONFIG;
|
||||
// cmdBuffer[2] = SUS::CONVERT_TEMPERATURE;
|
||||
// cmdBuffer[26] = SUS::CONVERT_DIFF_CHANNEL_0_1;
|
||||
// cmdBuffer[28] = SUS::CONVERT_DIFF_CHANNEL_2_3;
|
||||
// cmdBuffer[30] = SUS::CONVERT_DIFF_CHANNEL_4_5;
|
||||
rawPacket = cmdBuffer;
|
||||
rawPacketLen = 1;
|
||||
// rawPacketLen = SUS::SIZE_PERFORM_CONVERSIONS;
|
||||
rawPacketLen = 7;
|
||||
return RETURN_OK;
|
||||
}
|
||||
case(SUS::READ_CONVERSIONS): {
|
||||
cmdBuffer[0] = SUS::DUMMY_BYTE;
|
||||
cmdBuffer[1] = SUS::DUMMY_BYTE;
|
||||
cmdBuffer[2] = SUS::DUMMY_BYTE;
|
||||
cmdBuffer[3] = SUS::DUMMY_BYTE;
|
||||
cmdBuffer[4] = SUS::DUMMY_BYTE;
|
||||
cmdBuffer[5] = SUS::DUMMY_BYTE;
|
||||
cmdBuffer[6] = SUS::DUMMY_BYTE;
|
||||
cmdBuffer[7] = SUS::DUMMY_BYTE;
|
||||
cmdBuffer[8] = SUS::DUMMY_BYTE;
|
||||
rawPacket = cmdBuffer;
|
||||
rawPacketLen = SUS::READ_SIZE;
|
||||
case(SUS::READ_TEMP): {
|
||||
std::memset(cmdBuffer, 0, sizeof(cmdBuffer));
|
||||
rawPacket = cmdBuffer;
|
||||
rawPacketLen = 26;
|
||||
return RETURN_OK;
|
||||
}
|
||||
default:
|
||||
@ -104,9 +115,10 @@ ReturnValue_t SusHandler::buildCommandFromCommand(
|
||||
|
||||
void SusHandler::fillCommandAndReplyMap() {
|
||||
this->insertInCommandMap(SUS::WRITE_SETUP);
|
||||
this->insertInCommandMap(SUS::START_CONVERSION);
|
||||
this->insertInCommandAndReplyMap(SUS::READ_CONVERSIONS, 1, &dataset,
|
||||
SUS::READ_SIZE);
|
||||
this->insertInCommandAndReplyMap(SUS::READ_TEMP, 1, &dataset, SUS::SIZE_PERFORM_CONVERSIONS);
|
||||
// this->insertInCommandAndReplyMap(SUS::PERFORM_CONVERSIONS, 1, &dataset,
|
||||
// SUS::SIZE_PERFORM_CONVERSIONS);
|
||||
this->insertInCommandMap(SUS::PERFORM_CONVERSIONS);
|
||||
}
|
||||
|
||||
ReturnValue_t SusHandler::scanForReply(const uint8_t *start,
|
||||
@ -119,12 +131,12 @@ ReturnValue_t SusHandler::scanForReply(const uint8_t *start,
|
||||
ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
const uint8_t *packet) {
|
||||
switch (id) {
|
||||
case SUS::READ_CONVERSIONS: {
|
||||
case SUS::PERFORM_CONVERSIONS: {
|
||||
PoolReadGuard readSet(&dataset);
|
||||
dataset.temperatureCelcius = (*(packet) << 8 | *(packet + 1)) * 0.125;
|
||||
dataset.diffScanChannel0_1 = (*(packet + 2) << 8 | *(packet + 3));
|
||||
dataset.diffScanChannel2_3 = (*(packet + 2) << 8 | *(packet + 3));
|
||||
dataset.diffScanChannel4_5 = (*(packet + 2) << 8 | *(packet + 3));
|
||||
dataset.temperatureCelcius = (*(packet + 25) << 8 | *(packet + 26)) * 0.125;
|
||||
dataset.diffScanChannel0_1 = (*(packet + 29) << 8 | *(packet + 30));
|
||||
dataset.diffScanChannel2_3 = (*(packet + 31) << 8 | *(packet + 32));
|
||||
dataset.diffScanChannel4_5 = (*(packet + 33) << 8 | *(packet + 34));
|
||||
#if OBSW_VERBOSE_LEVEL >= 1 && DEBUG_SUS
|
||||
sif::info << "SUS with object id " << std::hex << this->getObjectId() << ", temperature: "
|
||||
<< dataset.temperatureCelcius << " °C" << std::endl;
|
||||
|
@ -40,8 +40,8 @@ protected:
|
||||
private:
|
||||
|
||||
enum class CommunicationStep {
|
||||
START_CONVERSION,
|
||||
READ_CONVERSIONS
|
||||
PERFORM_CONVERSIONS,
|
||||
READ_TEMP
|
||||
};
|
||||
|
||||
enum class InternalState {
|
||||
@ -51,11 +51,9 @@ private:
|
||||
|
||||
SUS::SusDataset dataset;
|
||||
|
||||
static const uint8_t MAX_CMD_LEN = SUS::READ_SIZE;
|
||||
|
||||
uint8_t cmdBuffer[MAX_CMD_LEN];
|
||||
uint8_t cmdBuffer[SUS::MAX_CMD_SIZE];
|
||||
InternalState internalState = InternalState::SETUP;
|
||||
CommunicationStep communicationStep = CommunicationStep::START_CONVERSION;
|
||||
CommunicationStep communicationStep = CommunicationStep::PERFORM_CONVERSIONS;
|
||||
};
|
||||
|
||||
#endif /* MISSION_DEVICES_SUSHANDLER_H_ */
|
||||
|
@ -10,8 +10,8 @@ namespace SUS {
|
||||
* 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 DeviceCommandId_t PERFORM_CONVERSIONS = 0x2;
|
||||
static const DeviceCommandId_t READ_TEMP = 0x3;
|
||||
|
||||
/**
|
||||
* @brief This is the configuration byte which will be written to the setup register after
|
||||
@ -19,12 +19,15 @@ namespace SUS {
|
||||
*
|
||||
* @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b10, following byte will be written to the
|
||||
* unipolar register to perform differential conversion
|
||||
* Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b11, external reference differential (AIN6 is REF-)
|
||||
* Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, MAX1227 uses internal oscillator for timing
|
||||
* Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, internal reference differential (AIN6 is REF-)
|
||||
* 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 = 0b01101110;
|
||||
// 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
|
||||
@ -38,21 +41,24 @@ namespace SUS {
|
||||
* @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)
|
||||
* Bit2 (SCAN1) and Bit1 (SCAN0): 0b11, No scan, converts channel N once only.
|
||||
* Scanning is not supported in spi clock mode.
|
||||
* Bit6 - Bit3 defines N: 0b0001 (N = 4)
|
||||
* Bit7: Always 1. Tells the ADC that this is the conversion register.
|
||||
*/
|
||||
static const uint8_t CONVERSION_DEFINITION = 0b10100001;
|
||||
// static const uint8_t CONVERT_TEMPERATURE = 0b10000111;
|
||||
static const uint8_t CONVERT_TEMPERATURE = 0b10000110;
|
||||
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 DUMMY_BYTE = 0xFF;
|
||||
static const uint8_t DUMMY_BYTE = 0x0;
|
||||
|
||||
static const uint8_t SUS_DATA_SET_ID = READ_CONVERSIONS;
|
||||
static const uint8_t SUS_DATA_SET_ID = PERFORM_CONVERSIONS;
|
||||
|
||||
/**
|
||||
* One temperature value, one differential conversion for channels 0/1, one for channels 2/3 and
|
||||
* one for channels 3/4
|
||||
*/
|
||||
static const uint8_t READ_SIZE = 8;
|
||||
static const uint8_t SIZE_PERFORM_CONVERSIONS = 34;
|
||||
|
||||
static const uint8_t MAX_CMD_SIZE = SIZE_PERFORM_CONVERSIONS;
|
||||
|
||||
enum Max1227PoolIds: lp_id_t {
|
||||
TEMPERATURE_C,
|
||||
|
Loading…
Reference in New Issue
Block a user