DCMI for f446re ,ov7670

Dependencies:   ILI9341_SPI OV7670_SCCB mbed

Committer:
tmnt
Date:
Sun Nov 20 12:06:27 2016 +0000
Revision:
2:a75d27406b2f
ADD PINMAP

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tmnt0:4e2fae6764b6 1#include "mbed.h"
tmnt0:4e2fae6764b6 2uint8_t frame_buffer[145][300]={0xff,0xff};
tmnt0:4e2fae6764b6 3
tmnt0:4e2fae6764b6 4DMA_HandleTypeDef dcmi_Dma;
tmnt0:4e2fae6764b6 5DCMI_HandleTypeDef dcmi;
tmnt0:4e2fae6764b6 6
tmnt0:4e2fae6764b6 7void dcmi_Init(){
tmnt0:4e2fae6764b6 8 frame_buffer[100][0]=0xFF;
tmnt0:4e2fae6764b6 9 frame_buffer[100][1]=0xFF;
tmnt0:4e2fae6764b6 10 GPIO_InitTypeDef GPIO_InitStruct;
tmnt0:4e2fae6764b6 11
tmnt0:4e2fae6764b6 12 /*Configure GPIO pin : PA8 MCO1 for cam XCLK*/
tmnt0:4e2fae6764b6 13 HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1);
tmnt0:4e2fae6764b6 14 __GPIOA_CLK_ENABLE();
tmnt0:4e2fae6764b6 15 GPIO_InitStruct.Pin = GPIO_PIN_8;
tmnt0:4e2fae6764b6 16 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
tmnt0:4e2fae6764b6 17 GPIO_InitStruct.Pull = GPIO_NOPULL;
tmnt0:4e2fae6764b6 18 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
tmnt0:4e2fae6764b6 19 GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
tmnt0:4e2fae6764b6 20 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
tmnt0:4e2fae6764b6 21
tmnt0:4e2fae6764b6 22
tmnt0:4e2fae6764b6 23 GPIO_InitTypeDef dcmipinsa,dcmipinsb,dcmipinsc;
tmnt0:4e2fae6764b6 24 dcmipinsa.Pin = GPIO_PIN_4|GPIO_PIN_6;
tmnt0:4e2fae6764b6 25 dcmipinsa.Mode = GPIO_MODE_AF_PP;
tmnt0:4e2fae6764b6 26 dcmipinsa.Pull = GPIO_PULLDOWN;
tmnt0:4e2fae6764b6 27 dcmipinsa.Speed = GPIO_SPEED_HIGH;
tmnt0:4e2fae6764b6 28 dcmipinsa.Alternate = GPIO_AF13_DCMI;
tmnt0:4e2fae6764b6 29 HAL_GPIO_Init(GPIOA, &dcmipinsa);
tmnt0:4e2fae6764b6 30
tmnt0:4e2fae6764b6 31 __GPIOB_CLK_ENABLE();
tmnt0:4e2fae6764b6 32 dcmipinsb.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9;
tmnt0:4e2fae6764b6 33 dcmipinsb.Mode = GPIO_MODE_AF_PP;
tmnt0:4e2fae6764b6 34 dcmipinsb.Pull = GPIO_PULLDOWN;
tmnt0:4e2fae6764b6 35 dcmipinsb.Speed = GPIO_SPEED_HIGH;
tmnt0:4e2fae6764b6 36 dcmipinsb.Alternate = GPIO_AF13_DCMI;
tmnt0:4e2fae6764b6 37 HAL_GPIO_Init(GPIOB, &dcmipinsb);
tmnt0:4e2fae6764b6 38
tmnt0:4e2fae6764b6 39 __GPIOC_CLK_ENABLE();
tmnt0:4e2fae6764b6 40 dcmipinsc.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_11;
tmnt0:4e2fae6764b6 41 dcmipinsc.Mode = GPIO_MODE_AF_PP;
tmnt0:4e2fae6764b6 42 dcmipinsc.Pull = GPIO_PULLDOWN;
tmnt0:4e2fae6764b6 43 dcmipinsc.Speed = GPIO_SPEED_HIGH;
tmnt0:4e2fae6764b6 44 dcmipinsc.Alternate = GPIO_AF13_DCMI;
tmnt0:4e2fae6764b6 45 HAL_GPIO_Init(GPIOC, &dcmipinsc);
tmnt0:4e2fae6764b6 46
tmnt0:4e2fae6764b6 47 __DMA2_CLK_ENABLE();
tmnt0:4e2fae6764b6 48 dcmi_Dma.Instance = DMA2_Stream1;
tmnt0:4e2fae6764b6 49 dcmi_Dma.Init.Channel = DMA_CHANNEL_1;
tmnt0:4e2fae6764b6 50 dcmi_Dma.Init.Direction = DMA_PERIPH_TO_MEMORY;
tmnt0:4e2fae6764b6 51 dcmi_Dma.Init.PeriphInc = DMA_PINC_DISABLE;
tmnt0:4e2fae6764b6 52 dcmi_Dma.Init.MemInc = DMA_MINC_ENABLE;
tmnt0:4e2fae6764b6 53 dcmi_Dma.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
tmnt0:4e2fae6764b6 54 dcmi_Dma.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD ;
tmnt0:4e2fae6764b6 55 dcmi_Dma.Init.Mode = DMA_CIRCULAR;
tmnt0:4e2fae6764b6 56 dcmi_Dma.Init.Priority = DMA_PRIORITY_HIGH;
tmnt0:4e2fae6764b6 57 dcmi_Dma.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
tmnt0:4e2fae6764b6 58 dcmi_Dma.Init.FIFOThreshold =DMA_FIFO_THRESHOLD_FULL;
tmnt0:4e2fae6764b6 59 dcmi_Dma.Init.MemBurst = DMA_PBURST_SINGLE;
tmnt0:4e2fae6764b6 60 dcmi_Dma.Init.PeriphBurst = DMA_PBURST_SINGLE;
tmnt0:4e2fae6764b6 61
tmnt0:4e2fae6764b6 62 HAL_DMA_Init(&dcmi_Dma);
tmnt0:4e2fae6764b6 63
tmnt0:4e2fae6764b6 64 __DCMI_CLK_ENABLE();
tmnt0:4e2fae6764b6 65 dcmi.Instance = DCMI;
tmnt0:4e2fae6764b6 66 dcmi.Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B;
tmnt0:4e2fae6764b6 67 dcmi.Init.CaptureRate = DCMI_CR_ALL_FRAME;
tmnt0:4e2fae6764b6 68 dcmi.Init.VSPolarity = DCMI_VSPOLARITY_HIGH;
tmnt0:4e2fae6764b6 69 dcmi.Init.HSPolarity = DCMI_HSPOLARITY_LOW;
tmnt0:4e2fae6764b6 70 dcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_RISING;
tmnt0:4e2fae6764b6 71 dcmi.Init.SynchroMode = DCMI_SYNCHRO_HARDWARE;
tmnt0:4e2fae6764b6 72 dcmi.DMA_Handle = &dcmi_Dma;
tmnt0:4e2fae6764b6 73 HAL_DCMI_Init(&dcmi);
tmnt0:4e2fae6764b6 74 __HAL_DCMI_ENABLE(&dcmi);
tmnt0:4e2fae6764b6 75 HAL_DCMI_Start_DMA(&dcmi, DCMI_MODE_CONTINUOUS, (uint32_t)&frame_buffer,43500/2);
tmnt0:4e2fae6764b6 76
tmnt0:4e2fae6764b6 77 }
tmnt0:4e2fae6764b6 78
tmnt0:4e2fae6764b6 79
tmnt0:4e2fae6764b6 80
tmnt0:4e2fae6764b6 81
tmnt0:4e2fae6764b6 82
tmnt0:4e2fae6764b6 83
tmnt0:4e2fae6764b6 84