gpt4 book ai didi

c - 编译 Dcmi 时出现 xError

转载 作者:太空宇宙 更新时间:2023-11-04 03:36:39 25 4
gpt4 key购买 nike

请原谅我的英语。

我想在 HAL 中设置 DCMI,因为使用 CooCox 必须从生成器 cubeMX 中复制代码

编译器不喜欢这一行:

__HAL_LINKDMA(hdcmi, DMA_Handle, hdma_dcmi);

代码:

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);
}

错误:

   [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] ^

最佳答案

使用 __HAL_LINKDMA(&hdcmi, DMA_Handle, hdma_dcmi); 似乎可以解决。

关于c - 编译 Dcmi 时出现 xError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32198425/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com