mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 11:29:58 +03:00
Move DMA IRQ acknowledge to before the callback as it's edge triggered (#14514)
* Remove superfluous comments * Move DMA IRQ acknowledge to before the callback as it's edge triggered
This commit is contained in:
parent
35aac9f924
commit
01329e3350
2 changed files with 9 additions and 27 deletions
|
@ -160,18 +160,6 @@ void spiPinConfigure(const struct spiPinConfig_s *pConfig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
static spi_inst_t *getSpiInstanceByDevice(SPI_TypeDef *spi)
|
|
||||||
{
|
|
||||||
if (spi == SPI0) {
|
|
||||||
return spi0;
|
|
||||||
} else if (spi == SPI1) {
|
|
||||||
return spi1;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void spiSetClockFromSpeed(spi_inst_t *spi, uint16_t speed)
|
static void spiSetClockFromSpeed(spi_inst_t *spi, uint16_t speed)
|
||||||
{
|
{
|
||||||
uint32_t freq = spiCalculateClock(speed);
|
uint32_t freq = spiCalculateClock(speed);
|
||||||
|
@ -219,14 +207,6 @@ Must be SPI_MSB_FIRST, no other values supported on the PL022
|
||||||
|
|
||||||
void spiInitDevice(SPIDevice device)
|
void spiInitDevice(SPIDevice device)
|
||||||
{
|
{
|
||||||
// maybe here set getSpiInstanceByDevice(spi->dev) SPI device with
|
|
||||||
// settings like
|
|
||||||
// STM does
|
|
||||||
//SetRXFIFOThreshold ...QF (1/4 full presumably)
|
|
||||||
// Init -> full duplex, master, 8biut, baudrate, MSBfirst, no CRC,
|
|
||||||
// Clock = PolarityHigh, Phase_2Edge
|
|
||||||
|
|
||||||
|
|
||||||
const spiDevice_t *spi = &spiDevice[device];
|
const spiDevice_t *spi = &spiDevice[device];
|
||||||
|
|
||||||
if (!spi->dev) {
|
if (!spi->dev) {
|
||||||
|
|
|
@ -63,21 +63,23 @@ void dma_irq_handler(bool isIrq1)
|
||||||
// channel equates to index in the dmaDescriptors array
|
// channel equates to index in the dmaDescriptors array
|
||||||
for (uint8_t channel = 0; channel < DMA_LAST_HANDLER; channel++) {
|
for (uint8_t channel = 0; channel < DMA_LAST_HANDLER; channel++) {
|
||||||
if (status & (1u << channel)) {
|
if (status & (1u << channel)) {
|
||||||
uint8_t index = DMA_CHANNEL_TO_INDEX(channel);
|
// Acknowledge the interrupt for this channel as it is edge, not
|
||||||
// Call the handler if it is set
|
// level triggered and the callback may trigger another DMA
|
||||||
if (dmaDescriptors[index].irqHandlerCallback) {
|
|
||||||
dmaDescriptors[index].irqHandlerCallback(&dmaDescriptors[index]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Acknowledge the interrupt for this channel
|
|
||||||
if (isIrq1) {
|
if (isIrq1) {
|
||||||
dma_channel_acknowledge_irq1(channel);
|
dma_channel_acknowledge_irq1(channel);
|
||||||
} else {
|
} else {
|
||||||
dma_channel_acknowledge_irq0(channel);
|
dma_channel_acknowledge_irq0(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t index = DMA_CHANNEL_TO_INDEX(channel);
|
||||||
|
// Call the handler if it is set
|
||||||
|
if (dmaDescriptors[index].irqHandlerCallback) {
|
||||||
|
dmaDescriptors[index].irqHandlerCallback(&dmaDescriptors[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void dma_irq0_handler(void)
|
void dma_irq0_handler(void)
|
||||||
{
|
{
|
||||||
dma_irq_handler(false);
|
dma_irq_handler(false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue