Excuse my English.
I want to set up DCMI in HAL, because use CooCox have to copy the code from the generator cubeMX
The compiler does not like the line:
__HAL_LINKDMA(hdcmi, DMA_Handle, hdma_dcmi);
Code:
void DCMI_DMA_init(void){
GPIO_InitTypeDef GPIO_InitStruct;
__GPIOE_CLK_ENABLE();
__GPIOA_CLK_ENABLE();
__GPIOC_CLK_ENABLE();
__GPIOD_CLK_ENABLE();
__DCMI_CLK_ENABLE();
__DMA2_CLK_ENABLE();
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_2);
HAL_NVIC_SetPriority(DCMI_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DCMI_IRQn);
/*
PE4 ------> DCMI_D4
PE5 ------> DCMI_D6
PE6 ------> DCMI_D7
PA6 ------> DCMI_PIXCK
PC6 ------> DCMI_D0
PC7 ------> DCMI_D1
PC8 ------> DCMI_D2
PC9 ------> DCMI_D3
PD3 ------> DCMI_D5
*/
GPIO_InitStruct.Pin = GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
hdcmi.Instance = DCMI;
hdcmi.Init.SynchroMode = DCMI_SYNCHRO_HARDWARE;
hdcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_FALLING;
hdcmi.Init.VSPolarity = DCMI_VSPOLARITY_HIGH;
hdcmi.Init.HSPolarity = DCMI_HSPOLARITY_HIGH;
hdcmi.Init.CaptureRate = DCMI_CR_ALL_FRAME;
hdcmi.Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B;
hdcmi.Init.JPEGMode = DCMI_JPEG_DISABLE;
HAL_DCMI_Init(&hdcmi);
hdma_dcmi.Instance = DMA2_Stream1;
hdma_dcmi.Init.Channel = DMA_CHANNEL_1;
hdma_dcmi.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_dcmi.Init.PeriphInc = DMA_PINC_ENABLE;
hdma_dcmi.Init.MemInc = DMA_MINC_ENABLE;
hdma_dcmi.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
hdma_dcmi.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_dcmi.Init.Mode = DMA_NORMAL;
hdma_dcmi.Init.Priority = DMA_PRIORITY_VERY_HIGH;
hdma_dcmi.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
hdma_dcmi.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
hdma_dcmi.Init.MemBurst = DMA_MBURST_SINGLE;
hdma_dcmi.Init.PeriphBurst = DMA_PBURST_SINGLE;
HAL_DMA_Init(&hdma_dcmi);
// Macro code:
//hdcmi->DMA_Handle = &hdma_dcmi;
//hdma_dcmi.Parent = hdcmi;
__HAL_LINKDMA(hdcmi, DMA_Handle, hdma_dcmi);
}
Error:
[cc] C:\.......\libs\ov7670\OV7670_control.c: In function 'DCMI_DMA_init':
[cc] C:\.......\STM32F429xx_cmsisboot\source\Hal/stm32f4xx_hal_def.h:95:43: error: invalid type argument of '->' (have 'DCMI_HandleTypeDef')
[cc] (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
[cc] ^
[cc] C:\.......\libs\ov7670\OV7670_control.c:249:2: note: in expansion of macro '__HAL_LINKDMA'
[cc] __HAL_LINKDMA(hdcmi, DMA_Handle, hdma_dcmi);
[cc] ^
[cc] C:\.......\STM32F429xx_cmsisboot\source\Hal/stm32f4xx_hal_def.h:96:55: error: incompatible types when assigning to type 'void *' from type 'DCMI_HandleTypeDef'
[cc] (__DMA_HANDLE__).Parent = (__HANDLE__); \
[cc] ^
[cc] C:\.......\libs\ov7670\OV7670_control.c:249:2: note: in expansion of macro '__HAL_LINKDMA'
[cc] __HAL_LINKDMA(hdcmi, DMA_Handle, hdma_dcmi);
[cc] ^
Using __HAL_LINKDMA(&hdcmi, DMA_Handle, hdma_dcmi); instead seems to solve.