macro hook allowing consumers to limit loops
This commit is contained in:
rusefillc 2024-08-08 11:17:48 -04:00
parent 41625a9b63
commit 4a2dcaa2fa
3 changed files with 9 additions and 4 deletions

View File

@ -28,6 +28,7 @@
#include "osal.h" #include "osal.h"
#include "board.h" #include "board.h"
#include "halconf.h" #include "halconf.h"
#include "limited_wait.h"
/* Error checks on the configuration header file.*/ /* Error checks on the configuration header file.*/
#if !defined(HAL_USE_PAL) #if !defined(HAL_USE_PAL)

View File

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

View File

@ -703,14 +703,12 @@ uint16_t spi_lld_polled_exchange(SPIDriver *spip, uint16_t frame) {
SPI_CR2_DS_0)) { SPI_CR2_DS_0)) {
volatile uint8_t *spidr = (volatile uint8_t *)&spip->spi->DR; volatile uint8_t *spidr = (volatile uint8_t *)&spip->spi->DR;
*spidr = (uint8_t)frame; *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; return (uint16_t)*spidr;
} }
else { else {
spip->spi->DR = frame; 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; return spip->spi->DR;
} }
} }