work on implementation of spi hardware driver

interrupts
polymurph 3 years ago
parent effed17ed8
commit 66aaacb37b

@ -236,7 +236,10 @@ typedef enum{
SPI_CH_2
} spiCH_t;
static const uint32_t spiBase_Addr_List[MAX_SPI_CHANNEL_COUNT] = {
SPI1_BASE,
SPI2_BASE
};
#ifdef __cplusplus

@ -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;
}

Loading…
Cancel
Save