mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 00:05:33 +03:00
Standardised the use of dma descriptor (outside of int)
This commit is contained in:
parent
ccd07cf03e
commit
b2fa0779ef
4 changed files with 16 additions and 11 deletions
|
@ -88,6 +88,7 @@ typedef enum {
|
|||
#define DMA_IT_FEIF ((uint32_t)0x00000001)
|
||||
|
||||
dmaIdentifier_e dmaGetIdentifier(const DMA_Stream_TypeDef* stream);
|
||||
dmaChannelDescriptor_t* getDmaDescriptor(const DMA_Stream_TypeDef* stream);
|
||||
|
||||
#else
|
||||
|
||||
|
|
|
@ -123,4 +123,14 @@ dmaIdentifier_e dmaGetIdentifier(const DMA_Stream_TypeDef* stream)
|
|||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
dmaChannelDescriptor_t* getDmaDescriptor(const DMA_Stream_TypeDef* stream)
|
||||
{
|
||||
for (int i = 0; i < DMA_MAX_DESCRIPTORS; i++) {
|
||||
if (dmaDescriptors[i].stream == stream) {
|
||||
return &dmaDescriptors[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -87,11 +87,7 @@ typedef struct {
|
|||
#else
|
||||
uint8_t dmaBuffer[MOTOR_DMA_BUFFER_SIZE];
|
||||
#endif
|
||||
#ifdef STM32F3
|
||||
dmaChannelDescriptor_t* dmaDescriptor;
|
||||
#else
|
||||
uint32_t dmaFlag;
|
||||
#endif
|
||||
#if defined(STM32F7)
|
||||
TIM_HandleTypeDef TimHandle;
|
||||
DMA_HandleTypeDef hdma_tim;
|
||||
|
|
|
@ -82,11 +82,10 @@ void pwmWriteDigital(uint8_t index, uint16_t value)
|
|||
packet <<= 1;
|
||||
}
|
||||
|
||||
DMA_Stream_TypeDef *stream = motor->timerHardware->dmaStream;
|
||||
TIM_DMACmd(motor->timerHardware->tim, motor->timerDmaSource, DISABLE);
|
||||
DMA_SetCurrDataCounter(stream, MOTOR_DMA_BUFFER_SIZE);
|
||||
DMA_ClearITPendingBit(stream, motor->dmaFlag);
|
||||
DMA_Cmd(stream, ENABLE);
|
||||
DMA_SetCurrDataCounter(motor->timerHardware->dmaStream, MOTOR_DMA_BUFFER_SIZE);
|
||||
DMA_CLEAR_FLAG(motor->dmaDescriptor, DMA_IT_TCIF);
|
||||
DMA_Cmd(motor->timerHardware->dmaStream, ENABLE);
|
||||
}
|
||||
|
||||
void pwmCompleteDigitalMotorUpdate(uint8_t motorCount)
|
||||
|
@ -169,6 +168,7 @@ void pwmDigitalMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t
|
|||
}
|
||||
|
||||
dmaInit(timerHardware->dmaIrqHandler, OWNER_MOTOR, RESOURCE_INDEX(motorIndex));
|
||||
motor->dmaDescriptor = getDmaDescriptor(stream);
|
||||
|
||||
DMA_Cmd(stream, DISABLE);
|
||||
DMA_DeInit(stream);
|
||||
|
@ -191,8 +191,6 @@ void pwmDigitalMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t
|
|||
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
|
||||
|
||||
DMA_Init(stream, &DMA_InitStructure);
|
||||
|
||||
motor->dmaFlag = dmaFlag_IT_TCIF(stream);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue