AnsweredAssumed Answered

Generate conditional Init with CubeMX

Question asked by Rémy Tremblay on May 22, 2018
Latest reply on May 22, 2018 by pavel a

Hi,

 

Is there a way to generate a condition inside the initialization code generated by CubeMx in TrueSTUDIO?

 

I want to do something like this inside the MX_SPI2_Init() :

    if (HAL_GPIO_ReadPin(GPIOI, GPIO_PIN_11) == GPIO_PIN_SET) {
            hSPI2.Init.Mode = SPI_MODE_SLAVE;
    } else {
            hSPI2.Init.Mode = SPI_MODE_MASTER;
    }

Currently, I can only have one or the other.

 

Is it possible to do it with CubeMx or I should override the generated initialization code by hand?

 

Thank you.

Outcomes