Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 2 months ago.
STM32 F411RE BurstSPI
Trying to port Burst to the STM32 F4 platform and hit a bit of a roadblock.
I have fastWrite working with the following
static SPI_HandleTypeDef SpiHandle; void BurstSPI::fastWrite(int data) { // Check if data is transmitted SpiHandle.Instance = (SPI_TypeDef *)(_spi.spi); while (!((__HAL_SPI_GET_FLAG(&SpiHandle, SPI_FLAG_TXE) != RESET) ? 1 : 0)); SpiHandle.Instance->DR =(uint16_t)data; }
having trouble clearing the RX buffer though, tried a bunch of different things with no success, i assumed the below would work as its mostly a direct port of the L152RE code, but no dice, any ideas?
SpiHandle.Instance = (SPI_TypeDef *)(_spi.spi); status = ((__HAL_SPI_GET_FLAG(&SpiHandle, SPI_FLAG_BSY) != RESET) ? 1 : 0); if(status){ while (!((__HAL_SPI_GET_FLAG(&SpiHandle, SPI_FLAG_RXNE) != RESET) ? 1 : 0)); uint16_t dummy = (uint16_t)SpiHandle.Instance->DR; }
This is unrelated to your problem, but I'm curious why you have expressions that evaluate to a boolean value, that you then apply extra logic to to convert to a 1 or 0, just in order to evaluate them as a boolean value in an if or while statement? Wouldn't this:
Just be this:
Appear to have got it working at least for my test cases Difference being wait till SPI isnt busy, then read RX, probably should have left the check if their was a byte available, but passes my tests.