SPI receive
SPI receive funtion not working correctly. Only one time is working, where is my mistake ?
thanks
void SPITransReceive(SPI_TypeDef* SPIx,uint8_t data,uint8_t *pbuff,uint8_t dataSize){
while(dataSize > 0){
while((SPIx->SR & SPI_I2S_FLAG_TXE) == RESET) {} ;
//SPI_SendData8(SPIx,data);
//SPIx->DR = data ;
*(__IO uint8_t *)(&SPIx->DR) = data;//16 bit type cast ;
while((SPIx->SR & SPI_I2S_FLAG_RXNE) == RESET) {} ;
SPI_I2S_ClearFlag(SPIx,SPI_I2S_FLAG_RXNE);
*pbuff = *(__IO uint8_t *)(&SPIx->DR);
++pbuff ;
--dataSize ;
}
}