It's nucleo f4 DMA trandfer for ov7670&ILI9341.

Dependencies:   mbed ILI9341_SPI OV7670_SCCB

Committer:
tmnt
Date:
Sun Nov 20 11:30:49 2016 +0000
Revision:
7:2ed3ce710cc2
i

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tmnt0:ce10b2e08479 1#include "mbed.h"
tmnt0:ce10b2e08479 2
tmnt0:ce10b2e08479 3
tmnt0:ce10b2e08479 4DMA_HandleTypeDef DMA_HandleType ={
tmnt0:ce10b2e08479 5 DMA2_Stream1,
tmnt0:ce10b2e08479 6 {
tmnt0:ce10b2e08479 7 DMA_CHANNEL_6, // Request source is TIM_CH1
tmnt0:ce10b2e08479 8 DMA_PERIPH_TO_MEMORY,
tmnt0:ce10b2e08479 9 DMA_PINC_DISABLE,
tmnt0:ce10b2e08479 10 DMA_MINC_ENABLE,
tmnt0:ce10b2e08479 11 DMA_PDATAALIGN_BYTE,
tmnt0:ce10b2e08479 12 DMA_MDATAALIGN_BYTE,
tmnt0:ce10b2e08479 13 DMA_CIRCULAR,//DMA_PFCTRL,//
tmnt0:ce10b2e08479 14 DMA_PRIORITY_VERY_HIGH,
tmnt0:ce10b2e08479 15 DMA_FIFOMODE_DISABLE,//DMA_FIFOMODE_ENABLE,
tmnt0:ce10b2e08479 16 DMA_FIFO_THRESHOLD_HALFFULL,
tmnt0:ce10b2e08479 17 DMA_PBURST_INC4 ,
tmnt0:ce10b2e08479 18 DMA_PBURST_SINGLE
tmnt0:ce10b2e08479 19 },
tmnt0:ce10b2e08479 20 HAL_UNLOCKED,
tmnt0:ce10b2e08479 21 HAL_DMA_STATE_RESET,//HAL_DMA_STATE_READY
tmnt0:ce10b2e08479 22 NULL, // parent
tmnt0:ce10b2e08479 23 NULL, //dma_transfer_complete, // XferCpltCallback
tmnt0:ce10b2e08479 24 NULL, // XferHalfCpltCallback
tmnt0:ce10b2e08479 25 NULL, // XferM1CpltCallback
tmnt0:ce10b2e08479 26 NULL, //dma_error, // XferErrorCallback
tmnt0:ce10b2e08479 27 NULL // ErrorCode
tmnt0:ce10b2e08479 28};
tmnt0:ce10b2e08479 29
tmnt0:ce10b2e08479 30TIM_HandleTypeDef htim;
tmnt0:ce10b2e08479 31
tmnt0:ce10b2e08479 32
tmnt0:ce10b2e08479 33
tmnt0:ce10b2e08479 34void dma_init(void)
tmnt0:ce10b2e08479 35{
tmnt0:ce10b2e08479 36 TIM_IC_InitTypeDef icconf;
tmnt0:ce10b2e08479 37 GPIO_InitTypeDef gpioconf;
tmnt0:ce10b2e08479 38 __DMA2_CLK_ENABLE();
tmnt0:ce10b2e08479 39 __TIM1_CLK_ENABLE();
tmnt0:ce10b2e08479 40 __GPIOA_CLK_ENABLE();
tmnt0:ce10b2e08479 41
tmnt0:ce10b2e08479 42
tmnt0:ce10b2e08479 43
tmnt0:ce10b2e08479 44 /* PA8 -> TIM1_CH1 */
tmnt0:ce10b2e08479 45
tmnt0:ce10b2e08479 46 gpioconf.Mode = GPIO_MODE_AF_OD;
tmnt0:ce10b2e08479 47 gpioconf.Pin = GPIO_PIN_8;
tmnt0:ce10b2e08479 48 gpioconf.Pull = GPIO_PULLUP;
tmnt0:ce10b2e08479 49 gpioconf.Speed = GPIO_SPEED_HIGH;
tmnt0:ce10b2e08479 50 gpioconf.Alternate = GPIO_AF1_TIM1;
tmnt0:ce10b2e08479 51 HAL_GPIO_Init(GPIOA, &gpioconf);
tmnt0:ce10b2e08479 52
tmnt0:ce10b2e08479 53 HAL_DMA_Init(&DMA_HandleType);
tmnt0:ce10b2e08479 54
tmnt0:ce10b2e08479 55 htim.Instance = TIM1;
tmnt0:ce10b2e08479 56 htim.Init.Period = 1;
tmnt0:ce10b2e08479 57 htim.Init.Prescaler = 0;
tmnt0:ce10b2e08479 58 htim.Init.ClockDivision = 0;
tmnt0:ce10b2e08479 59 htim.Init.CounterMode = TIM_COUNTERMODE_UP;
tmnt0:ce10b2e08479 60 HAL_TIM_IC_Init(&htim);
tmnt0:ce10b2e08479 61
tmnt0:ce10b2e08479 62 icconf.ICPolarity = TIM_ICPOLARITY_FALLING;
tmnt0:ce10b2e08479 63 //icconf.ICPolarity = TIM_ICPOLARITY_RISING;
tmnt0:ce10b2e08479 64 icconf.ICSelection = TIM_ICSELECTION_DIRECTTI;
tmnt0:ce10b2e08479 65 icconf.ICPrescaler = TIM_ICPSC_DIV1;
tmnt0:ce10b2e08479 66 icconf.ICFilter = 0;
tmnt0:ce10b2e08479 67 HAL_TIM_IC_ConfigChannel(&htim, &icconf, TIM_CHANNEL_1);
tmnt0:ce10b2e08479 68 __HAL_TIM_ENABLE_DMA(&htim, TIM_DMA_CC1);
tmnt0:ce10b2e08479 69
tmnt0:ce10b2e08479 70 /* Start the TIM1 Channel1 */
tmnt0:ce10b2e08479 71 HAL_TIM_IC_Start(&htim, TIM_CHANNEL_1);
tmnt0:ce10b2e08479 72
tmnt0:ce10b2e08479 73}