rw chip select decoding

This commit is contained in:
Jakob Meier 2021-06-21 17:15:19 +02:00
parent 428ae97e0e
commit 8d8bb41334
6 changed files with 57 additions and 11 deletions

View File

@ -551,9 +551,19 @@ void ObjectFactory::produce(void* args){
new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, plocUartCookie);
GpioCookie* gpioCookieRw = new GpioCookie;
GpiodRegular* rw1ChipSelect = new GpiodRegular(std::string("gpiochip5"), 7,
std::string("Chip Select RW 1"), gpio::OUT, 1);
gpioCookieRw->addGpio(gpioIds::RW1, rw1ChipSelect);
GpioCallback* csRw1 = new GpioCallback(std::string("Chip select reaction wheel 1"), gpio::OUT,
1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF);
gpioCookieRw->addGpio(gpioIds::EN_RW1, csRw1);
GpioCallback* csRw2 = new GpioCallback(std::string("Chip select reaction wheel 2"), gpio::OUT,
1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF);
gpioCookieRw->addGpio(gpioIds::EN_RW2, csRw2);
GpioCallback* csRw3 = new GpioCallback(std::string("Chip select reaction wheel 3"), gpio::OUT,
1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF);
gpioCookieRw->addGpio(gpioIds::EN_RW3, csRw3);
GpioCallback* csRw4 = new GpioCallback(std::string("Chip select reaction wheel 4"), gpio::OUT,
1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF);
gpioCookieRw->addGpio(gpioIds::EN_RW4, csRw4);
gpioComIF->addGpios(gpioCookieRw);
auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::RW1, "/dev/spidev2.0",

View File

@ -45,11 +45,13 @@ void initSpiCsDecoder(GpioIF* gpioComIF) {
GpiodRegular* spiMuxBit6 = new GpiodRegular(std::string("gpiochip7"), 18,
std::string("SPI Mux Bit 6"), gpio::OUT, 0);
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_6, spiMuxBit6);
GpiodRegular* enRwDecoder = new GpiodRegular(std::string("gpiochip5"), 17,
std::string("EN_RW_CS"), gpio::OUT, 0);
spiMuxGpios->addGpio(gpioIds::EN_RW_CS, enRwDecoder);
result = gpioComInterface->addGpios(spiMuxGpios);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "initSpiCsDecoder: Failed to add mux bit gpios to gpioComIF"
<< std::endl;
sif::error << "initSpiCsDecoder: Failed to add mux bit gpios to gpioComIF" << std::endl;
return;
}
}
@ -218,6 +220,26 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value
selectY6();
break;
}
case(gpioIds::EN_RW1): {
enableRwDecoder();
selectY0();
break;
}
case(gpioIds::EN_RW2): {
enableRwDecoder();
selectY1();
break;
}
case(gpioIds::EN_RW3): {
enableRwDecoder();
selectY3();
break;
}
case(gpioIds::EN_RW4): {
enableRwDecoder();
selectY4();
break;
}
default:
sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl;
}
@ -251,6 +273,13 @@ void enableDecoderInterfaceBoardIc2() {
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
}
void enableRwDecoder() {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullHigh(gpioIds::EN_RW_CS);
}
void selectY0() {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
@ -303,6 +332,7 @@ void disableAllDecoder() {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullLow(gpioIds::EN_RW_CS);
}
}

View File

@ -43,6 +43,11 @@ namespace gpioCallbacks {
*/
void enableDecoderInterfaceBoardIc2();
/**
* @brief Enables the reaction wheel chip select decoder (IC3).
*/
void enableRwDecoder();
/**
* @brief This function disables all decoder.
*/

2
fsfw

@ -1 +1 @@
Subproject commit d700fb551c85393b58a3ada96fbd3f807217d14b
Subproject commit cae69d540097acba46bffa47fd7afc6a8a19bd15

@ -1 +1 @@
Subproject commit ae322d981bd1ed8411a058ba6b4dc185f00a12f3
Subproject commit 8fe5d0afa0857025d9dee3c6f266c2503a22c517

View File

@ -70,10 +70,11 @@ namespace gpioIds {
PAPB_BUSY_N,
PAPB_EMPTY,
RW1,
RW2,
RW3,
RW4
EN_RW1,
EN_RW2,
EN_RW3,
EN_RW4,
EN_RW_CS
};
}