|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
#include "spi.h"
|
|
|
|
|
|
|
|
|
|
#define SPI_BASE ((SPI_TypeDef *)spiBase_Addr_List[spi_hw_ch])
|
|
|
|
|
|
|
|
|
|
// https://controllerstech.com/spi-using-registers-in-stm32/
|
|
|
|
|
|
|
|
|
|
void spi_initMater(spiCH_t_spi_hw_ch)
|
|
|
|
@ -25,5 +27,14 @@ void spi_initMater(spiCH_t_spi_hw_ch)
|
|
|
|
|
|
|
|
|
|
uint8_t spi_trx(spiCH_t_spi_hw_ch, uint8_t tx_data)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
// wait for SPY ready
|
|
|
|
|
while((SPI_BASE->SR) & (1 << 7));
|
|
|
|
|
|
|
|
|
|
// load tx data
|
|
|
|
|
SPI_BASE->DR = tx_data;
|
|
|
|
|
|
|
|
|
|
// Wait for RXNE flag to be set which indicates transmit complete
|
|
|
|
|
while(!((SPI_BASE->SR) & (1<<0));
|
|
|
|
|
|
|
|
|
|
return SPI_BASE->DR;
|
|
|
|
|
}
|
|
|
|
|