STM32 3-wire SPI MOSI high impedance
The SPI peripheral of the STM32F4 is configureable for a single wire bidirectional half duplex transfer. In this mode the MOSI pin is used as a master or the MISO as a slave, no need to short the pins together on the STM32 side as only one is used.

For that you need to use the BIDIMODE (=1) bit in SPI_CR1. To set the data direction, you have to use the BIDIOE bit (1 = output, 0 = input) also in SPI_CR1.

So to send data you set BIDIOE to 1 and transfer all the data with writing to SPI_DR after that you reset BIDIOE to 0 and receive data with dummy writing something to SPI_DR (in order to generate the clock, which will tell the slave to send the data) and reading the received data from SPI_DR.

I haven't used this feature yet, and I do not use the peripheral libraries provided by ST, so I can't comment on their capability on using this feature.