Complete the code to start the SPI data transfer by enabling the SPI peripheral.
SPI->[1] |= SPI_CR1_SPE;The SPI control register 1 (CR1) contains the SPE bit which enables the SPI peripheral.
Complete the code to wait until the SPI transmit buffer is empty before sending data.
while (!(SPI->SR & [1]));
The TXE (Transmit buffer empty) flag in the status register (SR) indicates when the transmit buffer is ready for new data.
Fix the error in the code that writes data to the SPI data register.
SPI->[1] = data;The data register (DR) is used to write data to be transmitted via SPI.
Fill both blanks to check if SPI is busy and wait until it is free before disabling it.
while (SPI->SR & [1]) {} SPI->[2] &= ~SPI_CR1_SPE;
The BSY flag in the status register (SR) shows if SPI is busy. The SPI is disabled by clearing SPE bit in CR1.
Fill all three blanks to create a function that sends a byte over SPI and waits for completion.
void SPI_SendByte(uint8_t data) {
while (!(SPI->SR & [1]));
SPI->[2] = data;
while (SPI->SR & [3]) {}
}This function waits for the transmit buffer to be empty (TXE), writes data to the data register (DR), then waits until SPI is not busy (BSY) before returning.