macro hook allowing consumers to limit loops
This commit is contained in:
parent
41625a9b63
commit
4a2dcaa2fa
|
@ -28,6 +28,7 @@
|
|||
#include "osal.h"
|
||||
#include "board.h"
|
||||
#include "halconf.h"
|
||||
#include "limited_wait.h"
|
||||
|
||||
/* Error checks on the configuration header file.*/
|
||||
#if !defined(HAL_USE_PAL)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
// this hook allows rusEFI to fail gracefully instead of on hanging
|
||||
#ifndef LIMITED_WHILE_LOOP
|
||||
#define LIMITED_WHILE_LOOP(msg, condition) { (void)msg ; while (condition) ; }
|
||||
#endif
|
|
@ -703,14 +703,12 @@ uint16_t spi_lld_polled_exchange(SPIDriver *spip, uint16_t frame) {
|
|||
SPI_CR2_DS_0)) {
|
||||
volatile uint8_t *spidr = (volatile uint8_t *)&spip->spi->DR;
|
||||
*spidr = (uint8_t)frame;
|
||||
while ((spip->spi->SR & SPI_SR_RXNE) == 0)
|
||||
;
|
||||
LIMITED_WHILE_LOOP("SPI_SR_RXNE", (spip->spi->SR & SPI_SR_RXNE) == 0);
|
||||
return (uint16_t)*spidr;
|
||||
}
|
||||
else {
|
||||
spip->spi->DR = frame;
|
||||
while ((spip->spi->SR & SPI_SR_RXNE) == 0)
|
||||
;
|
||||
LIMITED_WHILE_LOOP("SPI_SR_RXNE", (spip->spi->SR & SPI_SR_RXNE) == 0);
|
||||
return spip->spi->DR;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue