Merge remote-tracking branch 'origin/mueller/sus-update' into mueller/master
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
This commit is contained in:
commit
3a6be97c26
@ -54,12 +54,12 @@ static constexpr char HEATER_6[] = "heater6";
|
||||
static constexpr char HEATER_7[] = "heater7";
|
||||
static constexpr char SA_DPL_PIN_0[] = "sa_dpl_0";
|
||||
static constexpr char SA_DPL_PIN_1[] = "sa_dpl_1";
|
||||
static constexpr char SPI_MUX_BIT_1_PIN[] = "spi_mux_bit_1";
|
||||
static constexpr char SPI_MUX_BIT_2_PIN[] = "spi_mux_bit_2";
|
||||
static constexpr char SPI_MUX_BIT_3_PIN[] = "spi_mux_bit_3";
|
||||
static constexpr char SPI_MUX_BIT_4_PIN[] = "spi_mux_bit_4";
|
||||
static constexpr char SPI_MUX_BIT_5_PIN[] = "spi_mux_bit_5";
|
||||
static constexpr char SPI_MUX_BIT_6_PIN[] = "spi_mux_bit_6";
|
||||
static constexpr char SPI_MUX_BIT_0_PIN[] = "spi_mux_bit_1";
|
||||
static constexpr char SPI_MUX_BIT_1_PIN[] = "spi_mux_bit_2";
|
||||
static constexpr char SPI_MUX_BIT_2_PIN[] = "spi_mux_bit_3";
|
||||
static constexpr char SPI_MUX_BIT_3_PIN[] = "spi_mux_bit_4";
|
||||
static constexpr char SPI_MUX_BIT_4_PIN[] = "spi_mux_bit_5";
|
||||
static constexpr char SPI_MUX_BIT_5_PIN[] = "spi_mux_bit_6";
|
||||
static constexpr char EN_RW_CS[] = "en_rw_cs";
|
||||
static constexpr char EN_RW_1[] = "enable_rw_1";
|
||||
static constexpr char EN_RW_2[] = "enable_rw_2";
|
||||
|
@ -25,38 +25,28 @@ void initSpiCsDecoder(GpioIF* gpioComIF) {
|
||||
|
||||
GpiodRegularByLineName* spiMuxBit = nullptr;
|
||||
/** Setting mux bit 1 to low will disable IC21 on the interface board */
|
||||
spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1",
|
||||
spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_0_PIN, "SPI Mux Bit 1",
|
||||
gpio::DIR_OUT, gpio::HIGH);
|
||||
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_0, spiMuxBit);
|
||||
/** Setting mux bit 2 to low disables IC1 on the TCS board */
|
||||
spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 2",
|
||||
gpio::DIR_OUT, gpio::HIGH);
|
||||
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit);
|
||||
/** Setting mux bit 2 to low disables IC1 on the TCS board */
|
||||
spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2",
|
||||
gpio::DIR_OUT, gpio::HIGH);
|
||||
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit);
|
||||
/** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */
|
||||
spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3",
|
||||
spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 3",
|
||||
gpio::DIR_OUT, gpio::LOW);
|
||||
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit);
|
||||
|
||||
// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1",
|
||||
// gpio::OUT, gpio::LOW);
|
||||
// spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit);
|
||||
// /** Setting mux bit 2 to low disables IC1 on the TCS board */
|
||||
// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2",
|
||||
// gpio::OUT, gpio::HIGH); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit);
|
||||
// /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board
|
||||
// */ spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit
|
||||
// 3", gpio::OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit);
|
||||
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit);
|
||||
|
||||
/** The following gpios can take arbitrary initial values */
|
||||
spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 4",
|
||||
spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 4",
|
||||
gpio::DIR_OUT, gpio::LOW);
|
||||
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit);
|
||||
spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 5",
|
||||
gpio::DIR_OUT, gpio::LOW);
|
||||
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_4, spiMuxBit);
|
||||
spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_5_PIN, "SPI Mux Bit 5",
|
||||
spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_5_PIN, "SPI Mux Bit 6",
|
||||
gpio::DIR_OUT, gpio::LOW);
|
||||
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_5, spiMuxBit);
|
||||
spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_6_PIN, "SPI Mux Bit 6",
|
||||
gpio::DIR_OUT, gpio::LOW);
|
||||
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_6, spiMuxBit);
|
||||
GpiodRegularByLineName* enRwDecoder =
|
||||
new GpiodRegularByLineName(q7s::gpioNames::EN_RW_CS, "EN_RW_CS", gpio::DIR_OUT, gpio::HIGH);
|
||||
spiMuxGpios->addGpio(gpioIds::EN_RW_CS, enRwDecoder);
|
||||
@ -307,45 +297,45 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Lev
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_2): {
|
||||
selectY0();
|
||||
enableDecoderInterfaceBoardIc2();
|
||||
selectY2();
|
||||
enableDecoderInterfaceBoardIc1();
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_3): {
|
||||
selectY1();
|
||||
enableDecoderInterfaceBoardIc2();
|
||||
selectY3();
|
||||
enableDecoderInterfaceBoardIc1();
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_4): {
|
||||
selectY2();
|
||||
enableDecoderInterfaceBoardIc2();
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_5): {
|
||||
selectY2();
|
||||
enableDecoderInterfaceBoardIc1();
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_6): {
|
||||
selectY3();
|
||||
enableDecoderInterfaceBoardIc1();
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_7): {
|
||||
selectY3();
|
||||
enableDecoderInterfaceBoardIc2();
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_8): {
|
||||
selectY4();
|
||||
enableDecoderInterfaceBoardIc1();
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_9): {
|
||||
case (gpioIds::CS_SUS_5): {
|
||||
selectY5();
|
||||
enableDecoderInterfaceBoardIc1();
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_6): {
|
||||
selectY0();
|
||||
enableDecoderInterfaceBoardIc2();
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_7): {
|
||||
selectY1();
|
||||
enableDecoderInterfaceBoardIc2();
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_8): {
|
||||
selectY2();
|
||||
enableDecoderInterfaceBoardIc2();
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_9): {
|
||||
selectY3();
|
||||
enableDecoderInterfaceBoardIc2();
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_10): {
|
||||
selectY4();
|
||||
enableDecoderInterfaceBoardIc2();
|
||||
@ -385,52 +375,52 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Lev
|
||||
}
|
||||
|
||||
void enableDecoderTcsIc1() {
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void enableDecoderTcsIc2() {
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
}
|
||||
|
||||
void enableDecoderInterfaceBoardIc1() {
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void enableDecoderInterfaceBoardIc2() {
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void enableDecoderInterfaceBoardIc1() {
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
}
|
||||
|
||||
void enableDecoderInterfaceBoardIc2() {
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void disableDecoderTcsIc1() {
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void disableDecoderTcsIc2() {
|
||||
// DO NOT CHANGE THE ORDER HERE
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void disableDecoderInterfaceBoardIc1() {
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void disableDecoderInterfaceBoardIc2() {
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void enableRwDecoder() { gpioComInterface->pullHigh(gpioIds::EN_RW_CS); }
|
||||
@ -438,57 +428,57 @@ void enableRwDecoder() { gpioComInterface->pullHigh(gpioIds::EN_RW_CS); }
|
||||
void disableRwDecoder() { gpioComInterface->pullLow(gpioIds::EN_RW_CS); }
|
||||
|
||||
void 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);
|
||||
}
|
||||
|
||||
void selectY1() {
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioComInterface->pullHigh(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);
|
||||
}
|
||||
|
||||
void selectY2() {
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void selectY3() {
|
||||
gpioComInterface->pullHigh(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);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void 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);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void selectY5() {
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void selectY6() {
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||
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);
|
||||
}
|
||||
|
||||
void selectY7() {
|
||||
gpioComInterface->pullHigh(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);
|
||||
}
|
||||
|
||||
void disableAllDecoder() {
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioComInterface->pullLow(gpioIds::EN_RW_CS);
|
||||
}
|
||||
|
||||
|
@ -347,17 +347,17 @@ void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComI
|
||||
gpioComIF->addGpios(gpioCookieSus);
|
||||
|
||||
SpiCookie* spiCookie =
|
||||
new SpiCookie(addresses::SUS_0, gpioIds::CS_SUS_0, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
new SpiCookie(addresses::SUS_0, gpioIds::CS_SUS_0, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE,
|
||||
spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SusHandler* susHandler0 =
|
||||
new SusHandler(objects::SUS_0, objects::SPI_COM_IF, spiCookie, gpioComIF, gpioIds::CS_SUS_0);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_1, gpioIds::CS_SUS_1, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
spiCookie = new SpiCookie(addresses::SUS_1, gpioIds::CS_SUS_1, q7s::SPI_DEFAULT_DEV,
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SusHandler* susHandler1 =
|
||||
new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookie, gpioComIF, gpioIds::CS_SUS_1);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_2, gpioIds::CS_SUS_2, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
spiCookie = new SpiCookie(addresses::SUS_2, gpioIds::CS_SUS_2, q7s::SPI_DEFAULT_DEV,
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SusHandler* susHandler2 =
|
||||
new SusHandler(objects::SUS_2, objects::SPI_COM_IF, spiCookie, gpioComIF, gpioIds::CS_SUS_2);
|
||||
@ -377,33 +377,32 @@ void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComI
|
||||
SusHandler* susHandler5 =
|
||||
new SusHandler(objects::SUS_5, objects::SPI_COM_IF, spiCookie, gpioComIF, gpioIds::CS_SUS_5);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
spiCookie = new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, q7s::SPI_DEFAULT_DEV,
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SusHandler* susHandler6 =
|
||||
new SusHandler(objects::SUS_6, objects::SPI_COM_IF, spiCookie, gpioComIF, gpioIds::CS_SUS_6);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_7, gpioIds::CS_SUS_7, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
spiCookie = new SpiCookie(addresses::SUS_7, gpioIds::CS_SUS_7, q7s::SPI_DEFAULT_DEV,
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SusHandler* susHandler7 =
|
||||
new SusHandler(objects::SUS_7, objects::SPI_COM_IF, spiCookie, gpioComIF, gpioIds::CS_SUS_7);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_8, gpioIds::CS_SUS_8, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
spiCookie = new SpiCookie(addresses::SUS_8, gpioIds::CS_SUS_8, q7s::SPI_DEFAULT_DEV,
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SusHandler* susHandler8 =
|
||||
new SusHandler(objects::SUS_8, objects::SPI_COM_IF, spiCookie, gpioComIF, gpioIds::CS_SUS_8);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_9, gpioIds::CS_SUS_9, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
spiCookie = new SpiCookie(addresses::SUS_9, gpioIds::CS_SUS_9, q7s::SPI_DEFAULT_DEV,
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SusHandler* susHandler9 =
|
||||
new SusHandler(objects::SUS_9, objects::SPI_COM_IF, spiCookie, gpioComIF, gpioIds::CS_SUS_9);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_9, gpioIds::CS_SUS_10, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
spiCookie = new SpiCookie(addresses::SUS_10, gpioIds::CS_SUS_10, q7s::SPI_DEFAULT_DEV,
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SusHandler* susHandler10 = new SusHandler(objects::SUS_10, objects::SPI_COM_IF, spiCookie,
|
||||
gpioComIF, gpioIds::CS_SUS_10);
|
||||
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::SUS_11, gpioIds::CS_SUS_11, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
spiCookie = new SpiCookie(addresses::SUS_11, gpioIds::CS_SUS_11, q7s::SPI_DEFAULT_DEV,
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SusHandler* susHandler11 = new SusHandler(objects::SUS_11, objects::SPI_COM_IF, spiCookie,
|
||||
gpioComIF, gpioIds::CS_SUS_11);
|
||||
@ -419,7 +418,7 @@ void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComI
|
||||
static_cast<void>(susHandler9);
|
||||
static_cast<void>(susHandler10);
|
||||
static_cast<void>(susHandler11);
|
||||
#if OBSW_TEST_SUS == 1
|
||||
#if OBSW_TEST_SUS_HANDLER == 1
|
||||
susHandler0->setStartUpImmediately();
|
||||
susHandler1->setStartUpImmediately();
|
||||
susHandler2->setStartUpImmediately();
|
||||
|
@ -1,96 +1,82 @@
|
||||
#include "SusHandler.h"
|
||||
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include <fsfw/globalfunctions/arrayprinter.h>
|
||||
#include <fsfw_hal/linux/spi/SpiComIF.h>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
SusHandler::SusHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
|
||||
LinuxLibgpioIF *gpioComIF, gpioId_t chipSelectId)
|
||||
: DeviceHandlerBase(objectId, comIF, comCookie),
|
||||
divider(5),
|
||||
gpioComIF(gpioComIF),
|
||||
chipSelectId(chipSelectId),
|
||||
dataset(this) {
|
||||
if (comCookie == nullptr) {
|
||||
sif::error << "SusHandler: Invalid com cookie" << std::endl;
|
||||
}
|
||||
if (gpioComIF == nullptr) {
|
||||
sif::error << "SusHandler: Invalid GpioComIF" << std::endl;
|
||||
}
|
||||
}
|
||||
: DeviceHandlerBase(objectId, comIF, comCookie), divider(5), dataset(this) {}
|
||||
|
||||
SusHandler::~SusHandler() {}
|
||||
|
||||
ReturnValue_t SusHandler::performOperation(uint8_t counter) {
|
||||
if (counter != FIRST_WRITE) {
|
||||
DeviceHandlerBase::performOperation(counter);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
if (mode != MODE_NORMAL) {
|
||||
DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
/* If device is in normale mode the communication sequence is initiated here */
|
||||
if (communicationStep == CommunicationStep::IDLE) {
|
||||
communicationStep = CommunicationStep::WRITE_SETUP;
|
||||
}
|
||||
|
||||
DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE);
|
||||
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SusHandler::initialize() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
result = DeviceHandlerBase::initialize();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
auto spiComIF = dynamic_cast<SpiComIF *>(communicationInterface);
|
||||
if (spiComIF == nullptr) {
|
||||
sif::debug << "SusHandler::initialize: Invalid communication interface" << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
spiMutex = spiComIF->getMutex();
|
||||
if (spiMutex == nullptr) {
|
||||
sif::debug << "SusHandler::initialize: Failed to get spi mutex" << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void SusHandler::doStartUp() {
|
||||
if (comState == ComStates::IDLE) {
|
||||
comState = ComStates::WRITE_SETUP;
|
||||
commandExecuted = false;
|
||||
}
|
||||
if (comState == ComStates::WRITE_SETUP) {
|
||||
if (commandExecuted) {
|
||||
#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1
|
||||
setMode(MODE_NORMAL);
|
||||
#else
|
||||
setMode(_MODE_TO_ON);
|
||||
#endif
|
||||
commandExecuted = false;
|
||||
if (clkMode == Modes::INT_CLOCKED) {
|
||||
comState = ComStates::START_INT_CLOCKED_CONVERSIONS;
|
||||
} else {
|
||||
comState = ComStates::EXT_CLOCKED_CONVERSIONS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SusHandler::doShutDown() { setMode(_MODE_POWER_DOWN); }
|
||||
|
||||
ReturnValue_t SusHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
|
||||
if (communicationStep == CommunicationStep::IDLE) {
|
||||
switch (comState) {
|
||||
case (ComStates::IDLE): {
|
||||
return NOTHING_TO_SEND;
|
||||
}
|
||||
|
||||
if (communicationStep == CommunicationStep::WRITE_SETUP) {
|
||||
case (ComStates::WRITE_SETUP): {
|
||||
*id = SUS::WRITE_SETUP;
|
||||
communicationStep = CommunicationStep::START_CONVERSIONS;
|
||||
} else if (communicationStep == CommunicationStep::START_CONVERSIONS) {
|
||||
*id = SUS::START_CONVERSIONS;
|
||||
communicationStep = CommunicationStep::READ_CONVERSIONS;
|
||||
} else if (communicationStep == CommunicationStep::READ_CONVERSIONS) {
|
||||
*id = SUS::READ_CONVERSIONS;
|
||||
communicationStep = CommunicationStep::IDLE;
|
||||
}
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
case (ComStates::EXT_CLOCKED_CONVERSIONS): {
|
||||
*id = SUS::READ_EXT_TIMED_CONVERSIONS;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
case (ComStates::START_INT_CLOCKED_CONVERSIONS): {
|
||||
*id = SUS::START_INT_TIMED_CONVERSIONS;
|
||||
comState = ComStates::READ_INT_CLOCKED_CONVERSIONS;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
case (ComStates::READ_INT_CLOCKED_CONVERSIONS): {
|
||||
*id = SUS::READ_INT_TIMED_CONVERSIONS;
|
||||
comState = ComStates::START_INT_CLOCKED_CONVERSIONS;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
}
|
||||
return NOTHING_TO_SEND;
|
||||
}
|
||||
|
||||
ReturnValue_t SusHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) {
|
||||
if (comState == ComStates::WRITE_SETUP) {
|
||||
*id = SUS::WRITE_SETUP;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
@ -99,43 +85,37 @@ ReturnValue_t SusHandler::buildCommandFromCommand(DeviceCommandId_t deviceComman
|
||||
size_t commandDataLen) {
|
||||
switch (deviceCommand) {
|
||||
case (SUS::WRITE_SETUP): {
|
||||
/**
|
||||
* The sun sensor ADC is shutdown when CS is pulled high, so each time requesting a
|
||||
* measurement the setup has to be rewritten. There must also be a little delay between
|
||||
* the transmission of the setup byte and the first conversion. Thus the conversion
|
||||
* will be performed in an extra step.
|
||||
* Because the chip select is driven manually by the SusHandler the SPI bus must be
|
||||
* protected with a mutex here.
|
||||
*/
|
||||
ReturnValue_t result = spiMutex->lockMutex(timeoutType, timeoutMs);
|
||||
if (result == MutexIF::MUTEX_TIMEOUT) {
|
||||
sif::error << "SusHandler::buildCommandFromCommand: Mutex timeout" << std::endl;
|
||||
return ERROR_LOCK_MUTEX;
|
||||
} else if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "SusHandler::buildCommandFromCommand: Failed to lock spi mutex" << std::endl;
|
||||
return ERROR_LOCK_MUTEX;
|
||||
if (clkMode == Modes::INT_CLOCKED) {
|
||||
cmdBuffer[0] = SUS::SETUP_INT_CLOKED;
|
||||
} else {
|
||||
cmdBuffer[0] = SUS::SETUP_EXT_CLOCKED;
|
||||
}
|
||||
|
||||
result = gpioComIF->pullLow(chipSelectId);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
cmdBuffer[0] = SUS::SETUP;
|
||||
rawPacket = cmdBuffer;
|
||||
rawPacketLen = 1;
|
||||
return RETURN_OK;
|
||||
}
|
||||
case (SUS::START_CONVERSIONS): {
|
||||
case (SUS::START_INT_TIMED_CONVERSIONS): {
|
||||
std::memset(cmdBuffer, 0, sizeof(cmdBuffer));
|
||||
cmdBuffer[0] = SUS::CONVERSION;
|
||||
rawPacket = cmdBuffer;
|
||||
rawPacketLen = 2;
|
||||
return RETURN_OK;
|
||||
}
|
||||
case (SUS::READ_CONVERSIONS): {
|
||||
case (SUS::READ_INT_TIMED_CONVERSIONS): {
|
||||
std::memset(cmdBuffer, 0, sizeof(cmdBuffer));
|
||||
rawPacket = cmdBuffer;
|
||||
rawPacketLen = SUS::SIZE_READ_CONVERSIONS;
|
||||
rawPacketLen = SUS::SIZE_READ_INT_CONVERSIONS;
|
||||
return RETURN_OK;
|
||||
}
|
||||
case (SUS::READ_EXT_TIMED_CONVERSIONS): {
|
||||
std::memset(cmdBuffer, 0, sizeof(cmdBuffer));
|
||||
rawPacket = cmdBuffer;
|
||||
for (uint8_t idx = 0; idx < 6; idx++) {
|
||||
cmdBuffer[idx * 2] = buildConvByte(ScanModes::N_ONCE, 0, false);
|
||||
cmdBuffer[idx * 2 + 1] = 0;
|
||||
}
|
||||
rawPacketLen = SUS::SIZE_READ_EXT_CONVERSIONS;
|
||||
return RETURN_OK;
|
||||
}
|
||||
default:
|
||||
@ -145,9 +125,12 @@ ReturnValue_t SusHandler::buildCommandFromCommand(DeviceCommandId_t deviceComman
|
||||
}
|
||||
|
||||
void SusHandler::fillCommandAndReplyMap() {
|
||||
this->insertInCommandMap(SUS::WRITE_SETUP);
|
||||
this->insertInCommandMap(SUS::START_CONVERSIONS);
|
||||
this->insertInCommandAndReplyMap(SUS::READ_CONVERSIONS, 1, &dataset, SUS::SIZE_READ_CONVERSIONS);
|
||||
this->insertInCommandAndReplyMap(SUS::WRITE_SETUP, 1);
|
||||
this->insertInCommandAndReplyMap(SUS::START_INT_TIMED_CONVERSIONS, 1);
|
||||
this->insertInCommandAndReplyMap(SUS::READ_INT_TIMED_CONVERSIONS, 1, &dataset,
|
||||
SUS::SIZE_READ_INT_CONVERSIONS);
|
||||
this->insertInCommandAndReplyMap(SUS::READ_EXT_TIMED_CONVERSIONS, 1, &dataset,
|
||||
SUS::SIZE_READ_EXT_CONVERSIONS);
|
||||
}
|
||||
|
||||
ReturnValue_t SusHandler::scanForReply(const uint8_t *start, size_t remainingSize,
|
||||
@ -159,7 +142,16 @@ ReturnValue_t SusHandler::scanForReply(const uint8_t *start, size_t remainingSiz
|
||||
|
||||
ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) {
|
||||
switch (id) {
|
||||
case SUS::READ_CONVERSIONS: {
|
||||
case SUS::WRITE_SETUP: {
|
||||
if (mode == _MODE_START_UP) {
|
||||
commandExecuted = true;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
case SUS::START_INT_TIMED_CONVERSIONS: {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
case SUS::READ_INT_TIMED_CONVERSIONS: {
|
||||
PoolReadGuard readSet(&dataset);
|
||||
dataset.temperatureCelcius = (*(packet) << 8 | *(packet + 1)) * 0.125;
|
||||
dataset.ain0 = (*(packet + 2) << 8 | *(packet + 3));
|
||||
@ -168,31 +160,18 @@ ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8
|
||||
dataset.ain3 = (*(packet + 8) << 8 | *(packet + 9));
|
||||
dataset.ain4 = (*(packet + 10) << 8 | *(packet + 11));
|
||||
dataset.ain5 = (*(packet + 12) << 8 | *(packet + 13));
|
||||
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SUS == 1
|
||||
if (divider.checkAndIncrement()) {
|
||||
sif::info << "SUS object id 0x" << std::hex << this->getObjectId()
|
||||
<< ", Temperature: " << dataset.temperatureCelcius << " C" << std::endl;
|
||||
sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN0: " << std::dec
|
||||
<< dataset.ain0 << std::endl;
|
||||
sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN1: " << std::dec
|
||||
<< dataset.ain1 << std::endl;
|
||||
sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN2: " << std::dec
|
||||
<< dataset.ain2 << std::endl;
|
||||
sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN3: " << std::dec
|
||||
<< dataset.ain3 << std::endl;
|
||||
sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN4: " << std::dec
|
||||
<< dataset.ain4 << std::endl;
|
||||
sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN5: " << std::dec
|
||||
<< dataset.ain5 << std::endl;
|
||||
}
|
||||
#endif
|
||||
/** SUS can now be shutdown and thus the SPI bus released again */
|
||||
gpioComIF->pullHigh(chipSelectId);
|
||||
ReturnValue_t result = spiMutex->unlockMutex();
|
||||
if (result != RETURN_OK) {
|
||||
sif::error << "SusHandler::interpretDeviceReply: Failed to unlock spi mutex" << std::endl;
|
||||
return ERROR_UNLOCK_MUTEX;
|
||||
printDataset();
|
||||
break;
|
||||
}
|
||||
case (SUS::READ_EXT_TIMED_CONVERSIONS): {
|
||||
PoolReadGuard readSet(&dataset);
|
||||
dataset.ain0 = (packet[1] << 8) | packet[2];
|
||||
dataset.ain1 = (packet[3] << 8) | packet[4];
|
||||
dataset.ain2 = (packet[5] << 8) | packet[6];
|
||||
dataset.ain3 = (packet[7] << 8) | packet[8];
|
||||
dataset.ain4 = (packet[9] << 8) | packet[10];
|
||||
dataset.ain5 = (packet[11] << 8) | packet[12];
|
||||
printDataset();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -203,9 +182,7 @@ ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void SusHandler::setNormalDatapoolEntriesInvalid() {}
|
||||
|
||||
uint32_t SusHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 1000; }
|
||||
uint32_t SusHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 2000; }
|
||||
|
||||
ReturnValue_t SusHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||
LocalDataPoolManager &poolManager) {
|
||||
@ -220,3 +197,22 @@ ReturnValue_t SusHandler::initializeLocalDataPool(localpool::DataPool &localData
|
||||
}
|
||||
|
||||
void SusHandler::setToGoToNormalMode(bool enable) { this->goToNormalModeImmediately = enable; }
|
||||
|
||||
uint8_t SusHandler::buildConvByte(ScanModes scanMode, uint8_t channel, bool readTemp) {
|
||||
return (1 << 7) | (channel << 3) | (scanMode << 1) | readTemp;
|
||||
}
|
||||
|
||||
void SusHandler::printDataset() {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SUS == 1
|
||||
if (divider.checkAndIncrement()) {
|
||||
sif::info << "SUS Object ID 0x" << std::hex << this->getObjectId() << ":" << std::endl;
|
||||
sif::info << "Temperature: " << dataset.temperatureCelcius << " C" << std::endl;
|
||||
sif::info << "AIN0: " << std::dec << dataset.ain0 << std::endl;
|
||||
sif::info << "AIN1: " << std::dec << dataset.ain1 << std::endl;
|
||||
sif::info << "AIN2: " << std::dec << dataset.ain2 << std::endl;
|
||||
sif::info << "AIN3: " << std::dec << dataset.ain3 << std::endl;
|
||||
sif::info << "AIN4: " << std::dec << dataset.ain4 << std::endl;
|
||||
sif::info << "AIN5: " << std::dec << dataset.ain5 << std::endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -22,13 +22,22 @@
|
||||
*/
|
||||
class SusHandler : public DeviceHandlerBase {
|
||||
public:
|
||||
enum Modes { INT_CLOCKED, EXT_CLOCKED };
|
||||
|
||||
enum ScanModes : uint8_t {
|
||||
CHANNELS_0_TO_N = 0b00,
|
||||
CHANNEL_N_TO_HIGHEST = 0b01,
|
||||
N_REPEATEDLY = 0b10,
|
||||
N_ONCE = 0b11
|
||||
};
|
||||
|
||||
static const uint8_t FIRST_WRITE = 7;
|
||||
|
||||
SusHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
|
||||
LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId);
|
||||
virtual ~SusHandler();
|
||||
|
||||
virtual ReturnValue_t performOperation(uint8_t counter) override;
|
||||
// virtual ReturnValue_t performOperation(uint8_t counter) override;
|
||||
|
||||
virtual ReturnValue_t initialize() override;
|
||||
void setToGoToNormalMode(bool enable);
|
||||
@ -44,31 +53,42 @@ class SusHandler : public DeviceHandlerBase {
|
||||
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
|
||||
size_t* foundLen) override;
|
||||
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override;
|
||||
void setNormalDatapoolEntriesInvalid() override;
|
||||
// void setNormalDatapoolEntriesInvalid() override;
|
||||
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
|
||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) override;
|
||||
|
||||
uint8_t buildConvByte(ScanModes scanMode, uint8_t channel, bool readTemp);
|
||||
|
||||
private:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::SUS_HANDLER;
|
||||
|
||||
static const ReturnValue_t ERROR_UNLOCK_MUTEX = MAKE_RETURN_CODE(0xA0);
|
||||
static const ReturnValue_t ERROR_LOCK_MUTEX = MAKE_RETURN_CODE(0xA1);
|
||||
|
||||
enum class CommunicationStep { IDLE, WRITE_SETUP, START_CONVERSIONS, READ_CONVERSIONS };
|
||||
enum class ComStates {
|
||||
IDLE,
|
||||
WRITE_SETUP,
|
||||
EXT_CLOCKED_CONVERSIONS,
|
||||
START_INT_CLOCKED_CONVERSIONS,
|
||||
READ_INT_CLOCKED_CONVERSIONS
|
||||
};
|
||||
|
||||
PeriodicOperationDivider divider;
|
||||
LinuxLibgpioIF* gpioComIF = nullptr;
|
||||
// LinuxLibgpioIF* gpioComIF = nullptr;
|
||||
// gpioId_t chipSelectId = gpio::NO_GPIO;
|
||||
bool goToNormalModeImmediately = false;
|
||||
gpioId_t chipSelectId = gpio::NO_GPIO;
|
||||
bool commandExecuted = false;
|
||||
|
||||
SUS::SusDataset dataset;
|
||||
Modes clkMode = Modes::INT_CLOCKED;
|
||||
|
||||
uint8_t cmdBuffer[SUS::MAX_CMD_SIZE];
|
||||
CommunicationStep communicationStep = CommunicationStep::IDLE;
|
||||
ComStates comState = ComStates::IDLE;
|
||||
|
||||
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
|
||||
uint32_t timeoutMs = 20;
|
||||
void printDataset();
|
||||
|
||||
MutexIF* spiMutex = nullptr;
|
||||
};
|
||||
|
@ -21,12 +21,14 @@ static const DeviceCommandId_t WRITE_SETUP = 0x1;
|
||||
* This command initiates the ADC conversion for all channels including the internal
|
||||
* temperature sensor.
|
||||
*/
|
||||
static const DeviceCommandId_t START_CONVERSIONS = 0x2;
|
||||
static const DeviceCommandId_t START_INT_TIMED_CONVERSIONS = 0x2;
|
||||
/**
|
||||
* This command reads the internal fifo which holds the temperature and the channel
|
||||
* conversions.
|
||||
*/
|
||||
static const DeviceCommandId_t READ_CONVERSIONS = 0x3;
|
||||
static constexpr DeviceCommandId_t READ_INT_TIMED_CONVERSIONS = 0x3;
|
||||
|
||||
static constexpr DeviceCommandId_t READ_EXT_TIMED_CONVERSIONS = 0x4;
|
||||
|
||||
/**
|
||||
* @brief This is the configuration byte which will be written to the setup register after
|
||||
@ -39,7 +41,8 @@ static const DeviceCommandId_t READ_CONVERSIONS = 0x3;
|
||||
* written to the setup register
|
||||
*
|
||||
*/
|
||||
static const uint8_t SETUP = 0b01101000;
|
||||
static constexpr uint8_t SETUP_INT_CLOKED = 0b01101000;
|
||||
static constexpr uint8_t SETUP_EXT_CLOCKED = 0b01111000;
|
||||
|
||||
/**
|
||||
* @brief This values will always be written to the ADC conversion register to specify the
|
||||
@ -51,12 +54,14 @@ static const uint8_t SETUP = 0b01101000;
|
||||
*/
|
||||
static const uint8_t CONVERSION = 0b10101001;
|
||||
|
||||
static const uint8_t SUS_DATA_SET_ID = READ_CONVERSIONS;
|
||||
static const uint8_t SUS_DATA_SET_ID = READ_EXT_TIMED_CONVERSIONS;
|
||||
|
||||
/** Size of data replies. Temperature and 6 channel convesions (AIN0 - AIN5) */
|
||||
static const uint8_t SIZE_READ_CONVERSIONS = 14;
|
||||
static const uint8_t SIZE_READ_INT_CONVERSIONS = 14;
|
||||
// 6 * conv byte, 6 * 0 and one trailing zero
|
||||
static constexpr uint8_t SIZE_READ_EXT_CONVERSIONS = 13;
|
||||
|
||||
static const uint8_t MAX_CMD_SIZE = SIZE_READ_CONVERSIONS;
|
||||
static const uint8_t MAX_CMD_SIZE = 16;
|
||||
|
||||
static const uint8_t POOL_ENTRIES = 7;
|
||||
|
||||
|
@ -78,7 +78,6 @@ debugging. */
|
||||
|
||||
#define OBSW_TEST_LIBGPIOD 0
|
||||
#define OBSW_TEST_RADIATION_SENSOR_HANDLER 0
|
||||
#define OBSW_TEST_SUS 0
|
||||
#define OBSW_TEST_SUS_HANDLER 0
|
||||
#define OBSW_TEST_PLOC_HANDLER 0
|
||||
#define OBSW_TEST_BPX_BATT 0
|
||||
|
@ -1,7 +1 @@
|
||||
/**
|
||||
* \file logicalAddresses.cpp
|
||||
*
|
||||
* \date 06.11.2019
|
||||
*/
|
||||
|
||||
#include "addresses.h"
|
||||
|
@ -67,12 +67,12 @@ enum gpioId_t {
|
||||
CS_SUS_10,
|
||||
CS_SUS_11,
|
||||
|
||||
SPI_MUX_BIT_0,
|
||||
SPI_MUX_BIT_1,
|
||||
SPI_MUX_BIT_2,
|
||||
SPI_MUX_BIT_3,
|
||||
SPI_MUX_BIT_4,
|
||||
SPI_MUX_BIT_5,
|
||||
SPI_MUX_BIT_6,
|
||||
|
||||
CS_RAD_SENSOR,
|
||||
|
||||
|
@ -154,7 +154,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) {
|
||||
|
||||
#if OBSW_ADD_SUN_SENSORS == 1
|
||||
|
||||
bool addSus0 = false;
|
||||
bool addSus0 = true;
|
||||
bool addSus1 = false;
|
||||
bool addSus2 = false;
|
||||
bool addSus3 = false;
|
||||
@ -162,7 +162,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) {
|
||||
bool addSus5 = false;
|
||||
bool addSus6 = false;
|
||||
bool addSus7 = false;
|
||||
bool addSus8 = true;
|
||||
bool addSus8 = false;
|
||||
bool addSus9 = false;
|
||||
bool addSus10 = false;
|
||||
bool addSus11 = false;
|
||||
@ -177,18 +177,19 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) {
|
||||
if (addSus0) {
|
||||
/* Write setup */
|
||||
thisSequence->addSlot(objects::SUS_0, length * 0.933, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::SUS_0, length * 0.933, SusHandler::FIRST_WRITE);
|
||||
// thisSequence->addSlot(objects::SUS_0, length * 0.933, SusHandler::FIRST_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_0, length * 0.933, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_0, length * 0.933, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_0, length * 0.933, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::SUS_0, length * 0.933, DeviceHandlerIF::GET_READ);
|
||||
/* Start ADC conversions */
|
||||
thisSequence->addSlot(objects::SUS_0, length * 0.934, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
// thisSequence->addSlot(objects::SUS_0, length * 0.934, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::SUS_0, length * 0.934, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_0, length * 0.934, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_0, length * 0.934, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::SUS_0, length * 0.934, DeviceHandlerIF::GET_READ);
|
||||
/* Read ADC conversions */
|
||||
thisSequence->addSlot(objects::SUS_0, length * 0.935, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
// thisSequence->addSlot(objects::SUS_0, length * 0.935, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::SUS_0, length * 0.935, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_0, length * 0.935, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_0, length * 0.935, DeviceHandlerIF::SEND_READ);
|
||||
@ -340,7 +341,8 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) {
|
||||
if (addSus8) {
|
||||
/* Write setup */
|
||||
thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::SUS_8, length * 0.921, SusHandler::FIRST_WRITE);
|
||||
// thisSequence->addSlot(objects::SUS_8, length * 0.921, SusHandler::FIRST_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_READ);
|
||||
@ -361,18 +363,19 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) {
|
||||
if (addSus9) {
|
||||
/* Write setup */
|
||||
thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::SUS_9, length * 0.924, SusHandler::FIRST_WRITE);
|
||||
// thisSequence->addSlot(objects::SUS_9, length * 0.924, SusHandler::FIRST_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_READ);
|
||||
/* Start ADC conversions */
|
||||
thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
// thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_READ);
|
||||
/* Read ADC conversions */
|
||||
thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
// thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_READ);
|
||||
|
Loading…
Reference in New Issue
Block a user