2018-05-22 12:29 PM
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.
#if-else #condition #init #cubemxSolved! Go to Solution.
2018-05-22 02:14 PM
> Is it possible to do it with CubeMx or I should override the generated initialization code by hand?
By hand. CubeMx seems to place initialization of GPIOs before all other components, so if you configure the pin as input, it should work.
-- pa
2018-05-22 02:14 PM
> Is it possible to do it with CubeMx or I should override the generated initialization code by hand?
By hand. CubeMx seems to place initialization of GPIOs before all other components, so if you configure the pin as input, it should work.
-- pa