mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
Fix SPI sequencing in spiInternalReadWriteBufPolled for H7
This commit is contained in:
parent
5933d96bc3
commit
da849318b3
1 changed files with 10 additions and 16 deletions
|
@ -225,26 +225,20 @@ void spiInternalResetStream(dmaChannelDescriptor_t *descriptor)
|
||||||
static bool spiInternalReadWriteBufPolled(SPI_TypeDef *instance, const uint8_t *txData, uint8_t *rxData, int len)
|
static bool spiInternalReadWriteBufPolled(SPI_TypeDef *instance, const uint8_t *txData, uint8_t *rxData, int len)
|
||||||
{
|
{
|
||||||
#if defined(STM32H7)
|
#if defined(STM32H7)
|
||||||
int txLen = len;
|
LL_SPI_SetTransferSize(instance, len);
|
||||||
int rxLen = len;
|
|
||||||
|
|
||||||
LL_SPI_SetTransferSize(instance, txLen);
|
|
||||||
LL_SPI_Enable(instance);
|
LL_SPI_Enable(instance);
|
||||||
LL_SPI_StartMasterTransfer(instance);
|
LL_SPI_StartMasterTransfer(instance);
|
||||||
while (txLen || rxLen) {
|
while (len) {
|
||||||
if (txLen && LL_SPI_IsActiveFlag_TXP(instance)) {
|
while (!LL_SPI_IsActiveFlag_TXP(instance));
|
||||||
uint8_t b = txData ? *(txData++) : 0xFF;
|
uint8_t b = txData ? *(txData++) : 0xFF;
|
||||||
LL_SPI_TransmitData8(instance, b);
|
LL_SPI_TransmitData8(instance, b);
|
||||||
txLen--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rxLen && LL_SPI_IsActiveFlag_RXP(instance)) {
|
while (!LL_SPI_IsActiveFlag_RXP(instance));
|
||||||
uint8_t b = LL_SPI_ReceiveData8(instance);
|
b = LL_SPI_ReceiveData8(instance);
|
||||||
if (rxData) {
|
if (rxData) {
|
||||||
*(rxData++) = b;
|
*(rxData++) = b;
|
||||||
}
|
|
||||||
rxLen--;
|
|
||||||
}
|
}
|
||||||
|
--len;
|
||||||
}
|
}
|
||||||
while (!LL_SPI_IsActiveFlag_EOT(instance));
|
while (!LL_SPI_IsActiveFlag_EOT(instance));
|
||||||
LL_SPI_ClearFlag_TXTF(instance);
|
LL_SPI_ClearFlag_TXTF(instance);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue