mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 01:35:41 +03:00
G4 SPI DMA support
This commit is contained in:
parent
c283981d54
commit
ab66795eeb
10 changed files with 75 additions and 289 deletions
|
@ -543,7 +543,9 @@ void spiInitBusDMA()
|
|||
break;
|
||||
}
|
||||
#endif
|
||||
bus->dmaTxChannel = dmaTxChannelSpec->channel;
|
||||
bus->dmaTx = dmaGetDescriptorByIdentifier(dmaTxIdentifier);
|
||||
bus->dmaTx->stream = DMA_DEVICE_INDEX(dmaTxIdentifier);
|
||||
bus->dmaTx->channel = dmaTxChannelSpec->channel;
|
||||
dmaInit(dmaTxIdentifier, OWNER_SPI_MOSI, device + 1);
|
||||
break;
|
||||
}
|
||||
|
@ -564,16 +566,15 @@ void spiInitBusDMA()
|
|||
break;
|
||||
}
|
||||
#endif
|
||||
bus->dmaRxChannel = dmaRxChannelSpec->channel;
|
||||
bus->dmaRx = dmaGetDescriptorByIdentifier(dmaRxIdentifier);
|
||||
bus->dmaRx->stream = DMA_DEVICE_INDEX(dmaRxIdentifier);
|
||||
bus->dmaRx->channel = dmaRxChannelSpec->channel;
|
||||
dmaInit(dmaRxIdentifier, OWNER_SPI_MISO, device + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dmaTxIdentifier && dmaRxIdentifier) {
|
||||
bus->dmaTx = dmaGetDescriptorByIdentifier(dmaTxIdentifier);
|
||||
bus->dmaRx = dmaGetDescriptorByIdentifier(dmaRxIdentifier);
|
||||
|
||||
// Ensure streams are disabled
|
||||
spiInternalResetStream(bus->dmaRx);
|
||||
spiInternalResetStream(bus->dmaTx);
|
||||
|
@ -586,6 +587,10 @@ void spiInitBusDMA()
|
|||
dmaSetHandler(dmaRxIdentifier, spiRxIrqHandler, NVIC_PRIO_SPI_DMA, 0);
|
||||
|
||||
bus->useDMA = true;
|
||||
} else {
|
||||
// Disassociate channels from bus
|
||||
bus->dmaRx = (dmaChannelDescriptor_t *)NULL;
|
||||
bus->dmaTx = (dmaChannelDescriptor_t *)NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue