Setting up SPI between a STM32F4-Discovery Board and a MCP4151 Digital Pot
I am not sure is this helps any more given how old this post is. However, I noticed that you are setting PA5 and PA7 as Alternate Function, but not actually specifying which Alternate function through a GPIO_InitStruct.Alternate assignment.