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

Dependencies:   mbed ILI9341_SPI OV7670_SCCB

Committer:
tmnt
Date:
Wed Apr 27 13:19:11 2016 +0000
Revision:
3:901230f7d62b
Parent:
2:de327fb4e2c5
Child:
4:ba22760d537d
??????????

Who changed what in which revision?

UserRevisionLine numberNew 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 0:ce10b2e08479 4
tmnt 2:de327fb4e2c5 5
tmnt 0:ce10b2e08479 6 /*
tmnt 0:ce10b2e08479 7
tmnt 0:ce10b2e08479 8 ********ov7670********
tmnt 0:ce10b2e08479 9 +3V3 - 3V3 GND-GND
tmnt 0:ce10b2e08479 10 PC_12 - SIOC SIDO - PC10
tmnt 0:ce10b2e08479 11 PD_2 - VSYNC HREF - A3
tmnt 0:ce10b2e08479 12 B4,A4 - PCLK XCLK - PC_9
tmnt 0:ce10b2e08479 13 PB_7 - D7 D6 - PB_6
tmnt 0:ce10b2e08479 14 PB_5 - D5 D4 - PB_4
tmnt 0:ce10b2e08479 15 PB_3 - D3 D2 - PB_2
tmnt 0:ce10b2e08479 16 PB_1 - D1 D0 - PB_0
tmnt 0:ce10b2e08479 17 +3V3-330Ω-RESET
tmnt 0:ce10b2e08479 18
tmnt 0:ce10b2e08479 19 ********74HC00*********
tmnt 3:901230f7d62b 20 A1 VCC - +3V3
tmnt 0:ce10b2e08479 21 B1 B4 -- PCLK
tmnt 0:ce10b2e08479 22 Y1 A4 -- PCLK
tmnt 0:ce10b2e08479 23 A2 Y4 - B3
tmnt 0:ce10b2e08479 24 B2 B3 - Y4
tmnt 0:ce10b2e08479 25 Y2 A3 - HREF
tmnt 0:ce10b2e08479 26 GND Y3 - PA8
tmnt 0:ce10b2e08479 27
tmnt 0:ce10b2e08479 28 ********ILI9341*********
tmnt 0:ce10b2e08479 29 SDO - PA6
tmnt 3:901230f7d62b 30 LED - 10kΩ - +3V3
tmnt 0:ce10b2e08479 31 SCK - PA5
tmnt 0:ce10b2e08479 32 SDI - PA7
tmnt 0:ce10b2e08479 33 DC - PA_4
tmnt 0:ce10b2e08479 34 RS - PA_12
tmnt 0:ce10b2e08479 35 CS - PA_11
tmnt 0:ce10b2e08479 36 GND - GND
tmnt 0:ce10b2e08479 37 VCC - +5V
tmnt 0:ce10b2e08479 38
tmnt 0:ce10b2e08479 39 ********NUCLEOF401RE*******
tmnt 0:ce10b2e08479 40
tmnt 0:ce10b2e08479 41 U5V×
tmnt 0:ce10b2e08479 42 E5V○
tmnt 0:ce10b2e08479 43
tmnt 0:ce10b2e08479 44 */
tmnt 0:ce10b2e08479 45
tmnt 0:ce10b2e08479 46
tmnt 0:ce10b2e08479 47
tmnt 0:ce10b2e08479 48
tmnt 0:ce10b2e08479 49
tmnt 0:ce10b2e08479 50
tmnt 0:ce10b2e08479 51 #define REG_COM1 0x04 /* Control 1 */
tmnt 0:ce10b2e08479 52 #define REG_COM6 0x0f /* Control 6 */
tmnt 0:ce10b2e08479 53 #define REG_AECH 0x10 /* More bits of AEC value */
tmnt 0:ce10b2e08479 54 #define REG_CLKRC 0x11 /* Clocl control */
tmnt 0:ce10b2e08479 55 #define CLK_EXT 0x40 /* Use external clock directly */
tmnt 0:ce10b2e08479 56 #define CLK_SCALE 0x3f /* Mask for internal clock scale */
tmnt 0:ce10b2e08479 57 #define REG_COM7 0x12 /* Control 7 */
tmnt 0:ce10b2e08479 58 #define COM7_RESET 0x80 /* Register reset */
tmnt 0:ce10b2e08479 59 #define COM7_FMT_MASK 0x38
tmnt 0:ce10b2e08479 60 #define COM7_FMT_VGA 0x00
tmnt 0:ce10b2e08479 61 #define COM7_FMT_CIF 0x20 /* CIF format */
tmnt 0:ce10b2e08479 62 #define COM7_FMT_QVGA 0x10 /* QVGA format */
tmnt 0:ce10b2e08479 63 #define COM7_FMT_QCIF 0x08 /* QCIF format */
tmnt 0:ce10b2e08479 64 #define COM7_RGB 0x04 /* bits 0 and 2 - RGB format */
tmnt 0:ce10b2e08479 65 #define COM7_YUV 0x00 /* YUV */
tmnt 0:ce10b2e08479 66 #define COM7_BAYER 0x01 /* Bayer format */
tmnt 0:ce10b2e08479 67 #define COM7_PBAYER 0x05 /* "Processed bayer" */
tmnt 0:ce10b2e08479 68 #define REG_COM8 0x13 /* Control 8 */
tmnt 0:ce10b2e08479 69 #define REG_COM9 0x14 /* Control 9 - gain ceiling */
tmnt 0:ce10b2e08479 70 #define REG_TSLB 0x3a /* lots of stuff */
tmnt 0:ce10b2e08479 71 #define REG_COM15 0x40 /* Control 15 */
tmnt 0:ce10b2e08479 72 #define COM15_R10F0 0x00 /* Data range 10 to F0 */
tmnt 0:ce10b2e08479 73 #define COM15_R01FE 0x80 /* 01 to FE */
tmnt 0:ce10b2e08479 74 #define COM15_R00FF 0xc0 /* 00 to FF */
tmnt 0:ce10b2e08479 75 #define COM15_RGB565 0x10 /* RGB565 output */
tmnt 0:ce10b2e08479 76 #define COM15_RGB555 0x30 /* RGB555 output */
tmnt 0:ce10b2e08479 77 #define REG_COM16 0x41 /* Control 16 */
tmnt 0:ce10b2e08479 78 #define COM16_AWBGAIN 0x08 /* AWB gain enable */
tmnt 0:ce10b2e08479 79 #define REG_COM17 0x42 /* Control 17 */
tmnt 0:ce10b2e08479 80 #define COM17_AECWIN 0xc0 /* AEC window - must match COM4 */
tmnt 0:ce10b2e08479 81 #define COM17_CBAR 0x08 /* DSP Color bar */
tmnt 0:ce10b2e08479 82 #define REG_CMATRIX_BASE 0x4f
tmnt 0:ce10b2e08479 83 #define CMATRIX_LEN 6
tmnt 0:ce10b2e08479 84 #define REG_CMATRIX_SIGN 0x58
tmnt 0:ce10b2e08479 85 #define REG_BRIGHT 0x55 /* Brightness */
tmnt 0:ce10b2e08479 86 #define REG_CONTRAS 0x56 /* Contrast control */
tmnt 0:ce10b2e08479 87
tmnt 0:ce10b2e08479 88 #define REG_GFIX 0x69 /* Fix gain control */
tmnt 0:ce10b2e08479 89
tmnt 0:ce10b2e08479 90 #define REG_REG76 0x76 /* OV's name */
tmnt 0:ce10b2e08479 91 #define R76_BLKPCOR 0x80 /* Black pixel correction enable */
tmnt 0:ce10b2e08479 92 #define R76_WHTPCOR 0x40 /* White pixel correction enable */
tmnt 0:ce10b2e08479 93
tmnt 0:ce10b2e08479 94 #define REG_RGB444 0x8c /* RGB 444 control */
tmnt 0:ce10b2e08479 95 #define R444_ENABLE 0x02 /* Turn on RGB444, overrides 5x5 */
tmnt 0:ce10b2e08479 96 #define R444_RGBX 0x01 /* Empty nibble at end */
tmnt 0:ce10b2e08479 97
tmnt 0:ce10b2e08479 98 #define REG_HAECC1 0x9f /* Hist AEC/AGC control 1 */
tmnt 0:ce10b2e08479 99 #define REG_HAECC2 0xa0 /* Hist AEC/AGC control 2 */
tmnt 0:ce10b2e08479 100
tmnt 0:ce10b2e08479 101 #define REG_BD50MAX 0xa5 /* 50hz banding step limit */
tmnt 0:ce10b2e08479 102 #define REG_HAECC3 0xa6 /* Hist AEC/AGC control 3 */
tmnt 0:ce10b2e08479 103 #define REG_HAECC4 0xa7 /* Hist AEC/AGC control 4 */
tmnt 0:ce10b2e08479 104 #define REG_HAECC5 0xa8 /* Hist AEC/AGC control 5 */
tmnt 0:ce10b2e08479 105 #define REG_HAECC6 0xa9 /* Hist AEC/AGC control 6 */
tmnt 0:ce10b2e08479 106 #define REG_HAECC7 0xaa /* Hist AEC/AGC control 7 */
tmnt 0:ce10b2e08479 107 #define REG_BD60MAX 0xab /* 60hz banding step limit */
tmnt 0:ce10b2e08479 108
tmnt 0:ce10b2e08479 109
tmnt 0:ce10b2e08479 110
tmnt 0:ce10b2e08479 111 uint8_t dma_buf[145][300];
tmnt 0:ce10b2e08479 112 uint8_t flag_dma;
tmnt 0:ce10b2e08479 113
tmnt 0:ce10b2e08479 114
tmnt 0:ce10b2e08479 115
tmnt 0:ce10b2e08479 116 InterruptIn VSYNC(PD_2);
tmnt 0:ce10b2e08479 117
tmnt 0:ce10b2e08479 118 SPI spi(PA_7,PA_6,PA_5);
tmnt 0:ce10b2e08479 119
tmnt 0:ce10b2e08479 120 DigitalOut dc(PA_4);
tmnt 0:ce10b2e08479 121 DigitalOut rs(PA_12);
tmnt 0:ce10b2e08479 122 DigitalOut cs(PA_11);
tmnt 0:ce10b2e08479 123
tmnt 0:ce10b2e08479 124 DigitalInOut SDA(PC_10);
tmnt 0:ce10b2e08479 125 DigitalInOut SCL(PC_12);
tmnt 0:ce10b2e08479 126
tmnt 0:ce10b2e08479 127 PortIn cdata(PortB, 0x00ff);
tmnt 0:ce10b2e08479 128
tmnt 0:ce10b2e08479 129 void window (unsigned int x, unsigned int y, unsigned int w, unsigned int h);
tmnt 0:ce10b2e08479 130 void pixel(int x, int y, int color);
tmnt 0:ce10b2e08479 131 void vline(int x, int y0, int y1, int color);
tmnt 0:ce10b2e08479 132 void circle(int x0, int y0, int r, int color);
tmnt 0:ce10b2e08479 133 void fillcircle(int x0, int y0, int r, int color);
tmnt 0:ce10b2e08479 134 void fillrect(int x0, int y0, int x1, int y1, int color);
tmnt 0:ce10b2e08479 135 void wr_cmd(unsigned char cmd);
tmnt 0:ce10b2e08479 136 void wr_dat(unsigned char dat);
tmnt 0:ce10b2e08479 137 char rd_byte(unsigned char cmd);
tmnt 0:ce10b2e08479 138 int rd_32(unsigned char cmd);
tmnt 0:ce10b2e08479 139 int Read_ID(void);
tmnt 0:ce10b2e08479 140 void tft_reset();
tmnt 0:ce10b2e08479 141 void fillrect(int x0, int y0, int x1, int y1, int color);
tmnt 0:ce10b2e08479 142
tmnt 0:ce10b2e08479 143 void I2cstart(void);
tmnt 0:ce10b2e08479 144 void I2cstop(void);
tmnt 0:ce10b2e08479 145 void I2cout(unsigned char datar);
tmnt 0:ce10b2e08479 146 void c(unsigned char adrs,unsigned char datak);
tmnt 0:ce10b2e08479 147 void cam_init();
tmnt 0:ce10b2e08479 148
tmnt 0:ce10b2e08479 149 void camdma_start();
tmnt 0:ce10b2e08479 150
tmnt 0:ce10b2e08479 151 void test_color();
tmnt 0:ce10b2e08479 152
tmnt 0:ce10b2e08479 153
tmnt 0:ce10b2e08479 154
tmnt 0:ce10b2e08479 155
tmnt 0:ce10b2e08479 156 int main() {
tmnt 0:ce10b2e08479 157
tmnt 0:ce10b2e08479 158
tmnt 0:ce10b2e08479 159 GPIO_InitTypeDef gpioconf1;
tmnt 0:ce10b2e08479 160 __GPIOB_CLK_ENABLE();
tmnt 0:ce10b2e08479 161 gpioconf1.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 |GPIO_PIN_14 | GPIO_PIN_15;//pa13
tmnt 0:ce10b2e08479 162 gpioconf1.Mode = GPIO_MODE_INPUT;
tmnt 0:ce10b2e08479 163 gpioconf1.Pull = GPIO_PULLDOWN;
tmnt 0:ce10b2e08479 164 gpioconf1.Speed = GPIO_SPEED_HIGH;
tmnt 0:ce10b2e08479 165 HAL_GPIO_Init(GPIOB, &gpioconf1);
tmnt 0:ce10b2e08479 166
tmnt 0:ce10b2e08479 167
tmnt 0:ce10b2e08479 168 HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_HSE, RCC_MCODIV_1);
tmnt 0:ce10b2e08479 169
tmnt 0:ce10b2e08479 170 GPIO_InitTypeDef GPIO_InitStruct;
tmnt 0:ce10b2e08479 171 /*Configure GPIO pin : PC9 MCO2 for cam XCLK*/
tmnt 0:ce10b2e08479 172 __GPIOC_CLK_ENABLE();
tmnt 0:ce10b2e08479 173 GPIO_InitStruct.Pin = GPIO_PIN_9;
tmnt 0:ce10b2e08479 174 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
tmnt 0:ce10b2e08479 175 GPIO_InitStruct.Pull = GPIO_NOPULL;
tmnt 0:ce10b2e08479 176 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
tmnt 0:ce10b2e08479 177 GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
tmnt 0:ce10b2e08479 178 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
tmnt 0:ce10b2e08479 179 // spi_Init();
tmnt 0:ce10b2e08479 180 dma_init();
tmnt 0:ce10b2e08479 181
tmnt 0:ce10b2e08479 182 spi.format(8,3);
tmnt 0:ce10b2e08479 183 spi.frequency(20000000);
tmnt 0:ce10b2e08479 184 tft_reset();
tmnt 0:ce10b2e08479 185
tmnt 0:ce10b2e08479 186 __disable_irq();
tmnt 0:ce10b2e08479 187
tmnt 0:ce10b2e08479 188 VSYNC.rise(&camdma_start);//PCLK割り込み
tmnt 0:ce10b2e08479 189 cam_init();
tmnt 0:ce10b2e08479 190
tmnt 0:ce10b2e08479 191 fillrect(0,0,150,290,0xf800);//red
tmnt 0:ce10b2e08479 192
tmnt 0:ce10b2e08479 193
tmnt 3:901230f7d62b 194 wait(3);
tmnt 0:ce10b2e08479 195 wr_cmd(0x2C);
tmnt 0:ce10b2e08479 196 spi.write(0x66);
tmnt 0:ce10b2e08479 197 spi_Init();
tmnt 0:ce10b2e08479 198
tmnt 0:ce10b2e08479 199 __enable_irq();
tmnt 0:ce10b2e08479 200
tmnt 0:ce10b2e08479 201
tmnt 0:ce10b2e08479 202 while(1) {
tmnt 0:ce10b2e08479 203 }
tmnt 0:ce10b2e08479 204 }
tmnt 0:ce10b2e08479 205
tmnt 0:ce10b2e08479 206
tmnt 0:ce10b2e08479 207
tmnt 0:ce10b2e08479 208
tmnt 0:ce10b2e08479 209 void wr_cmd(unsigned char cmd)
tmnt 0:ce10b2e08479 210 {
tmnt 0:ce10b2e08479 211 dc = 0;
tmnt 0:ce10b2e08479 212 cs = 0;
tmnt 0:ce10b2e08479 213 spi.write(cmd); // mbed lib
tmnt 0:ce10b2e08479 214 dc = 1;
tmnt 0:ce10b2e08479 215 }
tmnt 0:ce10b2e08479 216 void wr_dat(unsigned char dat)
tmnt 0:ce10b2e08479 217 {
tmnt 0:ce10b2e08479 218 spi.write(dat); // mbed lib
tmnt 0:ce10b2e08479 219 }
tmnt 0:ce10b2e08479 220 char rd_byte(unsigned char cmd)
tmnt 0:ce10b2e08479 221 {
tmnt 0:ce10b2e08479 222 char r;
tmnt 0:ce10b2e08479 223 dc = 0;
tmnt 0:ce10b2e08479 224 cs = 0;
tmnt 0:ce10b2e08479 225 spi.write(cmd); // mbed lib
tmnt 0:ce10b2e08479 226 cs = 1;
tmnt 0:ce10b2e08479 227 r = spi.write(0xff);
tmnt 0:ce10b2e08479 228 cs = 1;
tmnt 0:ce10b2e08479 229 return(r);
tmnt 0:ce10b2e08479 230 }
tmnt 0:ce10b2e08479 231
tmnt 0:ce10b2e08479 232 // read 32 bit
tmnt 0:ce10b2e08479 233 int rd_32(unsigned char cmd)
tmnt 0:ce10b2e08479 234 {
tmnt 0:ce10b2e08479 235 int d;
tmnt 0:ce10b2e08479 236 char r;
tmnt 0:ce10b2e08479 237 dc = 0;
tmnt 0:ce10b2e08479 238 cs = 0;
tmnt 0:ce10b2e08479 239 d = cmd;
tmnt 0:ce10b2e08479 240 d = d << 1;
tmnt 0:ce10b2e08479 241 spi.format(9,3); // we have to add a dummy clock cycle
tmnt 0:ce10b2e08479 242 spi.write(d);
tmnt 0:ce10b2e08479 243 spi.format(8,3);
tmnt 0:ce10b2e08479 244 dc = 1;
tmnt 0:ce10b2e08479 245 r = spi.write(0xff);
tmnt 0:ce10b2e08479 246 d = r;
tmnt 0:ce10b2e08479 247 r = spi.write(0xff);
tmnt 0:ce10b2e08479 248 d = (d << 8) | r;
tmnt 0:ce10b2e08479 249 r = spi.write(0xff);
tmnt 0:ce10b2e08479 250 d = (d << 8) | r;
tmnt 0:ce10b2e08479 251 r = spi.write(0xff);
tmnt 0:ce10b2e08479 252 d = (d << 8) | r;
tmnt 0:ce10b2e08479 253 cs = 1;
tmnt 0:ce10b2e08479 254 return(d);
tmnt 0:ce10b2e08479 255 }
tmnt 0:ce10b2e08479 256
tmnt 0:ce10b2e08479 257 int Read_ID(void){
tmnt 0:ce10b2e08479 258 int r;
tmnt 0:ce10b2e08479 259 r = rd_byte(0x0A);
tmnt 0:ce10b2e08479 260 r = rd_byte(0x0A);
tmnt 0:ce10b2e08479 261 r = rd_byte(0x0A);
tmnt 0:ce10b2e08479 262 r = rd_byte(0x0A);
tmnt 0:ce10b2e08479 263 return(r);
tmnt 0:ce10b2e08479 264 }
tmnt 0:ce10b2e08479 265
tmnt 0:ce10b2e08479 266
tmnt 0:ce10b2e08479 267 // Init code based on MI0283QT datasheet
tmnt 0:ce10b2e08479 268
tmnt 0:ce10b2e08479 269 void tft_reset()
tmnt 0:ce10b2e08479 270 {
tmnt 0:ce10b2e08479 271 cs = 1; // cs high
tmnt 0:ce10b2e08479 272 dc = 1; // dc high
tmnt 0:ce10b2e08479 273 rs = 0; // display reset
tmnt 0:ce10b2e08479 274
tmnt 0:ce10b2e08479 275 wait_us(50);
tmnt 0:ce10b2e08479 276 rs = 1; // end hardware reset
tmnt 0:ce10b2e08479 277 wait_ms(5);
tmnt 0:ce10b2e08479 278
tmnt 0:ce10b2e08479 279 wr_cmd(0x01); // SW reset
tmnt 0:ce10b2e08479 280 wait_ms(5);
tmnt 0:ce10b2e08479 281 wr_cmd(0x28); // display off
tmnt 0:ce10b2e08479 282
tmnt 0:ce10b2e08479 283 /* Start Initial Sequence ----------------------------------------------------*/
tmnt 0:ce10b2e08479 284 wr_cmd(0xCF);
tmnt 0:ce10b2e08479 285 spi.write(0x00);
tmnt 0:ce10b2e08479 286 spi.write(0x83);
tmnt 0:ce10b2e08479 287 spi.write(0x30);
tmnt 0:ce10b2e08479 288 cs = 1;
tmnt 0:ce10b2e08479 289
tmnt 0:ce10b2e08479 290 wr_cmd(0xED);
tmnt 0:ce10b2e08479 291 spi.write(0x64);
tmnt 0:ce10b2e08479 292 spi.write(0x03);
tmnt 0:ce10b2e08479 293 spi.write(0x12);
tmnt 0:ce10b2e08479 294 spi.write(0x81);
tmnt 0:ce10b2e08479 295 cs = 1;
tmnt 0:ce10b2e08479 296
tmnt 0:ce10b2e08479 297 wr_cmd(0xE8);
tmnt 0:ce10b2e08479 298 spi.write(0x85);
tmnt 0:ce10b2e08479 299 spi.write(0x01);
tmnt 0:ce10b2e08479 300 spi.write(0x79);
tmnt 0:ce10b2e08479 301 cs = 1;
tmnt 0:ce10b2e08479 302
tmnt 0:ce10b2e08479 303 wr_cmd(0xCB);
tmnt 0:ce10b2e08479 304 spi.write(0x39);
tmnt 0:ce10b2e08479 305 spi.write(0x2C);
tmnt 0:ce10b2e08479 306 spi.write(0x00);
tmnt 0:ce10b2e08479 307 spi.write(0x34);
tmnt 0:ce10b2e08479 308 spi.write(0x02);
tmnt 0:ce10b2e08479 309 cs = 1;
tmnt 0:ce10b2e08479 310
tmnt 0:ce10b2e08479 311 wr_cmd(0xF7);
tmnt 0:ce10b2e08479 312 spi.write(0x20);
tmnt 0:ce10b2e08479 313 cs = 1;
tmnt 0:ce10b2e08479 314
tmnt 0:ce10b2e08479 315 wr_cmd(0xEA);
tmnt 0:ce10b2e08479 316 spi.write(0x00);
tmnt 0:ce10b2e08479 317 spi.write(0x00);
tmnt 0:ce10b2e08479 318 cs = 1;
tmnt 0:ce10b2e08479 319
tmnt 0:ce10b2e08479 320 wr_cmd(0xC0); // POWER_CONTROL_1
tmnt 0:ce10b2e08479 321 spi.write(0x26);
tmnt 0:ce10b2e08479 322 cs = 1;
tmnt 0:ce10b2e08479 323
tmnt 0:ce10b2e08479 324 wr_cmd(0xC1); // POWER_CONTROL_2
tmnt 0:ce10b2e08479 325 spi.write(0x11);
tmnt 0:ce10b2e08479 326 cs = 1;
tmnt 0:ce10b2e08479 327
tmnt 0:ce10b2e08479 328 wr_cmd(0xC5); // VCOM_CONTROL_1
tmnt 0:ce10b2e08479 329 spi.write(0x35);
tmnt 0:ce10b2e08479 330 spi.write(0x3E);
tmnt 0:ce10b2e08479 331 cs = 1;
tmnt 0:ce10b2e08479 332
tmnt 0:ce10b2e08479 333 wr_cmd(0xC7); // VCOM_CONTROL_2
tmnt 0:ce10b2e08479 334 spi.write(0xBE);
tmnt 0:ce10b2e08479 335 cs = 1;
tmnt 0:ce10b2e08479 336
tmnt 0:ce10b2e08479 337 wr_cmd(0x36); // MEMORY_ACCESS_CONTROL
tmnt 0:ce10b2e08479 338 spi.write(0x48);
tmnt 0:ce10b2e08479 339 cs = 1;
tmnt 0:ce10b2e08479 340
tmnt 0:ce10b2e08479 341 wr_cmd(0x3A); // COLMOD_PIXEL_FORMAT_SET
tmnt 0:ce10b2e08479 342 spi.write(0x55); // 16 bit pixel
tmnt 0:ce10b2e08479 343 cs = 1;
tmnt 0:ce10b2e08479 344
tmnt 0:ce10b2e08479 345 wr_cmd(0xB1); // Frame Rate
tmnt 0:ce10b2e08479 346 spi.write(0x00);
tmnt 0:ce10b2e08479 347 spi.write(0x1B);
tmnt 0:ce10b2e08479 348 cs = 1;
tmnt 0:ce10b2e08479 349
tmnt 0:ce10b2e08479 350 wr_cmd(0xF2); // Gamma Function Disable
tmnt 0:ce10b2e08479 351 spi.write(0x08);
tmnt 0:ce10b2e08479 352 cs = 1;
tmnt 0:ce10b2e08479 353
tmnt 0:ce10b2e08479 354 wr_cmd(0x26);
tmnt 0:ce10b2e08479 355 spi.write(0x01); // gamma set for curve 01/2/04/08
tmnt 0:ce10b2e08479 356 cs = 1;
tmnt 0:ce10b2e08479 357
tmnt 0:ce10b2e08479 358 wr_cmd(0xE0); // positive gamma correction
tmnt 0:ce10b2e08479 359 spi.write(0x1F);
tmnt 0:ce10b2e08479 360 spi.write(0x1A);
tmnt 0:ce10b2e08479 361 spi.write(0x18);
tmnt 0:ce10b2e08479 362 spi.write(0x0A);
tmnt 0:ce10b2e08479 363 spi.write(0x0F);
tmnt 0:ce10b2e08479 364 spi.write(0x06);
tmnt 0:ce10b2e08479 365 spi.write(0x45);
tmnt 0:ce10b2e08479 366 spi.write(0x87);
tmnt 0:ce10b2e08479 367 spi.write(0x32);
tmnt 0:ce10b2e08479 368 spi.write(0x0A);
tmnt 0:ce10b2e08479 369 spi.write(0x07);
tmnt 0:ce10b2e08479 370 spi.write(0x02);
tmnt 0:ce10b2e08479 371 spi.write(0x07);
tmnt 0:ce10b2e08479 372 spi.write(0x05);
tmnt 0:ce10b2e08479 373 spi.write(0x00);
tmnt 0:ce10b2e08479 374 cs = 1;
tmnt 0:ce10b2e08479 375
tmnt 0:ce10b2e08479 376 wr_cmd(0xE1); // negativ gamma correction
tmnt 0:ce10b2e08479 377 spi.write(0x00);
tmnt 0:ce10b2e08479 378 spi.write(0x25);
tmnt 0:ce10b2e08479 379 spi.write(0x27);
tmnt 0:ce10b2e08479 380 spi.write(0x05);
tmnt 0:ce10b2e08479 381 spi.write(0x10);
tmnt 0:ce10b2e08479 382 spi.write(0x09);
tmnt 0:ce10b2e08479 383 spi.write(0x3A);
tmnt 0:ce10b2e08479 384 spi.write(0x78);
tmnt 0:ce10b2e08479 385 spi.write(0x4D);
tmnt 0:ce10b2e08479 386 spi.write(0x05);
tmnt 0:ce10b2e08479 387 spi.write(0x18);
tmnt 0:ce10b2e08479 388 spi.write(0x0D);
tmnt 0:ce10b2e08479 389 spi.write(0x38);
tmnt 0:ce10b2e08479 390 spi.write(0x3A);
tmnt 0:ce10b2e08479 391 spi.write(0x1F);
tmnt 0:ce10b2e08479 392 cs = 1;
tmnt 0:ce10b2e08479 393
tmnt 0:ce10b2e08479 394 wr_cmd(0x2A);
tmnt 0:ce10b2e08479 395 spi.write(0);
tmnt 0:ce10b2e08479 396 spi.write(0);
tmnt 0:ce10b2e08479 397 spi.write(0);
tmnt 0:ce10b2e08479 398 spi.write(0x95);
tmnt 0:ce10b2e08479 399
tmnt 0:ce10b2e08479 400 cs = 1;
tmnt 0:ce10b2e08479 401 wr_cmd(0x2B);
tmnt 0:ce10b2e08479 402 spi.write(0);
tmnt 0:ce10b2e08479 403 spi.write(0);
tmnt 0:ce10b2e08479 404 spi.write(0x00);
tmnt 0:ce10b2e08479 405 spi.write(0x90);
tmnt 0:ce10b2e08479 406 cs = 1;
tmnt 0:ce10b2e08479 407
tmnt 0:ce10b2e08479 408 //wr_cmd(0x34); // tearing effect off
tmnt 0:ce10b2e08479 409 //_cs = 1;
tmnt 0:ce10b2e08479 410
tmnt 0:ce10b2e08479 411 //wr_cmd(0x35); // tearing effect on
tmnt 0:ce10b2e08479 412 //_cs = 1;
tmnt 0:ce10b2e08479 413
tmnt 0:ce10b2e08479 414 wr_cmd(0xB7); // entry mode
tmnt 0:ce10b2e08479 415 spi.write(0x07);
tmnt 0:ce10b2e08479 416 cs = 1;
tmnt 0:ce10b2e08479 417
tmnt 0:ce10b2e08479 418 wr_cmd(0xB6); // display function control
tmnt 0:ce10b2e08479 419 spi.write(0x0A);
tmnt 0:ce10b2e08479 420 spi.write(0x82);
tmnt 0:ce10b2e08479 421 spi.write(0x27);
tmnt 0:ce10b2e08479 422 spi.write(0x00);
tmnt 0:ce10b2e08479 423 cs = 1;
tmnt 0:ce10b2e08479 424
tmnt 0:ce10b2e08479 425 wr_cmd(0x11); // sleep out
tmnt 0:ce10b2e08479 426 cs = 1;
tmnt 0:ce10b2e08479 427
tmnt 0:ce10b2e08479 428 wait_ms(100);
tmnt 0:ce10b2e08479 429
tmnt 0:ce10b2e08479 430 wr_cmd(0x29); // display on
tmnt 0:ce10b2e08479 431 cs = 1;
tmnt 0:ce10b2e08479 432
tmnt 0:ce10b2e08479 433 wait_ms(100);
tmnt 0:ce10b2e08479 434
tmnt 0:ce10b2e08479 435 }
tmnt 0:ce10b2e08479 436 void pixel(int x, int y, int color)
tmnt 0:ce10b2e08479 437 {
tmnt 0:ce10b2e08479 438 wr_cmd(0x2A);
tmnt 0:ce10b2e08479 439 spi.write(x >> 8);
tmnt 0:ce10b2e08479 440 spi.write(x);
tmnt 0:ce10b2e08479 441 cs = 1;
tmnt 0:ce10b2e08479 442 wr_cmd(0x2B);
tmnt 0:ce10b2e08479 443 spi.write(y >> 8);
tmnt 0:ce10b2e08479 444 spi.write(y);
tmnt 0:ce10b2e08479 445 cs = 1;
tmnt 0:ce10b2e08479 446 wr_cmd(0x2C); // send pixel
tmnt 0:ce10b2e08479 447 //#if defined TARGET_KL25Z // 8 Bit SPI
tmnt 0:ce10b2e08479 448 spi.write(color >> 8);
tmnt 0:ce10b2e08479 449 spi.write(color & 0xff);
tmnt 0:ce10b2e08479 450 /*#else
tmnt 0:ce10b2e08479 451 SPI::format(16,3); // switch to 16 bit Mode 3
tmnt 0:ce10b2e08479 452 SPI::write(color); // Write D0..D15
tmnt 0:ce10b2e08479 453 SPI::format(8,3);
tmnt 0:ce10b2e08479 454 #endif*/
tmnt 0:ce10b2e08479 455 cs = 1;
tmnt 0:ce10b2e08479 456 }
tmnt 0:ce10b2e08479 457
tmnt 0:ce10b2e08479 458 void window (unsigned int x, unsigned int y, unsigned int w, unsigned int h)
tmnt 0:ce10b2e08479 459 {
tmnt 0:ce10b2e08479 460 wr_cmd(0x2A);
tmnt 0:ce10b2e08479 461 spi.write(x >> 8);
tmnt 0:ce10b2e08479 462 spi.write(x);
tmnt 0:ce10b2e08479 463 spi.write((x+w-1) >> 8);
tmnt 0:ce10b2e08479 464 spi.write(x+w-1);
tmnt 0:ce10b2e08479 465
tmnt 0:ce10b2e08479 466 cs = 1;
tmnt 0:ce10b2e08479 467 wr_cmd(0x2B);
tmnt 0:ce10b2e08479 468 spi.write(y >> 8);
tmnt 0:ce10b2e08479 469 spi.write(y);
tmnt 0:ce10b2e08479 470 spi.write((y+h-1) >> 8);
tmnt 0:ce10b2e08479 471 spi.write(y+h-1);
tmnt 0:ce10b2e08479 472 cs = 1;
tmnt 0:ce10b2e08479 473 }
tmnt 0:ce10b2e08479 474
tmnt 0:ce10b2e08479 475 void vline(int x, int y0, int y1, int color)
tmnt 0:ce10b2e08479 476 {
tmnt 0:ce10b2e08479 477 int h;
tmnt 0:ce10b2e08479 478 h = y1 - y0 + 1;
tmnt 0:ce10b2e08479 479 window(x,y0,1,h);
tmnt 0:ce10b2e08479 480 wr_cmd(0x2C); // send pixel
tmnt 0:ce10b2e08479 481 //#if defined TARGET_KL25Z // 8 Bit SPI
tmnt 0:ce10b2e08479 482 for (int y=0; y<h; y++) {
tmnt 0:ce10b2e08479 483 spi.write(color >> 8);
tmnt 0:ce10b2e08479 484 spi.write(color & 0xff);
tmnt 0:ce10b2e08479 485 }
tmnt 0:ce10b2e08479 486 /* #else
tmnt 0:ce10b2e08479 487 SPI::format(16,3); // switch to 16 bit Mode 3
tmnt 0:ce10b2e08479 488 for (int y=0; y<h; y++) {
tmnt 0:ce10b2e08479 489 SPI::write(color);
tmnt 0:ce10b2e08479 490 }
tmnt 0:ce10b2e08479 491 SPI::format(8,3);*/
tmnt 0:ce10b2e08479 492 //#endif
tmnt 0:ce10b2e08479 493 cs = 1;
tmnt 0:ce10b2e08479 494 //WindowMax();
tmnt 0:ce10b2e08479 495 return;
tmnt 0:ce10b2e08479 496 }
tmnt 0:ce10b2e08479 497
tmnt 0:ce10b2e08479 498 void fillcircle(int x0, int y0, int r, int color)
tmnt 0:ce10b2e08479 499 {
tmnt 0:ce10b2e08479 500 int x = -r, y = 0, err = 2-2*r, e2;
tmnt 0:ce10b2e08479 501 do {
tmnt 0:ce10b2e08479 502 vline(x0-x, y0-y, y0+y, color);
tmnt 0:ce10b2e08479 503 vline(x0+x, y0-y, y0+y, color);
tmnt 0:ce10b2e08479 504 e2 = err;
tmnt 0:ce10b2e08479 505 if (e2 <= y) {
tmnt 0:ce10b2e08479 506 err += ++y*2+1;
tmnt 0:ce10b2e08479 507 if (-x == y && e2 <= x) e2 = 0;
tmnt 0:ce10b2e08479 508 }
tmnt 0:ce10b2e08479 509 if (e2 > x) err += ++x*2+1;
tmnt 0:ce10b2e08479 510 } while (x <= 0);
tmnt 0:ce10b2e08479 511 }
tmnt 0:ce10b2e08479 512
tmnt 0:ce10b2e08479 513
tmnt 0:ce10b2e08479 514 void circle(int x0, int y0, int r, int color)
tmnt 0:ce10b2e08479 515 {
tmnt 0:ce10b2e08479 516
tmnt 0:ce10b2e08479 517 int x = -r, y = 0, err = 2-2*r, e2;
tmnt 0:ce10b2e08479 518 do {
tmnt 0:ce10b2e08479 519 pixel(x0-x, y0+y,color);
tmnt 0:ce10b2e08479 520 pixel(x0+x, y0+y,color);
tmnt 0:ce10b2e08479 521 pixel(x0+x, y0-y,color);
tmnt 0:ce10b2e08479 522 pixel(x0-x, y0-y,color);
tmnt 0:ce10b2e08479 523 e2 = err;
tmnt 0:ce10b2e08479 524 if (e2 <= y) {
tmnt 0:ce10b2e08479 525 err += ++y*2+1;
tmnt 0:ce10b2e08479 526 if (-x == y && e2 <= x) e2 = 0;
tmnt 0:ce10b2e08479 527 }
tmnt 0:ce10b2e08479 528 if (e2 > x) err += ++x*2+1;
tmnt 0:ce10b2e08479 529 } while (x <= 0);
tmnt 0:ce10b2e08479 530 }
tmnt 0:ce10b2e08479 531 void fillrect(int x0, int y0, int x1, int y1, int color)
tmnt 0:ce10b2e08479 532 {
tmnt 0:ce10b2e08479 533
tmnt 0:ce10b2e08479 534 int h = y1 - y0 + 1;
tmnt 0:ce10b2e08479 535 int w = x1 - x0 + 1;
tmnt 0:ce10b2e08479 536 int pixel = h * w;
tmnt 0:ce10b2e08479 537 //window(x0,y0,w,h);
tmnt 0:ce10b2e08479 538 wr_cmd(0x2C); // send pixel
tmnt 0:ce10b2e08479 539 //#if defined TARGET_KL25Z // 8 Bit SPI
tmnt 0:ce10b2e08479 540 for (int p=0; p<pixel; p++) {
tmnt 0:ce10b2e08479 541 spi.write(color >> 8);
tmnt 0:ce10b2e08479 542 spi.write(color & 0xff);
tmnt 0:ce10b2e08479 543 }
tmnt 0:ce10b2e08479 544 /*#else
tmnt 0:ce10b2e08479 545 SPI::format(16,3); // switch to 16 bit Mode 3
tmnt 0:ce10b2e08479 546 for (int p=0; p<pixel; p++) {
tmnt 0:ce10b2e08479 547 SPI::write(color);
tmnt 0:ce10b2e08479 548 }
tmnt 0:ce10b2e08479 549 SPI::format(8,3);
tmnt 0:ce10b2e08479 550 #endif*/
tmnt 0:ce10b2e08479 551 cs = 1;
tmnt 0:ce10b2e08479 552 //WindowMax();
tmnt 0:ce10b2e08479 553 return;
tmnt 0:ce10b2e08479 554 }
tmnt 0:ce10b2e08479 555
tmnt 0:ce10b2e08479 556 void I2cstart(void)
tmnt 0:ce10b2e08479 557 {
tmnt 0:ce10b2e08479 558 SDA=1;SCL=1; /* SCL,SDAは常時Highとする */
tmnt 0:ce10b2e08479 559 wait_us(2);
tmnt 0:ce10b2e08479 560 SDA=0;
tmnt 0:ce10b2e08479 561 wait_us(2); // SDA出力
tmnt 0:ce10b2e08479 562 }
tmnt 0:ce10b2e08479 563
tmnt 0:ce10b2e08479 564 void I2cstop(void)
tmnt 0:ce10b2e08479 565 {
tmnt 0:ce10b2e08479 566 SCL=0; // 先にSDA Low
tmnt 0:ce10b2e08479 567 wait_us(2);
tmnt 0:ce10b2e08479 568 SDA=0; // SCL Low
tmnt 0:ce10b2e08479 569 wait_us(2);
tmnt 0:ce10b2e08479 570 SCL=1; // SDA Low // 出力モードに戻す SDA =Low
tmnt 0:ce10b2e08479 571 wait_us(2);
tmnt 0:ce10b2e08479 572 SDA=1; // 先にSCLをHigh
tmnt 0:ce10b2e08479 573 wait_us(2);
tmnt 0:ce10b2e08479 574 // 後からSDAをHigh
tmnt 0:ce10b2e08479 575
tmnt 0:ce10b2e08479 576 }
tmnt 0:ce10b2e08479 577 void I2cout(unsigned char datar)
tmnt 0:ce10b2e08479 578 {
tmnt 0:ce10b2e08479 579 int ia;
tmnt 0:ce10b2e08479 580 for(ia=0;ia<8;ia++){
tmnt 0:ce10b2e08479 581 SCL=0;
tmnt 0:ce10b2e08479 582 if(datar & 0x80){SDA=1;}
tmnt 0:ce10b2e08479 583 else SDA=0;
tmnt 0:ce10b2e08479 584 datar<<=1;
tmnt 0:ce10b2e08479 585 wait_us(1);
tmnt 0:ce10b2e08479 586 SCL=1;
tmnt 0:ce10b2e08479 587 wait_us(2);
tmnt 0:ce10b2e08479 588 SCL=0;
tmnt 0:ce10b2e08479 589 wait_us(1);//wait();
tmnt 0:ce10b2e08479 590 }
tmnt 0:ce10b2e08479 591 wait_us(1);
tmnt 0:ce10b2e08479 592
tmnt 0:ce10b2e08479 593 SCL=1;
tmnt 0:ce10b2e08479 594 datar<<=1;
tmnt 0:ce10b2e08479 595 wait_us(2);
tmnt 0:ce10b2e08479 596 SCL=0;
tmnt 0:ce10b2e08479 597
tmnt 0:ce10b2e08479 598 wait_us(1);
tmnt 0:ce10b2e08479 599 }
tmnt 0:ce10b2e08479 600
tmnt 0:ce10b2e08479 601
tmnt 0:ce10b2e08479 602 void c(unsigned char adrs,unsigned char datak)
tmnt 0:ce10b2e08479 603 {
tmnt 0:ce10b2e08479 604 I2cstart();
tmnt 0:ce10b2e08479 605 I2cout(0x42);
tmnt 0:ce10b2e08479 606 I2cout(adrs);
tmnt 0:ce10b2e08479 607 I2cout(datak);
tmnt 0:ce10b2e08479 608 I2cstop();
tmnt 0:ce10b2e08479 609 wait_ms(10);
tmnt 0:ce10b2e08479 610 }
tmnt 0:ce10b2e08479 611
tmnt 0:ce10b2e08479 612
tmnt 0:ce10b2e08479 613 void cam_init(){
tmnt 0:ce10b2e08479 614 c(REG_COM7, COM7_RESET); //0x12:COM7(Reset,QCIF,Cbar,RGBformat)
tmnt 0:ce10b2e08479 615 wait_ms(200); //200ms
tmnt 0:ce10b2e08479 616
tmnt 0:ce10b2e08479 617 c(REG_COM7,COM7_RGB|COM7_FMT_QCIF); //0x12:COM7 , 0x0C) //QCIF, RGB
tmnt 0:ce10b2e08479 618
tmnt 0:ce10b2e08479 619 c(REG_RGB444, 0x00); //0x8c:RGB 444 control
tmnt 0:ce10b2e08479 620 c(REG_COM1, 0x00); //0x40 //0x04:COM1(CCIR656,AEC) //0) //0x40)
tmnt 0:ce10b2e08479 621 c(REG_COM15, COM15_R01FE|COM15_RGB565); //0x40:COM15
tmnt 0:ce10b2e08479 622
tmnt 0:ce10b2e08479 623 c(REG_COM9, 0x48); // 38 0x14:COM9=max AGC gain ceiling, Freeze AGC/AEC
tmnt 0:ce10b2e08479 624
tmnt 0:ce10b2e08479 625 //c(0x3d,0xc3); //(REG_COM13, COM13_GAMMA|COM13_UVSAT|0x2) //0x3d:COM13
tmnt 0:ce10b2e08479 626 c(REG_HAECC7,0x94); //0xaa:Hist AEC/AGC control 7 c(0xAA,0x94) //AEC algorithm
tmnt 0:ce10b2e08479 627
tmnt 0:ce10b2e08479 628 c(REG_TSLB,0x04); //0x3a:Neg,UVval,YUYV,window TSLB_YLAST) //0x04) //0x0C) //0x80) //0x00) //0x04)
tmnt 0:ce10b2e08479 629 c(0x20,0x04); //ADCCTR0, A/D range&ref, mu0102
tmnt 0:ce10b2e08479 630
tmnt 0:ce10b2e08479 631 /******* ringo *********/
tmnt 0:ce10b2e08479 632 c(REG_COM8,0xfd); //AGC,AWB OFF,res OK
tmnt 0:ce10b2e08479 633
tmnt 0:ce10b2e08479 634 c(0x10,0x0f);//AECコントロール(中位ビット)
tmnt 0:ce10b2e08479 635 c(0x07,0x00);//AECコントロール(上位ビット)
tmnt 0:ce10b2e08479 636 //by Mr.Shiono
tmnt 0:ce10b2e08479 637
tmnt 0:ce10b2e08479 638 c(0x01,0x40);
tmnt 0:ce10b2e08479 639 c(0x02,0x60);
tmnt 0:ce10b2e08479 640 c(0x03,0x0a);
tmnt 0:ce10b2e08479 641 c(0x0c,0x00);
tmnt 0:ce10b2e08479 642 c(0x0e,0x61);
tmnt 0:ce10b2e08479 643 c(0x0f,0x4b);
tmnt 0:ce10b2e08479 644 c(0x15,0x00);
tmnt 0:ce10b2e08479 645 c(0x16,0x02);
tmnt 0:ce10b2e08479 646 c(0x17,0x18); //HSTART
tmnt 0:ce10b2e08479 647 c(0x18,0x01);
tmnt 0:ce10b2e08479 648 c(0x19,0x02);
tmnt 0:ce10b2e08479 649 c(0x1a,0x7a);
tmnt 0:ce10b2e08479 650 c(0x1e,0x07);
tmnt 0:ce10b2e08479 651 c(0x21,0x02);
tmnt 0:ce10b2e08479 652 c(0x22,0x91);
tmnt 0:ce10b2e08479 653 c(0x29,0x07);
tmnt 0:ce10b2e08479 654 c(0x32,0xb6);
tmnt 0:ce10b2e08479 655 c(0x33,0x0b);
tmnt 0:ce10b2e08479 656 c(0x34,0x11);
tmnt 0:ce10b2e08479 657 c(0x35,0x0b);
tmnt 0:ce10b2e08479 658 c(0x37,0x1d);
tmnt 0:ce10b2e08479 659 c(0x38,0x71);
tmnt 0:ce10b2e08479 660 c(0x39,0x2a);
tmnt 0:ce10b2e08479 661 c(0x3b,0x92);//com11 ナイトモード
tmnt 0:ce10b2e08479 662 c(0x3c,0x78);
tmnt 0:ce10b2e08479 663 c(0x3d,0xc3);
tmnt 0:ce10b2e08479 664 c(0x3e,0x00);
tmnt 0:ce10b2e08479 665 c(0x3f,0x00);
tmnt 0:ce10b2e08479 666 c(0x41,0x08);
tmnt 0:ce10b2e08479 667 c(0x41,0x38);
tmnt 0:ce10b2e08479 668 c(0x43,0x0a);
tmnt 0:ce10b2e08479 669 c(0x44,0xf0);
tmnt 0:ce10b2e08479 670 c(0x45,0x34);
tmnt 0:ce10b2e08479 671 c(0x46,0x58);
tmnt 0:ce10b2e08479 672 c(0x47,0x28);
tmnt 0:ce10b2e08479 673 c(0x48,0x3a);
tmnt 0:ce10b2e08479 674 c(0x4b,0x09);
tmnt 0:ce10b2e08479 675 c(0x4c,0x00);
tmnt 0:ce10b2e08479 676 c(0x4d,0x40);
tmnt 0:ce10b2e08479 677 c(0x4e,0x20);
tmnt 0:ce10b2e08479 678 c(0x4f,0x80);//c(0x4f,0x80); 彩度調整
tmnt 0:ce10b2e08479 679 c(0x50,0x80);//c(0x50,0x80);
tmnt 0:ce10b2e08479 680 c(0x51,0x00);
tmnt 0:ce10b2e08479 681 c(0x52,0x22);//c(0x52,0x22);
tmnt 0:ce10b2e08479 682 c(0x53,0x5e);//c(0x52,0x5e);
tmnt 0:ce10b2e08479 683 c(0x54,0x80);//c(0x54,0x80);
tmnt 0:ce10b2e08479 684 c(0x56,0x40);
tmnt 0:ce10b2e08479 685 c(0x58,0x9e);
tmnt 0:ce10b2e08479 686 c(0x59,0x88);
tmnt 0:ce10b2e08479 687 c(0x5a,0x88);
tmnt 0:ce10b2e08479 688 c(0x5b,0x44);
tmnt 0:ce10b2e08479 689 c(0x5c,0x67);
tmnt 0:ce10b2e08479 690 c(0x5d,0x49);
tmnt 0:ce10b2e08479 691 c(0x5e,0x0e);
tmnt 0:ce10b2e08479 692 c(0x69,0x00);
tmnt 0:ce10b2e08479 693 c(0x6a,0x40);
tmnt 0:ce10b2e08479 694 c(0x6b,0x0a);
tmnt 0:ce10b2e08479 695 c(0x6c,0x0a);
tmnt 0:ce10b2e08479 696 c(0x6d,0x55);
tmnt 0:ce10b2e08479 697 c(0x6e,0x11);
tmnt 0:ce10b2e08479 698 c(0x6f,0x9f);
tmnt 0:ce10b2e08479 699 c(0x70,0x3a);
tmnt 0:ce10b2e08479 700 c(0x71,0x35);
tmnt 0:ce10b2e08479 701 c(0x72,0x11);
tmnt 0:ce10b2e08479 702 c(0x73,0xf0);
tmnt 0:ce10b2e08479 703 c(0x74,0x10);
tmnt 0:ce10b2e08479 704 c(0x75,0x05);
tmnt 0:ce10b2e08479 705 c(0x76,0xe1);
tmnt 0:ce10b2e08479 706 c(0x77,0x01);
tmnt 0:ce10b2e08479 707 c(0x78,0x04);
tmnt 0:ce10b2e08479 708 c(0x79,0x01);
tmnt 0:ce10b2e08479 709 c(0x8d,0x4f);
tmnt 0:ce10b2e08479 710 c(0x8e,0x00);
tmnt 0:ce10b2e08479 711 c(0x8f,0x00);
tmnt 0:ce10b2e08479 712 c(0x90,0x00);
tmnt 0:ce10b2e08479 713 c(0x91,0x00);
tmnt 0:ce10b2e08479 714 c(0x96,0x00);
tmnt 0:ce10b2e08479 715 c(0x96,0x00); //?
tmnt 0:ce10b2e08479 716 c(0x97,0x30);
tmnt 0:ce10b2e08479 717 c(0x98,0x20);
tmnt 0:ce10b2e08479 718 c(0x99,0x30);
tmnt 0:ce10b2e08479 719 c(0x9a,0x00);
tmnt 0:ce10b2e08479 720 c(0x9a,0x84); //?
tmnt 0:ce10b2e08479 721 c(0x9b,0x29);
tmnt 0:ce10b2e08479 722 c(0x9c,0x03);
tmnt 0:ce10b2e08479 723 c(0x9d,0x4c);
tmnt 0:ce10b2e08479 724 c(0x9e,0x3f);
tmnt 0:ce10b2e08479 725 c(0xa2,0x02);
tmnt 0:ce10b2e08479 726 c(0xa4,0x88);
tmnt 0:ce10b2e08479 727 c(0xb0,0x84);
tmnt 0:ce10b2e08479 728 c(0xb1,0x0c);
tmnt 0:ce10b2e08479 729 c(0xb2,0x0e);
tmnt 0:ce10b2e08479 730 c(0xb3,0x82);
tmnt 0:ce10b2e08479 731 c(0xb8,0x0a);
tmnt 0:ce10b2e08479 732 c(0xc8,0xf0);
tmnt 0:ce10b2e08479 733 c(0xc9,0x60);
tmnt 0:ce10b2e08479 734 c(0x6b,0x40);//入力クロックx4
tmnt 0:ce10b2e08479 735 c(REG_CLKRC,0x40); //0xaf //PCLK*(1/48)
tmnt 0:ce10b2e08479 736
tmnt 0:ce10b2e08479 737 }
tmnt 0:ce10b2e08479 738
tmnt 0:ce10b2e08479 739
tmnt 0:ce10b2e08479 740
tmnt 0:ce10b2e08479 741 void camdma_start()
tmnt 0:ce10b2e08479 742 {
tmnt 0:ce10b2e08479 743 if(flag_dma==0){
tmnt 0:ce10b2e08479 744 HAL_DMA_Start_IT(&DMA_HandleType/*DMA初期設定構造体*/, (uint32_t)&GPIOB->IDR/*&0x00ff転送元アドレス*/, (uint32_t)dma_buf/*転送先アドレス*/,43500/*データ転送回数*/);
tmnt 0:ce10b2e08479 745
tmnt 0:ce10b2e08479 746 HAL_SPI_Transmit_DMA(&spi1, (uint8_t*)dma_buf, sizeof(dma_buf));
tmnt 0:ce10b2e08479 747
tmnt 0:ce10b2e08479 748 // HAL_ADC_Start_DMA(&ADC_1_dma,(uint32_t*)ad_dma_buf,3);
tmnt 0:ce10b2e08479 749 }
tmnt 0:ce10b2e08479 750 flag_dma=1;
tmnt 0:ce10b2e08479 751 }