Skip to content

Commit

Permalink
[H7] Use channel member for H7 DMA request
Browse files Browse the repository at this point in the history
  • Loading branch information
ezshinoda committed Jun 5, 2019
1 parent d486c47 commit e18c4ec
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 23 deletions.
5 changes: 1 addition & 4 deletions src/main/drivers/adc_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,9 @@ typedef struct adcDevice_s {
ADC_TypeDef* ADCx;
rccPeriphTag_t rccADC;
#if !defined(USE_DMA_SPEC)
#if defined(STM32F4) || defined(STM32F7)
#if defined(STM32F4) || defined(STM32F7) || defined(STM32H7)
DMA_Stream_TypeDef* DMAy_Streamx;
uint32_t channel;
#elif defined(STM32H7)
DMA_Stream_TypeDef* DMAy_Streamx;
uint32_t request;
#else
DMA_Channel_TypeDef* DMAy_Channelx;
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/main/drivers/adc_stm32h7xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ const adcDevice_t adcHardware[ADCDEV_COUNT] = {
.ADCx = ADC1_INSTANCE,
.rccADC = RCC_AHB1(ADC12),
.DMAy_Streamx = ADC1_DMA_STREAM,
.request = DMA_REQUEST_ADC1,
.channel = DMA_REQUEST_ADC1,
},
{ .ADCx = ADC2_INSTANCE,
.rccADC = RCC_AHB1(ADC12),
.DMAy_Streamx = ADC2_DMA_STREAM,
.request = DMA_REQUEST_ADC2,
.channel = DMA_REQUEST_ADC2,
},
// ADC3 can be serviced by BDMA also, but we settle for DMA1 or 2 (for now).
{
.ADCx = ADC3_INSTANCE,
.rccADC = RCC_AHB4(ADC3),
.DMAy_Streamx = ADC3_DMA_STREAM,
.request = DMA_REQUEST_ADC3,
.channel = DMA_REQUEST_ADC3,
}
};

Expand Down Expand Up @@ -361,7 +361,7 @@ void adcInit(const adcConfig_t *config)
dmaInit(dmaIdentifier, OWNER_ADC, RESOURCE_INDEX(dev));

adc->DmaHandle.Instance = adc->DMAy_Streamx;
adc->DmaHandle.Init.Request = adc->request;
adc->DmaHandle.Init.Request = adc->channel;
adc->DmaHandle.Init.Direction = DMA_PERIPH_TO_MEMORY;
adc->DmaHandle.Init.PeriphInc = DMA_PINC_DISABLE;
adc->DmaHandle.Init.MemInc = DMA_MINC_ENABLE;
Expand Down
5 changes: 0 additions & 5 deletions src/main/drivers/light_ws2811strip_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,8 @@ bool ws2811LedStripHardwareInit(ioTag_t ioTag)
uint32_t dmaChannel = dmaSpec->channel;
#else
dmaStream_t *dmaRef = timerHardware->dmaRef;
#ifdef STM32H7
uint32_t dmaChannel = timerHardware->dmaRequest;
#else
uint32_t dmaChannel = timerHardware->dmaChannel;
#endif
#endif


if (dmaRef == NULL) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/drivers/pwm_output_dshot_hal_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ P - High - High -
motor->dmaBuffer[DSHOT_DMA_BUFFER_SIZE-1] = 0; // XXX Is this necessary?

motor->hdma_tim.Instance = timerHardware->dmaRef;
motor->hdma_tim.Init.Request = timerHardware->dmaRequest;
motor->hdma_tim.Init.Request = timerHardware->dmaChannel;

/* Link hdma_tim to hdma[x] (channelx) */
__HAL_LINKDMA(&motor->TimHandle, hdma[motor->timerDmaIndex], motor->hdma_tim);
Expand Down
11 changes: 6 additions & 5 deletions src/main/drivers/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,13 @@ typedef struct timerHardware_s {
DMA_Channel_TypeDef *dmaRefConfigured;
#endif
#else
#if defined(STM32F4) || defined(STM32F7)
DMA_Stream_TypeDef *dmaRef;
uint32_t dmaChannel;
#elif defined(STM32H7)
#if defined(STM32F4) || defined(STM32F7) || defined(STM32H7)
DMA_Stream_TypeDef *dmaRef;
uint8_t dmaRequest;

// For F4 and F7, dmaChannel is channel for DMA1 or DMA2.
// For H7, dmaChannel is DMA request number for DMAMUX

uint32_t dmaChannel; // XXX Can be much smaller (e.g. uint8_t)
#else
DMA_Channel_TypeDef *dmaRef;
#endif
Expand Down
4 changes: 0 additions & 4 deletions src/main/drivers/transponder_ir_io_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ void transponderIrHardwareInit(ioTag_t ioTag, transponder_t *transponder)
uint32_t dmaChannel = dmaSpec->channel;
#else
dmaStream_t *dmaRef = timerHardware->dmaRef;
#ifdef STM32H7
uint32_t dmaChannel = timerHardware->dmaRequest;
#else
uint32_t dmaChannel = timerHardware->dmaChannel;
#endif
#endif

if (dmaRef == NULL) {
Expand Down

0 comments on commit e18c4ec

Please sign in to comment.