#pragma once

#include <fsfw_hal/common/gpio/gpioDefinitions.h>

class GpioIF;

namespace gpioCallbacks {

/**
 * @brief   This function implements the decoding to multiply gpios by using the decoder
 *          chips SN74LVC138APWR on the TCS board and the interface board.
 */
void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Levels 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(GpioIF* gpioIF);

/**
 * @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(GpioIF* gpioIF);

/**
 * @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 enableDecoderInterfaceBoardIc1(GpioIF* gpioIF);

/**
 * @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 enableDecoderInterfaceBoardIc2(GpioIF* gpioIF);

void disableDecoderTcsIc1(GpioIF* gpioIF);
void disableDecoderTcsIc2(GpioIF* gpioIF);
void disableDecoderInterfaceBoardIc1(GpioIF* gpioIF);
void disableDecoderInterfaceBoardIc2(GpioIF* gpioIF);

/**
 * @brief   Enables the reaction wheel chip select decoder (IC3).
 */
void enableRwDecoder(GpioIF* gpioIF);
void disableRwDecoder(GpioIF* gpioIF);

/**
 * @brief   This function disables all decoder.
 */
void disableAllDecoder(GpioIF* gpioIF);

/** The following functions enable the appropriate channel of the currently enabled decoder */
void selectY0(GpioIF* gpioIF);
void selectY1(GpioIF* gpioIF);
void selectY2(GpioIF* gpioIF);
void selectY3(GpioIF* gpioIF);
void selectY4(GpioIF* gpioIF);
void selectY5(GpioIF* gpioIF);
void selectY6(GpioIF* gpioIF);
void selectY7(GpioIF* gpioIF);

}  // namespace gpioCallbacks