It's nucleo f4 DMA trandfer for ov7670&ILI9341.
Dependencies: mbed ILI9341_SPI OV7670_SCCB
main.cpp@5:541e2adc765d, 2016-04-29 (annotated)
- Committer:
- tmnt
- Date:
- Fri Apr 29 13:39:26 2016 +0000
- Revision:
- 5:541e2adc765d
- Parent:
- 4:ba22760d537d
- Child:
- 7:2ed3ce710cc2
Simplification of the program.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tmnt | 0:ce10b2e08479 | 1 | #include "mbed.h" |
tmnt | 0:ce10b2e08479 | 2 | #include "TIM_DMAInit.h" |
tmnt | 0:ce10b2e08479 | 3 | #include "SPI_DMAInit.h" |
tmnt | 5:541e2adc765d | 4 | #include "ILI9341.h" |
tmnt | 5:541e2adc765d | 5 | #include "SCCB.h" |
tmnt | 5:541e2adc765d | 6 | #include "GPIOInit.h" |
tmnt | 0:ce10b2e08479 | 7 | /* |
tmnt | 0:ce10b2e08479 | 8 | |
tmnt | 0:ce10b2e08479 | 9 | ********ov7670******** |
tmnt | 0:ce10b2e08479 | 10 | +3V3 - 3V3 GND-GND |
tmnt | 0:ce10b2e08479 | 11 | PC_12 - SIOC SIDO - PC10 |
tmnt | 0:ce10b2e08479 | 12 | PD_2 - VSYNC HREF - A3 |
tmnt | 0:ce10b2e08479 | 13 | B4,A4 - PCLK XCLK - PC_9 |
tmnt | 0:ce10b2e08479 | 14 | PB_7 - D7 D6 - PB_6 |
tmnt | 0:ce10b2e08479 | 15 | PB_5 - D5 D4 - PB_4 |
tmnt | 0:ce10b2e08479 | 16 | PB_3 - D3 D2 - PB_2 |
tmnt | 0:ce10b2e08479 | 17 | PB_1 - D1 D0 - PB_0 |
tmnt | 0:ce10b2e08479 | 18 | +3V3-330Ω-RESET |
tmnt | 0:ce10b2e08479 | 19 | |
tmnt | 0:ce10b2e08479 | 20 | ********74HC00********* |
tmnt | 3:901230f7d62b | 21 | A1 VCC - +3V3 |
tmnt | 0:ce10b2e08479 | 22 | B1 B4 -- PCLK |
tmnt | 0:ce10b2e08479 | 23 | Y1 A4 -- PCLK |
tmnt | 0:ce10b2e08479 | 24 | A2 Y4 - B3 |
tmnt | 0:ce10b2e08479 | 25 | B2 B3 - Y4 |
tmnt | 0:ce10b2e08479 | 26 | Y2 A3 - HREF |
tmnt | 0:ce10b2e08479 | 27 | GND Y3 - PA8 |
tmnt | 0:ce10b2e08479 | 28 | |
tmnt | 0:ce10b2e08479 | 29 | ********ILI9341********* |
tmnt | 0:ce10b2e08479 | 30 | SDO - PA6 |
tmnt | 3:901230f7d62b | 31 | LED - 10kΩ - +3V3 |
tmnt | 0:ce10b2e08479 | 32 | SCK - PA5 |
tmnt | 0:ce10b2e08479 | 33 | SDI - PA7 |
tmnt | 0:ce10b2e08479 | 34 | DC - PA_4 |
tmnt | 0:ce10b2e08479 | 35 | RS - PA_12 |
tmnt | 0:ce10b2e08479 | 36 | CS - PA_11 |
tmnt | 0:ce10b2e08479 | 37 | GND - GND |
tmnt | 0:ce10b2e08479 | 38 | VCC - +5V |
tmnt | 0:ce10b2e08479 | 39 | |
tmnt | 5:541e2adc765d | 40 | |
tmnt | 0:ce10b2e08479 | 41 | |
tmnt | 0:ce10b2e08479 | 42 | */ |
tmnt | 0:ce10b2e08479 | 43 | |
tmnt | 0:ce10b2e08479 | 44 | uint8_t dma_buf[145][300]; |
tmnt | 0:ce10b2e08479 | 45 | uint8_t flag_dma; |
tmnt | 0:ce10b2e08479 | 46 | |
tmnt | 0:ce10b2e08479 | 47 | InterruptIn VSYNC(PD_2); |
tmnt | 0:ce10b2e08479 | 48 | SPI spi(PA_7,PA_6,PA_5); |
tmnt | 5:541e2adc765d | 49 | ili9341_spi lcd(spi,PA_11,PA_4,PA_12); |
tmnt | 5:541e2adc765d | 50 | ov7670_sccb sccb(PC_10,PC_12); |
tmnt | 0:ce10b2e08479 | 51 | PortIn cdata(PortB, 0x00ff); |
tmnt | 0:ce10b2e08479 | 52 | |
tmnt | 0:ce10b2e08479 | 53 | void camdma_start(); |
tmnt | 0:ce10b2e08479 | 54 | |
tmnt | 0:ce10b2e08479 | 55 | int main() { |
tmnt | 0:ce10b2e08479 | 56 | |
tmnt | 0:ce10b2e08479 | 57 | |
tmnt | 5:541e2adc765d | 58 | gpio_Init(); |
tmnt | 0:ce10b2e08479 | 59 | dma_init(); |
tmnt | 0:ce10b2e08479 | 60 | |
tmnt | 0:ce10b2e08479 | 61 | spi.format(8,3); |
tmnt | 0:ce10b2e08479 | 62 | spi.frequency(20000000); |
tmnt | 5:541e2adc765d | 63 | lcd.tft_reset(); |
tmnt | 0:ce10b2e08479 | 64 | |
tmnt | 0:ce10b2e08479 | 65 | __disable_irq(); |
tmnt | 0:ce10b2e08479 | 66 | |
tmnt | 5:541e2adc765d | 67 | VSYNC.rise(&camdma_start); |
tmnt | 5:541e2adc765d | 68 | sccb.cam_init(); |
tmnt | 0:ce10b2e08479 | 69 | |
tmnt | 5:541e2adc765d | 70 | lcd.fillrect(0,0,150,290,0xf800);//red |
tmnt | 0:ce10b2e08479 | 71 | |
tmnt | 5:541e2adc765d | 72 | wait(1); |
tmnt | 5:541e2adc765d | 73 | lcd.wr_cmd(0x2C); |
tmnt | 0:ce10b2e08479 | 74 | spi.write(0x66); |
tmnt | 0:ce10b2e08479 | 75 | spi_Init(); |
tmnt | 0:ce10b2e08479 | 76 | |
tmnt | 0:ce10b2e08479 | 77 | __enable_irq(); |
tmnt | 0:ce10b2e08479 | 78 | |
tmnt | 0:ce10b2e08479 | 79 | |
tmnt | 0:ce10b2e08479 | 80 | while(1) { |
tmnt | 0:ce10b2e08479 | 81 | } |
tmnt | 0:ce10b2e08479 | 82 | } |
tmnt | 0:ce10b2e08479 | 83 | |
tmnt | 0:ce10b2e08479 | 84 | |
tmnt | 0:ce10b2e08479 | 85 | void camdma_start() |
tmnt | 0:ce10b2e08479 | 86 | { |
tmnt | 0:ce10b2e08479 | 87 | if(flag_dma==0){ |
tmnt | 0:ce10b2e08479 | 88 | HAL_DMA_Start_IT(&DMA_HandleType/*DMA初期設定構造体*/, (uint32_t)&GPIOB->IDR/*&0x00ff転送元アドレス*/, (uint32_t)dma_buf/*転送先アドレス*/,43500/*データ転送回数*/); |
tmnt | 0:ce10b2e08479 | 89 | |
tmnt | 0:ce10b2e08479 | 90 | HAL_SPI_Transmit_DMA(&spi1, (uint8_t*)dma_buf, sizeof(dma_buf)); |
tmnt | 0:ce10b2e08479 | 91 | } |
tmnt | 0:ce10b2e08479 | 92 | flag_dma=1; |
tmnt | 0:ce10b2e08479 | 93 | } |