I am using a BlueNRG-MS connected to an STM32L4 MCU over an SPI bus. I was able to make it work using code from the BlueNRG development kit, but I could not make it work if I generated code using CubeMX. After a lot of trial and error, I realized that the CubeMX code was configuring all 4 SPI pins as alternate function (AF5_SPI2), but the BlueNRG example was configuring the slave select pin as an output push pull, which was working. My question is, which is supposed to be correct? As it is, when I enable the SPI2 peripheral in CubeMX, it automatically configures all 4 SPI pins as alternate function, with no other options. I don't know if this is a bug in CubeMX, or if I have some other conflicting configuration that is breaking my setup.