kopia lustrzana https://github.com/SP8EBC/ParaTNC
spi data race fix to be tested
rodzic
5b1173106a
commit
c5f9270941
|
@ -621,22 +621,22 @@ void spi_irq_handler(void) {
|
|||
*(uint8_t *)(&SPI2->DR) = spi_tx_buffer_ptr[spi_current_tx_cntr++];
|
||||
}
|
||||
else {
|
||||
while((SPI2->SR & SPI_SR_BSY) != 0) { // blocking!!
|
||||
do { // blocking!!
|
||||
// clear RX fifo while rest of bytes are transmitted
|
||||
do {
|
||||
spi_garbage = SPI2->DR & 0xFF;
|
||||
} while ((SPI2->SR & SPI_SR_RXNE) != 0);
|
||||
}
|
||||
} while ((SPI2->SR & SPI_SR_BSY) != 0);
|
||||
|
||||
// finish transmission
|
||||
spi_tx_state = SPI_TX_DONE;
|
||||
|
||||
// check if reception shall begin
|
||||
if (spi_rx_state == SPI_RX_WAITING_FOR_RX) {
|
||||
spi_rx_state = SPI_RX_RXING;
|
||||
|
||||
*(uint8_t *)(&SPI2->DR) = 0xFF;
|
||||
}
|
||||
// if (spi_rx_state == SPI_RX_WAITING_FOR_RX) {
|
||||
// spi_rx_state = SPI_RX_RXING;
|
||||
//
|
||||
// *(uint8_t *)(&SPI2->DR) = 0xFF;
|
||||
// }
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -648,6 +648,11 @@ void spi_irq_handler(void) {
|
|||
if (spi_rx_state == SPI_RX_RXING) {
|
||||
*(uint8_t *)(&SPI2->DR) = 0xFF;
|
||||
}
|
||||
else if (spi_rx_state == SPI_RX_WAITING_FOR_RX) {
|
||||
spi_rx_state = SPI_RX_RXING;
|
||||
|
||||
*(uint8_t *)(&SPI2->DR) = 0xFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "drivers/max31865.h"
|
||||
#include <math.h>
|
||||
|
||||
#define DATA_RACE_WORKAROUND
|
||||
|
||||
#define REFERENCE_RESISTOR 4300.0f
|
||||
|
||||
#define RTD_A 3.9083e-3
|
||||
|
@ -319,6 +321,12 @@ void max31865_pool(void) {
|
|||
// get a pointer to results
|
||||
result_ptr = spi_get_rx_data();
|
||||
|
||||
#ifdef DATA_RACE_WORKAROUND
|
||||
if ((max31865_current_config_register & 0xDF) == *(result_ptr + 1)) {
|
||||
result_ptr++;
|
||||
}
|
||||
#endif
|
||||
|
||||
// check communication results by comparing a value of config register
|
||||
if ((max31865_current_config_register & 0xDF) == *result_ptr) { // fifth bit read always zero
|
||||
// save raw results
|
||||
|
|
Ładowanie…
Reference in New Issue