LibDriver OV2640
Loading...
Searching...
No Matches
driver_ov2640.c
Go to the documentation of this file.
1
36
37#include "driver_ov2640.h"
38
42#define CHIP_NAME "OmniVision OV2640"
43#define MANUFACTURER_NAME "OmniVision"
44#define SUPPLY_VOLTAGE_MIN 2.5f
45#define SUPPLY_VOLTAGE_MAX 3.0f
46#define MAX_CURRENT 40.0f
47#define TEMPERATURE_MIN -30.0f
48#define TEMPERATURE_MAX 70.0f
49#define DRIVER_VERSION 1000
50
54#define OV2640_ADDRESS 0x60
55
59#define OV2640_REG_DSP_BANK_R_BYPASS 0x05
60#define OV2640_REG_DSP_BANK_QS 0x44
61#define OV2640_REG_DSP_BANK_CTRLI 0x50
62#define OV2640_REG_DSP_BANK_HSIZE 0x51
63#define OV2640_REG_DSP_BANK_VSIZE 0x52
64#define OV2640_REG_DSP_BANK_XOFFL 0x53
65#define OV2640_REG_DSP_BANK_YOFFL 0x54
66#define OV2640_REG_DSP_BANK_VHYX 0x55
67#define OV2640_REG_DSP_BANK_DPRP 0x56
68#define OV2640_REG_DSP_BANK_TEST 0x57
69#define OV2640_REG_DSP_BANK_ZMOW 0x5A
70#define OV2640_REG_DSP_BANK_ZMOH 0x5B
71#define OV2640_REG_DSP_BANK_ZMHH 0x5C
72#define OV2640_REG_DSP_BANK_BPADDR 0x7C
73#define OV2640_REG_DSP_BANK_BPDATA 0x7D
74#define OV2640_REG_DSP_BANK_CTRL2 0x86
75#define OV2640_REG_DSP_BANK_CTRL3 0x87
76#define OV2640_REG_DSP_BANK_SIZEL 0x8C
77#define OV2640_REG_DSP_BANK_HSIZE8 0xC0
78#define OV2640_REG_DSP_BANK_VSIZE8 0xC1
79#define OV2640_REG_DSP_BANK_CTRL0 0xC2
80#define OV2640_REG_DSP_BANK_CTRL1 0xC3
81#define OV2640_REG_DSP_BANK_R_DVP_SP 0xD3
82#define OV2640_REG_DSP_BANK_IMAGE_MODE 0xDA
83#define OV2640_REG_DSP_BANK_RESET 0xE0
84#define OV2640_REG_DSP_BANK_MS_SP 0xF0
85#define OV2640_REG_DSP_BANK_SS_ID 0xF7
86#define OV2640_REG_DSP_BANK_SS_CTRL 0xF8
87#define OV2640_REG_DSP_BANK_MC_BIST 0xF9
88#define OV2640_REG_DSP_BANK_MC_AL 0xFA
89#define OV2640_REG_DSP_BANK_MC_AH 0xFB
90#define OV2640_REG_DSP_BANK_MC_D 0xFC
91#define OV2640_REG_DSP_BANK_P_CMD 0xFD
92#define OV2640_REG_DSP_BANK_P_STATUS 0xFE
93#define OV2640_REG_DSP_BANK_RA_DLMT 0xFF
94
98#define OV2640_REG_SENSOR_BANK_GAIN 0x00
99#define OV2640_REG_SENSOR_BANK_COM1 0x03
100#define OV2640_REG_SENSOR_BANK_REG04 0x04
101#define OV2640_REG_SENSOR_BANK_REG08 0x08
102#define OV2640_REG_SENSOR_BANK_COM2 0x09
103#define OV2640_REG_SENSOR_BANK_PIDH 0x0A
104#define OV2640_REG_SENSOR_BANK_PIDL 0x0B
105#define OV2640_REG_SENSOR_BANK_COM3 0x0C
106#define OV2640_REG_SENSOR_BANK_COM4 0x0D
107#define OV2640_REG_SENSOR_BANK_AEC 0x10
108#define OV2640_REG_SENSOR_BANK_CLKRC 0x11
109#define OV2640_REG_SENSOR_BANK_COM7 0x12
110#define OV2640_REG_SENSOR_BANK_COM8 0x13
111#define OV2640_REG_SENSOR_BANK_COM9 0x14
112#define OV2640_REG_SENSOR_BANK_COM10 0x15
113#define OV2640_REG_SENSOR_BANK_HREFST 0x17
114#define OV2640_REG_SENSOR_BANK_HREFEND 0x18
115#define OV2640_REG_SENSOR_BANK_VSTRT 0x19
116#define OV2640_REG_SENSOR_BANK_VEND 0x1A
117#define OV2640_REG_SENSOR_BANK_MIDH 0x1C
118#define OV2640_REG_SENSOR_BANK_MIDL 0x1D
119#define OV2640_REG_SENSOR_BANK_AEW 0x24
120#define OV2640_REG_SENSOR_BANK_AEB 0x25
121#define OV2640_REG_SENSOR_BANK_VV 0x26
122#define OV2640_REG_SENSOR_BANK_REG2A 0x2A
123#define OV2640_REG_SENSOR_BANK_FRARL 0x2B
124#define OV2640_REG_SENSOR_BANK_ADDVSL 0x2D
125#define OV2640_REG_SENSOR_BANK_ADDVSH 0x2E
126#define OV2640_REG_SENSOR_BANK_YAVG 0x2F
127#define OV2640_REG_SENSOR_BANK_HSDY 0x30
128#define OV2640_REG_SENSOR_BANK_HEDY 0x31
129#define OV2640_REG_SENSOR_BANK_REG32 0x32
130#define OV2640_REG_SENSOR_BANK_ARCOM2 0x34
131#define OV2640_REG_SENSOR_BANK_REG45 0x45
132#define OV2640_REG_SENSOR_BANK_FLL 0x46
133#define OV2640_REG_SENSOR_BANK_FLH 0x47
134#define OV2640_REG_SENSOR_BANK_COM19 0x48
135#define OV2640_REG_SENSOR_BANK_ZOOMS 0x49
136#define OV2640_REG_SENSOR_BANK_COM22 0x4B
137#define OV2640_REG_SENSOR_BANK_COM25 0x4E
138#define OV2640_REG_SENSOR_BANK_BD50 0x4F
139#define OV2640_REG_SENSOR_BANK_BD60 0x50
140#define OV2640_REG_SENSOR_BANK_REG5D 0x5D
141#define OV2640_REG_SENSOR_BANK_REG5E 0x5E
142#define OV2640_REG_SENSOR_BANK_REG5F 0x5F
143#define OV2640_REG_SENSOR_BANK_REG60 0x60
144#define OV2640_REG_SENSOR_BANK_HISTO_LOW 0x61
145#define OV2640_REG_SENSOR_BANK_HISTO_HIGH 0x62
146
150const uint8_t gsc_ov2640_init_table[][2];
151const uint8_t gsc_ov2640_jpeg_init_table[][2];
153
157const uint8_t gsc_ov2640_init_table[][2] =
158{
159 {0xFF, 0x00},
160 {0x2C, 0xFF},
161 {0x2E, 0xDF},
162 {0xFF, 0x01},
163 {0x3C, 0x32},
164 {0x11, 0x00},
165 {0x09, 0x02},
166 {0x04, 0xD8},
167 {0x13, 0xE5},
168 {0x14, 0x48},
169 {0x2C, 0x0C},
170 {0x33, 0x78},
171 {0x3A, 0x33},
172 {0x3B, 0xFB},
173 {0x3E, 0x00},
174 {0x43, 0x11},
175 {0x16, 0x10},
176 {0x39, 0x92},
177 {0x35, 0xDA},
178 {0x22, 0x1A},
179 {0x37, 0xC3},
180 {0x23, 0x00},
181 {0x34, 0xC0},
182 {0x36, 0x1A},
183 {0x06, 0x88},
184 {0x07, 0xC0},
185 {0x0D, 0x87},
186 {0x0E, 0x41},
187 {0x4C, 0x00},
188 {0x48, 0x00},
189 {0x5B, 0x00},
190 {0x42, 0x03},
191 {0x4A, 0x81},
192 {0x21, 0x99},
193 {0x24, 0x40},
194 {0x25, 0x38},
195 {0x26, 0x82},
196 {0x5C, 0x00},
197 {0x63, 0x00},
198 {0x46, 0x00},
199 {0x0C, 0x3C},
200 {0x61, 0x70},
201 {0x62, 0x80},
202 {0x7C, 0x05},
203 {0x20, 0x80},
204 {0x28, 0x30},
205 {0x6C, 0x00},
206 {0x6D, 0x80},
207 {0x6E, 0x00},
208 {0x70, 0x02},
209 {0x71, 0x94},
210 {0x73, 0xC1},
211 {0x3D, 0x34},
212 {0x5A, 0x57},
213 {0x12, 0x00},
214 {0x17, 0x11},
215 {0x18, 0x75},
216 {0x19, 0x01},
217 {0x1A, 0x97},
218 {0x32, 0x36},
219 {0x03, 0x0F},
220 {0x37, 0x40},
221 {0x4F, 0xCA},
222 {0x50, 0xA8},
223 {0x5A, 0x23},
224 {0x6D, 0x00},
225 {0x6D, 0x38},
226 {0xFF, 0x00},
227 {0xE5, 0x7F},
228 {0xF9, 0xC0},
229 {0x41, 0x24},
230 {0xE0, 0x14},
231 {0x76, 0xFF},
232 {0x33, 0xA0},
233 {0x42, 0x20},
234 {0x43, 0x18},
235 {0x4C, 0x00},
236 {0x87, 0xD5},
237 {0x88, 0x3F},
238 {0xD7, 0x03},
239 {0xD9, 0x10},
240 {0xD3, 0x82},
241 {0xC8, 0x08},
242 {0xC9, 0x80},
243 {0x7C, 0x00},
244 {0x7D, 0x00},
245 {0x7C, 0x03},
246 {0x7D, 0x48},
247 {0x7D, 0x48},
248 {0x7C, 0x08},
249 {0x7D, 0x20},
250 {0x7D, 0x10},
251 {0x7D, 0x0E},
252 {0x90, 0x00},
253 {0x91, 0x0E},
254 {0x91, 0x1A},
255 {0x91, 0x31},
256 {0x91, 0x5A},
257 {0x91, 0x69},
258 {0x91, 0x75},
259 {0x91, 0x7E},
260 {0x91, 0x88},
261 {0x91, 0x8F},
262 {0x91, 0x96},
263 {0x91, 0xA3},
264 {0x91, 0xAF},
265 {0x91, 0xC4},
266 {0x91, 0xD7},
267 {0x91, 0xE8},
268 {0x91, 0x20},
269 {0x92, 0x00},
270 {0x93, 0x06},
271 {0x93, 0xE3},
272 {0x93, 0x05},
273 {0x93, 0x05},
274 {0x93, 0x00},
275 {0x93, 0x04},
276 {0x93, 0x00},
277 {0x93, 0x00},
278 {0x93, 0x00},
279 {0x93, 0x00},
280 {0x93, 0x00},
281 {0x93, 0x00},
282 {0x93, 0x00},
283 {0x96, 0x00},
284 {0x97, 0x08},
285 {0x97, 0x19},
286 {0x97, 0x02},
287 {0x97, 0x0C},
288 {0x97, 0x24},
289 {0x97, 0x30},
290 {0x97, 0x28},
291 {0x97, 0x26},
292 {0x97, 0x02},
293 {0x97, 0x98},
294 {0x97, 0x80},
295 {0x97, 0x00},
296 {0x97, 0x00},
297 {0xC3, 0xEF},
298 {0xA4, 0x00},
299 {0xA8, 0x00},
300 {0xC5, 0x11},
301 {0xC6, 0x51},
302 {0xBF, 0x80},
303 {0xC7, 0x10},
304 {0xB6, 0x66},
305 {0xB8, 0xA5},
306 {0xB7, 0x64},
307 {0xB9, 0x7C},
308 {0xB3, 0xAF},
309 {0xB4, 0x97},
310 {0xB5, 0xFF},
311 {0xB0, 0xC5},
312 {0xB1, 0x94},
313 {0xB2, 0x0F},
314 {0xC4, 0x5C},
315 {0xC0, 0xC8},
316 {0xC1, 0x96},
317 {0x8C, 0x00},
318 {0x86, 0x3D},
319 {0x50, 0x00},
320 {0x51, 0x90},
321 {0x52, 0x2C},
322 {0x53, 0x00},
323 {0x54, 0x00},
324 {0x55, 0x88},
325 {0x5A, 0x90},
326 {0x5B, 0x2C},
327 {0x5C, 0x05},
328 {0xD3, 0x02},
329 {0xC3, 0xED},
330 {0x7F, 0x00},
331 {0xDA, 0x09},
332 {0xE5, 0x1F},
333 {0xE1, 0x67},
334 {0xE0, 0x00},
335 {0xDD, 0x7F},
336 {0x05, 0x00},
337};
338
342const uint8_t gsc_ov2640_jpeg_init_table[][2] =
343{
344 {0xFF, 0x00},
345 {0xDA, 0x10},
346 {0xD7, 0x03},
347 {0xDF, 0x00},
348 {0x33, 0x80},
349 {0x3C, 0x40},
350 {0xE1, 0x77},
351 {0x00, 0x00},
352 {0xFF, 0x01},
353 {0xE0, 0x14},
354 {0xE1, 0x77},
355 {0xE5, 0x1F},
356 {0xD7, 0x03},
357 {0xDA, 0x10},
358 {0xE0, 0x00},
359};
360
364const uint8_t gsc_ov2640_rgb565_init_table[][2] =
365{
366 {0xFF, 0x00},
367 {0xDA, 0x09},
368 {0xD7, 0x03},
369 {0xDF, 0x02},
370 {0x33, 0xA0},
371 {0x3C, 0x00},
372 {0xE1, 0x67},
373 {0xFF, 0x01},
374 {0xE0, 0x00},
375 {0xE1, 0x00},
376 {0xE5, 0x00},
377 {0xD7, 0x00},
378 {0xDA, 0x00},
379 {0xE0, 0x00},
380};
381
392static uint8_t a_ov2640_dsp_read(ov2640_handle_t *handle, uint8_t reg, uint8_t *data)
393{
394 uint8_t config;
395
396 if (handle->sccb_read(OV2640_ADDRESS, OV2640_REG_DSP_BANK_RA_DLMT, &config, 1) != 0) /* read ra_dlmt */
397 {
398 return 1; /* return error */
399 }
400 if ((config & 0x01) != 0) /* check config */
401 {
402 config &= ~(1 << 0); /* clear bit0 */
403 if (handle->sccb_write(OV2640_ADDRESS, OV2640_REG_DSP_BANK_RA_DLMT, &config, 1) != 0) /* use the dsp bank */
404 {
405 return 1; /* return error */
406 }
407 }
408
409 if (handle->sccb_read(OV2640_ADDRESS, reg, data, 1) != 0) /* read dsp reg */
410 {
411 return 1; /* return error */
412 }
413
414 return 0; /* success return 0 */
415}
416
427static uint8_t a_ov2640_dsp_write(ov2640_handle_t *handle, uint8_t reg, uint8_t data)
428{
429 uint8_t config;
430
431 if (handle->sccb_read(OV2640_ADDRESS, OV2640_REG_DSP_BANK_RA_DLMT, &config, 1) != 0) /* read ra_dlmt */
432 {
433 return 1; /* return error */
434 }
435 if ((config & 0x01) != 0) /* check config */
436 {
437 config &= ~(1 << 0); /* clear bit0 */
438 if (handle->sccb_write(OV2640_ADDRESS, OV2640_REG_DSP_BANK_RA_DLMT, &config, 1) != 0) /* use the dsp bank */
439 {
440 return 1; /* return error */
441 }
442 }
443
444 if (handle->sccb_write(OV2640_ADDRESS, reg, &data, 1) != 0) /* write dsp reg */
445 {
446 return 1; /* return error */
447 }
448
449 return 0; /* success return 0 */
450}
451
462static uint8_t a_ov2640_sensor_read(ov2640_handle_t *handle, uint8_t reg, uint8_t *data)
463{
464 uint8_t config;
465
466 if (handle->sccb_read(OV2640_ADDRESS, OV2640_REG_DSP_BANK_RA_DLMT, &config, 1) != 0) /* read ra_dlmt */
467 {
468 return 1; /* return error */
469 }
470 if ((config & 0x01) == 0) /* check config */
471 {
472 config |= (1 << 0); /* set bit0 */
473 if (handle->sccb_write(OV2640_ADDRESS, OV2640_REG_DSP_BANK_RA_DLMT, &config, 1) != 0) /* use the dsp bank */
474 {
475 return 1; /* return error */
476 }
477 }
478
479 if (handle->sccb_read(OV2640_ADDRESS, reg, data, 1) != 0) /* read dsp reg */
480 {
481 return 1; /* return error */
482 }
483
484 return 0; /* success return 0 */
485}
486
497static uint8_t a_ov2640_sensor_write(ov2640_handle_t *handle, uint8_t reg, uint8_t data)
498{
499 uint8_t config;
500
501 if (handle->sccb_read(OV2640_ADDRESS, OV2640_REG_DSP_BANK_RA_DLMT, &config, 1) != 0) /* read ra_dlmt */
502 {
503 return 1; /* return error */
504 }
505 if ((config & 0x01) == 0) /* check config */
506 {
507 config |= (1 << 0); /* set bit0 */
508 if (handle->sccb_write(OV2640_ADDRESS, OV2640_REG_DSP_BANK_RA_DLMT, &config, 1) != 0) /* use the dsp bank */
509 {
510 return 1; /* return error */
511 }
512 }
513
514 if (handle->sccb_write(OV2640_ADDRESS, reg, &data, 1) != 0) /* write dsp reg */
515 {
516 return 1; /* return error */
517 }
518
519 return 0; /* success return 0 */
520}
521
538{
539 uint8_t res;
540 uint8_t reg;
541 uint16_t id;
542
543 if (handle == NULL) /* check handle */
544 {
545 return 2; /* return error */
546 }
547 if (handle->debug_print == NULL) /* check debug_print */
548 {
549 return 3; /* return error */
550 }
551 if (handle->sccb_init == NULL) /* check sccb_init */
552 {
553 handle->debug_print("ov2640: sccb_init is null.\n"); /* sccb_init is null */
554
555 return 3; /* return error */
556 }
557 if (handle->sccb_deinit == NULL) /* check sccb_deinit */
558 {
559 handle->debug_print("ov2640: sccb_deinit is null.\n"); /* sccb_deinit is null */
560
561 return 3; /* return error */
562 }
563 if (handle->sccb_read == NULL) /* check sccb_read */
564 {
565 handle->debug_print("ov2640: sccb_read is null.\n"); /* sccb_read is null */
566
567 return 3; /* return error */
568 }
569 if (handle->sccb_write == NULL) /* check sccb_write */
570 {
571 handle->debug_print("ov2640: sccb_write is null.\n"); /* sccb_write is null */
572
573 return 3; /* return error */
574 }
575 if (handle->power_down_init == NULL) /* check power_down_init */
576 {
577 handle->debug_print("ov2640: power_down_init is null.\n"); /* power_down_init is null */
578
579 return 3; /* return error */
580 }
581 if (handle->power_down_deinit == NULL) /* check power_down_deinit */
582 {
583 handle->debug_print("ov2640: power_down_deinit is null.\n"); /* power_down_deinit is null */
584
585 return 3; /* return error */
586 }
587 if (handle->power_down_write == NULL) /* check power_down_write */
588 {
589 handle->debug_print("ov2640: power_down_write is null.\n"); /* power_down_write is null */
590
591 return 3; /* return error */
592 }
593 if (handle->reset_init == NULL) /* check reset_init */
594 {
595 handle->debug_print("ov2640: reset_init is null.\n"); /* reset_init is null */
596
597 return 3; /* return error */
598 }
599 if (handle->reset_deinit == NULL) /* check reset_deinit */
600 {
601 handle->debug_print("ov2640: reset_deinit is null.\n"); /* reset_deinit is null */
602
603 return 3; /* return error */
604 }
605 if (handle->reset_write == NULL) /* check reset_write */
606 {
607 handle->debug_print("ov2640: reset_write is null.\n"); /* reset_write is null */
608
609 return 3; /* return error */
610 }
611 if (handle->delay_ms == NULL) /* check delay_ms */
612 {
613 handle->debug_print("ov2640: delay_ms is null.\n"); /* delay_ms is null */
614
615 return 3; /* return error */
616 }
617
618 if (handle->power_down_init() != 0) /* power down init */
619 {
620 handle->debug_print("ov2640: power down init failed.\n"); /* power down init failed */
621
622 return 4; /* return error */
623 }
624 if (handle->reset_init() != 0) /* reset init */
625 {
626 handle->debug_print("ov2640: reset init failed.\n"); /* reset init failed */
627 (void)handle->power_down_deinit(); /* power down deinit */
628
629 return 4; /* return error */
630 }
631 if (handle->sccb_init() != 0) /* sccb init */
632 {
633 handle->debug_print("ov2640: sccb init failed.\n"); /* sccb init failed */
634 (void)handle->reset_deinit(); /* reset deinit */
635 (void)handle->power_down_deinit(); /* power down deinit */
636
637 return 1; /* return error */
638 }
639
640 if (handle->power_down_write(0) != 0) /* power on */
641 {
642 handle->debug_print("ov2640: power down write failed.\n"); /* power down write failed */
643 (void)handle->sccb_deinit(); /* sccb deinit */
644 (void)handle->reset_deinit(); /* reset deinit */
645 (void)handle->power_down_deinit(); /* power down deinit */
646
647 return 5; /* return error */
648 }
649 handle->delay_ms(10); /* delay 10ms */
650
651 if (handle->reset_write(0) != 0) /* reset write low */
652 {
653 handle->debug_print("ov2640: reset write failed.\n"); /* reset write failed */
654 (void)handle->sccb_deinit(); /* sccb deinit */
655 (void)handle->reset_deinit(); /* reset deinit */
656 (void)handle->power_down_deinit(); /* power down deinit */
657
658 return 5; /* return error */
659 }
660 handle->delay_ms(10); /* delay 10ms */
661 if (handle->reset_write(1) != 0) /* reset write high */
662 {
663 handle->debug_print("ov2640: reset write failed.\n"); /* reset write failed */
664 (void)handle->sccb_deinit(); /* sccb deinit */
665 (void)handle->reset_deinit(); /* reset deinit */
666 (void)handle->power_down_deinit(); /* power down deinit */
667
668 return 5; /* return error */
669 }
670 handle->delay_ms(10); /* delay 10ms */
671
672 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM7, &reg); /* read com7 */
673 if (res != 0) /* check result */
674 {
675 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
676 (void)handle->sccb_deinit(); /* sccb deinit */
677 (void)handle->reset_deinit(); /* reset deinit */
678 (void)handle->power_down_deinit(); /* power down deinit */
679
680 return 6; /* return error */
681 }
682 reg |= (1 << 7); /* set software reset */
683 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM7, reg); /* write com7 */
684 if (res != 0) /* check result */
685 {
686 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
687 (void)handle->sccb_deinit(); /* sccb deinit */
688 (void)handle->reset_deinit(); /* reset deinit */
689 (void)handle->power_down_deinit(); /* power down deinit */
690
691 return 6; /* return error */
692 }
693 handle->delay_ms(50); /* delay 50ms */
694
695 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_MIDH, &reg); /* read id number */
696 if (res != 0) /* check result */
697 {
698 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
699 (void)handle->sccb_deinit(); /* sccb deinit */
700 (void)handle->reset_deinit(); /* reset deinit */
701 (void)handle->power_down_deinit(); /* power down deinit */
702
703 return 7; /* return error */
704 }
705 id = (uint16_t)reg << 8; /* set msb */
706 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_MIDL, &reg); /* read id number */
707 if (res != 0) /* check result */
708 {
709 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
710 (void)handle->sccb_deinit(); /* sccb deinit */
711 (void)handle->reset_deinit(); /* reset deinit */
712 (void)handle->power_down_deinit(); /* power down deinit */
713
714 return 7; /* return error */
715 }
716 id |= reg; /* set lsb */
717 if (id != 0X7FA2) /* check id */
718 {
719 handle->debug_print("ov2640: manufacturer id is invalid.\n"); /* manufacturer id is invalid */
720 (void)handle->sccb_deinit(); /* sccb deinit */
721 (void)handle->reset_deinit(); /* reset deinit */
722 (void)handle->power_down_deinit(); /* power down deinit */
723
724 return 7; /* return error */
725 }
726 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_PIDH, &reg); /* read product id number msb */
727 if (res != 0) /* check result */
728 {
729 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
730 (void)handle->sccb_deinit(); /* sccb deinit */
731 (void)handle->reset_deinit(); /* reset deinit */
732 (void)handle->power_down_deinit(); /* power down deinit */
733
734 return 8; /* return error */
735 }
736 id = (uint16_t)reg << 8; /* set msb */
737 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_PIDL, &reg); /* read product id number lsb */
738 if (res != 0) /* check result */
739 {
740 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
741 (void)handle->sccb_deinit(); /* sccb deinit */
742 (void)handle->reset_deinit(); /* reset deinit */
743 (void)handle->power_down_deinit(); /* power down deinit */
744
745 return 8; /* return error */
746 }
747 id |= reg; /* set lsb */
748 if (id != 0X2642) /* check id */
749 {
750 handle->debug_print("ov2640: product id is invalid.\n"); /* product id is invalid */
751 (void)handle->sccb_deinit(); /* sccb deinit */
752 (void)handle->reset_deinit(); /* reset deinit */
753 (void)handle->power_down_deinit(); /* power down deinit */
754
755 return 8; /* return error */
756 }
757 handle->inited = 1; /* flag finish initialization */
758
759 return 0; /* success return 0 */
760}
761
775{
776 uint8_t res;
777 uint8_t reg;
778
779 if (handle == NULL) /* check handle */
780 {
781 return 2; /* return error */
782 }
783 if (handle->inited != 1) /* check handle initialization */
784 {
785 return 3; /* return error */
786 }
787
788 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM7, &reg); /* read com7 */
789 if (res != 0) /* check result */
790 {
791 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
792
793 return 4; /* return error */
794 }
795 reg |= (1 << 7); /* set software reset */
796 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM7, reg); /* write com7 */
797 if (res != 0) /* check result */
798 {
799 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
800
801 return 4; /* return error */
802 }
803 handle->delay_ms(50); /* delay 50ms */
804
805 if (handle->power_down_write(1) != 0) /* power down */
806 {
807 handle->debug_print("ov2640: power down write failed.\n"); /* power down write failed */
808
809 return 5; /* return error */
810 }
811 handle->delay_ms(10); /* delay 10ms */
812
813 if (handle->reset_deinit() != 0) /* reset deinit */
814 {
815 handle->debug_print("ov2640: reset deinit failed.\n"); /* reset deinit failed */
816
817 return 1; /* return error */
818 }
819 if (handle->power_down_deinit() != 0) /* power down deinit */
820 {
821 handle->debug_print("ov2640: power down deinit failed.\n"); /* power down deinit failed */
822
823 return 1; /* return error */
824 }
825 if (handle->sccb_deinit() != 0) /* sccb deinit */
826 {
827 handle->debug_print("ov2640: sccb deinit failed.\n"); /* sccb deinit failed */
828
829 return 1; /* return error */
830 }
831 handle->inited = 0; /* flag close */
832
833 return 0; /* success return 0 */
834}
835
847{
848 uint8_t res;
849 uint8_t reg;
850 uint16_t i;
851
852 if (handle == NULL) /* check handle */
853 {
854 return 2; /* return error */
855 }
856 if (handle->inited != 1) /* check handle initialization */
857 {
858 return 3; /* return error */
859 }
860
861 for (i = 0; i < (sizeof(gsc_ov2640_init_table) / 2); i++) /* write all */
862 {
863 reg = gsc_ov2640_init_table[i][1]; /* set reg */
864 res = handle->sccb_write(OV2640_ADDRESS,
866 (uint8_t *)&reg, 1); /* sccb write */
867 if (res != 0) /* check the result */
868 {
869 handle->debug_print("ov2640: sccb write failed.\n"); /* sccb write failed */
870
871 return 1; /* return error */
872 }
873 }
874
875 return 0; /* success return 0 */
876}
877
889{
890 uint8_t res;
891 uint8_t reg;
892 uint16_t i;
893
894 if (handle == NULL) /* check handle */
895 {
896 return 2; /* return error */
897 }
898 if (handle->inited != 1) /* check handle initialization */
899 {
900 return 3; /* return error */
901 }
902
903 for (i = 0; i < (sizeof(gsc_ov2640_jpeg_init_table) / 2); i++) /* write all */
904 {
905 reg = gsc_ov2640_jpeg_init_table[i][1]; /* set reg */
906 res = handle->sccb_write(OV2640_ADDRESS,
908 (uint8_t *)&reg, 1); /* sccb write */
909 if (res != 0) /* check the result */
910 {
911 handle->debug_print("ov2640: sccb write failed.\n"); /* sccb write failed */
912
913 return 1; /* return error */
914 }
915 }
916
917 return 0; /* success return 0 */
918}
919
931{
932 uint8_t res;
933 uint8_t reg;
934 uint16_t i;
935
936 if (handle == NULL) /* check handle */
937 {
938 return 2; /* return error */
939 }
940 if (handle->inited != 1) /* check handle initialization */
941 {
942 return 3; /* return error */
943 }
944
945 for (i = 0; i < (sizeof(gsc_ov2640_rgb565_init_table) / 2); i++) /* write all */
946 {
947 reg = gsc_ov2640_rgb565_init_table[i][1]; /* set reg */
948 res = handle->sccb_write(OV2640_ADDRESS,
950 (uint8_t *)&reg, 1); /* sccb write */
951 if (res != 0) /* check the result */
952 {
953 handle->debug_print("ov2640: sccb write failed.\n"); /* sccb write failed */
954
955 return 1; /* return error */
956 }
957 }
958
959 return 0; /* success return 0 */
960}
961
975uint8_t ov2640_set_agc_gain(ov2640_handle_t *handle, uint16_t gain)
976{
977 uint8_t res;
978 uint8_t prev;
979
980 if (handle == NULL) /* check handle */
981 {
982 return 2; /* return error */
983 }
984 if (handle->inited != 1) /* check handle initialization */
985 {
986 return 3; /* return error */
987 }
988 if (gain > 0x3FF) /* check gain */
989 {
990 handle->debug_print("ov2640: gain > 0x3FF.\n"); /* gain > 0x3FF */
991
992 return 4; /* return error */
993 }
994
995 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_GAIN, gain & 0xFF); /* write gain */
996 if (res != 0) /* check result */
997 {
998 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
999
1000 return 1; /* return error */
1001 }
1002 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG45, &prev); /* read gain */
1003 if (res != 0) /* check result */
1004 {
1005 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1006
1007 return 1; /* return error */
1008 }
1009 prev &= ~(3 << 6); /* clear settings */
1010 prev |= ((gain >> 8) & 0x03) << 6; /* set gain */
1011 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_REG45, prev); /* write gain */
1012 if (res != 0) /* check result */
1013 {
1014 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
1015
1016 return 1; /* return error */
1017 }
1018
1019 return 0; /* success return 0 */
1020}
1021
1033uint8_t ov2640_get_agc_gain(ov2640_handle_t *handle, uint16_t *gain)
1034{
1035 uint8_t res;
1036 uint8_t prev;
1037
1038 if (handle == NULL) /* check handle */
1039 {
1040 return 2; /* return error */
1041 }
1042 if (handle->inited != 1) /* check handle initialization */
1043 {
1044 return 3; /* return error */
1045 }
1046
1047 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_GAIN, &prev); /* read gain */
1048 if (res != 0) /* check result */
1049 {
1050 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1051
1052 return 1; /* return error */
1053 }
1054 *gain = prev; /* get gain */
1055 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG45, &prev); /* read gain */
1056 if (res != 0) /* check result */
1057 {
1058 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1059
1060 return 1; /* return error */
1061 }
1062 *gain |= (uint16_t)((prev >> 6) & 0x03) << 8; /* get gain */
1063
1064 return 0; /* success return 0 */
1065}
1066
1079{
1080 uint8_t res;
1081 uint8_t prev;
1082
1083 if (handle == NULL) /* check handle */
1084 {
1085 return 2; /* return error */
1086 }
1087 if (handle->inited != 1) /* check handle initialization */
1088 {
1089 return 3; /* return error */
1090 }
1091
1092 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM1, &prev); /* read com1 */
1093 if (res != 0) /* check result */
1094 {
1095 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1096
1097 return 1; /* return error */
1098 }
1099 prev &= ~(3 << 6); /* clear settings */
1100 prev |= (frame << 6); /* set frame */
1101 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM1, prev); /* write com1 */
1102 if (res != 0) /* check result */
1103 {
1104 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
1105
1106 return 1; /* return error */
1107 }
1108
1109 return 0; /* success return 0 */
1110}
1111
1124{
1125 uint8_t res;
1126 uint8_t prev;
1127
1128 if (handle == NULL) /* check handle */
1129 {
1130 return 2; /* return error */
1131 }
1132 if (handle->inited != 1) /* check handle initialization */
1133 {
1134 return 3; /* return error */
1135 }
1136
1137 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM1, &prev); /* read com1 */
1138 if (res != 0) /* check result */
1139 {
1140 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1141
1142 return 1; /* return error */
1143 }
1144 *frame = (ov2640_dummy_frame_t)((prev >> 6) & 0x03); /* get frame */
1145
1146 return 0; /* success return 0 */
1147}
1148
1162{
1163 uint8_t res;
1164 uint8_t prev;
1165
1166 if (handle == NULL) /* check handle */
1167 {
1168 return 2; /* return error */
1169 }
1170 if (handle->inited != 1) /* check handle initialization */
1171 {
1172 return 3; /* return error */
1173 }
1174 if (start > 0x3FF) /* check start */
1175 {
1176 handle->debug_print("ov2640: start > 0x3FF.\n"); /* start > 0x3FF */
1177
1178 return 4; /* return error */
1179 }
1180
1181 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM1, &prev); /* read com1 */
1182 if (res != 0) /* check result */
1183 {
1184 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1185
1186 return 1; /* return error */
1187 }
1188 prev &= ~(3 << 0); /* clear settings */
1189 prev |= ((start & 0x03) << 0); /* set vstart */
1190 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM1, prev); /* write com1 */
1191 if (res != 0) /* check result */
1192 {
1193 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
1194
1195 return 1; /* return error */
1196 }
1197 prev = (start >> 2) & 0xFF; /* set msb part */
1198 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_VSTRT, prev); /* write vstart */
1199 if (res != 0) /* check result */
1200 {
1201 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
1202
1203 return 1; /* return error */
1204 }
1205
1206 return 0; /* success return 0 */
1207}
1208
1221{
1222 uint8_t res;
1223 uint8_t prev;
1224
1225 if (handle == NULL) /* check handle */
1226 {
1227 return 2; /* return error */
1228 }
1229 if (handle->inited != 1) /* check handle initialization */
1230 {
1231 return 3; /* return error */
1232 }
1233
1234 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM1, &prev); /* read com1 */
1235 if (res != 0) /* check result */
1236 {
1237 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1238
1239 return 1; /* return error */
1240 }
1241 *start = prev & 0x03; /* set start lsb */
1242 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_VSTRT, &prev); /* read vstart */
1243 if (res != 0) /* check result */
1244 {
1245 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1246
1247 return 1; /* return error */
1248 }
1249 *start |= (prev << 2); /* set msb */
1250
1251 return 0; /* success return 0 */
1252}
1253
1267{
1268 uint8_t res;
1269 uint8_t prev;
1270
1271 if (handle == NULL) /* check handle */
1272 {
1273 return 2; /* return error */
1274 }
1275 if (handle->inited != 1) /* check handle initialization */
1276 {
1277 return 3; /* return error */
1278 }
1279 if (end > 0x3FF) /* check end */
1280 {
1281 handle->debug_print("ov2640: end > 0x3FF.\n"); /* end > 0x3FF */
1282
1283 return 4; /* return error */
1284 }
1285
1286 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM1, &prev); /* read com1 */
1287 if (res != 0) /* check result */
1288 {
1289 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1290
1291 return 1; /* return error */
1292 }
1293 prev &= ~(3 << 2); /* clear settings */
1294 prev |= ((end & 0x03) << 2); /* set vend */
1295 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM1, prev); /* write com1 */
1296 if (res != 0) /* check result */
1297 {
1298 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
1299
1300 return 1; /* return error */
1301 }
1302 prev = (end >> 2) & 0xFF; /* set msb part */
1303 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_VEND, prev); /* write vend */
1304 if (res != 0) /* check result */
1305 {
1306 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
1307
1308 return 1; /* return error */
1309 }
1310
1311 return 0; /* success return 0 */
1312}
1313
1326{
1327 uint8_t res;
1328 uint8_t prev;
1329
1330 if (handle == NULL) /* check handle */
1331 {
1332 return 2; /* return error */
1333 }
1334 if (handle->inited != 1) /* check handle initialization */
1335 {
1336 return 3; /* return error */
1337 }
1338
1339 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM1, &prev); /* read com1 */
1340 if (res != 0) /* check result */
1341 {
1342 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1343
1344 return 1; /* return error */
1345 }
1346 *end = (prev >> 2) & 0x03; /* set end lsb */
1347 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_VEND, &prev); /* read vend */
1348 if (res != 0) /* check result */
1349 {
1350 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1351
1352 return 1; /* return error */
1353 }
1354 *end |= (prev << 2); /* set msb */
1355
1356 return 0; /* success return 0 */
1357}
1358
1371{
1372 uint8_t res;
1373 uint8_t prev;
1374
1375 if (handle == NULL) /* check handle */
1376 {
1377 return 2; /* return error */
1378 }
1379 if (handle->inited != 1) /* check handle initialization */
1380 {
1381 return 3; /* return error */
1382 }
1383
1384 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG04, &prev); /* read reg04 */
1385 if (res != 0) /* check result */
1386 {
1387 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1388
1389 return 1; /* return error */
1390 }
1391 prev &= ~(1 << 7); /* clear settings */
1392 prev |= enable << 7; /* set bool */
1393 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_REG04, prev); /* write reg04 */
1394 if (res != 0) /* check result */
1395 {
1396 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
1397
1398 return 1; /* return error */
1399 }
1400
1401 return 0; /* success return 0 */
1402}
1403
1416{
1417 uint8_t res;
1418 uint8_t prev;
1419
1420 if (handle == NULL) /* check handle */
1421 {
1422 return 2; /* return error */
1423 }
1424 if (handle->inited != 1) /* check handle initialization */
1425 {
1426 return 3; /* return error */
1427 }
1428
1429 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG04, &prev); /* read reg04 */
1430 if (res != 0) /* check result */
1431 {
1432 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1433
1434 return 1; /* return error */
1435 }
1436 *enable = (ov2640_bool_t)((prev >> 7) & 0x01); /* get bool */
1437
1438 return 0; /* success return 0 */
1439}
1440
1453{
1454 uint8_t res;
1455 uint8_t prev;
1456
1457 if (handle == NULL) /* check handle */
1458 {
1459 return 2; /* return error */
1460 }
1461 if (handle->inited != 1) /* check handle initialization */
1462 {
1463 return 3; /* return error */
1464 }
1465
1466 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG04, &prev); /* read reg04 */
1467 if (res != 0) /* check result */
1468 {
1469 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1470
1471 return 1; /* return error */
1472 }
1473 prev &= ~(1 << 6); /* clear settings */
1474 prev |= enable << 6; /* set bool */
1475 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_REG04, prev); /* write reg04 */
1476 if (res != 0) /* check result */
1477 {
1478 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
1479
1480 return 1; /* return error */
1481 }
1482
1483 return 0; /* success return 0 */
1484}
1485
1498{
1499 uint8_t res;
1500 uint8_t prev;
1501
1502 if (handle == NULL) /* check handle */
1503 {
1504 return 2; /* return error */
1505 }
1506 if (handle->inited != 1) /* check handle initialization */
1507 {
1508 return 3; /* return error */
1509 }
1510
1511 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG04, &prev); /* read reg04 */
1512 if (res != 0) /* check result */
1513 {
1514 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1515
1516 return 1; /* return error */
1517 }
1518 *enable = (ov2640_bool_t)((prev >> 6) & 0x01); /* get bool */
1519
1520 return 0; /* success return 0 */
1521}
1522
1534uint8_t ov2640_set_aec(ov2640_handle_t *handle, uint16_t aec)
1535{
1536 uint8_t res;
1537 uint8_t prev;
1538
1539 if (handle == NULL) /* check handle */
1540 {
1541 return 2; /* return error */
1542 }
1543 if (handle->inited != 1) /* check handle initialization */
1544 {
1545 return 3; /* return error */
1546 }
1547
1548 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG04, &prev); /* read reg04 */
1549 if (res != 0) /* check result */
1550 {
1551 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1552
1553 return 1; /* return error */
1554 }
1555 prev &= ~(3 << 0); /* clear settings */
1556 prev |= (aec & 0x03) << 0; /* set aec */
1557 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_REG04, prev); /* write reg04 */
1558 if (res != 0) /* check result */
1559 {
1560 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
1561
1562 return 1; /* return error */
1563 }
1564 prev = (aec >> 2) & 0xFF; /* set aec */
1565 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_AEC, prev); /* write aec */
1566 if (res != 0) /* check result */
1567 {
1568 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
1569
1570 return 1; /* return error */
1571 }
1572 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG45, &prev); /* read reg45 */
1573 if (res != 0) /* check result */
1574 {
1575 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1576
1577 return 1; /* return error */
1578 }
1579 prev &= ~(0x3F << 0); /* clear settings */
1580 prev |= ((aec >> 10) & 0x3F) << 0; /* set aec */
1581 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_REG45, prev); /* write reg45 */
1582 if (res != 0) /* check result */
1583 {
1584 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
1585
1586 return 1; /* return error */
1587 }
1588
1589 return 0; /* success return 0 */
1590}
1591
1603uint8_t ov2640_get_aec(ov2640_handle_t *handle, uint16_t *aec)
1604{
1605 uint8_t res;
1606 uint8_t prev;
1607
1608 if (handle == NULL) /* check handle */
1609 {
1610 return 2; /* return error */
1611 }
1612 if (handle->inited != 1) /* check handle initialization */
1613 {
1614 return 3; /* return error */
1615 }
1616
1617 *aec = 0; /* init 0 */
1618 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG04, &prev); /* read reg04 */
1619 if (res != 0) /* check result */
1620 {
1621 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1622
1623 return 1; /* return error */
1624 }
1625 *aec |= prev & 0x03; /* set bit[1:0] */
1626 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_AEC, &prev); /* read aec */
1627 if (res != 0) /* check result */
1628 {
1629 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1630
1631 return 1; /* return error */
1632 }
1633 *aec |= (prev << 2); /* set bit[9:2] */
1634 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG45, &prev); /* read reg45 */
1635 if (res != 0) /* check result */
1636 {
1637 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1638
1639 return 1; /* return error */
1640 }
1641 *aec |= ((prev & 0x3F) << 10); /* set bit[15:10] */
1642
1643 return 0; /* success return 0 */
1644}
1645
1658{
1659 uint8_t res;
1660 uint8_t prev;
1661
1662 if (handle == NULL) /* check handle */
1663 {
1664 return 2; /* return error */
1665 }
1666 if (handle->inited != 1) /* check handle initialization */
1667 {
1668 return 3; /* return error */
1669 }
1670
1671 prev = num; /* set number */
1672 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_REG08, prev); /* write reg08 */
1673 if (res != 0) /* check result */
1674 {
1675 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
1676
1677 return 1; /* return error */
1678 }
1679
1680 return 0; /* success return 0 */
1681}
1682
1695{
1696 uint8_t res;
1697
1698 if (handle == NULL) /* check handle */
1699 {
1700 return 2; /* return error */
1701 }
1702 if (handle->inited != 1) /* check handle initialization */
1703 {
1704 return 3; /* return error */
1705 }
1706
1707 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG08, num); /* read reg08 */
1708 if (res != 0) /* check result */
1709 {
1710 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1711
1712 return 1; /* return error */
1713 }
1714
1715 return 0; /* success return 0 */
1716}
1717
1730{
1731 uint8_t res;
1732 uint8_t prev;
1733
1734 if (handle == NULL) /* check handle */
1735 {
1736 return 2; /* return error */
1737 }
1738 if (handle->inited != 1) /* check handle initialization */
1739 {
1740 return 3; /* return error */
1741 }
1742
1743 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM2, &prev); /* read com2 */
1744 if (res != 0) /* check result */
1745 {
1746 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1747
1748 return 1; /* return error */
1749 }
1750 prev &= ~(1 << 4); /* clear settings */
1751 prev |= mode << 4; /* set mode */
1752 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM2, prev); /* write com2 */
1753 if (res != 0) /* check result */
1754 {
1755 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
1756
1757 return 1; /* return error */
1758 }
1759
1760 return 0; /* success return 0 */
1761}
1762
1775{
1776 uint8_t res;
1777 uint8_t prev;
1778
1779 if (handle == NULL) /* check handle */
1780 {
1781 return 2; /* return error */
1782 }
1783 if (handle->inited != 1) /* check handle initialization */
1784 {
1785 return 3; /* return error */
1786 }
1787
1788 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM2, &prev); /* read com2 */
1789 if (res != 0) /* check result */
1790 {
1791 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1792
1793 return 1; /* return error */
1794 }
1795 *mode = (ov2640_mode_t)((prev >> 4) & 0x01); /* get mode */
1796
1797 return 0; /* success return 0 */
1798}
1799
1812{
1813 uint8_t res;
1814 uint8_t prev;
1815
1816 if (handle == NULL) /* check handle */
1817 {
1818 return 2; /* return error */
1819 }
1820 if (handle->inited != 1) /* check handle initialization */
1821 {
1822 return 3; /* return error */
1823 }
1824
1825 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM2, &prev); /* read com2 */
1826 if (res != 0) /* check result */
1827 {
1828 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1829
1830 return 1; /* return error */
1831 }
1832 prev &= ~(1 << 2); /* clear settings */
1833 prev |= enable << 2; /* set bool */
1834 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM2, prev); /* write com2 */
1835 if (res != 0) /* check result */
1836 {
1837 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
1838
1839 return 1; /* return error */
1840 }
1841
1842 return 0; /* success return 0 */
1843}
1844
1857{
1858 uint8_t res;
1859 uint8_t prev;
1860
1861 if (handle == NULL) /* check handle */
1862 {
1863 return 2; /* return error */
1864 }
1865 if (handle->inited != 1) /* check handle initialization */
1866 {
1867 return 3; /* return error */
1868 }
1869
1870 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM2, &prev); /* read com2 */
1871 if (res != 0) /* check result */
1872 {
1873 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1874
1875 return 1; /* return error */
1876 }
1877 *enable = (ov2640_bool_t)((prev >> 2) & 0x01); /* get bool */
1878
1879 return 0; /* success return 0 */
1880}
1881
1894{
1895 uint8_t res;
1896 uint8_t prev;
1897
1898 if (handle == NULL) /* check handle */
1899 {
1900 return 2; /* return error */
1901 }
1902 if (handle->inited != 1) /* check handle initialization */
1903 {
1904 return 3; /* return error */
1905 }
1906
1907 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM2, &prev); /* read com2 */
1908 if (res != 0) /* check result */
1909 {
1910 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1911
1912 return 1; /* return error */
1913 }
1914 prev &= ~(3 << 0); /* clear settings */
1915 prev |= select << 0; /* set select */
1916 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM2, prev); /* write com2 */
1917 if (res != 0) /* check result */
1918 {
1919 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
1920
1921 return 1; /* return error */
1922 }
1923
1924 return 0; /* success return 0 */
1925}
1926
1939{
1940 uint8_t res;
1941 uint8_t prev;
1942
1943 if (handle == NULL) /* check handle */
1944 {
1945 return 2; /* return error */
1946 }
1947 if (handle->inited != 1) /* check handle initialization */
1948 {
1949 return 3; /* return error */
1950 }
1951
1952 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM2, &prev); /* read com2 */
1953 if (res != 0) /* check result */
1954 {
1955 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1956
1957 return 1; /* return error */
1958 }
1959 *select = (ov2640_output_drive_t)(prev & 0x03); /* get drive */
1960
1961 return 0; /* success return 0 */
1962}
1963
1976{
1977 uint8_t res;
1978 uint8_t prev;
1979
1980 if (handle == NULL) /* check handle */
1981 {
1982 return 2; /* return error */
1983 }
1984 if (handle->inited != 1) /* check handle initialization */
1985 {
1986 return 3; /* return error */
1987 }
1988
1989 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM3, &prev); /* read com3 */
1990 if (res != 0) /* check result */
1991 {
1992 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
1993
1994 return 1; /* return error */
1995 }
1996 prev &= ~(1 << 2); /* clear settings */
1997 prev |= band << 2; /* set band */
1998 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM3, prev); /* write com3 */
1999 if (res != 0) /* check result */
2000 {
2001 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
2002
2003 return 1; /* return error */
2004 }
2005
2006 return 0; /* success return 0 */
2007}
2008
2021{
2022 uint8_t res;
2023 uint8_t prev;
2024
2025 if (handle == NULL) /* check handle */
2026 {
2027 return 2; /* return error */
2028 }
2029 if (handle->inited != 1) /* check handle initialization */
2030 {
2031 return 3; /* return error */
2032 }
2033
2034 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM3, &prev); /* read com3 */
2035 if (res != 0) /* check result */
2036 {
2037 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2038
2039 return 1; /* return error */
2040 }
2041 *band = (ov2640_band_t)((prev >> 2) & 0x01); /* get band */
2042
2043 return 0; /* success return 0 */
2044}
2045
2058{
2059 uint8_t res;
2060 uint8_t prev;
2061
2062 if (handle == NULL) /* check handle */
2063 {
2064 return 2; /* return error */
2065 }
2066 if (handle->inited != 1) /* check handle initialization */
2067 {
2068 return 3; /* return error */
2069 }
2070
2071 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM3, &prev); /* read com3 */
2072 if (res != 0) /* check result */
2073 {
2074 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2075
2076 return 1; /* return error */
2077 }
2078 prev &= ~(1 << 1); /* clear settings */
2079 prev |= enable << 1; /* set bool */
2080 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM3, prev); /* write com3 */
2081 if (res != 0) /* check result */
2082 {
2083 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
2084
2085 return 1; /* return error */
2086 }
2087
2088 return 0; /* success return 0 */
2089}
2090
2103{
2104 uint8_t res;
2105 uint8_t prev;
2106
2107 if (handle == NULL) /* check handle */
2108 {
2109 return 2; /* return error */
2110 }
2111 if (handle->inited != 1) /* check handle initialization */
2112 {
2113 return 3; /* return error */
2114 }
2115
2116 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM3, &prev); /* read com3 */
2117 if (res != 0) /* check result */
2118 {
2119 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2120
2121 return 1; /* return error */
2122 }
2123 *enable = (ov2640_bool_t)((prev >> 1) & 0x01); /* get bool */
2124
2125 return 0; /* success return 0 */
2126}
2127
2140{
2141 uint8_t res;
2142 uint8_t prev;
2143
2144 if (handle == NULL) /* check handle */
2145 {
2146 return 2; /* return error */
2147 }
2148 if (handle->inited != 1) /* check handle initialization */
2149 {
2150 return 3; /* return error */
2151 }
2152
2153 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM3, &prev); /* read com3 */
2154 if (res != 0) /* check result */
2155 {
2156 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2157
2158 return 1; /* return error */
2159 }
2160 prev &= ~(1 << 0); /* clear settings */
2161 prev |= enable << 0; /* set bool */
2162 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM3, prev); /* write com3 */
2163 if (res != 0) /* check result */
2164 {
2165 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
2166
2167 return 1; /* return error */
2168 }
2169
2170 return 0; /* success return 0 */
2171}
2172
2185{
2186 uint8_t res;
2187 uint8_t prev;
2188
2189 if (handle == NULL) /* check handle */
2190 {
2191 return 2; /* return error */
2192 }
2193 if (handle->inited != 1) /* check handle initialization */
2194 {
2195 return 3; /* return error */
2196 }
2197
2198 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM3, &prev); /* read com3 */
2199 if (res != 0) /* check result */
2200 {
2201 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2202
2203 return 1; /* return error */
2204 }
2205 *enable = (ov2640_bool_t)((prev >> 0) & 0x01); /* get bool */
2206
2207 return 0; /* success return 0 */
2208}
2209
2222{
2223 uint8_t res;
2224 uint8_t prev;
2225
2226 if (handle == NULL) /* check handle */
2227 {
2228 return 2; /* return error */
2229 }
2230 if (handle->inited != 1) /* check handle initialization */
2231 {
2232 return 3; /* return error */
2233 }
2234
2235 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM4, &prev); /* read com4 */
2236 if (res != 0) /* check result */
2237 {
2238 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2239
2240 return 1; /* return error */
2241 }
2242 prev &= ~(1 << 2); /* clear settings */
2243 prev |= status << 2; /* set status */
2244 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM4, prev); /* write com4 */
2245 if (res != 0) /* check result */
2246 {
2247 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
2248
2249 return 1; /* return error */
2250 }
2251
2252 return 0; /* success return 0 */
2253}
2254
2267{
2268 uint8_t res;
2269 uint8_t prev;
2270
2271 if (handle == NULL) /* check handle */
2272 {
2273 return 2; /* return error */
2274 }
2275 if (handle->inited != 1) /* check handle initialization */
2276 {
2277 return 3; /* return error */
2278 }
2279
2280 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM4, &prev); /* read com4 */
2281 if (res != 0) /* check result */
2282 {
2283 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2284
2285 return 1; /* return error */
2286 }
2287 *status = (ov2640_pin_status_t)((prev >> 2) & 0x01); /* get pin status */
2288
2289 return 0; /* success return 0 */
2290}
2291
2304{
2305 uint8_t res;
2306 uint8_t prev;
2307
2308 if (handle == NULL) /* check handle */
2309 {
2310 return 2; /* return error */
2311 }
2312 if (handle->inited != 1) /* check handle initialization */
2313 {
2314 return 3; /* return error */
2315 }
2316
2317 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_CLKRC, &prev); /* read clkrc */
2318 if (res != 0) /* check result */
2319 {
2320 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2321
2322 return 1; /* return error */
2323 }
2324 prev &= ~(1 << 7); /* clear settings */
2325 prev |= enable << 7; /* set bool */
2326 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_CLKRC, prev); /* write clkrc */
2327 if (res != 0) /* check result */
2328 {
2329 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
2330
2331 return 1; /* return error */
2332 }
2333
2334 return 0; /* success return 0 */
2335}
2336
2349{
2350 uint8_t res;
2351 uint8_t prev;
2352
2353 if (handle == NULL) /* check handle */
2354 {
2355 return 2; /* return error */
2356 }
2357 if (handle->inited != 1) /* check handle initialization */
2358 {
2359 return 3; /* return error */
2360 }
2361
2362 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_CLKRC, &prev); /* read clkrc */
2363 if (res != 0) /* check result */
2364 {
2365 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2366
2367 return 1; /* return error */
2368 }
2369 *enable = (ov2640_bool_t)((prev >> 7) & 0x01); /* get bool */
2370
2371 return 0; /* success return 0 */
2372}
2373
2386uint8_t ov2640_set_clock_divider(ov2640_handle_t *handle, uint8_t divider)
2387{
2388 uint8_t res;
2389 uint8_t prev;
2390
2391 if (handle == NULL) /* check handle */
2392 {
2393 return 2; /* return error */
2394 }
2395 if (handle->inited != 1) /* check handle initialization */
2396 {
2397 return 3; /* return error */
2398 }
2399 if (divider > 0x3F) /* check divider */
2400 {
2401 handle->debug_print("ov2640: divider > 0x3F.\n"); /* divider > 0x3F */
2402
2403 return 4; /* return error */
2404 }
2405
2406 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_CLKRC, &prev); /* read clkrc */
2407 if (res != 0) /* check result */
2408 {
2409 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2410
2411 return 1; /* return error */
2412 }
2413 prev &= ~(0x3F << 0); /* clear settings */
2414 prev |= divider << 0; /* set divider */
2415 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_CLKRC, prev); /* write clkrc */
2416 if (res != 0) /* check result */
2417 {
2418 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
2419
2420 return 1; /* return error */
2421 }
2422
2423 return 0; /* success return 0 */
2424}
2425
2437uint8_t ov2640_get_clock_divider(ov2640_handle_t *handle, uint8_t *divider)
2438{
2439 uint8_t res;
2440 uint8_t prev;
2441
2442 if (handle == NULL) /* check handle */
2443 {
2444 return 2; /* return error */
2445 }
2446 if (handle->inited != 1) /* check handle initialization */
2447 {
2448 return 3; /* return error */
2449 }
2450
2451 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_CLKRC, &prev); /* read clkrc */
2452 if (res != 0) /* check result */
2453 {
2454 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2455
2456 return 1; /* return error */
2457 }
2458 *divider = (prev & 0x3F); /* get divider */
2459
2460 return 0; /* success return 0 */
2461}
2462
2474{
2475 uint8_t res;
2476 uint8_t prev;
2477
2478 if (handle == NULL) /* check handle */
2479 {
2480 return 2; /* return error */
2481 }
2482 if (handle->inited != 1) /* check handle initialization */
2483 {
2484 return 3; /* return error */
2485 }
2486
2487 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM7, &prev); /* read com7 */
2488 if (res != 0) /* check result */
2489 {
2490 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2491
2492 return 1; /* return error */
2493 }
2494 prev &= ~(1 << 7); /* clear settings */
2495 prev |= 1 << 7; /* set enable */
2496 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM7, prev); /* write com7 */
2497 if (res != 0) /* check result */
2498 {
2499 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
2500
2501 return 1; /* return error */
2502 }
2503 handle->delay_ms(10); /* delay 10ms */
2504
2505 return 0; /* success return 0 */
2506}
2507
2520{
2521 uint8_t res;
2522 uint8_t prev;
2523
2524 if (handle == NULL) /* check handle */
2525 {
2526 return 2; /* return error */
2527 }
2528 if (handle->inited != 1) /* check handle initialization */
2529 {
2530 return 3; /* return error */
2531 }
2532
2533 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM7, &prev); /* read com7 */
2534 if (res != 0) /* check result */
2535 {
2536 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2537
2538 return 1; /* return error */
2539 }
2540 prev &= ~(7 << 4); /* clear settings */
2541 prev |= resolution << 4; /* set resolution */
2542 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM7, prev); /* write com7 */
2543 if (res != 0) /* check result */
2544 {
2545 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
2546
2547 return 1; /* return error */
2548 }
2549
2550 return 0; /* success return 0 */
2551}
2552
2565{
2566 uint8_t res;
2567 uint8_t prev;
2568
2569 if (handle == NULL) /* check handle */
2570 {
2571 return 2; /* return error */
2572 }
2573 if (handle->inited != 1) /* check handle initialization */
2574 {
2575 return 3; /* return error */
2576 }
2577
2578 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM7, &prev); /* read com7 */
2579 if (res != 0) /* check result */
2580 {
2581 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2582
2583 return 1; /* return error */
2584 }
2585 *resolution = (ov2640_resolution_t)((prev >> 4) & 0x07); /* get resolution */
2586
2587 return 0; /* success return 0 */
2588}
2589
2602{
2603 uint8_t res;
2604 uint8_t prev;
2605
2606 if (handle == NULL) /* check handle */
2607 {
2608 return 2; /* return error */
2609 }
2610 if (handle->inited != 1) /* check handle initialization */
2611 {
2612 return 3; /* return error */
2613 }
2614
2615 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM7, &prev); /* read com7 */
2616 if (res != 0) /* check result */
2617 {
2618 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2619
2620 return 1; /* return error */
2621 }
2622 prev &= ~(1 << 2); /* clear settings */
2623 prev |= enable << 2; /* set bool */
2624 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM7, prev); /* write com7 */
2625 if (res != 0) /* check result */
2626 {
2627 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
2628
2629 return 1; /* return error */
2630 }
2631
2632 return 0; /* success return 0 */
2633}
2634
2647{
2648 uint8_t res;
2649 uint8_t prev;
2650
2651 if (handle == NULL) /* check handle */
2652 {
2653 return 2; /* return error */
2654 }
2655 if (handle->inited != 1) /* check handle initialization */
2656 {
2657 return 3; /* return error */
2658 }
2659
2660 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM7, &prev); /* read com7 */
2661 if (res != 0) /* check result */
2662 {
2663 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2664
2665 return 1; /* return error */
2666 }
2667 *enable = (ov2640_bool_t)((prev >> 2) & 0x01); /* get bool */
2668
2669 return 0; /* success return 0 */
2670}
2671
2684{
2685 uint8_t res;
2686 uint8_t prev;
2687
2688 if (handle == NULL) /* check handle */
2689 {
2690 return 2; /* return error */
2691 }
2692 if (handle->inited != 1) /* check handle initialization */
2693 {
2694 return 3; /* return error */
2695 }
2696
2697 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM7, &prev); /* read com7 */
2698 if (res != 0) /* check result */
2699 {
2700 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2701
2702 return 1; /* return error */
2703 }
2704 prev &= ~(1 << 1); /* clear settings */
2705 prev |= enable << 1; /* set bool */
2706 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM7, prev); /* write com7 */
2707 if (res != 0) /* check result */
2708 {
2709 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
2710
2711 return 1; /* return error */
2712 }
2713
2714 return 0; /* success return 0 */
2715}
2716
2729{
2730 uint8_t res;
2731 uint8_t prev;
2732
2733 if (handle == NULL) /* check handle */
2734 {
2735 return 2; /* return error */
2736 }
2737 if (handle->inited != 1) /* check handle initialization */
2738 {
2739 return 3; /* return error */
2740 }
2741
2742 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM7, &prev); /* read com7 */
2743 if (res != 0) /* check result */
2744 {
2745 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2746
2747 return 1; /* return error */
2748 }
2749 *enable = (ov2640_bool_t)((prev >> 1) & 0x01); /* get bool */
2750
2751 return 0; /* success return 0 */
2752}
2753
2766{
2767 uint8_t res;
2768 uint8_t prev;
2769
2770 if (handle == NULL) /* check handle */
2771 {
2772 return 2; /* return error */
2773 }
2774 if (handle->inited != 1) /* check handle initialization */
2775 {
2776 return 3; /* return error */
2777 }
2778
2779 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM8, &prev); /* read com8 */
2780 if (res != 0) /* check result */
2781 {
2782 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2783
2784 return 1; /* return error */
2785 }
2786 prev &= ~(1 << 5); /* clear settings */
2787 prev |= enable << 5; /* set bool */
2788 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM8, prev); /* write com8 */
2789 if (res != 0) /* check result */
2790 {
2791 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
2792
2793 return 1; /* return error */
2794 }
2795
2796 return 0; /* success return 0 */
2797}
2798
2811{
2812 uint8_t res;
2813 uint8_t prev;
2814
2815 if (handle == NULL) /* check handle */
2816 {
2817 return 2; /* return error */
2818 }
2819 if (handle->inited != 1) /* check handle initialization */
2820 {
2821 return 3; /* return error */
2822 }
2823
2824 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM8, &prev); /* read com8 */
2825 if (res != 0) /* check result */
2826 {
2827 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2828
2829 return 1; /* return error */
2830 }
2831 *enable = (ov2640_bool_t)((prev >> 5) & 0x01); /* get the bool */
2832
2833 return 0; /* success return 0 */
2834}
2835
2848{
2849 uint8_t res;
2850 uint8_t prev;
2851
2852 if (handle == NULL) /* check handle */
2853 {
2854 return 2; /* return error */
2855 }
2856 if (handle->inited != 1) /* check handle initialization */
2857 {
2858 return 3; /* return error */
2859 }
2860
2861 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM8, &prev); /* read com8 */
2862 if (res != 0) /* check result */
2863 {
2864 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2865
2866 return 1; /* return error */
2867 }
2868 prev &= ~(1 << 2); /* clear settings */
2869 prev |= control << 2; /* set control */
2870 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM8, prev); /* write com8 */
2871 if (res != 0) /* check result */
2872 {
2873 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
2874
2875 return 1; /* return error */
2876 }
2877
2878 return 0; /* success return 0 */
2879}
2880
2893{
2894 uint8_t res;
2895 uint8_t prev;
2896
2897 if (handle == NULL) /* check handle */
2898 {
2899 return 2; /* return error */
2900 }
2901 if (handle->inited != 1) /* check handle initialization */
2902 {
2903 return 3; /* return error */
2904 }
2905
2906 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM8, &prev); /* read com8 */
2907 if (res != 0) /* check result */
2908 {
2909 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2910
2911 return 1; /* return error */
2912 }
2913 *control = (ov2640_control_t)((prev >> 2) & 0x01); /* get control */
2914
2915 return 0; /* success return 0 */
2916}
2917
2930{
2931 uint8_t res;
2932 uint8_t prev;
2933
2934 if (handle == NULL) /* check handle */
2935 {
2936 return 2; /* return error */
2937 }
2938 if (handle->inited != 1) /* check handle initialization */
2939 {
2940 return 3; /* return error */
2941 }
2942
2943 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM8, &prev); /* read com8 */
2944 if (res != 0) /* check result */
2945 {
2946 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2947
2948 return 1; /* return error */
2949 }
2950 prev &= ~(1 << 0); /* clear settings */
2951 prev |= control << 0; /* set control */
2952 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM8, prev); /* write com8 */
2953 if (res != 0) /* check result */
2954 {
2955 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
2956
2957 return 1; /* return error */
2958 }
2959
2960 return 0; /* success return 0 */
2961}
2962
2975{
2976 uint8_t res;
2977 uint8_t prev;
2978
2979 if (handle == NULL) /* check handle */
2980 {
2981 return 2; /* return error */
2982 }
2983 if (handle->inited != 1) /* check handle initialization */
2984 {
2985 return 3; /* return error */
2986 }
2987
2988 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM8, &prev); /* read com8 */
2989 if (res != 0) /* check result */
2990 {
2991 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
2992
2993 return 1; /* return error */
2994 }
2995 *control = (ov2640_control_t)((prev >> 0) & 0x01); /* get control */
2996
2997 return 0; /* success return 0 */
2998}
2999
3012{
3013 uint8_t res;
3014 uint8_t prev;
3015
3016 if (handle == NULL) /* check handle */
3017 {
3018 return 2; /* return error */
3019 }
3020 if (handle->inited != 1) /* check handle initialization */
3021 {
3022 return 3; /* return error */
3023 }
3024
3025 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM9, &prev); /* read com9 */
3026 if (res != 0) /* check result */
3027 {
3028 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3029
3030 return 1; /* return error */
3031 }
3032 prev &= ~(7 << 5); /* clear settings */
3033 prev |= agc << 5; /* set agc */
3034 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM9, prev); /* write com9 */
3035 if (res != 0) /* check result */
3036 {
3037 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
3038
3039 return 1; /* return error */
3040 }
3041
3042 return 0; /* success return 0 */
3043}
3044
3057{
3058 uint8_t res;
3059 uint8_t prev;
3060
3061 if (handle == NULL) /* check handle */
3062 {
3063 return 2; /* return error */
3064 }
3065 if (handle->inited != 1) /* check handle initialization */
3066 {
3067 return 3; /* return error */
3068 }
3069
3070 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM9, &prev); /* read com9 */
3071 if (res != 0) /* check result */
3072 {
3073 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3074
3075 return 1; /* return error */
3076 }
3077 *agc = (ov2640_agc_gain_t)((prev >> 5) & 0x07); /* get agc */
3078
3079 return 0; /* success return 0 */
3080}
3081
3094{
3095 uint8_t res;
3096 uint8_t prev;
3097
3098 if (handle == NULL) /* check handle */
3099 {
3100 return 2; /* return error */
3101 }
3102 if (handle->inited != 1) /* check handle initialization */
3103 {
3104 return 3; /* return error */
3105 }
3106
3107 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM10, &prev); /* read com10 */
3108 if (res != 0) /* check result */
3109 {
3110 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3111
3112 return 1; /* return error */
3113 }
3114 prev &= ~(1 << 7); /* clear settings */
3115 prev |= enable << 7; /* set bool */
3116 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM10, prev); /* write com10 */
3117 if (res != 0) /* check result */
3118 {
3119 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
3120
3121 return 1; /* return error */
3122 }
3123
3124 return 0; /* success return 0 */
3125}
3126
3139{
3140 uint8_t res;
3141 uint8_t prev;
3142
3143 if (handle == NULL) /* check handle */
3144 {
3145 return 2; /* return error */
3146 }
3147 if (handle->inited != 1) /* check handle initialization */
3148 {
3149 return 3; /* return error */
3150 }
3151
3152 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM10, &prev); /* read com10 */
3153 if (res != 0) /* check result */
3154 {
3155 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3156
3157 return 1; /* return error */
3158 }
3159 *enable = (ov2640_bool_t)((prev >> 7) & 0x01); /* get bool */
3160
3161 return 0; /* success return 0 */
3162}
3163
3176{
3177 uint8_t res;
3178 uint8_t prev;
3179
3180 if (handle == NULL) /* check handle */
3181 {
3182 return 2; /* return error */
3183 }
3184 if (handle->inited != 1) /* check handle initialization */
3185 {
3186 return 3; /* return error */
3187 }
3188
3189 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM10, &prev); /* read com10 */
3190 if (res != 0) /* check result */
3191 {
3192 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3193
3194 return 1; /* return error */
3195 }
3196 prev &= ~(1 << 6); /* clear settings */
3197 prev |= enable << 6; /* set bool */
3198 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM10, prev); /* write com10 */
3199 if (res != 0) /* check result */
3200 {
3201 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
3202
3203 return 1; /* return error */
3204 }
3205
3206 return 0; /* success return 0 */
3207}
3208
3221{
3222 uint8_t res;
3223 uint8_t prev;
3224
3225 if (handle == NULL) /* check handle */
3226 {
3227 return 2; /* return error */
3228 }
3229 if (handle->inited != 1) /* check handle initialization */
3230 {
3231 return 3; /* return error */
3232 }
3233
3234 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM10, &prev); /* read com10 */
3235 if (res != 0) /* check result */
3236 {
3237 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3238
3239 return 1; /* return error */
3240 }
3241 *enable = (ov2640_bool_t)((prev >> 6) & 0x01); /* get bool */
3242
3243 return 0; /* success return 0 */
3244}
3245
3258{
3259 uint8_t res;
3260 uint8_t prev;
3261
3262 if (handle == NULL) /* check handle */
3263 {
3264 return 2; /* return error */
3265 }
3266 if (handle->inited != 1) /* check handle initialization */
3267 {
3268 return 3; /* return error */
3269 }
3270
3271 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM10, &prev); /* read com10 */
3272 if (res != 0) /* check result */
3273 {
3274 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3275
3276 return 1; /* return error */
3277 }
3278 prev &= ~(1 << 5); /* clear settings */
3279 prev |= enable << 5; /* set bool */
3280 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM10, prev); /* write com10 */
3281 if (res != 0) /* check result */
3282 {
3283 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
3284
3285 return 1; /* return error */
3286 }
3287
3288 return 0; /* success return 0 */
3289}
3290
3303{
3304 uint8_t res;
3305 uint8_t prev;
3306
3307 if (handle == NULL) /* check handle */
3308 {
3309 return 2; /* return error */
3310 }
3311 if (handle->inited != 1) /* check handle initialization */
3312 {
3313 return 3; /* return error */
3314 }
3315
3316 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM10, &prev); /* read com10 */
3317 if (res != 0) /* check result */
3318 {
3319 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3320
3321 return 1; /* return error */
3322 }
3323 *enable = (ov2640_bool_t)((prev >> 5) & 0x01); /* get bool */
3324
3325 return 0; /* success return 0 */
3326}
3327
3340{
3341 uint8_t res;
3342 uint8_t prev;
3343
3344 if (handle == NULL) /* check handle */
3345 {
3346 return 2; /* return error */
3347 }
3348 if (handle->inited != 1) /* check handle initialization */
3349 {
3350 return 3; /* return error */
3351 }
3352
3353 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM10, &prev); /* read com10 */
3354 if (res != 0) /* check result */
3355 {
3356 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3357
3358 return 1; /* return error */
3359 }
3360 prev &= ~(1 << 4); /* clear settings */
3361 prev |= edge << 4; /* set edge */
3362 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM10, prev); /* write com10 */
3363 if (res != 0) /* check result */
3364 {
3365 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
3366
3367 return 1; /* return error */
3368 }
3369
3370 return 0; /* success return 0 */
3371}
3372
3385{
3386 uint8_t res;
3387 uint8_t prev;
3388
3389 if (handle == NULL) /* check handle */
3390 {
3391 return 2; /* return error */
3392 }
3393 if (handle->inited != 1) /* check handle initialization */
3394 {
3395 return 3; /* return error */
3396 }
3397
3398 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM10, &prev); /* read com10 */
3399 if (res != 0) /* check result */
3400 {
3401 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3402
3403 return 1; /* return error */
3404 }
3405 *edge = (ov2640_edge_t)((prev >> 4) & 0x01); /* get edge */
3406
3407 return 0; /* success return 0 */
3408}
3409
3422{
3423 uint8_t res;
3424 uint8_t prev;
3425
3426 if (handle == NULL) /* check handle */
3427 {
3428 return 2; /* return error */
3429 }
3430 if (handle->inited != 1) /* check handle initialization */
3431 {
3432 return 3; /* return error */
3433 }
3434
3435 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM10, &prev); /* read com10 */
3436 if (res != 0) /* check result */
3437 {
3438 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3439
3440 return 1; /* return error */
3441 }
3442 prev &= ~(1 << 3); /* clear settings */
3443 prev |= polarity << 3; /* set polarity */
3444 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM10, prev); /* write com10 */
3445 if (res != 0) /* check result */
3446 {
3447 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
3448
3449 return 1; /* return error */
3450 }
3451
3452 return 0; /* success return 0 */
3453}
3454
3467{
3468 uint8_t res;
3469 uint8_t prev;
3470
3471 if (handle == NULL) /* check handle */
3472 {
3473 return 2; /* return error */
3474 }
3475 if (handle->inited != 1) /* check handle initialization */
3476 {
3477 return 3; /* return error */
3478 }
3479
3480 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM10, &prev); /* read com10 */
3481 if (res != 0) /* check result */
3482 {
3483 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3484
3485 return 1; /* return error */
3486 }
3487 *polarity = (ov2640_polarity_t)((prev >> 3) & 0x01); /* get polarity */
3488
3489 return 0; /* success return 0 */
3490}
3491
3504{
3505 uint8_t res;
3506 uint8_t prev;
3507
3508 if (handle == NULL) /* check handle */
3509 {
3510 return 2; /* return error */
3511 }
3512 if (handle->inited != 1) /* check handle initialization */
3513 {
3514 return 3; /* return error */
3515 }
3516
3517 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM10, &prev); /* read com10 */
3518 if (res != 0) /* check result */
3519 {
3520 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3521
3522 return 1; /* return error */
3523 }
3524 prev &= ~(1 << 1); /* clear settings */
3525 prev |= polarity << 1; /* set polarity */
3526 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM10, prev); /* write com10 */
3527 if (res != 0) /* check result */
3528 {
3529 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
3530
3531 return 1; /* return error */
3532 }
3533
3534 return 0; /* success return 0 */
3535}
3536
3549{
3550 uint8_t res;
3551 uint8_t prev;
3552
3553 if (handle == NULL) /* check handle */
3554 {
3555 return 2; /* return error */
3556 }
3557 if (handle->inited != 1) /* check handle initialization */
3558 {
3559 return 3; /* return error */
3560 }
3561
3562 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM10, &prev); /* read com10 */
3563 if (res != 0) /* check result */
3564 {
3565 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3566
3567 return 1; /* return error */
3568 }
3569 *polarity = (ov2640_polarity_t)((prev >> 1) & 0x01); /* get polarity */
3570
3571 return 0; /* success return 0 */
3572}
3573
3586{
3587 uint8_t res;
3588 uint8_t prev;
3589
3590 if (handle == NULL) /* check handle */
3591 {
3592 return 2; /* return error */
3593 }
3594 if (handle->inited != 1) /* check handle initialization */
3595 {
3596 return 3; /* return error */
3597 }
3598
3599 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM10, &prev); /* read com10 */
3600 if (res != 0) /* check result */
3601 {
3602 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3603
3604 return 1; /* return error */
3605 }
3606 prev &= ~(1 << 0); /* clear settings */
3607 prev |= polarity << 0; /* set polarity */
3608 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM10, prev); /* write com10 */
3609 if (res != 0) /* check result */
3610 {
3611 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
3612
3613 return 1; /* return error */
3614 }
3615
3616 return 0; /* success return 0 */
3617}
3618
3631{
3632 uint8_t res;
3633 uint8_t prev;
3634
3635 if (handle == NULL) /* check handle */
3636 {
3637 return 2; /* return error */
3638 }
3639 if (handle->inited != 1) /* check handle initialization */
3640 {
3641 return 3; /* return error */
3642 }
3643
3644 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM10, &prev); /* read com10 */
3645 if (res != 0) /* check result */
3646 {
3647 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3648
3649 return 1; /* return error */
3650 }
3651 *polarity = (ov2640_polarity_t)((prev >> 0) & 0x01); /* get polarity */
3652
3653 return 0; /* success return 0 */
3654}
3655
3668{
3669 uint8_t res;
3670 uint8_t prev;
3671
3672 if (handle == NULL) /* check handle */
3673 {
3674 return 2; /* return error */
3675 }
3676 if (handle->inited != 1) /* check handle initialization */
3677 {
3678 return 3; /* return error */
3679 }
3680
3681 prev = range; /* set range */
3682 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_AEW, prev); /* write aew */
3683 if (res != 0) /* check result */
3684 {
3685 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
3686
3687 return 1; /* return error */
3688 }
3689
3690 return 0; /* success return 0 */
3691}
3692
3705{
3706 uint8_t res;
3707
3708 if (handle == NULL) /* check handle */
3709 {
3710 return 2; /* return error */
3711 }
3712 if (handle->inited != 1) /* check handle initialization */
3713 {
3714 return 3; /* return error */
3715 }
3716
3717 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_AEW, range); /* read aew */
3718 if (res != 0) /* check result */
3719 {
3720 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3721
3722 return 1; /* return error */
3723 }
3724
3725 return 0; /* success return 0 */
3726}
3727
3740{
3741 uint8_t res;
3742 uint8_t prev;
3743
3744 if (handle == NULL) /* check handle */
3745 {
3746 return 2; /* return error */
3747 }
3748 if (handle->inited != 1) /* check handle initialization */
3749 {
3750 return 3; /* return error */
3751 }
3752
3753 prev = range; /* set range */
3754 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_AEB, prev); /* write aeb */
3755 if (res != 0) /* check result */
3756 {
3757 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
3758
3759 return 1; /* return error */
3760 }
3761
3762 return 0; /* success return 0 */
3763}
3764
3777{
3778 uint8_t res;
3779
3780 if (handle == NULL) /* check handle */
3781 {
3782 return 2; /* return error */
3783 }
3784 if (handle->inited != 1) /* check handle initialization */
3785 {
3786 return 3; /* return error */
3787 }
3788
3789 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_AEB, range); /* read aeb */
3790 if (res != 0) /* check result */
3791 {
3792 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3793
3794 return 1; /* return error */
3795 }
3796
3797 return 0; /* success return 0 */
3798}
3799
3814uint8_t ov2640_set_fast_mode_large_step_range(ov2640_handle_t *handle, uint8_t high_threshold, uint8_t low_threshold)
3815{
3816 uint8_t res;
3817 uint8_t prev;
3818
3819 if (handle == NULL) /* check handle */
3820 {
3821 return 2; /* return error */
3822 }
3823 if (handle->inited != 1) /* check handle initialization */
3824 {
3825 return 3; /* return error */
3826 }
3827 if (high_threshold > 0xF) /* check high_threshold */
3828 {
3829 handle->debug_print("ov2640: high_threshold > 0xF.\n"); /* high_threshold > 0xF */
3830
3831 return 4; /* return error */
3832 }
3833 if (low_threshold > 0xF) /* check low_threshold */
3834 {
3835 handle->debug_print("ov2640: low_threshold > 0xF.\n"); /* low_threshold > 0xF */
3836
3837 return 5; /* return error */
3838 }
3839
3840 prev = (high_threshold & 0xF) << 4 | (low_threshold & 0xF); /* set range */
3841 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_VV, prev); /* write vv */
3842 if (res != 0) /* check result */
3843 {
3844 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
3845
3846 return 1; /* return error */
3847 }
3848
3849 return 0; /* success return 0 */
3850}
3851
3864uint8_t ov2640_get_fast_mode_large_step_range(ov2640_handle_t *handle, uint8_t *high_threshold, uint8_t *low_threshold)
3865{
3866 uint8_t res;
3867 uint8_t prev;
3868
3869 if (handle == NULL) /* check handle */
3870 {
3871 return 2; /* return error */
3872 }
3873 if (handle->inited != 1) /* check handle initialization */
3874 {
3875 return 3; /* return error */
3876 }
3877
3878 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_VV, &prev); /* read vv */
3879 if (res != 0) /* check result */
3880 {
3881 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3882
3883 return 1; /* return error */
3884 }
3885 *high_threshold = (prev >> 4) & 0x0F; /* get high threshold */
3886 *low_threshold = (prev >> 0) & 0x0F; /* get low threshold */
3887
3888 return 0; /* success return 0 */
3889}
3890
3903uint8_t ov2640_set_line_interval_adjust(ov2640_handle_t *handle, uint16_t adjust)
3904{
3905 uint8_t res;
3906 uint8_t prev;
3907
3908 if (handle == NULL) /* check handle */
3909 {
3910 return 2; /* return error */
3911 }
3912 if (handle->inited != 1) /* check handle initialization */
3913 {
3914 return 3; /* return error */
3915 }
3916 if (adjust > 0xFFF) /* check adjust */
3917 {
3918 handle->debug_print("ov2640: adjust > 0xFFF.\n"); /* adjust > 0xFFF */
3919
3920 return 4; /* return error */
3921 }
3922
3923 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG2A, &prev); /* read reg2a */
3924 if (res != 0) /* check result */
3925 {
3926 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3927
3928 return 1; /* return error */
3929 }
3930 prev &= ~(0xF << 4); /* clear settings */
3931 prev |= ((adjust >> 8) & 0xF) << 4; /* set adjust */
3932 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_REG2A, prev); /* write reg 2a */
3933 if (res != 0) /* check result */
3934 {
3935 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
3936
3937 return 1; /* return error */
3938 }
3939 prev = adjust & 0xFF; /* set adjust */
3940 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_FRARL, prev); /* write frarl */
3941 if (res != 0) /* check result */
3942 {
3943 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
3944
3945 return 1; /* return error */
3946 }
3947
3948 return 0; /* success return 0 */
3949}
3950
3962uint8_t ov2640_get_line_interval_adjust(ov2640_handle_t *handle, uint16_t *adjust)
3963{
3964 uint8_t res;
3965 uint8_t prev;
3966
3967 if (handle == NULL) /* check handle */
3968 {
3969 return 2; /* return error */
3970 }
3971 if (handle->inited != 1) /* check handle initialization */
3972 {
3973 return 3; /* return error */
3974 }
3975
3976 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG2A, &prev); /* read reg2a */
3977 if (res != 0) /* check result */
3978 {
3979 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3980
3981 return 1; /* return error */
3982 }
3983 *adjust = (uint16_t)((prev >> 4) & 0xFF) << 8; /* set adjust */
3984 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_FRARL, &prev); /* read frarl */
3985 if (res != 0) /* check result */
3986 {
3987 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
3988
3989 return 1; /* return error */
3990 }
3991 *adjust |= prev; /* set adjust */
3992
3993 return 0; /* success return 0 */
3994}
3995
4009{
4010 uint8_t res;
4011 uint8_t prev;
4012
4013 if (handle == NULL) /* check handle */
4014 {
4015 return 2; /* return error */
4016 }
4017 if (handle->inited != 1) /* check handle initialization */
4018 {
4019 return 3; /* return error */
4020 }
4021 if (position > 0x3FF) /* check position */
4022 {
4023 handle->debug_print("ov2640: position > 0x3FF.\n"); /* position > 0x3FF */
4024
4025 return 4; /* return error */
4026 }
4027
4028 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG2A, &prev); /* read reg2a */
4029 if (res != 0) /* check result */
4030 {
4031 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4032
4033 return 1; /* return error */
4034 }
4035 prev &= ~(0x3 << 2); /* clear settings */
4036 prev |= ((position >> 8) & 0x3) << 2; /* set position */
4037 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_REG2A, prev); /* write reg 2a */
4038 if (res != 0) /* check result */
4039 {
4040 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4041
4042 return 1; /* return error */
4043 }
4044 prev = position & 0xFF; /* set position */
4045 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_HEDY, prev); /* write hedy */
4046 if (res != 0) /* check result */
4047 {
4048 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4049
4050 return 1; /* return error */
4051 }
4052
4053 return 0; /* success return 0 */
4054}
4055
4068{
4069 uint8_t res;
4070 uint8_t prev;
4071
4072 if (handle == NULL) /* check handle */
4073 {
4074 return 2; /* return error */
4075 }
4076 if (handle->inited != 1) /* check handle initialization */
4077 {
4078 return 3; /* return error */
4079 }
4080
4081 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG2A, &prev); /* read reg2a */
4082 if (res != 0) /* check result */
4083 {
4084 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4085
4086 return 1; /* return error */
4087 }
4088 *position = (uint16_t)((prev >> 2) & 0x03) << 8; /* set position */
4089 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_HEDY, &prev); /* read hedy */
4090 if (res != 0) /* check result */
4091 {
4092 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4093
4094 return 1; /* return error */
4095 }
4096 *position |= prev; /* set position */
4097
4098 return 0; /* success return 0 */
4099}
4100
4114{
4115 uint8_t res;
4116 uint8_t prev;
4117
4118 if (handle == NULL) /* check handle */
4119 {
4120 return 2; /* return error */
4121 }
4122 if (handle->inited != 1) /* check handle initialization */
4123 {
4124 return 3; /* return error */
4125 }
4126 if (position > 0x3FF) /* check position */
4127 {
4128 handle->debug_print("ov2640: position > 0x3FF.\n"); /* position > 0x3FF */
4129
4130 return 4; /* return error */
4131 }
4132
4133 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG2A, &prev); /* read reg2a */
4134 if (res != 0) /* check result */
4135 {
4136 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4137
4138 return 1; /* return error */
4139 }
4140 prev &= ~(0x3 << 0); /* clear settings */
4141 prev |= ((position >> 8) & 0x3) << 0; /* set position */
4142 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_REG2A, prev); /* write reg 2a */
4143 if (res != 0) /* check result */
4144 {
4145 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4146
4147 return 1; /* return error */
4148 }
4149 prev = position & 0xFF; /* set position */
4150 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_HSDY, prev); /* write hsdy */
4151 if (res != 0) /* check result */
4152 {
4153 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4154
4155 return 1; /* return error */
4156 }
4157
4158 return 0; /* success return 0 */
4159}
4160
4173{
4174 uint8_t res;
4175 uint8_t prev;
4176
4177 if (handle == NULL) /* check handle */
4178 {
4179 return 2; /* return error */
4180 }
4181 if (handle->inited != 1) /* check handle initialization */
4182 {
4183 return 3; /* return error */
4184 }
4185
4186 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG2A, &prev); /* read reg2a */
4187 if (res != 0) /* check result */
4188 {
4189 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4190
4191 return 1; /* return error */
4192 }
4193 *position = (uint16_t)((prev >> 0) & 0x03) << 8; /* set position */
4194 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_HSDY, &prev); /* read hsdy */
4195 if (res != 0) /* check result */
4196 {
4197 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4198
4199 return 1; /* return error */
4200 }
4201 *position |= prev; /* set position */
4202
4203 return 0; /* success return 0 */
4204}
4205
4217uint8_t ov2640_set_vsync_pulse_width(ov2640_handle_t *handle, uint16_t width)
4218{
4219 uint8_t res;
4220 uint8_t prev;
4221
4222 if (handle == NULL) /* check handle */
4223 {
4224 return 2; /* return error */
4225 }
4226 if (handle->inited != 1) /* check handle initialization */
4227 {
4228 return 3; /* return error */
4229 }
4230
4231 prev = width & 0xFF; /* set width */
4232 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_ADDVSL, prev); /* write addvsl */
4233 if (res != 0) /* check result */
4234 {
4235 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4236
4237 return 1; /* return error */
4238 }
4239 prev = (width >> 8) & 0xFF; /* set width */
4240 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_ADDVSH, prev); /* write addvsh */
4241 if (res != 0) /* check result */
4242 {
4243 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4244
4245 return 1; /* return error */
4246 }
4247
4248 return 0; /* success return 0 */
4249}
4250
4262uint8_t ov2640_get_vsync_pulse_width(ov2640_handle_t *handle, uint16_t *width)
4263{
4264 uint8_t res;
4265 uint8_t prev;
4266
4267 if (handle == NULL) /* check handle */
4268 {
4269 return 2; /* return error */
4270 }
4271 if (handle->inited != 1) /* check handle initialization */
4272 {
4273 return 3; /* return error */
4274 }
4275
4276 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_ADDVSL, &prev); /* read addvsl */
4277 if (res != 0) /* check result */
4278 {
4279 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor read failed */
4280
4281 return 1; /* return error */
4282 }
4283 *width = (uint16_t)prev; /* set width */
4284 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_ADDVSH, &prev); /* read addvsh */
4285 if (res != 0) /* check result */
4286 {
4287 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4288
4289 return 1; /* return error */
4290 }
4291 *width |= (uint16_t)prev << 8; /* set width */
4292
4293 return 0; /* success return 0 */
4294}
4295
4307uint8_t ov2640_set_luminance_average(ov2640_handle_t *handle, uint8_t average)
4308{
4309 uint8_t res;
4310 uint8_t prev;
4311
4312 if (handle == NULL) /* check handle */
4313 {
4314 return 2; /* return error */
4315 }
4316 if (handle->inited != 1) /* check handle initialization */
4317 {
4318 return 3; /* return error */
4319 }
4320
4321 prev = average; /* set average */
4322 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_YAVG, prev); /* write yavg */
4323 if (res != 0) /* check result */
4324 {
4325 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4326
4327 return 1; /* return error */
4328 }
4329
4330 return 0; /* success return 0 */
4331}
4332
4344uint8_t ov2640_get_luminance_average(ov2640_handle_t *handle, uint8_t *average)
4345{
4346 uint8_t res;
4347 uint8_t prev;
4348
4349 if (handle == NULL) /* check handle */
4350 {
4351 return 2; /* return error */
4352 }
4353 if (handle->inited != 1) /* check handle initialization */
4354 {
4355 return 3; /* return error */
4356 }
4357
4358 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_YAVG, &prev); /* read yavg */
4359 if (res != 0) /* check result */
4360 {
4361 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4362
4363 return 1; /* return error */
4364 }
4365 *average = prev; /* set average */
4366
4367 return 0; /* success return 0 */
4368}
4369
4383{
4384 uint8_t res;
4385 uint8_t prev;
4386
4387 if (handle == NULL) /* check handle */
4388 {
4389 return 2; /* return error */
4390 }
4391 if (handle->inited != 1) /* check handle initialization */
4392 {
4393 return 3; /* return error */
4394 }
4395 if (start > 0x7FF) /* check start */
4396 {
4397 handle->debug_print("ov2640: start > 0x7FF.\n"); /* start > 0x7FF */
4398
4399 return 4; /* return error */
4400 }
4401
4402 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG32, &prev); /* read reg32 */
4403 if (res != 0) /* check result */
4404 {
4405 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4406
4407 return 1; /* return error */
4408 }
4409 prev &= ~(7 << 0); /* clear settings */
4410 prev |= ((start & 0x07) << 0); /* set start */
4411 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_REG32, prev); /* write reg32 */
4412 if (res != 0) /* check result */
4413 {
4414 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4415
4416 return 1; /* return error */
4417 }
4418 prev = (start >> 3) & 0xFF; /* set msb part */
4419 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_HREFST, prev); /* write hrefst */
4420 if (res != 0) /* check result */
4421 {
4422 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4423
4424 return 1; /* return error */
4425 }
4426
4427 return 0; /* success return 0 */
4428}
4429
4442{
4443 uint8_t res;
4444 uint8_t prev;
4445
4446 if (handle == NULL) /* check handle */
4447 {
4448 return 2; /* return error */
4449 }
4450 if (handle->inited != 1) /* check handle initialization */
4451 {
4452 return 3; /* return error */
4453 }
4454
4455 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG32, &prev); /* read reg32 */
4456 if (res != 0) /* check result */
4457 {
4458 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4459
4460 return 1; /* return error */
4461 }
4462 *start = prev & 0x07; /* set start lsb */
4463 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_HREFST, &prev); /* read hrefst */
4464 if (res != 0) /* check result */
4465 {
4466 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4467
4468 return 1; /* return error */
4469 }
4470 *start |= (prev << 3); /* set msb */
4471
4472 return 0; /* success return 0 */
4473}
4474
4488{
4489 uint8_t res;
4490 uint8_t prev;
4491
4492 if (handle == NULL) /* check handle */
4493 {
4494 return 2; /* return error */
4495 }
4496 if (handle->inited != 1) /* check handle initialization */
4497 {
4498 return 3; /* return error */
4499 }
4500 if (end > 0x7FF) /* check end */
4501 {
4502 handle->debug_print("ov2640: end > 0x7FF.\n"); /* end > 0x7FF */
4503
4504 return 4; /* return error */
4505 }
4506
4507 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG32, &prev); /* read reg32 */
4508 if (res != 0) /* check result */
4509 {
4510 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4511
4512 return 1; /* return error */
4513 }
4514 prev &= ~(7 << 3); /* clear settings */
4515 prev |= ((end & 0x07) << 3); /* set end */
4516 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_REG32, prev); /* write reg32 */
4517 if (res != 0) /* check result */
4518 {
4519 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4520
4521 return 1; /* return error */
4522 }
4523 prev = (end >> 3) & 0xFF; /* set msb part */
4524 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_HREFEND, prev); /* write hrefend */
4525 if (res != 0) /* check result */
4526 {
4527 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4528
4529 return 1; /* return error */
4530 }
4531
4532 return 0; /* success return 0 */
4533}
4534
4547{
4548 uint8_t res;
4549 uint8_t prev;
4550
4551 if (handle == NULL) /* check handle */
4552 {
4553 return 2; /* return error */
4554 }
4555 if (handle->inited != 1) /* check handle initialization */
4556 {
4557 return 3; /* return error */
4558 }
4559
4560 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG32, &prev); /* read reg32 */
4561 if (res != 0) /* check result */
4562 {
4563 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4564
4565 return 1; /* return error */
4566 }
4567 *end = (prev >> 3) & 0x07; /* set start lsb */
4568 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_HREFEND, &prev); /* read hrefend */
4569 if (res != 0) /* check result */
4570 {
4571 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4572
4573 return 1; /* return error */
4574 }
4575 *end |= (prev << 3); /* set msb */
4576
4577 return 0; /* success return 0 */
4578}
4579
4592{
4593 uint8_t res;
4594 uint8_t prev;
4595
4596 if (handle == NULL) /* check handle */
4597 {
4598 return 2; /* return error */
4599 }
4600 if (handle->inited != 1) /* check handle initialization */
4601 {
4602 return 3; /* return error */
4603 }
4604
4605 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG32, &prev); /* read reg32 */
4606 if (res != 0) /* check result */
4607 {
4608 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4609
4610 return 1; /* return error */
4611 }
4612 prev &= ~(3 << 6); /* clear settings */
4613 prev |= (pclk << 6); /* pclk start */
4614 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_REG32, prev); /* write reg32 */
4615 if (res != 0) /* check result */
4616 {
4617 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4618
4619 return 1; /* return error */
4620 }
4621
4622 return 0; /* success return 0 */
4623}
4624
4637{
4638 uint8_t res;
4639 uint8_t prev;
4640
4641 if (handle == NULL) /* check handle */
4642 {
4643 return 2; /* return error */
4644 }
4645 if (handle->inited != 1) /* check handle initialization */
4646 {
4647 return 3; /* return error */
4648 }
4649
4650 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG32, &prev); /* read reg32 */
4651 if (res != 0) /* check result */
4652 {
4653 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4654
4655 return 1; /* return error */
4656 }
4657 *pclk = (ov2640_pclk_t)((prev >> 6) & 0x03); /* get pclk */
4658
4659 return 0; /* success return 0 */
4660}
4661
4674{
4675 uint8_t res;
4676 uint8_t prev;
4677
4678 if (handle == NULL) /* check handle */
4679 {
4680 return 2; /* return error */
4681 }
4682 if (handle->inited != 1) /* check handle initialization */
4683 {
4684 return 3; /* return error */
4685 }
4686
4687 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_ARCOM2, &prev); /* read arcom2 */
4688 if (res != 0) /* check result */
4689 {
4690 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4691
4692 return 1; /* return error */
4693 }
4694 prev &= ~(1 << 2); /* clear settings */
4695 prev |= (enable << 2); /* set bool */
4696 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_ARCOM2, prev); /* write arcom2 */
4697 if (res != 0) /* check result */
4698 {
4699 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4700
4701 return 1; /* return error */
4702 }
4703
4704 return 0; /* success return 0 */
4705}
4706
4719{
4720 uint8_t res;
4721 uint8_t prev;
4722
4723 if (handle == NULL) /* check handle */
4724 {
4725 return 2; /* return error */
4726 }
4727 if (handle->inited != 1) /* check handle initialization */
4728 {
4729 return 3; /* return error */
4730 }
4731
4732 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_ARCOM2, &prev); /* read arcom2 */
4733 if (res != 0) /* check result */
4734 {
4735 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4736
4737 return 1; /* return error */
4738 }
4739 *enable = (ov2640_bool_t)((prev >> 2) & 0x01); /* get bool */
4740
4741 return 0; /* success return 0 */
4742}
4743
4757{
4758 uint8_t res;
4759 uint8_t prev;
4760
4761 if (handle == NULL) /* check handle */
4762 {
4763 return 2; /* return error */
4764 }
4765 if (handle->inited != 1) /* check handle initialization */
4766 {
4767 return 3; /* return error */
4768 }
4769 if (frame > 0x3FF) /* check frame */
4770 {
4771 handle->debug_print("ov2640: frame > 0x3FF.\n"); /* frame > 0x3FF */
4772
4773 return 4; /* return error */
4774 }
4775
4776 prev = frame & 0xFF; /* set frame lsb */
4777 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_FLL, prev); /* write fll */
4778 if (res != 0) /* check result */
4779 {
4780 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4781
4782 return 1; /* return error */
4783 }
4784 prev = (frame >> 8) & 0xFF; /* set frame msb */
4785 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_FLH, prev); /* write flh */
4786 if (res != 0) /* check result */
4787 {
4788 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4789
4790 return 1; /* return error */
4791 }
4792
4793 return 0; /* success return 0 */
4794}
4795
4808{
4809 uint8_t res;
4810 uint8_t prev;
4811
4812 if (handle == NULL) /* check handle */
4813 {
4814 return 2; /* return error */
4815 }
4816 if (handle->inited != 1) /* check handle initialization */
4817 {
4818 return 3; /* return error */
4819 }
4820
4821 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_FLL, &prev); /* read fll */
4822 if (res != 0) /* check result */
4823 {
4824 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4825
4826 return 1; /* return error */
4827 }
4828 *frame = (uint16_t)prev; /* set frame */
4829 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_FLH, &prev); /* read flh */
4830 if (res != 0) /* check result */
4831 {
4832 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4833
4834 return 1; /* return error */
4835 }
4836 *frame |= (uint16_t)prev << 8; /* set frame */
4837
4838 return 0; /* success return 0 */
4839}
4840
4854{
4855 uint8_t res;
4856 uint8_t prev;
4857
4858 if (handle == NULL) /* check handle */
4859 {
4860 return 2; /* return error */
4861 }
4862 if (handle->inited != 1) /* check handle initialization */
4863 {
4864 return 3; /* return error */
4865 }
4866 if (point > 0x3FF) /* check point */
4867 {
4868 handle->debug_print("ov2640: point > 0x3FF.\n"); /* point > 0x3FF */
4869
4870 return 4; /* return error */
4871 }
4872
4873 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM19, &prev); /* read com19 */
4874 if (res != 0) /* check result */
4875 {
4876 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4877
4878 return 1; /* return error */
4879 }
4880 prev &= ~(3 << 0); /* clear settings */
4881 prev |= point & 0x03; /* set point */
4882 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM19, prev); /* write com19 */
4883 if (res != 0) /* check result */
4884 {
4885 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4886
4887 return 1; /* return error */
4888 }
4889 prev = (point >> 2) & 0xFF; /* set point */
4890 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_ZOOMS, prev); /* write zooms */
4891 if (res != 0) /* check result */
4892 {
4893 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4894
4895 return 1; /* return error */
4896 }
4897
4898 return 0; /* success return 0 */
4899}
4900
4913{
4914 uint8_t res;
4915 uint8_t prev;
4916
4917 if (handle == NULL) /* check handle */
4918 {
4919 return 2; /* return error */
4920 }
4921 if (handle->inited != 1) /* check handle initialization */
4922 {
4923 return 3; /* return error */
4924 }
4925
4926 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM19, &prev); /* read com19 */
4927 if (res != 0) /* check result */
4928 {
4929 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4930
4931 return 1; /* return error */
4932 }
4933 *point = prev & 0x03; /* get point */
4934 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_ZOOMS, &prev); /* read zooms */
4935 if (res != 0) /* check result */
4936 {
4937 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
4938
4939 return 1; /* return error */
4940 }
4941 *point |= prev << 2; /* set point */
4942
4943 return 0; /* success return 0 */
4944}
4945
4957uint8_t ov2640_set_flash_light(ov2640_handle_t *handle, uint8_t control)
4958{
4959 uint8_t res;
4960 uint8_t prev;
4961
4962 if (handle == NULL) /* check handle */
4963 {
4964 return 2; /* return error */
4965 }
4966 if (handle->inited != 1) /* check handle initialization */
4967 {
4968 return 3; /* return error */
4969 }
4970
4971 prev = control; /* set control */
4972 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM22, prev); /* write com22 */
4973 if (res != 0) /* check result */
4974 {
4975 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
4976
4977 return 1; /* return error */
4978 }
4979
4980 return 0; /* success return 0 */
4981}
4982
4994uint8_t ov2640_get_flash_light(ov2640_handle_t *handle, uint8_t *control)
4995{
4996 uint8_t res;
4997 uint8_t prev;
4998
4999 if (handle == NULL) /* check handle */
5000 {
5001 return 2; /* return error */
5002 }
5003 if (handle->inited != 1) /* check handle initialization */
5004 {
5005 return 3; /* return error */
5006 }
5007
5008 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM22, &prev); /* read com22 */
5009 if (res != 0) /* check result */
5010 {
5011 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
5012
5013 return 1; /* return error */
5014 }
5015 *control = prev; /* get control */
5016
5017 return 0; /* success return 0 */
5018}
5019
5032uint8_t ov2640_set_50hz_banding_aec(ov2640_handle_t *handle, uint16_t aec)
5033{
5034 uint8_t res;
5035 uint8_t prev;
5036
5037 if (handle == NULL) /* check handle */
5038 {
5039 return 2; /* return error */
5040 }
5041 if (handle->inited != 1) /* check handle initialization */
5042 {
5043 return 3; /* return error */
5044 }
5045 if (aec > 0x3FF) /* check aec */
5046 {
5047 handle->debug_print("ov2640: aec > 0x3FF.\n"); /* aec > 0x3FF */
5048
5049 return 4; /* return error */
5050 }
5051
5052 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM25, &prev); /* read com25 */
5053 if (res != 0) /* check result */
5054 {
5055 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
5056
5057 return 1; /* return error */
5058 }
5059 prev &= ~(3 << 6); /* clear settings */
5060 prev |= ((aec >> 8) & 0x03) << 6; /* set aec */
5061 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM25, prev); /* write com25 */
5062 if (res != 0) /* check result */
5063 {
5064 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
5065
5066 return 1; /* return error */
5067 }
5068 prev = aec & 0xFF; /* set aec */
5069 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_BD50, prev); /* write bd50 */
5070 if (res != 0) /* check result */
5071 {
5072 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
5073
5074 return 1; /* return error */
5075 }
5076
5077 return 0; /* success return 0 */
5078}
5079
5091uint8_t ov2640_get_50hz_banding_aec(ov2640_handle_t *handle, uint16_t *aec)
5092{
5093 uint8_t res;
5094 uint8_t prev;
5095
5096 if (handle == NULL) /* check handle */
5097 {
5098 return 2; /* return error */
5099 }
5100 if (handle->inited != 1) /* check handle initialization */
5101 {
5102 return 3; /* return error */
5103 }
5104
5105 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM25, &prev); /* read com25 */
5106 if (res != 0) /* check result */
5107 {
5108 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
5109
5110 return 1; /* return error */
5111 }
5112 *aec = (uint16_t)((prev >> 6) & 0x03) << 8; /* set aec */
5113 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_BD50, &prev); /* read bd50 */
5114 if (res != 0) /* check result */
5115 {
5116 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
5117
5118 return 1; /* return error */
5119 }
5120 *aec |= prev; /* set aec */
5121
5122 return 0; /* success return 0 */
5123}
5124
5137uint8_t ov2640_set_60hz_banding_aec(ov2640_handle_t *handle, uint16_t aec)
5138{
5139 uint8_t res;
5140 uint8_t prev;
5141
5142 if (handle == NULL) /* check handle */
5143 {
5144 return 2; /* return error */
5145 }
5146 if (handle->inited != 1) /* check handle initialization */
5147 {
5148 return 3; /* return error */
5149 }
5150 if (aec > 0x3FF) /* check aec */
5151 {
5152 handle->debug_print("ov2640: aec > 0x3FF.\n"); /* aec > 0x3FF */
5153
5154 return 4; /* return error */
5155 }
5156
5157 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM25, &prev); /* read com25 */
5158 if (res != 0) /* check result */
5159 {
5160 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
5161
5162 return 1; /* return error */
5163 }
5164 prev &= ~(3 << 4); /* clear settings */
5165 prev |= ((aec >> 8) & 0x03) << 4; /* set aec */
5166 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_COM25, prev); /* write com25 */
5167 if (res != 0) /* check result */
5168 {
5169 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
5170
5171 return 1; /* return error */
5172 }
5173 prev = aec & 0xFF; /* set aec */
5174 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_BD60, prev); /* write bd60 */
5175 if (res != 0) /* check result */
5176 {
5177 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
5178
5179 return 1; /* return error */
5180 }
5181
5182 return 0; /* success return 0 */
5183}
5184
5196uint8_t ov2640_get_60hz_banding_aec(ov2640_handle_t *handle, uint16_t *aec)
5197{
5198 uint8_t res;
5199 uint8_t prev;
5200
5201 if (handle == NULL) /* check handle */
5202 {
5203 return 2; /* return error */
5204 }
5205 if (handle->inited != 1) /* check handle initialization */
5206 {
5207 return 3; /* return error */
5208 }
5209
5210 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_COM25, &prev); /* read com25 */
5211 if (res != 0) /* check result */
5212 {
5213 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
5214
5215 return 1; /* return error */
5216 }
5217 *aec = (uint16_t)((prev >> 4) & 0x03) << 8; /* set aec */
5218 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_BD60, &prev); /* read bd60 */
5219 if (res != 0) /* check result */
5220 {
5221 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
5222
5223 return 1; /* return error */
5224 }
5225 *aec |= prev; /* set aec */
5226
5227 return 0; /* success return 0 */
5228}
5229
5242{
5243 uint8_t res;
5244 uint8_t prev;
5245
5246 if (handle == NULL) /* check handle */
5247 {
5248 return 2; /* return error */
5249 }
5250 if (handle->inited != 1) /* check handle initialization */
5251 {
5252 return 3; /* return error */
5253 }
5254
5255 prev = (avg >> 0) & 0xFF; /* set avg */
5256 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_REG5D, prev); /* write reg 5d */
5257 if (res != 0) /* check result */
5258 {
5259 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
5260
5261 return 1; /* return error */
5262 }
5263 prev = (avg >> 8) & 0xFF; /* set avg */
5264 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_REG5E, prev); /* write reg5e */
5265 if (res != 0) /* check result */
5266 {
5267 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
5268
5269 return 1; /* return error */
5270 }
5271 prev = (avg >> 16) & 0xFF; /* set avg */
5272 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_REG5F, prev); /* write reg 5f */
5273 if (res != 0) /* check result */
5274 {
5275 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
5276
5277 return 1; /* return error */
5278 }
5279 prev = (avg >> 24) & 0xFF; /* set avg */
5280 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_REG60, prev); /* write reg60 */
5281 if (res != 0) /* check result */
5282 {
5283 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
5284
5285 return 1; /* return error */
5286 }
5287
5288 return 0; /* success return 0 */
5289}
5290
5303{
5304 uint8_t res;
5305 uint8_t prev;
5306
5307 if (handle == NULL) /* check handle */
5308 {
5309 return 2; /* return error */
5310 }
5311 if (handle->inited != 1) /* check handle initialization */
5312 {
5313 return 3; /* return error */
5314 }
5315
5316 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG5D, &prev); /* read reg5d */
5317 if (res != 0) /* check result */
5318 {
5319 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
5320
5321 return 1; /* return error */
5322 }
5323 *avg = (uint32_t)prev; /* set avg */
5324 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG5E, &prev); /* read reg5e */
5325 if (res != 0) /* check result */
5326 {
5327 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
5328
5329 return 1; /* return error */
5330 }
5331 *avg |= (uint32_t)prev << 8; /* set avg */
5332 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG5F, &prev); /* read reg5f */
5333 if (res != 0) /* check result */
5334 {
5335 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
5336
5337 return 1; /* return error */
5338 }
5339 *avg |= (uint32_t)prev << 16; /* set avg */
5340 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_REG60, &prev); /* read reg60 */
5341 if (res != 0) /* check result */
5342 {
5343 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
5344
5345 return 1; /* return error */
5346 }
5347 *avg |= (uint32_t)prev << 24; /* set avg */
5348
5349 return 0; /* success return 0 */
5350}
5351
5364{
5365 uint8_t res;
5366 uint8_t prev;
5367
5368 if (handle == NULL) /* check handle */
5369 {
5370 return 2; /* return error */
5371 }
5372 if (handle->inited != 1) /* check handle initialization */
5373 {
5374 return 3; /* return error */
5375 }
5376
5377 prev = level; /* set level */
5378 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_HISTO_LOW, prev); /* write histo low */
5379 if (res != 0) /* check result */
5380 {
5381 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
5382
5383 return 1; /* return error */
5384 }
5385
5386 return 0; /* success return 0 */
5387}
5388
5401{
5402 uint8_t res;
5403 uint8_t prev;
5404
5405 if (handle == NULL) /* check handle */
5406 {
5407 return 2; /* return error */
5408 }
5409 if (handle->inited != 1) /* check handle initialization */
5410 {
5411 return 3; /* return error */
5412 }
5413
5414 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_HISTO_LOW, &prev); /* read histo low */
5415 if (res != 0) /* check result */
5416 {
5417 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
5418
5419 return 1; /* return error */
5420 }
5421 *level = prev; /* get level */
5422
5423 return 0; /* success return 0 */
5424}
5425
5438{
5439 uint8_t res;
5440 uint8_t prev;
5441
5442 if (handle == NULL) /* check handle */
5443 {
5444 return 2; /* return error */
5445 }
5446 if (handle->inited != 1) /* check handle initialization */
5447 {
5448 return 3; /* return error */
5449 }
5450
5451 prev = level; /* set level */
5452 res = a_ov2640_sensor_write(handle, OV2640_REG_SENSOR_BANK_HISTO_HIGH, prev); /* write histo high */
5453 if (res != 0) /* check result */
5454 {
5455 handle->debug_print("ov2640: sensor write failed.\n"); /* sensor write failed */
5456
5457 return 1; /* return error */
5458 }
5459
5460 return 0; /* success return 0 */
5461}
5462
5475{
5476 uint8_t res;
5477 uint8_t prev;
5478
5479 if (handle == NULL) /* check handle */
5480 {
5481 return 2; /* return error */
5482 }
5483 if (handle->inited != 1) /* check handle initialization */
5484 {
5485 return 3; /* return error */
5486 }
5487
5488 res = a_ov2640_sensor_read(handle, OV2640_REG_SENSOR_BANK_HISTO_HIGH, &prev); /* read histo high */
5489 if (res != 0) /* check result */
5490 {
5491 handle->debug_print("ov2640: sensor read failed.\n"); /* sensor read failed */
5492
5493 return 1; /* return error */
5494 }
5495 *level = prev; /* set level */
5496
5497 return 0; /* success return 0 */
5498}
5499
5512{
5513 uint8_t res;
5514 uint8_t prev;
5515
5516 if (handle == NULL) /* check handle */
5517 {
5518 return 2; /* return error */
5519 }
5520 if (handle->inited != 1) /* check handle initialization */
5521 {
5522 return 3; /* return error */
5523 }
5524
5525 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_R_BYPASS, &prev); /* read r bypass */
5526 if (res != 0) /* check result */
5527 {
5528 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
5529
5530 return 1; /* return error */
5531 }
5532 prev &= ~(1 << 0); /* clear settings */
5533 prev |= enable << 0; /* set bool */
5534 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_R_BYPASS, prev); /* write r bypass */
5535 if (res != 0) /* check result */
5536 {
5537 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
5538
5539 return 1; /* return error */
5540 }
5541
5542 return 0; /* success return 0 */
5543}
5544
5557{
5558 uint8_t res;
5559 uint8_t prev;
5560
5561 if (handle == NULL) /* check handle */
5562 {
5563 return 2; /* return error */
5564 }
5565 if (handle->inited != 1) /* check handle initialization */
5566 {
5567 return 3; /* return error */
5568 }
5569
5570 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_R_BYPASS, &prev); /* read r bypass */
5571 if (res != 0) /* check result */
5572 {
5573 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
5574
5575 return 1; /* return error */
5576 }
5577 *enable = (ov2640_bool_t)((prev >> 0) & 0x01); /* get bool */
5578
5579 return 0; /* success return 0 */
5580}
5581
5594{
5595 uint8_t res;
5596 uint8_t prev;
5597
5598 if (handle == NULL) /* check handle */
5599 {
5600 return 2; /* return error */
5601 }
5602 if (handle->inited != 1) /* check handle initialization */
5603 {
5604 return 3; /* return error */
5605 }
5606
5607 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_R_DVP_SP, &prev); /* read r dvp sp */
5608 if (res != 0) /* check result */
5609 {
5610 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
5611
5612 return 1; /* return error */
5613 }
5614 prev &= ~(1 << 7); /* clear settings */
5615 prev |= enable << 7; /* set bool */
5616 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_R_DVP_SP, prev); /* write r dvp sp */
5617 if (res != 0) /* check result */
5618 {
5619 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
5620
5621 return 1; /* return error */
5622 }
5623
5624 return 0; /* success return 0 */
5625}
5626
5639{
5640 uint8_t res;
5641 uint8_t prev;
5642
5643 if (handle == NULL) /* check handle */
5644 {
5645 return 2; /* return error */
5646 }
5647 if (handle->inited != 1) /* check handle initialization */
5648 {
5649 return 3; /* return error */
5650 }
5651
5652 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_R_DVP_SP, &prev); /* read r dvp sp */
5653 if (res != 0) /* check result */
5654 {
5655 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
5656
5657 return 1; /* return error */
5658 }
5659 *enable = (ov2640_bool_t)((prev >> 7) & 0x01); /* get bool */
5660
5661 return 0; /* success return 0 */
5662}
5663
5676uint8_t ov2640_set_dvp_pclk(ov2640_handle_t *handle, uint8_t pclk)
5677{
5678 uint8_t res;
5679 uint8_t prev;
5680
5681 if (handle == NULL) /* check handle */
5682 {
5683 return 2; /* return error */
5684 }
5685 if (handle->inited != 1) /* check handle initialization */
5686 {
5687 return 3; /* return error */
5688 }
5689 if (pclk > 0x7F) /* check pclk */
5690 {
5691 handle->debug_print("ov2640: pclk > 0x7F.\n"); /* pclk > 0x7F */
5692
5693 return 4; /* return error */
5694 }
5695
5696 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_R_DVP_SP, &prev); /* read r dvp sp */
5697 if (res != 0) /* check result */
5698 {
5699 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
5700
5701 return 1; /* return error */
5702 }
5703 prev &= ~(0x7F << 0); /* clear settings */
5704 prev |= pclk << 0; /* set pclk */
5705 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_R_DVP_SP, prev); /* write r dvp sp */
5706 if (res != 0) /* check result */
5707 {
5708 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
5709
5710 return 1; /* return error */
5711 }
5712
5713 return 0; /* success return 0 */
5714}
5715
5727uint8_t ov2640_get_dvp_pclk(ov2640_handle_t *handle, uint8_t *pclk)
5728{
5729 uint8_t res;
5730 uint8_t prev;
5731
5732 if (handle == NULL) /* check handle */
5733 {
5734 return 2; /* return error */
5735 }
5736 if (handle->inited != 1) /* check handle initialization */
5737 {
5738 return 3; /* return error */
5739 }
5740
5741 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_R_DVP_SP, &prev); /* read r dvp sp */
5742 if (res != 0) /* check result */
5743 {
5744 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
5745
5746 return 1; /* return error */
5747 }
5748 *pclk = prev & 0x7F; /* get pclk */
5749
5750 return 0; /* success return 0 */
5751}
5752
5765{
5766 uint8_t res;
5767 uint8_t prev;
5768
5769 if (handle == NULL) /* check handle */
5770 {
5771 return 2; /* return error */
5772 }
5773 if (handle->inited != 1) /* check handle initialization */
5774 {
5775 return 3; /* return error */
5776 }
5777
5778 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_IMAGE_MODE, &prev); /* read image mode */
5779 if (res != 0) /* check result */
5780 {
5781 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
5782
5783 return 1; /* return error */
5784 }
5785 prev &= ~(1 << 6); /* clear settings */
5786 prev |= enable << 6; /* set bool */
5787 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_IMAGE_MODE, prev); /* write image mode */
5788 if (res != 0) /* check result */
5789 {
5790 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
5791
5792 return 1; /* return error */
5793 }
5794
5795 return 0; /* success return 0 */
5796}
5797
5810{
5811 uint8_t res;
5812 uint8_t prev;
5813
5814 if (handle == NULL) /* check handle */
5815 {
5816 return 2; /* return error */
5817 }
5818 if (handle->inited != 1) /* check handle initialization */
5819 {
5820 return 3; /* return error */
5821 }
5822
5823 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_IMAGE_MODE, &prev); /* read image mode */
5824 if (res != 0) /* check result */
5825 {
5826 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
5827
5828 return 1; /* return error */
5829 }
5830 *enable = (ov2640_bool_t)((prev >> 6) & 0x01); /* get bool */
5831
5832 return 0; /* success return 0 */
5833}
5834
5847{
5848 uint8_t res;
5849 uint8_t prev;
5850
5851 if (handle == NULL) /* check handle */
5852 {
5853 return 2; /* return error */
5854 }
5855 if (handle->inited != 1) /* check handle initialization */
5856 {
5857 return 3; /* return error */
5858 }
5859
5860 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_IMAGE_MODE, &prev); /* read image mode */
5861 if (res != 0) /* check result */
5862 {
5863 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
5864
5865 return 1; /* return error */
5866 }
5867 prev &= ~(1 << 4); /* clear settings */
5868 prev |= enable << 4; /* set bool */
5869 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_IMAGE_MODE, prev); /* write image mode */
5870 if (res != 0) /* check result */
5871 {
5872 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
5873
5874 return 1; /* return error */
5875 }
5876
5877 return 0; /* success return 0 */
5878}
5879
5892{
5893 uint8_t res;
5894 uint8_t prev;
5895
5896 if (handle == NULL) /* check handle */
5897 {
5898 return 2; /* return error */
5899 }
5900 if (handle->inited != 1) /* check handle initialization */
5901 {
5902 return 3; /* return error */
5903 }
5904
5905 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_IMAGE_MODE, &prev); /* read image mode */
5906 if (res != 0) /* check result */
5907 {
5908 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
5909
5910 return 1; /* return error */
5911 }
5912 *enable = (ov2640_bool_t)((prev >> 4) & 0x01); /* get bool */
5913
5914 return 0; /* success return 0 */
5915}
5916
5929{
5930 uint8_t res;
5931 uint8_t prev;
5932
5933 if (handle == NULL) /* check handle */
5934 {
5935 return 2; /* return error */
5936 }
5937 if (handle->inited != 1) /* check handle initialization */
5938 {
5939 return 3; /* return error */
5940 }
5941
5942 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_IMAGE_MODE, &prev); /* read image mode */
5943 if (res != 0) /* check result */
5944 {
5945 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
5946
5947 return 1; /* return error */
5948 }
5949 prev &= ~(3 << 2); /* clear settings */
5950 prev |= format << 2; /* set format */
5951 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_IMAGE_MODE, prev); /* write image mode */
5952 if (res != 0) /* check result */
5953 {
5954 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
5955
5956 return 1; /* return error */
5957 }
5958
5959 return 0; /* success return 0 */
5960}
5961
5974{
5975 uint8_t res;
5976 uint8_t prev;
5977
5978 if (handle == NULL) /* check handle */
5979 {
5980 return 2; /* return error */
5981 }
5982 if (handle->inited != 1) /* check handle initialization */
5983 {
5984 return 3; /* return error */
5985 }
5986
5987 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_IMAGE_MODE, &prev); /* read image mode */
5988 if (res != 0) /* check result */
5989 {
5990 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
5991
5992 return 1; /* return error */
5993 }
5994 *format = (ov2640_dvp_output_format_t)((prev >> 2) & 0x3); /* set format */
5995
5996 return 0; /* success return 0 */
5997}
5998
6011{
6012 uint8_t res;
6013 uint8_t prev;
6014
6015 if (handle == NULL) /* check handle */
6016 {
6017 return 2; /* return error */
6018 }
6019 if (handle->inited != 1) /* check handle initialization */
6020 {
6021 return 3; /* return error */
6022 }
6023
6024 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_IMAGE_MODE, &prev); /* read image mode */
6025 if (res != 0) /* check result */
6026 {
6027 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6028
6029 return 1; /* return error */
6030 }
6031 prev &= ~(1 << 1); /* clear settings */
6032 prev |= timing << 1; /* set timing */
6033 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_IMAGE_MODE, prev); /* write image mode */
6034 if (res != 0) /* check result */
6035 {
6036 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
6037
6038 return 1; /* return error */
6039 }
6040
6041 return 0; /* success return 0 */
6042}
6043
6056{
6057 uint8_t res;
6058 uint8_t prev;
6059
6060 if (handle == NULL) /* check handle */
6061 {
6062 return 2; /* return error */
6063 }
6064 if (handle->inited != 1) /* check handle initialization */
6065 {
6066 return 3; /* return error */
6067 }
6068
6069 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_IMAGE_MODE, &prev); /* read image mode */
6070 if (res != 0) /* check result */
6071 {
6072 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6073
6074 return 1; /* return error */
6075 }
6076 *timing = (ov2640_href_timing_t)((prev >> 1) & 0x01); /* get timing */
6077
6078 return 0; /* success return 0 */
6079}
6080
6093{
6094 uint8_t res;
6095 uint8_t prev;
6096
6097 if (handle == NULL) /* check handle */
6098 {
6099 return 2; /* return error */
6100 }
6101 if (handle->inited != 1) /* check handle initialization */
6102 {
6103 return 3; /* return error */
6104 }
6105
6106 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_IMAGE_MODE, &prev); /* read image mode */
6107 if (res != 0) /* check result */
6108 {
6109 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6110
6111 return 1; /* return error */
6112 }
6113 prev &= ~(1 << 0); /* clear settings */
6114 prev |= byte_swap << 0; /* set byte swap */
6115 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_IMAGE_MODE, prev); /* write image mode */
6116 if (res != 0) /* check result */
6117 {
6118 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
6119
6120 return 1; /* return error */
6121 }
6122
6123 return 0; /* success return 0 */
6124}
6125
6138{
6139 uint8_t res;
6140 uint8_t prev;
6141
6142 if (handle == NULL) /* check handle */
6143 {
6144 return 2; /* return error */
6145 }
6146 if (handle->inited != 1) /* check handle initialization */
6147 {
6148 return 3; /* return error */
6149 }
6150
6151 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_IMAGE_MODE, &prev); /* read image mode */
6152 if (res != 0) /* check result */
6153 {
6154 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6155
6156 return 1; /* return error */
6157 }
6158 *byte_swap = (ov2640_byte_swap_t)((prev >> 0) & 0x01); /* get byte swap */
6159
6160 return 0; /* success return 0 */
6161}
6162
6176{
6177 uint8_t res;
6178 uint8_t prev;
6179
6180 if (handle == NULL) /* check handle */
6181 {
6182 return 2; /* return error */
6183 }
6184 if (handle->inited != 1) /* check handle initialization */
6185 {
6186 return 3; /* return error */
6187 }
6188
6189 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_RESET, &prev); /* read reset */
6190 if (res != 0) /* check result */
6191 {
6192 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6193
6194 return 1; /* return error */
6195 }
6196 prev &= ~(1 << type); /* clear settings */
6197 prev |= enable << type; /* set bool */
6198 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_RESET, prev); /* write reset */
6199 if (res != 0) /* check result */
6200 {
6201 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
6202
6203 return 1; /* return error */
6204 }
6205 handle->delay_ms(10); /* delay 10ms */
6206
6207 return 0; /* success return 0 */
6208}
6209
6223{
6224 uint8_t res;
6225 uint8_t prev;
6226
6227 if (handle == NULL) /* check handle */
6228 {
6229 return 2; /* return error */
6230 }
6231 if (handle->inited != 1) /* check handle initialization */
6232 {
6233 return 3; /* return error */
6234 }
6235
6236 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_RESET, &prev); /* read reset */
6237 if (res != 0) /* check result */
6238 {
6239 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6240
6241 return 1; /* return error */
6242 }
6243 *enable = (ov2640_bool_t)((prev >> type) & 0x01); /* get bool */
6244
6245 return 0; /* success return 0 */
6246}
6247
6259uint8_t ov2640_set_sccb_master_speed(ov2640_handle_t *handle, uint8_t speed)
6260{
6261 uint8_t res;
6262 uint8_t prev;
6263
6264 if (handle == NULL) /* check handle */
6265 {
6266 return 2; /* return error */
6267 }
6268 if (handle->inited != 1) /* check handle initialization */
6269 {
6270 return 3; /* return error */
6271 }
6272
6273 prev = speed; /* set speed */
6274 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_MS_SP, prev); /* write sccb master speed */
6275 if (res != 0) /* check result */
6276 {
6277 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
6278
6279 return 1; /* return error */
6280 }
6281
6282 return 0; /* success return 0 */
6283}
6284
6296uint8_t ov2640_get_sccb_master_speed(ov2640_handle_t *handle, uint8_t *speed)
6297{
6298 uint8_t res;
6299 uint8_t prev;
6300
6301 if (handle == NULL) /* check handle */
6302 {
6303 return 2; /* return error */
6304 }
6305 if (handle->inited != 1) /* check handle initialization */
6306 {
6307 return 3; /* return error */
6308 }
6309
6310 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_MS_SP, &prev); /* read sccb master speed */
6311 if (res != 0) /* check result */
6312 {
6313 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6314
6315 return 1; /* return error */
6316 }
6317 *speed = prev; /* get speed */
6318
6319 return 0; /* success return 0 */
6320}
6321
6333uint8_t ov2640_set_sccb_slave_id(ov2640_handle_t *handle, uint8_t id)
6334{
6335 uint8_t res;
6336 uint8_t prev;
6337
6338 if (handle == NULL) /* check handle */
6339 {
6340 return 2; /* return error */
6341 }
6342 if (handle->inited != 1) /* check handle initialization */
6343 {
6344 return 3; /* return error */
6345 }
6346
6347 prev = id; /* set id */
6348 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_SS_ID, prev); /* write sccb slave id */
6349 if (res != 0) /* check result */
6350 {
6351 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
6352
6353 return 1; /* return error */
6354 }
6355
6356 return 0; /* success return 0 */
6357}
6358
6370uint8_t ov2640_get_sccb_slave_id(ov2640_handle_t *handle, uint8_t *id)
6371{
6372 uint8_t res;
6373 uint8_t prev;
6374
6375 if (handle == NULL) /* check handle */
6376 {
6377 return 2; /* return error */
6378 }
6379 if (handle->inited != 1) /* check handle initialization */
6380 {
6381 return 3; /* return error */
6382 }
6383
6384 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_SS_ID, &prev); /* read sccb slave id */
6385 if (res != 0) /* check result */
6386 {
6387 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6388
6389 return 1; /* return error */
6390 }
6391 *id = prev; /* set id */
6392
6393 return 0; /* success return 0 */
6394}
6395
6408{
6409 uint8_t res;
6410 uint8_t prev;
6411
6412 if (handle == NULL) /* check handle */
6413 {
6414 return 2; /* return error */
6415 }
6416 if (handle->inited != 1) /* check handle initialization */
6417 {
6418 return 3; /* return error */
6419 }
6420
6421 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_SS_CTRL, &prev); /* read ss ctrl */
6422 if (res != 0) /* check result */
6423 {
6424 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6425
6426 return 1; /* return error */
6427 }
6428 prev &= ~(1 << 5); /* clear settings */
6429 prev |= enable << 5; /* set bool */
6430 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_SS_CTRL, prev); /* write ss ctrl */
6431 if (res != 0) /* check result */
6432 {
6433 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
6434
6435 return 1; /* return error */
6436 }
6437
6438 return 0; /* success return 0 */
6439}
6440
6453{
6454 uint8_t res;
6455 uint8_t prev;
6456
6457 if (handle == NULL) /* check handle */
6458 {
6459 return 2; /* return error */
6460 }
6461 if (handle->inited != 1) /* check handle initialization */
6462 {
6463 return 3; /* return error */
6464 }
6465
6466 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_SS_CTRL, &prev); /* read ss ctrl */
6467 if (res != 0) /* check result */
6468 {
6469 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6470
6471 return 1; /* return error */
6472 }
6473 *enable = (ov2640_bool_t)((prev >> 5) & 0x01); /* get bool */
6474
6475 return 0; /* success return 0 */
6476}
6477
6490{
6491 uint8_t res;
6492 uint8_t prev;
6493
6494 if (handle == NULL) /* check handle */
6495 {
6496 return 2; /* return error */
6497 }
6498 if (handle->inited != 1) /* check handle initialization */
6499 {
6500 return 3; /* return error */
6501 }
6502
6503 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_SS_CTRL, &prev); /* read ss ctrl */
6504 if (res != 0) /* check result */
6505 {
6506 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6507
6508 return 1; /* return error */
6509 }
6510 prev &= ~(1 << 3); /* clear settings */
6511 prev |= enable << 3; /* set bool */
6512 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_SS_CTRL, prev); /* write ss ctrl */
6513 if (res != 0) /* check result */
6514 {
6515 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
6516
6517 return 1; /* return error */
6518 }
6519
6520 return 0; /* success return 0 */
6521}
6522
6535{
6536 uint8_t res;
6537 uint8_t prev;
6538
6539 if (handle == NULL) /* check handle */
6540 {
6541 return 2; /* return error */
6542 }
6543 if (handle->inited != 1) /* check handle initialization */
6544 {
6545 return 3; /* return error */
6546 }
6547
6548 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_SS_CTRL, &prev); /* read ss ctrl */
6549 if (res != 0) /* check result */
6550 {
6551 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6552
6553 return 1; /* return error */
6554 }
6555 *enable = (ov2640_bool_t)((prev >> 3) & 0x01); /* get bool */
6556
6557 return 0; /* success return 0 */
6558}
6559
6572{
6573 uint8_t res;
6574 uint8_t prev;
6575
6576 if (handle == NULL) /* check handle */
6577 {
6578 return 2; /* return error */
6579 }
6580 if (handle->inited != 1) /* check handle initialization */
6581 {
6582 return 3; /* return error */
6583 }
6584
6585 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_SS_CTRL, &prev); /* read ss ctrl */
6586 if (res != 0) /* check result */
6587 {
6588 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6589
6590 return 1; /* return error */
6591 }
6592 prev &= ~(1 << 2); /* clear settings */
6593 prev |= enable << 2; /* set bool */
6594 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_SS_CTRL, prev); /* write ss ctrl */
6595 if (res != 0) /* check result */
6596 {
6597 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
6598
6599 return 1; /* return error */
6600 }
6601
6602 return 0; /* success return 0 */
6603}
6604
6617{
6618 uint8_t res;
6619 uint8_t prev;
6620
6621 if (handle == NULL) /* check handle */
6622 {
6623 return 2; /* return error */
6624 }
6625 if (handle->inited != 1) /* check handle initialization */
6626 {
6627 return 3; /* return error */
6628 }
6629
6630 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_SS_CTRL, &prev); /* read ss ctrl */
6631 if (res != 0) /* check result */
6632 {
6633 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6634
6635 return 1; /* return error */
6636 }
6637 *enable = (ov2640_bool_t)((prev >> 2) & 0x01); /* get bool */
6638
6639 return 0; /* success return 0 */
6640}
6641
6654{
6655 uint8_t res;
6656 uint8_t prev;
6657
6658 if (handle == NULL) /* check handle */
6659 {
6660 return 2; /* return error */
6661 }
6662 if (handle->inited != 1) /* check handle initialization */
6663 {
6664 return 3; /* return error */
6665 }
6666
6667 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_SS_CTRL, &prev); /* read ss ctrl */
6668 if (res != 0) /* check result */
6669 {
6670 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6671
6672 return 1; /* return error */
6673 }
6674 prev &= ~(1 << 1); /* clear settings */
6675 prev |= enable << 1; /* set bool */
6676 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_SS_CTRL, prev); /* write ss ctrl */
6677 if (res != 0) /* check result */
6678 {
6679 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
6680
6681 return 1; /* return error */
6682 }
6683
6684 return 0; /* success return 0 */
6685}
6686
6699{
6700 uint8_t res;
6701 uint8_t prev;
6702
6703 if (handle == NULL) /* check handle */
6704 {
6705 return 2; /* return error */
6706 }
6707 if (handle->inited != 1) /* check handle initialization */
6708 {
6709 return 3; /* return error */
6710 }
6711
6712 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_SS_CTRL, &prev); /* read ss ctrl */
6713 if (res != 0) /* check result */
6714 {
6715 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6716
6717 return 1; /* return error */
6718 }
6719 *enable = (ov2640_bool_t)((prev >> 1) & 0x01); /* get bool */
6720
6721 return 0; /* success return 0 */
6722}
6723
6736{
6737 uint8_t res;
6738 uint8_t prev;
6739
6740 if (handle == NULL) /* check handle */
6741 {
6742 return 2; /* return error */
6743 }
6744 if (handle->inited != 1) /* check handle initialization */
6745 {
6746 return 3; /* return error */
6747 }
6748
6749 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_SS_CTRL, &prev); /* read ss ctrl */
6750 if (res != 0) /* check result */
6751 {
6752 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6753
6754 return 1; /* return error */
6755 }
6756 prev &= ~(1 << 0); /* clear settings */
6757 prev |= enable << 0; /* set bool */
6758 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_SS_CTRL, prev); /* write ss ctrl */
6759 if (res != 0) /* check result */
6760 {
6761 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
6762
6763 return 1; /* return error */
6764 }
6765
6766 return 0; /* success return 0 */
6767}
6768
6781{
6782 uint8_t res;
6783 uint8_t prev;
6784
6785 if (handle == NULL) /* check handle */
6786 {
6787 return 2; /* return error */
6788 }
6789 if (handle->inited != 1) /* check handle initialization */
6790 {
6791 return 3; /* return error */
6792 }
6793
6794 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_SS_CTRL, &prev); /* read ss ctrl */
6795 if (res != 0) /* check result */
6796 {
6797 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6798
6799 return 1; /* return error */
6800 }
6801 *enable = (ov2640_bool_t)((prev >> 0) & 0x01); /* get bool */
6802
6803 return 0; /* success return 0 */
6804}
6805
6819{
6820 uint8_t res;
6821 uint8_t prev;
6822
6823 if (handle == NULL) /* check handle */
6824 {
6825 return 2; /* return error */
6826 }
6827 if (handle->inited != 1) /* check handle initialization */
6828 {
6829 return 3; /* return error */
6830 }
6831
6832 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_MC_BIST, &prev); /* read mc bist */
6833 if (res != 0) /* check result */
6834 {
6835 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6836
6837 return 1; /* return error */
6838 }
6839 prev &= ~(1 << bist); /* clear settings */
6840 prev |= enable << bist; /* set bool */
6841 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_MC_BIST, prev); /* write mc bist */
6842 if (res != 0) /* check result */
6843 {
6844 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
6845
6846 return 1; /* return error */
6847 }
6848
6849 return 0; /* success return 0 */
6850}
6851
6865{
6866 uint8_t res;
6867 uint8_t prev;
6868
6869 if (handle == NULL) /* check handle */
6870 {
6871 return 2; /* return error */
6872 }
6873 if (handle->inited != 1) /* check handle initialization */
6874 {
6875 return 3; /* return error */
6876 }
6877
6878 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_MC_BIST, &prev); /* read mc bist */
6879 if (res != 0) /* check result */
6880 {
6881 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6882
6883 return 1; /* return error */
6884 }
6885 *enable = (ov2640_bool_t)((prev >> bist) & 0x01); /* get bool */
6886
6887 return 0; /* success return 0 */
6888}
6889
6902{
6903 uint8_t res;
6904 uint8_t prev;
6905
6906 if (handle == NULL) /* check handle */
6907 {
6908 return 2; /* return error */
6909 }
6910 if (handle->inited != 1) /* check handle initialization */
6911 {
6912 return 3; /* return error */
6913 }
6914
6915 prev = addr & 0xFF; /* set address low */
6916 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_MC_AL, prev); /* write mc al */
6917 if (res != 0) /* check result */
6918 {
6919 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
6920
6921 return 1; /* return error */
6922 }
6923 prev = (addr >> 8) & 0xFF; /* set address high */
6924 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_MC_AH, prev); /* write mc ah */
6925 if (res != 0) /* check result */
6926 {
6927 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
6928
6929 return 1; /* return error */
6930 }
6931
6932 return 0; /* success return 0 */
6933}
6934
6947{
6948 uint8_t res;
6949 uint8_t prev;
6950
6951 if (handle == NULL) /* check handle */
6952 {
6953 return 2; /* return error */
6954 }
6955 if (handle->inited != 1) /* check handle initialization */
6956 {
6957 return 3; /* return error */
6958 }
6959
6960 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_MC_AL, &prev); /* read mc al */
6961 if (res != 0) /* check result */
6962 {
6963 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6964
6965 return 1; /* return error */
6966 }
6967 *addr = (uint16_t)prev; /* set lsb */
6968 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_MC_AH, &prev); /* read mc ah */
6969 if (res != 0) /* check result */
6970 {
6971 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
6972
6973 return 1; /* return error */
6974 }
6975 *addr |= (uint16_t)((uint16_t)prev << 8); /* set msb */
6976
6977 return 0; /* success return 0 */
6978}
6979
6992{
6993 uint8_t res;
6994 uint8_t prev;
6995
6996 if (handle == NULL) /* check handle */
6997 {
6998 return 2; /* return error */
6999 }
7000 if (handle->inited != 1) /* check handle initialization */
7001 {
7002 return 3; /* return error */
7003 }
7004
7005 prev = addr; /* set address */
7006 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_MC_D, prev); /* write mc d */
7007 if (res != 0) /* check result */
7008 {
7009 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
7010
7011 return 1; /* return error */
7012 }
7013
7014 return 0; /* success return 0 */
7015}
7016
7029{
7030 uint8_t res;
7031 uint8_t prev;
7032
7033 if (handle == NULL) /* check handle */
7034 {
7035 return 2; /* return error */
7036 }
7037 if (handle->inited != 1) /* check handle initialization */
7038 {
7039 return 3; /* return error */
7040 }
7041
7042 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_MC_D, &prev); /* read mc d */
7043 if (res != 0) /* check result */
7044 {
7045 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7046
7047 return 1; /* return error */
7048 }
7049 *addr = prev; /* set address */
7050
7051 return 0; /* success return 0 */
7052}
7053
7066{
7067 uint8_t res;
7068 uint8_t prev;
7069
7070 if (handle == NULL) /* check handle */
7071 {
7072 return 2; /* return error */
7073 }
7074 if (handle->inited != 1) /* check handle initialization */
7075 {
7076 return 3; /* return error */
7077 }
7078
7079 prev = cmd; /* set command */
7080 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_P_CMD, prev); /* write p cmd */
7081 if (res != 0) /* check result */
7082 {
7083 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
7084
7085 return 1; /* return error */
7086 }
7087
7088 return 0; /* success return 0 */
7089}
7090
7103{
7104 uint8_t res;
7105 uint8_t prev;
7106
7107 if (handle == NULL) /* check handle */
7108 {
7109 return 2; /* return error */
7110 }
7111 if (handle->inited != 1) /* check handle initialization */
7112 {
7113 return 3; /* return error */
7114 }
7115
7116 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_P_CMD, &prev); /* read p cmd */
7117 if (res != 0) /* check result */
7118 {
7119 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7120
7121 return 1; /* return error */
7122 }
7123 *cmd = prev; /* set command */
7124
7125 return 0; /* success return 0 */
7126}
7127
7139uint8_t ov2640_set_sccb_protocol_status(ov2640_handle_t *handle, uint8_t status)
7140{
7141 uint8_t res;
7142 uint8_t prev;
7143
7144 if (handle == NULL) /* check handle */
7145 {
7146 return 2; /* return error */
7147 }
7148 if (handle->inited != 1) /* check handle initialization */
7149 {
7150 return 3; /* return error */
7151 }
7152
7153 prev = status; /* set status */
7154 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_P_STATUS, prev); /* write p status */
7155 if (res != 0) /* check result */
7156 {
7157 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
7158
7159 return 1; /* return error */
7160 }
7161
7162 return 0; /* success return 0 */
7163}
7164
7176uint8_t ov2640_get_sccb_protocol_status(ov2640_handle_t *handle, uint8_t *status)
7177{
7178 uint8_t res;
7179 uint8_t prev;
7180
7181 if (handle == NULL) /* check handle */
7182 {
7183 return 2; /* return error */
7184 }
7185 if (handle->inited != 1) /* check handle initialization */
7186 {
7187 return 3; /* return error */
7188 }
7189
7190 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_P_STATUS, &prev); /* read p status */
7191 if (res != 0) /* check result */
7192 {
7193 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7194
7195 return 1; /* return error */
7196 }
7197 *status = prev; /* set status */
7198
7199 return 0; /* success return 0 */
7200}
7201
7214{
7215 uint8_t res;
7216 uint8_t prev;
7217
7218 if (handle == NULL) /* check handle */
7219 {
7220 return 2; /* return error */
7221 }
7222 if (handle->inited != 1) /* check handle initialization */
7223 {
7224 return 3; /* return error */
7225 }
7226
7227 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL1, &prev); /* read ctrl1 */
7228 if (res != 0) /* check result */
7229 {
7230 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7231
7232 return 1; /* return error */
7233 }
7234 prev &= ~(1 << 7); /* clear settings */
7235 prev |= enable << 7; /* set bool */
7236 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL1, prev); /* write ctrl1 */
7237 if (res != 0) /* check result */
7238 {
7239 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
7240
7241 return 1; /* return error */
7242 }
7243
7244 return 0; /* success return 0 */
7245}
7246
7259{
7260 uint8_t res;
7261 uint8_t prev;
7262
7263 if (handle == NULL) /* check handle */
7264 {
7265 return 2; /* return error */
7266 }
7267 if (handle->inited != 1) /* check handle initialization */
7268 {
7269 return 3; /* return error */
7270 }
7271
7272 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL1, &prev); /* read ctrl1 */
7273 if (res != 0) /* check result */
7274 {
7275 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7276
7277 return 1; /* return error */
7278 }
7279 *enable = (ov2640_bool_t)((prev >> 7) & 0x01); /* get bool */
7280
7281 return 0; /* success return 0 */
7282}
7283
7296{
7297 uint8_t res;
7298 uint8_t prev;
7299
7300 if (handle == NULL) /* check handle */
7301 {
7302 return 2; /* return error */
7303 }
7304 if (handle->inited != 1) /* check handle initialization */
7305 {
7306 return 3; /* return error */
7307 }
7308
7309 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL1, &prev); /* read ctrl1 */
7310 if (res != 0) /* check result */
7311 {
7312 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7313
7314 return 1; /* return error */
7315 }
7316 prev &= ~(1 << 6); /* clear settings */
7317 prev |= enable << 6; /* set bool */
7318 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL1, prev); /* write ctrl1 */
7319 if (res != 0) /* check result */
7320 {
7321 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
7322
7323 return 1; /* return error */
7324 }
7325
7326 return 0; /* success return 0 */
7327}
7328
7341{
7342 uint8_t res;
7343 uint8_t prev;
7344
7345 if (handle == NULL) /* check handle */
7346 {
7347 return 2; /* return error */
7348 }
7349 if (handle->inited != 1) /* check handle initialization */
7350 {
7351 return 3; /* return error */
7352 }
7353
7354 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL1, &prev); /* read ctrl1 */
7355 if (res != 0) /* check result */
7356 {
7357 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7358
7359 return 1; /* return error */
7360 }
7361 *enable = (ov2640_bool_t)((prev >> 6) & 0x01); /* get bool */
7362
7363 return 0; /* success return 0 */
7364}
7365
7378{
7379 uint8_t res;
7380 uint8_t prev;
7381
7382 if (handle == NULL) /* check handle */
7383 {
7384 return 2; /* return error */
7385 }
7386 if (handle->inited != 1) /* check handle initialization */
7387 {
7388 return 3; /* return error */
7389 }
7390
7391 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL1, &prev); /* read ctrl1 */
7392 if (res != 0) /* check result */
7393 {
7394 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7395
7396 return 1; /* return error */
7397 }
7398 prev &= ~(1 << 5); /* clear settings */
7399 prev |= enable << 5; /* set bool */
7400 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL1, prev); /* write ctrl1 */
7401 if (res != 0) /* check result */
7402 {
7403 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
7404
7405 return 1; /* return error */
7406 }
7407
7408 return 0; /* success return 0 */
7409}
7410
7423{
7424 uint8_t res;
7425 uint8_t prev;
7426
7427 if (handle == NULL) /* check handle */
7428 {
7429 return 2; /* return error */
7430 }
7431 if (handle->inited != 1) /* check handle initialization */
7432 {
7433 return 3; /* return error */
7434 }
7435
7436 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL1, &prev); /* read ctrl1 */
7437 if (res != 0) /* check result */
7438 {
7439 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7440
7441 return 1; /* return error */
7442 }
7443 *enable = (ov2640_bool_t)((prev >> 5) & 0x01); /* get bool */
7444
7445 return 0; /* success return 0 */
7446}
7447
7460{
7461 uint8_t res;
7462 uint8_t prev;
7463
7464 if (handle == NULL) /* check handle */
7465 {
7466 return 2; /* return error */
7467 }
7468 if (handle->inited != 1) /* check handle initialization */
7469 {
7470 return 3; /* return error */
7471 }
7472
7473 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL1, &prev); /* read ctrl1 */
7474 if (res != 0) /* check result */
7475 {
7476 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7477
7478 return 1; /* return error */
7479 }
7480 prev &= ~(1 << 4); /* clear settings */
7481 prev |= enable << 4; /* set bool */
7482 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL1, prev); /* write ctrl1 */
7483 if (res != 0) /* check result */
7484 {
7485 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
7486
7487 return 1; /* return error */
7488 }
7489
7490 return 0; /* success return 0 */
7491}
7492
7505{
7506 uint8_t res;
7507 uint8_t prev;
7508
7509 if (handle == NULL) /* check handle */
7510 {
7511 return 2; /* return error */
7512 }
7513 if (handle->inited != 1) /* check handle initialization */
7514 {
7515 return 3; /* return error */
7516 }
7517
7518 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL1, &prev); /* read ctrl1 */
7519 if (res != 0) /* check result */
7520 {
7521 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7522
7523 return 1; /* return error */
7524 }
7525 *enable = (ov2640_bool_t)((prev >> 4) & 0x01); /* get bool */
7526
7527 return 0; /* success return 0 */
7528}
7529
7542{
7543 uint8_t res;
7544 uint8_t prev;
7545
7546 if (handle == NULL) /* check handle */
7547 {
7548 return 2; /* return error */
7549 }
7550 if (handle->inited != 1) /* check handle initialization */
7551 {
7552 return 3; /* return error */
7553 }
7554
7555 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL1, &prev); /* read ctrl1 */
7556 if (res != 0) /* check result */
7557 {
7558 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7559
7560 return 1; /* return error */
7561 }
7562 prev &= ~(1 << 3); /* clear settings */
7563 prev |= enable << 3; /* set bool */
7564 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL1, prev); /* write ctrl1 */
7565 if (res != 0) /* check result */
7566 {
7567 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
7568
7569 return 1; /* return error */
7570 }
7571
7572 return 0; /* success return 0 */
7573}
7574
7587{
7588 uint8_t res;
7589 uint8_t prev;
7590
7591 if (handle == NULL) /* check handle */
7592 {
7593 return 2; /* return error */
7594 }
7595 if (handle->inited != 1) /* check handle initialization */
7596 {
7597 return 3; /* return error */
7598 }
7599
7600 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL1, &prev); /* read ctrl1 */
7601 if (res != 0) /* check result */
7602 {
7603 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7604
7605 return 1; /* return error */
7606 }
7607 *enable = (ov2640_bool_t)((prev >> 3) & 0x01); /* get bool */
7608
7609 return 0; /* success return 0 */
7610}
7611
7624{
7625 uint8_t res;
7626 uint8_t prev;
7627
7628 if (handle == NULL) /* check handle */
7629 {
7630 return 2; /* return error */
7631 }
7632 if (handle->inited != 1) /* check handle initialization */
7633 {
7634 return 3; /* return error */
7635 }
7636
7637 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL1, &prev); /* read ctrl1 */
7638 if (res != 0) /* check result */
7639 {
7640 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7641
7642 return 1; /* return error */
7643 }
7644 prev &= ~(1 << 2); /* clear settings */
7645 prev |= enable << 2; /* set bool */
7646 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL1, prev); /* write ctrl1 */
7647 if (res != 0) /* check result */
7648 {
7649 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
7650
7651 return 1; /* return error */
7652 }
7653
7654 return 0; /* success return 0 */
7655}
7656
7669{
7670 uint8_t res;
7671 uint8_t prev;
7672
7673 if (handle == NULL) /* check handle */
7674 {
7675 return 2; /* return error */
7676 }
7677 if (handle->inited != 1) /* check handle initialization */
7678 {
7679 return 3; /* return error */
7680 }
7681
7682 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL1, &prev); /* read ctrl1 */
7683 if (res != 0) /* check result */
7684 {
7685 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7686
7687 return 1; /* return error */
7688 }
7689 *enable = (ov2640_bool_t)((prev >> 2) & 0x01); /* get bool */
7690
7691 return 0; /* success return 0 */
7692}
7693
7706{
7707 uint8_t res;
7708 uint8_t prev;
7709
7710 if (handle == NULL) /* check handle */
7711 {
7712 return 2; /* return error */
7713 }
7714 if (handle->inited != 1) /* check handle initialization */
7715 {
7716 return 3; /* return error */
7717 }
7718
7719 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL1, &prev); /* read ctrl1 */
7720 if (res != 0) /* check result */
7721 {
7722 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7723
7724 return 1; /* return error */
7725 }
7726 prev &= ~(1 << 1); /* clear settings */
7727 prev |= enable << 1; /* set bool */
7728 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL1, prev); /* write ctrl1 */
7729 if (res != 0) /* check result */
7730 {
7731 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
7732
7733 return 1; /* return error */
7734 }
7735
7736 return 0; /* success return 0 */
7737}
7738
7751{
7752 uint8_t res;
7753 uint8_t prev;
7754
7755 if (handle == NULL) /* check handle */
7756 {
7757 return 2; /* return error */
7758 }
7759 if (handle->inited != 1) /* check handle initialization */
7760 {
7761 return 3; /* return error */
7762 }
7763
7764 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL1, &prev); /* read ctrl1 */
7765 if (res != 0) /* check result */
7766 {
7767 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7768
7769 return 1; /* return error */
7770 }
7771 *enable = (ov2640_bool_t)((prev >> 1) & 0x01); /* get bool */
7772
7773 return 0; /* success return 0 */
7774}
7775
7788{
7789 uint8_t res;
7790 uint8_t prev;
7791
7792 if (handle == NULL) /* check handle */
7793 {
7794 return 2; /* return error */
7795 }
7796 if (handle->inited != 1) /* check handle initialization */
7797 {
7798 return 3; /* return error */
7799 }
7800
7801 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL1, &prev); /* read ctrl1 */
7802 if (res != 0) /* check result */
7803 {
7804 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7805
7806 return 1; /* return error */
7807 }
7808 prev &= ~(1 << 0); /* clear settings */
7809 prev |= enable << 0; /* set bool */
7810 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL1, prev); /* write ctrl1 */
7811 if (res != 0) /* check result */
7812 {
7813 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
7814
7815 return 1; /* return error */
7816 }
7817
7818 return 0; /* success return 0 */
7819}
7820
7833{
7834 uint8_t res;
7835 uint8_t prev;
7836
7837 if (handle == NULL) /* check handle */
7838 {
7839 return 2; /* return error */
7840 }
7841 if (handle->inited != 1) /* check handle initialization */
7842 {
7843 return 3; /* return error */
7844 }
7845
7846 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL1, &prev); /* read ctrl1 */
7847 if (res != 0) /* check result */
7848 {
7849 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7850
7851 return 1; /* return error */
7852 }
7853 *enable = (ov2640_bool_t)((prev >> 0) & 0x01); /* get bool */
7854
7855 return 0; /* success return 0 */
7856}
7857
7870{
7871 uint8_t res;
7872 uint8_t prev;
7873
7874 if (handle == NULL) /* check handle */
7875 {
7876 return 2; /* return error */
7877 }
7878 if (handle->inited != 1) /* check handle initialization */
7879 {
7880 return 3; /* return error */
7881 }
7882
7883 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL0, &prev); /* read ctrl0 */
7884 if (res != 0) /* check result */
7885 {
7886 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7887
7888 return 1; /* return error */
7889 }
7890 prev &= ~(1 << 7); /* clear settings */
7891 prev |= enable << 7; /* set bool */
7892 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL0, prev); /* write ctrl0 */
7893 if (res != 0) /* check result */
7894 {
7895 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
7896
7897 return 1; /* return error */
7898 }
7899
7900 return 0; /* success return 0 */
7901}
7902
7915{
7916 uint8_t res;
7917 uint8_t prev;
7918
7919 if (handle == NULL) /* check handle */
7920 {
7921 return 2; /* return error */
7922 }
7923 if (handle->inited != 1) /* check handle initialization */
7924 {
7925 return 3; /* return error */
7926 }
7927
7928 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL0, &prev); /* read ctrl0 */
7929 if (res != 0) /* check result */
7930 {
7931 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7932
7933 return 1; /* return error */
7934 }
7935 *enable = (ov2640_bool_t)((prev >> 7) & 0x01); /* get bool */
7936
7937 return 0; /* success return 0 */
7938}
7939
7952{
7953 uint8_t res;
7954 uint8_t prev;
7955
7956 if (handle == NULL) /* check handle */
7957 {
7958 return 2; /* return error */
7959 }
7960 if (handle->inited != 1) /* check handle initialization */
7961 {
7962 return 3; /* return error */
7963 }
7964
7965 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL0, &prev); /* read ctrl0 */
7966 if (res != 0) /* check result */
7967 {
7968 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
7969
7970 return 1; /* return error */
7971 }
7972 prev &= ~(1 << 6); /* clear settings */
7973 prev |= enable << 6; /* set bool */
7974 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL0, prev); /* write ctrl0 */
7975 if (res != 0) /* check result */
7976 {
7977 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
7978
7979 return 1; /* return error */
7980 }
7981
7982 return 0; /* success return 0 */
7983}
7984
7997{
7998 uint8_t res;
7999 uint8_t prev;
8000
8001 if (handle == NULL) /* check handle */
8002 {
8003 return 2; /* return error */
8004 }
8005 if (handle->inited != 1) /* check handle initialization */
8006 {
8007 return 3; /* return error */
8008 }
8009
8010 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL0, &prev); /* read ctrl0 */
8011 if (res != 0) /* check result */
8012 {
8013 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8014
8015 return 1; /* return error */
8016 }
8017 *enable = (ov2640_bool_t)((prev >> 6) & 0x01); /* get bool */
8018
8019 return 0; /* success return 0 */
8020}
8021
8034{
8035 uint8_t res;
8036 uint8_t prev;
8037
8038 if (handle == NULL) /* check handle */
8039 {
8040 return 2; /* return error */
8041 }
8042 if (handle->inited != 1) /* check handle initialization */
8043 {
8044 return 3; /* return error */
8045 }
8046
8047 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL0, &prev); /* read ctrl0 */
8048 if (res != 0) /* check result */
8049 {
8050 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8051
8052 return 1; /* return error */
8053 }
8054 prev &= ~(1 << 5); /* clear settings */
8055 prev |= enable << 5; /* set bool */
8056 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL0, prev); /* write ctrl0 */
8057 if (res != 0) /* check result */
8058 {
8059 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
8060
8061 return 1; /* return error */
8062 }
8063
8064 return 0; /* success return 0 */
8065}
8066
8079{
8080 uint8_t res;
8081 uint8_t prev;
8082
8083 if (handle == NULL) /* check handle */
8084 {
8085 return 2; /* return error */
8086 }
8087 if (handle->inited != 1) /* check handle initialization */
8088 {
8089 return 3; /* return error */
8090 }
8091
8092 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL0, &prev); /* read ctrl0 */
8093 if (res != 0) /* check result */
8094 {
8095 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8096
8097 return 1; /* return error */
8098 }
8099 *enable = (ov2640_bool_t)((prev >> 5) & 0x01); /* get bool */
8100
8101 return 0; /* success return 0 */
8102}
8103
8116{
8117 uint8_t res;
8118 uint8_t prev;
8119
8120 if (handle == NULL) /* check handle */
8121 {
8122 return 2; /* return error */
8123 }
8124 if (handle->inited != 1) /* check handle initialization */
8125 {
8126 return 3; /* return error */
8127 }
8128
8129 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL0, &prev); /* read ctrl0 */
8130 if (res != 0) /* check result */
8131 {
8132 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8133
8134 return 1; /* return error */
8135 }
8136 prev &= ~(1 << 4); /* clear settings */
8137 prev |= enable << 4; /* set bool */
8138 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL0, prev); /* write ctrl0 */
8139 if (res != 0) /* check result */
8140 {
8141 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
8142
8143 return 1; /* return error */
8144 }
8145
8146 return 0; /* success return 0 */
8147}
8148
8161{
8162 uint8_t res;
8163 uint8_t prev;
8164
8165 if (handle == NULL) /* check handle */
8166 {
8167 return 2; /* return error */
8168 }
8169 if (handle->inited != 1) /* check handle initialization */
8170 {
8171 return 3; /* return error */
8172 }
8173
8174 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL0, &prev); /* read ctrl0 */
8175 if (res != 0) /* check result */
8176 {
8177 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8178
8179 return 1; /* return error */
8180 }
8181 *enable = (ov2640_bool_t)((prev >> 4) & 0x01); /* get bool */
8182
8183 return 0; /* success return 0 */
8184}
8185
8198{
8199 uint8_t res;
8200 uint8_t prev;
8201
8202 if (handle == NULL) /* check handle */
8203 {
8204 return 2; /* return error */
8205 }
8206 if (handle->inited != 1) /* check handle initialization */
8207 {
8208 return 3; /* return error */
8209 }
8210
8211 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL0, &prev); /* read ctrl0 */
8212 if (res != 0) /* check result */
8213 {
8214 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8215
8216 return 1; /* return error */
8217 }
8218 prev &= ~(1 << 3); /* clear settings */
8219 prev |= enable << 3; /* set bool */
8220 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL0, prev); /* write ctrl0 */
8221 if (res != 0) /* check result */
8222 {
8223 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
8224
8225 return 1; /* return error */
8226 }
8227
8228 return 0; /* success return 0 */
8229}
8230
8243{
8244 uint8_t res;
8245 uint8_t prev;
8246
8247 if (handle == NULL) /* check handle */
8248 {
8249 return 2; /* return error */
8250 }
8251 if (handle->inited != 1) /* check handle initialization */
8252 {
8253 return 3; /* return error */
8254 }
8255
8256 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL0, &prev); /* read ctrl0 */
8257 if (res != 0) /* check result */
8258 {
8259 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8260
8261 return 1; /* return error */
8262 }
8263 *enable = (ov2640_bool_t)((prev >> 3) & 0x01); /* get bool */
8264
8265 return 0; /* success return 0 */
8266}
8267
8280{
8281 uint8_t res;
8282 uint8_t prev;
8283
8284 if (handle == NULL) /* check handle */
8285 {
8286 return 2; /* return error */
8287 }
8288 if (handle->inited != 1) /* check handle initialization */
8289 {
8290 return 3; /* return error */
8291 }
8292
8293 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL0, &prev); /* read ctrl0 */
8294 if (res != 0) /* check result */
8295 {
8296 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8297
8298 return 1; /* return error */
8299 }
8300 prev &= ~(1 << 2); /* clear settings */
8301 prev |= enable << 2; /* set bool */
8302 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL0, prev); /* write ctrl0 */
8303 if (res != 0) /* check result */
8304 {
8305 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
8306
8307 return 1; /* return error */
8308 }
8309
8310 return 0; /* success return 0 */
8311}
8312
8325{
8326 uint8_t res;
8327 uint8_t prev;
8328
8329 if (handle == NULL) /* check handle */
8330 {
8331 return 2; /* return error */
8332 }
8333 if (handle->inited != 1) /* check handle initialization */
8334 {
8335 return 3; /* return error */
8336 }
8337
8338 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL0, &prev); /* read ctrl0 */
8339 if (res != 0) /* check result */
8340 {
8341 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8342
8343 return 1; /* return error */
8344 }
8345 *enable = (ov2640_bool_t)((prev >> 2) & 0x01); /* get bool */
8346
8347 return 0; /* success return 0 */
8348}
8349
8362{
8363 uint8_t res;
8364 uint8_t prev;
8365
8366 if (handle == NULL) /* check handle */
8367 {
8368 return 2; /* return error */
8369 }
8370 if (handle->inited != 1) /* check handle initialization */
8371 {
8372 return 3; /* return error */
8373 }
8374
8375 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL0, &prev); /* read ctrl0 */
8376 if (res != 0) /* check result */
8377 {
8378 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8379
8380 return 1; /* return error */
8381 }
8382 prev &= ~(1 << 1); /* clear settings */
8383 prev |= enable << 1; /* set bool */
8384 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL0, prev); /* write ctrl0 */
8385 if (res != 0) /* check result */
8386 {
8387 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
8388
8389 return 1; /* return error */
8390 }
8391
8392 return 0; /* success return 0 */
8393}
8394
8407{
8408 uint8_t res;
8409 uint8_t prev;
8410
8411 if (handle == NULL) /* check handle */
8412 {
8413 return 2; /* return error */
8414 }
8415 if (handle->inited != 1) /* check handle initialization */
8416 {
8417 return 3; /* return error */
8418 }
8419
8420 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL0, &prev); /* read ctrl0 */
8421 if (res != 0) /* check result */
8422 {
8423 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8424
8425 return 1; /* return error */
8426 }
8427 *enable = (ov2640_bool_t)((prev >> 1) & 0x01); /* get bool */
8428
8429 return 0; /* success return 0 */
8430}
8431
8444{
8445 uint8_t res;
8446 uint8_t prev;
8447
8448 if (handle == NULL) /* check handle */
8449 {
8450 return 2; /* return error */
8451 }
8452 if (handle->inited != 1) /* check handle initialization */
8453 {
8454 return 3; /* return error */
8455 }
8456
8457 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL0, &prev); /* read ctrl0 */
8458 if (res != 0) /* check result */
8459 {
8460 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8461
8462 return 1; /* return error */
8463 }
8464 prev &= ~(1 << 0); /* clear settings */
8465 prev |= enable << 0; /* set bool */
8466 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL0, prev); /* write ctrl0 */
8467 if (res != 0) /* check result */
8468 {
8469 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
8470
8471 return 1; /* return error */
8472 }
8473
8474 return 0; /* success return 0 */
8475}
8476
8489{
8490 uint8_t res;
8491 uint8_t prev;
8492
8493 if (handle == NULL) /* check handle */
8494 {
8495 return 2; /* return error */
8496 }
8497 if (handle->inited != 1) /* check handle initialization */
8498 {
8499 return 3; /* return error */
8500 }
8501
8502 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL0, &prev); /* read ctrl0 */
8503 if (res != 0) /* check result */
8504 {
8505 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8506
8507 return 1; /* return error */
8508 }
8509 *enable = (ov2640_bool_t)((prev >> 0) & 0x01); /* get bool */
8510
8511 return 0; /* success return 0 */
8512}
8513
8526{
8527 uint8_t res;
8528 uint8_t prev;
8529
8530 if (handle == NULL) /* check handle */
8531 {
8532 return 2; /* return error */
8533 }
8534 if (handle->inited != 1) /* check handle initialization */
8535 {
8536 return 3; /* return error */
8537 }
8538
8539 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL2, &prev); /* read ctrl2 */
8540 if (res != 0) /* check result */
8541 {
8542 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8543
8544 return 1; /* return error */
8545 }
8546 prev &= ~(1 << 5); /* clear settings */
8547 prev |= enable << 5; /* set bool */
8548 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL2, prev); /* write ctrl2 */
8549 if (res != 0) /* check result */
8550 {
8551 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
8552
8553 return 1; /* return error */
8554 }
8555
8556 return 0; /* success return 0 */
8557}
8558
8571{
8572 uint8_t res;
8573 uint8_t prev;
8574
8575 if (handle == NULL) /* check handle */
8576 {
8577 return 2; /* return error */
8578 }
8579 if (handle->inited != 1) /* check handle initialization */
8580 {
8581 return 3; /* return error */
8582 }
8583
8584 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL2, &prev); /* read ctrl2 */
8585 if (res != 0) /* check result */
8586 {
8587 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8588
8589 return 1; /* return error */
8590 }
8591 *enable = (ov2640_bool_t)((prev >> 5) & 0x01); /* get bool */
8592
8593 return 0; /* success return 0 */
8594}
8595
8608{
8609 uint8_t res;
8610 uint8_t prev;
8611
8612 if (handle == NULL) /* check handle */
8613 {
8614 return 2; /* return error */
8615 }
8616 if (handle->inited != 1) /* check handle initialization */
8617 {
8618 return 3; /* return error */
8619 }
8620
8621 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL2, &prev); /* read ctrl2 */
8622 if (res != 0) /* check result */
8623 {
8624 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8625
8626 return 1; /* return error */
8627 }
8628 prev &= ~(1 << 4); /* clear settings */
8629 prev |= enable << 4; /* set bool */
8630 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL2, prev); /* write ctrl2 */
8631 if (res != 0) /* check result */
8632 {
8633 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
8634
8635 return 1; /* return error */
8636 }
8637
8638 return 0; /* success return 0 */
8639}
8640
8653{
8654 uint8_t res;
8655 uint8_t prev;
8656
8657 if (handle == NULL) /* check handle */
8658 {
8659 return 2; /* return error */
8660 }
8661 if (handle->inited != 1) /* check handle initialization */
8662 {
8663 return 3; /* return error */
8664 }
8665
8666 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL2, &prev); /* read ctrl2 */
8667 if (res != 0) /* check result */
8668 {
8669 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8670
8671 return 1; /* return error */
8672 }
8673 *enable = (ov2640_bool_t)((prev >> 4) & 0x01); /* get bool */
8674
8675 return 0; /* success return 0 */
8676}
8677
8690{
8691 uint8_t res;
8692 uint8_t prev;
8693
8694 if (handle == NULL) /* check handle */
8695 {
8696 return 2; /* return error */
8697 }
8698 if (handle->inited != 1) /* check handle initialization */
8699 {
8700 return 3; /* return error */
8701 }
8702
8703 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL2, &prev); /* read ctrl2 */
8704 if (res != 0) /* check result */
8705 {
8706 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8707
8708 return 1; /* return error */
8709 }
8710 prev &= ~(1 << 3); /* clear settings */
8711 prev |= enable << 3; /* set bool */
8712 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL2, prev); /* write ctrl2 */
8713 if (res != 0) /* check result */
8714 {
8715 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
8716
8717 return 1; /* return error */
8718 }
8719
8720 return 0; /* success return 0 */
8721}
8722
8735{
8736 uint8_t res;
8737 uint8_t prev;
8738
8739 if (handle == NULL) /* check handle */
8740 {
8741 return 2; /* return error */
8742 }
8743 if (handle->inited != 1) /* check handle initialization */
8744 {
8745 return 3; /* return error */
8746 }
8747
8748 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL2, &prev); /* read ctrl2 */
8749 if (res != 0) /* check result */
8750 {
8751 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8752
8753 return 1; /* return error */
8754 }
8755 *enable = (ov2640_bool_t)((prev >> 3) & 0x01); /* get bool */
8756
8757 return 0; /* success return 0 */
8758}
8759
8772{
8773 uint8_t res;
8774 uint8_t prev;
8775
8776 if (handle == NULL) /* check handle */
8777 {
8778 return 2; /* return error */
8779 }
8780 if (handle->inited != 1) /* check handle initialization */
8781 {
8782 return 3; /* return error */
8783 }
8784
8785 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL2, &prev); /* read ctrl2 */
8786 if (res != 0) /* check result */
8787 {
8788 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8789
8790 return 1; /* return error */
8791 }
8792 prev &= ~(1 << 2); /* clear settings */
8793 prev |= enable << 2; /* set bool */
8794 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL2, prev); /* write ctrl2 */
8795 if (res != 0) /* check result */
8796 {
8797 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
8798
8799 return 1; /* return error */
8800 }
8801
8802 return 0; /* success return 0 */
8803}
8804
8817{
8818 uint8_t res;
8819 uint8_t prev;
8820
8821 if (handle == NULL) /* check handle */
8822 {
8823 return 2; /* return error */
8824 }
8825 if (handle->inited != 1) /* check handle initialization */
8826 {
8827 return 3; /* return error */
8828 }
8829
8830 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL2, &prev); /* read ctrl2 */
8831 if (res != 0) /* check result */
8832 {
8833 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8834
8835 return 1; /* return error */
8836 }
8837 *enable = (ov2640_bool_t)((prev >> 2) & 0x01); /* get bool */
8838
8839 return 0; /* success return 0 */
8840}
8841
8854{
8855 uint8_t res;
8856 uint8_t prev;
8857
8858 if (handle == NULL) /* check handle */
8859 {
8860 return 2; /* return error */
8861 }
8862 if (handle->inited != 1) /* check handle initialization */
8863 {
8864 return 3; /* return error */
8865 }
8866
8867 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL2, &prev); /* read ctrl2 */
8868 if (res != 0) /* check result */
8869 {
8870 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8871
8872 return 1; /* return error */
8873 }
8874 prev &= ~(1 << 0); /* clear settings */
8875 prev |= enable << 0; /* set bool */
8876 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL2, prev); /* write ctrl2 */
8877 if (res != 0) /* check result */
8878 {
8879 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
8880
8881 return 1; /* return error */
8882 }
8883
8884 return 0; /* success return 0 */
8885}
8886
8899{
8900 uint8_t res;
8901 uint8_t prev;
8902
8903 if (handle == NULL) /* check handle */
8904 {
8905 return 2; /* return error */
8906 }
8907 if (handle->inited != 1) /* check handle initialization */
8908 {
8909 return 3; /* return error */
8910 }
8911
8912 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL2, &prev); /* read ctrl2 */
8913 if (res != 0) /* check result */
8914 {
8915 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8916
8917 return 1; /* return error */
8918 }
8919 *enable = (ov2640_bool_t)((prev >> 0) & 0x01); /* get bool */
8920
8921 return 0; /* success return 0 */
8922}
8923
8936{
8937 uint8_t res;
8938 uint8_t prev;
8939
8940 if (handle == NULL) /* check handle */
8941 {
8942 return 2; /* return error */
8943 }
8944 if (handle->inited != 1) /* check handle initialization */
8945 {
8946 return 3; /* return error */
8947 }
8948
8949 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL3, &prev); /* read ctrl3 */
8950 if (res != 0) /* check result */
8951 {
8952 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8953
8954 return 1; /* return error */
8955 }
8956 prev &= ~(1 << 7); /* clear settings */
8957 prev |= enable << 7; /* set bool */
8958 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL3, prev); /* write ctrl3 */
8959 if (res != 0) /* check result */
8960 {
8961 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
8962
8963 return 1; /* return error */
8964 }
8965
8966 return 0; /* success return 0 */
8967}
8968
8981{
8982 uint8_t res;
8983 uint8_t prev;
8984
8985 if (handle == NULL) /* check handle */
8986 {
8987 return 2; /* return error */
8988 }
8989 if (handle->inited != 1) /* check handle initialization */
8990 {
8991 return 3; /* return error */
8992 }
8993
8994 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL3, &prev); /* read ctrl3 */
8995 if (res != 0) /* check result */
8996 {
8997 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
8998
8999 return 1; /* return error */
9000 }
9001 *enable = (ov2640_bool_t)((prev >> 7) & 0x01); /* get bool */
9002
9003 return 0; /* success return 0 */
9004}
9005
9018{
9019 uint8_t res;
9020 uint8_t prev;
9021
9022 if (handle == NULL) /* check handle */
9023 {
9024 return 2; /* return error */
9025 }
9026 if (handle->inited != 1) /* check handle initialization */
9027 {
9028 return 3; /* return error */
9029 }
9030
9031 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL3, &prev); /* read ctrl3 */
9032 if (res != 0) /* check result */
9033 {
9034 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9035
9036 return 1; /* return error */
9037 }
9038 prev &= ~(1 << 6); /* clear settings */
9039 prev |= enable << 6; /* set bool */
9040 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRL3, prev); /* write ctrl3 */
9041 if (res != 0) /* check result */
9042 {
9043 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
9044
9045 return 1; /* return error */
9046 }
9047
9048 return 0; /* success return 0 */
9049}
9050
9063{
9064 uint8_t res;
9065 uint8_t prev;
9066
9067 if (handle == NULL) /* check handle */
9068 {
9069 return 2; /* return error */
9070 }
9071 if (handle->inited != 1) /* check handle initialization */
9072 {
9073 return 3; /* return error */
9074 }
9075
9076 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRL3, &prev); /* read ctrl3 */
9077 if (res != 0) /* check result */
9078 {
9079 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9080
9081 return 1; /* return error */
9082 }
9083 *enable = (ov2640_bool_t)((prev >> 6) & 0x01); /* get bool */
9084
9085 return 0; /* success return 0 */
9086}
9087
9100{
9101 uint8_t res;
9102 uint8_t prev;
9103
9104 if (handle == NULL) /* check handle */
9105 {
9106 return 2; /* return error */
9107 }
9108 if (handle->inited != 1) /* check handle initialization */
9109 {
9110 return 3; /* return error */
9111 }
9112
9113 prev = addr; /* set address */
9114 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_BPADDR, prev); /* write bpaddr */
9115 if (res != 0) /* check result */
9116 {
9117 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
9118
9119 return 1; /* return error */
9120 }
9121
9122 return 0; /* success return 0 */
9123}
9124
9137{
9138 uint8_t res;
9139 uint8_t prev;
9140
9141 if (handle == NULL) /* check handle */
9142 {
9143 return 2; /* return error */
9144 }
9145 if (handle->inited != 1) /* check handle initialization */
9146 {
9147 return 3; /* return error */
9148 }
9149
9150 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_BPADDR, &prev); /* read bpaddr */
9151 if (res != 0) /* check result */
9152 {
9153 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9154
9155 return 1; /* return error */
9156 }
9157 *addr = prev; /* get address */
9158
9159 return 0; /* success return 0 */
9160}
9161
9174{
9175 uint8_t res;
9176 uint8_t prev;
9177
9178 if (handle == NULL) /* check handle */
9179 {
9180 return 2; /* return error */
9181 }
9182 if (handle->inited != 1) /* check handle initialization */
9183 {
9184 return 3; /* return error */
9185 }
9186
9187 prev = data; /* set data */
9188 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_BPDATA, prev); /* write bpdata */
9189 if (res != 0) /* check result */
9190 {
9191 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
9192
9193 return 1; /* return error */
9194 }
9195
9196 return 0; /* success return 0 */
9197}
9198
9211{
9212 uint8_t res;
9213 uint8_t prev;
9214
9215 if (handle == NULL) /* check handle */
9216 {
9217 return 2; /* return error */
9218 }
9219 if (handle->inited != 1) /* check handle initialization */
9220 {
9221 return 3; /* return error */
9222 }
9223
9224 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_BPDATA, &prev); /* read bpdata */
9225 if (res != 0) /* check result */
9226 {
9227 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9228
9229 return 1; /* return error */
9230 }
9231 *data = prev; /* get data */
9232
9233 return 0; /* success return 0 */
9234}
9235
9248uint8_t ov2640_set_image_horizontal(ov2640_handle_t *handle, uint16_t size)
9249{
9250 uint8_t res;
9251 uint8_t prev;
9252
9253 if (handle == NULL) /* check handle */
9254 {
9255 return 2; /* return error */
9256 }
9257 if (handle->inited != 1) /* check handle initialization */
9258 {
9259 return 3; /* return error */
9260 }
9261 if (size > 0xFFF) /* check size */
9262 {
9263 handle->debug_print("ov2640: size > 0xFFF.\n"); /* size > 0xFFF */
9264
9265 return 4; /* return error */
9266 }
9267
9268 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_SIZEL, &prev); /* read sizel */
9269 if (res != 0) /* check result */
9270 {
9271 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9272
9273 return 1; /* return error */
9274 }
9275 prev &= ~(1 << 6); /* clear hsize bit11 */
9276 prev &= ~(7 << 3); /* clear hsize bit2-0 */
9277 prev |= ((size >> 11) & 0x01) << 6; /* set bit11 */
9278 prev |= ((size >> 0) & 0x07) << 3; /* set bit2-0 */
9279 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_SIZEL, prev); /* write sizel */
9280 if (res != 0) /* check result */
9281 {
9282 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
9283
9284 return 1; /* return error */
9285 }
9286 prev = (size >> 3) & 0xFF; /* set data */
9287 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_HSIZE8, prev); /* write hsize8 */
9288 if (res != 0) /* check result */
9289 {
9290 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
9291
9292 return 1; /* return error */
9293 }
9294
9295 return 0; /* success return 0 */
9296}
9297
9309uint8_t ov2640_get_image_horizontal(ov2640_handle_t *handle, uint16_t *size)
9310{
9311 uint8_t res;
9312 uint8_t prev;
9313
9314 if (handle == NULL) /* check handle */
9315 {
9316 return 2; /* return error */
9317 }
9318 if (handle->inited != 1) /* check handle initialization */
9319 {
9320 return 3; /* return error */
9321 }
9322
9323 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_SIZEL, &prev); /* read sizel */
9324 if (res != 0) /* check result */
9325 {
9326 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9327
9328 return 1; /* return error */
9329 }
9330 *size = (uint16_t)((prev >> 6) & 0x01) << 11; /* set bit11 */
9331 *size |= ((prev >> 3) & 0x07) << 0; /* set bit0-2 */
9332 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_HSIZE8, &prev); /* read hsize8 */
9333 if (res != 0) /* check result */
9334 {
9335 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9336
9337 return 1; /* return error */
9338 }
9339 *size |= prev << 3; /* set bit3-10 */
9340
9341 return 0; /* success return 0 */
9342}
9343
9356uint8_t ov2640_set_image_vertical(ov2640_handle_t *handle, uint16_t size)
9357{
9358 uint8_t res;
9359 uint8_t prev;
9360
9361 if (handle == NULL) /* check handle */
9362 {
9363 return 2; /* return error */
9364 }
9365 if (handle->inited != 1) /* check handle initialization */
9366 {
9367 return 3; /* return error */
9368 }
9369 if (size > 0x7FF) /* check size */
9370 {
9371 handle->debug_print("ov2640: size > 0x7FF.\n"); /* size > 0x7FF */
9372
9373 return 4; /* return error */
9374 }
9375
9376 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_SIZEL, &prev); /* read sizel */
9377 if (res != 0) /* check result */
9378 {
9379 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9380
9381 return 1; /* return error */
9382 }
9383 prev &= ~(7 << 0); /* clear hsize bit2-0 */
9384 prev |= ((size >> 0) & 0x07) << 0; /* set bit2-0 */
9385 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_SIZEL, prev); /* write sizel */
9386 if (res != 0) /* check result */
9387 {
9388 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
9389
9390 return 1; /* return error */
9391 }
9392 prev = (size >> 3) & 0xFF; /* set data */
9393 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_VSIZE8, prev); /* write vsize8 */
9394 if (res != 0) /* check result */
9395 {
9396 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
9397
9398 return 1; /* return error */
9399 }
9400
9401 return 0; /* success return 0 */
9402}
9403
9415uint8_t ov2640_get_image_vertical(ov2640_handle_t *handle, uint16_t *size)
9416{
9417 uint8_t res;
9418 uint8_t prev;
9419
9420 if (handle == NULL) /* check handle */
9421 {
9422 return 2; /* return error */
9423 }
9424 if (handle->inited != 1) /* check handle initialization */
9425 {
9426 return 3; /* return error */
9427 }
9428
9429 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_SIZEL, &prev); /* read sizel */
9430 if (res != 0) /* check result */
9431 {
9432 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9433
9434 return 1; /* return error */
9435 }
9436 *size = ((prev >> 0) & 0x07) << 0; /* set bit0-2 */
9437 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_VSIZE8, &prev); /* read vsize8 */
9438 if (res != 0) /* check result */
9439 {
9440 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9441
9442 return 1; /* return error */
9443 }
9444 *size |= prev << 3; /* set bit3-10 */
9445
9446 return 0; /* success return 0 */
9447}
9448
9461{
9462 uint8_t res;
9463 uint8_t prev;
9464
9465 if (handle == NULL) /* check handle */
9466 {
9467 return 2; /* return error */
9468 }
9469 if (handle->inited != 1) /* check handle initialization */
9470 {
9471 return 3; /* return error */
9472 }
9473
9474 prev = factor; /* set factor */
9475 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_QS, prev); /* write qs */
9476 if (res != 0) /* check result */
9477 {
9478 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
9479
9480 return 1; /* return error */
9481 }
9482
9483 return 0; /* success return 0 */
9484}
9485
9498{
9499 uint8_t res;
9500 uint8_t prev;
9501
9502 if (handle == NULL) /* check handle */
9503 {
9504 return 2; /* return error */
9505 }
9506 if (handle->inited != 1) /* check handle initialization */
9507 {
9508 return 3; /* return error */
9509 }
9510
9511 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_QS, &prev); /* read qs */
9512 if (res != 0) /* check result */
9513 {
9514 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9515
9516 return 1; /* return error */
9517 }
9518 *factor = prev; /* set factor */
9519
9520 return 0; /* success return 0 */
9521}
9522
9535{
9536 uint8_t res;
9537 uint8_t prev;
9538
9539 if (handle == NULL) /* check handle */
9540 {
9541 return 2; /* return error */
9542 }
9543 if (handle->inited != 1) /* check handle initialization */
9544 {
9545 return 3; /* return error */
9546 }
9547
9548 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRLI, &prev); /* read ctrli */
9549 if (res != 0) /* check result */
9550 {
9551 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9552
9553 return 1; /* return error */
9554 }
9555 prev &= ~(1 << 7); /* clear settings */
9556 prev |= enable << 7; /* set bool */
9557 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRLI, prev); /* write ctrli */
9558 if (res != 0) /* check result */
9559 {
9560 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
9561
9562 return 1; /* return error */
9563 }
9564
9565 return 0; /* success return 0 */
9566}
9567
9580{
9581 uint8_t res;
9582 uint8_t prev;
9583
9584 if (handle == NULL) /* check handle */
9585 {
9586 return 2; /* return error */
9587 }
9588 if (handle->inited != 1) /* check handle initialization */
9589 {
9590 return 3; /* return error */
9591 }
9592
9593 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRLI, &prev); /* read ctrli */
9594 if (res != 0) /* check result */
9595 {
9596 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9597
9598 return 1; /* return error */
9599 }
9600 *enable = (ov2640_bool_t)((prev >> 7) & 0x01); /* get bool */
9601
9602 return 0; /* success return 0 */
9603}
9604
9617{
9618 uint8_t res;
9619 uint8_t prev;
9620
9621 if (handle == NULL) /* check handle */
9622 {
9623 return 2; /* return error */
9624 }
9625 if (handle->inited != 1) /* check handle initialization */
9626 {
9627 return 3; /* return error */
9628 }
9629
9630 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRLI, &prev); /* read ctrli */
9631 if (res != 0) /* check result */
9632 {
9633 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9634
9635 return 1; /* return error */
9636 }
9637 prev &= ~(1 << 6); /* clear settings */
9638 prev |= enable << 6; /* set bool */
9639 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRLI, prev); /* write ctrli */
9640 if (res != 0) /* check result */
9641 {
9642 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
9643
9644 return 1; /* return error */
9645 }
9646
9647 return 0; /* success return 0 */
9648}
9649
9662{
9663 uint8_t res;
9664 uint8_t prev;
9665
9666 if (handle == NULL) /* check handle */
9667 {
9668 return 2; /* return error */
9669 }
9670 if (handle->inited != 1) /* check handle initialization */
9671 {
9672 return 3; /* return error */
9673 }
9674
9675 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRLI, &prev); /* read ctrli */
9676 if (res != 0) /* check result */
9677 {
9678 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9679
9680 return 1; /* return error */
9681 }
9682 *enable = (ov2640_bool_t)((prev >> 6) & 0x01); /* get bool */
9683
9684 return 0; /* success return 0 */
9685}
9686
9699uint8_t ov2640_set_vertical_divider(ov2640_handle_t *handle, uint8_t divider)
9700{
9701 uint8_t res;
9702 uint8_t prev;
9703
9704 if (handle == NULL) /* check handle */
9705 {
9706 return 2; /* return error */
9707 }
9708 if (handle->inited != 1) /* check handle initialization */
9709 {
9710 return 3; /* return error */
9711 }
9712 if (divider > 7) /* check divider */
9713 {
9714 handle->debug_print("ov2640: divider > 7.\n"); /* divider > 7 */
9715
9716 return 4; /* return error */
9717 }
9718
9719 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRLI, &prev); /* read ctrli */
9720 if (res != 0) /* check result */
9721 {
9722 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9723
9724 return 1; /* return error */
9725 }
9726 prev &= ~(7 << 3); /* clear settings */
9727 prev |= divider << 3; /* set divider */
9728 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRLI, prev); /* write ctrli */
9729 if (res != 0) /* check result */
9730 {
9731 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
9732
9733 return 1; /* return error */
9734 }
9735
9736 return 0; /* success return 0 */
9737}
9738
9750uint8_t ov2640_get_vertical_divider(ov2640_handle_t *handle, uint8_t *divider)
9751{
9752 uint8_t res;
9753 uint8_t prev;
9754
9755 if (handle == NULL) /* check handle */
9756 {
9757 return 2; /* return error */
9758 }
9759 if (handle->inited != 1) /* check handle initialization */
9760 {
9761 return 3; /* return error */
9762 }
9763
9764 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRLI, &prev); /* read ctrli */
9765 if (res != 0) /* check result */
9766 {
9767 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9768
9769 return 1; /* return error */
9770 }
9771 *divider = (prev >> 3) & 0x7; /* set divider */
9772
9773 return 0; /* success return 0 */
9774}
9775
9788uint8_t ov2640_set_horizontal_divider(ov2640_handle_t *handle, uint8_t divider)
9789{
9790 uint8_t res;
9791 uint8_t prev;
9792
9793 if (handle == NULL) /* check handle */
9794 {
9795 return 2; /* return error */
9796 }
9797 if (handle->inited != 1) /* check handle initialization */
9798 {
9799 return 3; /* return error */
9800 }
9801 if (divider > 7) /* check divider */
9802 {
9803 handle->debug_print("ov2640: divider > 7.\n"); /* divider > 7 */
9804
9805 return 4; /* return error */
9806 }
9807
9808 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRLI, &prev); /* read ctrli */
9809 if (res != 0) /* check result */
9810 {
9811 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9812
9813 return 1; /* return error */
9814 }
9815 prev &= ~(7 << 0); /* clear settings */
9816 prev |= divider << 0; /* set divider */
9817 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_CTRLI, prev); /* write ctrli */
9818 if (res != 0) /* check result */
9819 {
9820 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
9821
9822 return 1; /* return error */
9823 }
9824
9825 return 0; /* success return 0 */
9826}
9827
9839uint8_t ov2640_get_horizontal_divider(ov2640_handle_t *handle, uint8_t *divider)
9840{
9841 uint8_t res;
9842 uint8_t prev;
9843
9844 if (handle == NULL) /* check handle */
9845 {
9846 return 2; /* return error */
9847 }
9848 if (handle->inited != 1) /* check handle initialization */
9849 {
9850 return 3; /* return error */
9851 }
9852
9853 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_CTRLI, &prev); /* read ctrli */
9854 if (res != 0) /* check result */
9855 {
9856 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9857
9858 return 1; /* return error */
9859 }
9860 *divider = (prev >> 0) & 0x7; /* set divider */
9861
9862 return 0; /* success return 0 */
9863}
9864
9877uint8_t ov2640_set_horizontal_size(ov2640_handle_t *handle, uint16_t size)
9878{
9879 uint8_t res;
9880 uint8_t prev;
9881
9882 if (handle == NULL) /* check handle */
9883 {
9884 return 2; /* return error */
9885 }
9886 if (handle->inited != 1) /* check handle initialization */
9887 {
9888 return 3; /* return error */
9889 }
9890 if (size > 0x3FF) /* check size */
9891 {
9892 handle->debug_print("ov2640: size > 0x3FF.\n"); /* size > 0x3FF */
9893
9894 return 4; /* return error */
9895 }
9896
9897 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_TEST, &prev); /* read test */
9898 if (res != 0) /* check result */
9899 {
9900 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9901
9902 return 1; /* return error */
9903 }
9904 prev &= ~(1 << 7); /* clear hsize bit11 */
9905 prev |= ((size >> 9) & 0x01) << 7; /* set bit9 */
9906 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_TEST, prev); /* write test */
9907 if (res != 0) /* check result */
9908 {
9909 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
9910
9911 return 1; /* return error */
9912 }
9913 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_VHYX, &prev); /* read vhyx */
9914 if (res != 0) /* check result */
9915 {
9916 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9917
9918 return 1; /* return error */
9919 }
9920 prev &= ~(1 << 3); /* clear hsize bit11 */
9921 prev |= ((size >> 8) & 0x01) << 3; /* set bit8 */
9922 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_VHYX, prev); /* write vhyx */
9923 if (res != 0) /* check result */
9924 {
9925 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
9926
9927 return 1; /* return error */
9928 }
9929 prev = (size >> 0) & 0xFF; /* set data */
9930 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_HSIZE, prev); /* write hsize */
9931 if (res != 0) /* check result */
9932 {
9933 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
9934
9935 return 1; /* return error */
9936 }
9937
9938 return 0; /* success return 0 */
9939}
9940
9952uint8_t ov2640_get_horizontal_size(ov2640_handle_t *handle, uint16_t *size)
9953{
9954 uint8_t res;
9955 uint8_t prev;
9956
9957 if (handle == NULL) /* check handle */
9958 {
9959 return 2; /* return error */
9960 }
9961 if (handle->inited != 1) /* check handle initialization */
9962 {
9963 return 3; /* return error */
9964 }
9965
9966 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_TEST, &prev); /* read test */
9967 if (res != 0) /* check result */
9968 {
9969 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9970
9971 return 1; /* return error */
9972 }
9973 *size = (uint16_t)((prev >> 7) & 0x01) << 9; /* set size */
9974 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_VHYX, &prev); /* read vhyx */
9975 if (res != 0) /* check result */
9976 {
9977 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9978
9979 return 1; /* return error */
9980 }
9981 *size |= (uint16_t)((prev >> 3) & 0x01) << 8; /* set size */
9982 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_HSIZE, &prev); /* read hsize */
9983 if (res != 0) /* check result */
9984 {
9985 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
9986
9987 return 1; /* return error */
9988 }
9989 *size |= prev; /* set size */
9990
9991 return 0; /* success return 0 */
9992}
9993
10006uint8_t ov2640_set_vertical_size(ov2640_handle_t *handle, uint16_t size)
10007{
10008 uint8_t res;
10009 uint8_t prev;
10010
10011 if (handle == NULL) /* check handle */
10012 {
10013 return 2; /* return error */
10014 }
10015 if (handle->inited != 1) /* check handle initialization */
10016 {
10017 return 3; /* return error */
10018 }
10019 if (size > 0x1FF) /* check size */
10020 {
10021 handle->debug_print("ov2640: size > 0x1FF.\n"); /* size > 0x1FF */
10022
10023 return 4; /* return error */
10024 }
10025
10026 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_VHYX, &prev); /* read vhyx */
10027 if (res != 0) /* check result */
10028 {
10029 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10030
10031 return 1; /* return error */
10032 }
10033 prev &= ~(1 << 7); /* clear hsize bit11 */
10034 prev |= ((size >> 8) & 0x01) << 7; /* set bit8 */
10035 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_VHYX, prev); /* write vhyx */
10036 if (res != 0) /* check result */
10037 {
10038 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10039
10040 return 1; /* return error */
10041 }
10042 prev = (size >> 0) & 0xFF; /* set data */
10043 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_VSIZE, prev); /* write vsize */
10044 if (res != 0) /* check result */
10045 {
10046 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10047
10048 return 1; /* return error */
10049 }
10050
10051 return 0; /* success return 0 */
10052}
10053
10065uint8_t ov2640_get_vertical_size(ov2640_handle_t *handle, uint16_t *size)
10066{
10067 uint8_t res;
10068 uint8_t prev;
10069
10070 if (handle == NULL) /* check handle */
10071 {
10072 return 2; /* return error */
10073 }
10074 if (handle->inited != 1) /* check handle initialization */
10075 {
10076 return 3; /* return error */
10077 }
10078
10079 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_VHYX, &prev); /* read vhyx */
10080 if (res != 0) /* check result */
10081 {
10082 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10083
10084 return 1; /* return error */
10085 }
10086 *size = (uint16_t)((prev >> 7) & 0x01) << 8; /* set size */
10087 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_VSIZE, &prev); /* read vsize */
10088 if (res != 0) /* check result */
10089 {
10090 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10091
10092 return 1; /* return error */
10093 }
10094 *size |= prev; /* set size */
10095
10096 return 0; /* success return 0 */
10097}
10098
10111uint8_t ov2640_set_offset_x(ov2640_handle_t *handle, uint16_t size)
10112{
10113 uint8_t res;
10114 uint8_t prev;
10115
10116 if (handle == NULL) /* check handle */
10117 {
10118 return 2; /* return error */
10119 }
10120 if (handle->inited != 1) /* check handle initialization */
10121 {
10122 return 3; /* return error */
10123 }
10124 if (size > 0x7FF) /* check size */
10125 {
10126 handle->debug_print("ov2640: size > 0x7FF.\n"); /* size > 0x7FF */
10127
10128 return 4; /* return error */
10129 }
10130
10131 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_VHYX, &prev); /* read vhyx */
10132 if (res != 0) /* check result */
10133 {
10134 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10135
10136 return 1; /* return error */
10137 }
10138 prev &= ~(7 << 0); /* clear settings */
10139 prev |= ((size >> 8) & 0x07) << 0; /* set bit8 */
10140 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_VHYX, prev); /* write vhyx */
10141 if (res != 0) /* check result */
10142 {
10143 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10144
10145 return 1; /* return error */
10146 }
10147 prev = (size >> 0) & 0xFF; /* set data */
10148 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_XOFFL, prev); /* write xoffl */
10149 if (res != 0) /* check result */
10150 {
10151 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10152
10153 return 1; /* return error */
10154 }
10155
10156 return 0; /* success return 0 */
10157}
10158
10170uint8_t ov2640_get_offset_x(ov2640_handle_t *handle, uint16_t *size)
10171{
10172 uint8_t res;
10173 uint8_t prev;
10174
10175 if (handle == NULL) /* check handle */
10176 {
10177 return 2; /* return error */
10178 }
10179 if (handle->inited != 1) /* check handle initialization */
10180 {
10181 return 3; /* return error */
10182 }
10183
10184 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_VHYX, &prev); /* read vhyx */
10185 if (res != 0) /* check result */
10186 {
10187 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10188
10189 return 1; /* return error */
10190 }
10191 *size = (uint16_t)((prev >> 0) & 0x07) << 8; /* set size */
10192 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_XOFFL, &prev); /* read xoffl */
10193 if (res != 0) /* check result */
10194 {
10195 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10196
10197 return 1; /* return error */
10198 }
10199 *size |= prev; /* set size */
10200
10201 return 0; /* success return 0 */
10202}
10203
10216uint8_t ov2640_set_offset_y(ov2640_handle_t *handle, uint16_t size)
10217{
10218 uint8_t res;
10219 uint8_t prev;
10220
10221 if (handle == NULL) /* check handle */
10222 {
10223 return 2; /* return error */
10224 }
10225 if (handle->inited != 1) /* check handle initialization */
10226 {
10227 return 3; /* return error */
10228 }
10229 if (size > 0x7FF) /* check size */
10230 {
10231 handle->debug_print("ov2640: size > 0x7FF.\n"); /* size > 0x7FF */
10232
10233 return 4; /* return error */
10234 }
10235
10236 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_VHYX, &prev); /* read vhyx */
10237 if (res != 0) /* check result */
10238 {
10239 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10240
10241 return 1; /* return error */
10242 }
10243 prev &= ~(7 << 4); /* clear settings */
10244 prev |= ((size >> 8) & 0x07) << 4; /* set bit8 */
10245 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_VHYX, prev); /* write vhyx */
10246 if (res != 0) /* check result */
10247 {
10248 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10249
10250 return 1; /* return error */
10251 }
10252 prev = (size >> 0) & 0xFF; /* set data */
10253 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_YOFFL, prev); /* write yoffl */
10254 if (res != 0) /* check result */
10255 {
10256 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10257
10258 return 1; /* return error */
10259 }
10260
10261 return 0; /* success return 0 */
10262}
10263
10275uint8_t ov2640_get_offset_y(ov2640_handle_t *handle, uint16_t *size)
10276{
10277 uint8_t res;
10278 uint8_t prev;
10279
10280 if (handle == NULL) /* check handle */
10281 {
10282 return 2; /* return error */
10283 }
10284 if (handle->inited != 1) /* check handle initialization */
10285 {
10286 return 3; /* return error */
10287 }
10288
10289 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_VHYX, &prev); /* read vhyx */
10290 if (res != 0) /* check result */
10291 {
10292 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10293
10294 return 1; /* return error */
10295 }
10296 *size = (uint16_t)((prev >> 4) & 0x07) << 8; /* set size */
10297 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_YOFFL, &prev); /* read yoffl */
10298 if (res != 0) /* check result */
10299 {
10300 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10301
10302 return 1; /* return error */
10303 }
10304 *size |= prev; /* set size */
10305
10306 return 0; /* success return 0 */
10307}
10308
10321uint8_t ov2640_set_dp_selx(ov2640_handle_t *handle, uint8_t size)
10322{
10323 uint8_t res;
10324 uint8_t prev;
10325
10326 if (handle == NULL) /* check handle */
10327 {
10328 return 2; /* return error */
10329 }
10330 if (handle->inited != 1) /* check handle initialization */
10331 {
10332 return 3; /* return error */
10333 }
10334 if (size > 0xF) /* check size */
10335 {
10336 handle->debug_print("ov2640: size > 0xF.\n"); /* size > 0xF */
10337
10338 return 4; /* return error */
10339 }
10340
10341 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_DPRP, &prev); /* read dprp */
10342 if (res != 0) /* check result */
10343 {
10344 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10345
10346 return 1; /* return error */
10347 }
10348 prev &= ~(0xF << 0); /* clear settings */
10349 prev |= size << 0; /* set size */
10350 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_DPRP, prev); /* write dprp */
10351 if (res != 0) /* check result */
10352 {
10353 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10354
10355 return 1; /* return error */
10356 }
10357
10358 return 0; /* success return 0 */
10359}
10360
10372uint8_t ov2640_get_dp_selx(ov2640_handle_t *handle, uint8_t *size)
10373{
10374 uint8_t res;
10375 uint8_t prev;
10376
10377 if (handle == NULL) /* check handle */
10378 {
10379 return 2; /* return error */
10380 }
10381 if (handle->inited != 1) /* check handle initialization */
10382 {
10383 return 3; /* return error */
10384 }
10385
10386 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_DPRP, &prev); /* read dprp */
10387 if (res != 0) /* check result */
10388 {
10389 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10390
10391 return 1; /* return error */
10392 }
10393 *size = prev & 0xF; /* get size */
10394
10395 return 0; /* success return 0 */
10396}
10397
10410uint8_t ov2640_set_dp_sely(ov2640_handle_t *handle, uint8_t size)
10411{
10412 uint8_t res;
10413 uint8_t prev;
10414
10415 if (handle == NULL) /* check handle */
10416 {
10417 return 2; /* return error */
10418 }
10419 if (handle->inited != 1) /* check handle initialization */
10420 {
10421 return 3; /* return error */
10422 }
10423 if (size > 0xF) /* check size */
10424 {
10425 handle->debug_print("ov2640: size > 0xF.\n"); /* size > 0xF */
10426
10427 return 4; /* return error */
10428 }
10429
10430 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_DPRP, &prev); /* read dprp */
10431 if (res != 0) /* check result */
10432 {
10433 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10434
10435 return 1; /* return error */
10436 }
10437 prev &= ~(0xF << 4); /* clear settings */
10438 prev |= size << 4; /* set size */
10439 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_DPRP, prev); /* write dprp */
10440 if (res != 0) /* check result */
10441 {
10442 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10443
10444 return 1; /* return error */
10445 }
10446
10447 return 0; /* success return 0 */
10448}
10449
10461uint8_t ov2640_get_dp_sely(ov2640_handle_t *handle, uint8_t *size)
10462{
10463 uint8_t res;
10464 uint8_t prev;
10465
10466 if (handle == NULL) /* check handle */
10467 {
10468 return 2; /* return error */
10469 }
10470 if (handle->inited != 1) /* check handle initialization */
10471 {
10472 return 3; /* return error */
10473 }
10474
10475 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_DPRP, &prev); /* read dprp */
10476 if (res != 0) /* check result */
10477 {
10478 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10479
10480 return 1; /* return error */
10481 }
10482 *size = (prev >> 4) & 0xF; /* get size */
10483
10484 return 0; /* success return 0 */
10485}
10486
10499uint8_t ov2640_set_output_width(ov2640_handle_t *handle, uint16_t size)
10500{
10501 uint8_t res;
10502 uint8_t prev;
10503
10504 if (handle == NULL) /* check handle */
10505 {
10506 return 2; /* return error */
10507 }
10508 if (handle->inited != 1) /* check handle initialization */
10509 {
10510 return 3; /* return error */
10511 }
10512 if (size > 0x3FF) /* check size */
10513 {
10514 handle->debug_print("ov2640: size > 0x3FF.\n"); /* size > 0x3FF */
10515
10516 return 4; /* return error */
10517 }
10518
10519 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_ZMHH, &prev); /* read zmhh */
10520 if (res != 0) /* check result */
10521 {
10522 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10523
10524 return 1; /* return error */
10525 }
10526 prev &= ~(0x3 << 0); /* clear settings */
10527 prev |= ((size >> 8) & 0x3) << 0; /* set size */
10528 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_ZMHH, prev); /* write zmhh */
10529 if (res != 0) /* check result */
10530 {
10531 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10532
10533 return 1; /* return error */
10534 }
10535 prev = size & 0xFF; /* set size */
10536 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_ZMOW, prev); /* write zmow */
10537 if (res != 0) /* check result */
10538 {
10539 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10540
10541 return 1; /* return error */
10542 }
10543
10544 return 0; /* success return 0 */
10545}
10546
10558uint8_t ov2640_get_output_width(ov2640_handle_t *handle, uint16_t *size)
10559{
10560 uint8_t res;
10561 uint8_t prev;
10562
10563 if (handle == NULL) /* check handle */
10564 {
10565 return 2; /* return error */
10566 }
10567 if (handle->inited != 1) /* check handle initialization */
10568 {
10569 return 3; /* return error */
10570 }
10571
10572 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_ZMHH, &prev); /* read zmhh */
10573 if (res != 0) /* check result */
10574 {
10575 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10576
10577 return 1; /* return error */
10578 }
10579 *size = (uint16_t)(prev & 0x03) << 8; /* set size */
10580 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_ZMOW, &prev); /* read zmow */
10581 if (res != 0) /* check result */
10582 {
10583 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10584
10585 return 1; /* return error */
10586 }
10587 *size |= prev; /* set size */
10588
10589 return 0; /* success return 0 */
10590}
10591
10604uint8_t ov2640_set_output_height(ov2640_handle_t *handle, uint16_t size)
10605{
10606 uint8_t res;
10607 uint8_t prev;
10608
10609 if (handle == NULL) /* check handle */
10610 {
10611 return 2; /* return error */
10612 }
10613 if (handle->inited != 1) /* check handle initialization */
10614 {
10615 return 3; /* return error */
10616 }
10617 if (size > 0x1FF) /* check size */
10618 {
10619 handle->debug_print("ov2640: size > 0x1FF.\n"); /* size > 0x1FF */
10620
10621 return 4; /* return error */
10622 }
10623
10624 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_ZMHH, &prev); /* read zmhh */
10625 if (res != 0) /* check result */
10626 {
10627 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10628
10629 return 1; /* return error */
10630 }
10631 prev &= ~(0x1 << 2); /* clear settings */
10632 prev |= ((size >> 8) & 0x1) << 2; /* set size */
10633 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_ZMHH, prev); /* write zmhh */
10634 if (res != 0) /* check result */
10635 {
10636 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10637
10638 return 1; /* return error */
10639 }
10640 prev = size & 0xFF; /* set size */
10641 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_ZMOH, prev); /* write zmoh */
10642 if (res != 0) /* check result */
10643 {
10644 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10645
10646 return 1; /* return error */
10647 }
10648
10649 return 0; /* success return 0 */
10650}
10651
10663uint8_t ov2640_get_output_height(ov2640_handle_t *handle, uint16_t *size)
10664{
10665 uint8_t res;
10666 uint8_t prev;
10667
10668 if (handle == NULL) /* check handle */
10669 {
10670 return 2; /* return error */
10671 }
10672 if (handle->inited != 1) /* check handle initialization */
10673 {
10674 return 3; /* return error */
10675 }
10676
10677 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_ZMHH, &prev); /* read zmhh */
10678 if (res != 0) /* check result */
10679 {
10680 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10681
10682 return 1; /* return error */
10683 }
10684 *size = (uint16_t)((prev >> 2) & 0x01) << 8; /* set size */
10685 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_ZMOH, &prev); /* read zmoh */
10686 if (res != 0) /* check result */
10687 {
10688 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10689
10690 return 1; /* return error */
10691 }
10692 *size |= prev; /* set size */
10693
10694 return 0; /* success return 0 */
10695}
10696
10709uint8_t ov2640_set_zoom_speed(ov2640_handle_t *handle, uint8_t speed)
10710{
10711 uint8_t res;
10712 uint8_t prev;
10713
10714 if (handle == NULL) /* check handle */
10715 {
10716 return 2; /* return error */
10717 }
10718 if (handle->inited != 1) /* check handle initialization */
10719 {
10720 return 3; /* return error */
10721 }
10722 if (speed > 0xF) /* check result */
10723 {
10724 handle->debug_print("ov2640: speed > 0xF.\n"); /* speed > 0xF */
10725
10726 return 4; /* return error */
10727 }
10728
10729 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_ZMHH, &prev); /* read zmhh */
10730 if (res != 0) /* check result */
10731 {
10732 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10733
10734 return 1; /* return error */
10735 }
10736 prev &= ~(0xF << 4); /* clear settings */
10737 prev |= speed << 4; /* set speed */
10738 res = a_ov2640_dsp_write(handle, OV2640_REG_DSP_BANK_ZMHH, prev); /* write zmhh */
10739 if (res != 0) /* check result */
10740 {
10741 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10742
10743 return 1; /* return error */
10744 }
10745
10746 return 0; /* success return 0 */
10747}
10748
10760uint8_t ov2640_get_zoom_speed(ov2640_handle_t *handle, uint8_t *speed)
10761{
10762 uint8_t res;
10763 uint8_t prev;
10764
10765 if (handle == NULL) /* check handle */
10766 {
10767 return 2; /* return error */
10768 }
10769 if (handle->inited != 1) /* check handle initialization */
10770 {
10771 return 3; /* return error */
10772 }
10773
10774 res = a_ov2640_dsp_read(handle, OV2640_REG_DSP_BANK_ZMHH, &prev); /* read zmhh */
10775 if (res != 0) /* check result */
10776 {
10777 handle->debug_print("ov2640: dsp read failed.\n"); /* dsp read failed */
10778
10779 return 1; /* return error */
10780 }
10781 *speed = (prev >> 4) & 0xFF; /* get speed */
10782
10783 return 0; /* success return 0 */
10784}
10785
10798{
10799 uint8_t res;
10800 uint8_t prev;
10801
10802 if (handle == NULL) /* check handle */
10803 {
10804 return 2; /* return error */
10805 }
10806 if (handle->inited != 1) /* check handle initialization */
10807 {
10808 return 3; /* return error */
10809 }
10810
10811 switch (mode) /* select mode */
10812 {
10813 case OV2640_LIGHT_MODE_AUTO : /* auto */
10814 {
10815 prev = 0x00; /* set 0x00 */
10816 res = a_ov2640_dsp_write(handle, 0xC7, prev); /* write 0xc7 */
10817 if (res != 0) /* check result */
10818 {
10819 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10820
10821 break; /* break */
10822 }
10823
10824 break; /* break */
10825 }
10826 case OV2640_LIGHT_MODE_SUNNY : /* sunny */
10827 {
10828 prev = 0x40; /* set 0x40 */
10829 res = a_ov2640_dsp_write(handle, 0xC7, prev); /* write 0xc7 */
10830 if (res != 0) /* check result */
10831 {
10832 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10833
10834 break; /* break */
10835 }
10836 prev = 0x5E; /* set 0x5E */
10837 res = a_ov2640_dsp_write(handle, 0xCC, prev); /* write 0xcc */
10838 if (res != 0) /* check result */
10839 {
10840 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10841
10842 break; /* break */
10843 }
10844 prev = 0x41; /* set 0x41 */
10845 res = a_ov2640_dsp_write(handle, 0xCD, prev); /* write 0xcd */
10846 if (res != 0) /* check result */
10847 {
10848 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10849
10850 break; /* break */
10851 }
10852 prev = 0x54; /* set 0x54 */
10853 res = a_ov2640_dsp_write(handle, 0xCE, prev); /* write 0xce */
10854 if (res != 0) /* check result */
10855 {
10856 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10857
10858 break; /* break */
10859 }
10860
10861 break; /* break */
10862 }
10863 case OV2640_LIGHT_MODE_CLOUDY : /* cloudy */
10864 {
10865 prev = 0x40; /* set 0x40 */
10866 res = a_ov2640_dsp_write(handle, 0xC7, prev); /* write 0xc7 */
10867 if (res != 0) /* check result */
10868 {
10869 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10870
10871 break; /* break */
10872 }
10873 prev = 0x65; /* set 0x65 */
10874 res = a_ov2640_dsp_write(handle, 0xCC, prev); /* write 0xcc */
10875 if (res != 0) /* check result */
10876 {
10877 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10878
10879 break; /* break */
10880 }
10881 prev = 0x41; /* set 0x41 */
10882 res = a_ov2640_dsp_write(handle, 0xCD, prev); /* write 0xcd */
10883 if (res != 0) /* check result */
10884 {
10885 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10886
10887 break; /* break */
10888 }
10889 prev = 0x4F; /* set 0x4F */
10890 res = a_ov2640_dsp_write(handle, 0xCE, prev); /* write 0xce */
10891 if (res != 0) /* check result */
10892 {
10893 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10894
10895 break; /* break */
10896 }
10897
10898 break; /* break */
10899 }
10900 case OV2640_LIGHT_MODE_OFFICE : /* office */
10901 {
10902 prev = 0x40; /* set 0x40 */
10903 res = a_ov2640_dsp_write(handle, 0xC7, prev); /* write 0xc7 */
10904 if (res != 0) /* check result */
10905 {
10906 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10907
10908 break; /* break */
10909 }
10910 prev = 0x52; /* set 0x52 */
10911 res = a_ov2640_dsp_write(handle, 0xCC, prev); /* write 0xcc */
10912 if (res != 0) /* check result */
10913 {
10914 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10915
10916 break; /* break */
10917 }
10918 prev = 0x41; /* set 0x41 */
10919 res = a_ov2640_dsp_write(handle, 0xCD, prev); /* write 0xcd */
10920 if (res != 0) /* check result */
10921 {
10922 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10923
10924 break; /* break */
10925 }
10926 prev = 0x66; /* set 0x66 */
10927 res = a_ov2640_dsp_write(handle, 0xCE, prev); /* write 0xce */
10928 if (res != 0) /* check result */
10929 {
10930 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10931
10932 break; /* break */
10933 }
10934
10935 break; /* break */
10936 }
10937 case OV2640_LIGHT_MODE_HOME : /* home */
10938 {
10939 prev = 0x40; /* set 0x40 */
10940 res = a_ov2640_dsp_write(handle, 0xC7, prev); /* write 0xc7 */
10941 if (res != 0) /* check result */
10942 {
10943 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10944
10945 break; /* break */
10946 }
10947 prev = 0x42; /* set 0x42 */
10948 res = a_ov2640_dsp_write(handle, 0xCC, prev); /* write 0xcc */
10949 if (res != 0) /* check result */
10950 {
10951 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10952
10953 break; /* break */
10954 }
10955 prev = 0x3F; /* set 0x3F */
10956 res = a_ov2640_dsp_write(handle, 0xCD, prev); /* write 0xcd */
10957 if (res != 0) /* check result */
10958 {
10959 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10960
10961 break; /* break */
10962 }
10963 prev = 0x71; /* set 0x71 */
10964 res = a_ov2640_dsp_write(handle, 0xCE, prev); /* write 0xce */
10965 if (res != 0) /* check result */
10966 {
10967 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
10968
10969 break; /* break */
10970 }
10971
10972 break; /* break */
10973 }
10974 default : /* default */
10975 {
10976 res = 1; /* set error */
10977
10978 break; /* break */
10979 }
10980 }
10981
10982 return res; /* success return 0 */
10983}
10984
10997{
10998 uint8_t res;
10999 uint8_t prev;
11000
11001 if (handle == NULL) /* check handle */
11002 {
11003 return 2; /* return error */
11004 }
11005 if (handle->inited != 1) /* check handle initialization */
11006 {
11007 return 3; /* return error */
11008 }
11009
11010 switch (color) /* select color saturation */
11011 {
11012 case OV2640_COLOR_SATURATION_POSITIVE_2 : /* saturation +2 */
11013 {
11014 prev = 0x00; /* set 0x00 */
11015 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11016 if (res != 0) /* check result */
11017 {
11018 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11019
11020 break; /* break */
11021 }
11022 prev = 0x02; /* set 0x02 */
11023 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11024 if (res != 0) /* check result */
11025 {
11026 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11027
11028 break; /* break */
11029 }
11030 prev = 0x03; /* set 0x03 */
11031 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11032 if (res != 0) /* check result */
11033 {
11034 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11035
11036 break; /* break */
11037 }
11038 prev = 0x68; /* set 0x68 */
11039 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11040 if (res != 0) /* check result */
11041 {
11042 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11043
11044 break; /* break */
11045 }
11046 prev = 0x68; /* set 0x68 */
11047 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11048 if (res != 0) /* check result */
11049 {
11050 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11051
11052 break; /* break */
11053 }
11054
11055 break; /* break */
11056 }
11057 case OV2640_COLOR_SATURATION_POSITIVE_1 : /* saturation +1 */
11058 {
11059 prev = 0x00; /* set 0x00 */
11060 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11061 if (res != 0) /* check result */
11062 {
11063 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11064
11065 break; /* break */
11066 }
11067 prev = 0x02; /* set 0x02 */
11068 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11069 if (res != 0) /* check result */
11070 {
11071 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11072
11073 break; /* break */
11074 }
11075 prev = 0x03; /* set 0x03 */
11076 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11077 if (res != 0) /* check result */
11078 {
11079 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11080
11081 break; /* break */
11082 }
11083 prev = 0x58; /* set 0x58 */
11084 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11085 if (res != 0) /* check result */
11086 {
11087 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11088
11089 break; /* break */
11090 }
11091 prev = 0x58; /* set 0x58 */
11092 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11093 if (res != 0) /* check result */
11094 {
11095 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11096
11097 break; /* break */
11098 }
11099
11100 break; /* break */
11101 }
11102 case OV2640_COLOR_SATURATION_0 : /* saturation 0 */
11103 {
11104 prev = 0x00; /* set 0x00 */
11105 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11106 if (res != 0) /* check result */
11107 {
11108 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11109
11110 break; /* break */
11111 }
11112 prev = 0x02; /* set 0x02 */
11113 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11114 if (res != 0) /* check result */
11115 {
11116 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11117
11118 break; /* break */
11119 }
11120 prev = 0x03; /* set 0x03 */
11121 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11122 if (res != 0) /* check result */
11123 {
11124 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11125
11126 break; /* break */
11127 }
11128 prev = 0x48; /* set 0x48 */
11129 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11130 if (res != 0) /* check result */
11131 {
11132 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11133
11134 break; /* break */
11135 }
11136 prev = 0x48; /* set 0x48 */
11137 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11138 if (res != 0) /* check result */
11139 {
11140 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11141
11142 break; /* break */
11143 }
11144
11145 break; /* break */
11146 }
11147 case OV2640_COLOR_SATURATION_NEGATIVE_1 : /* saturation -1 */
11148 {
11149 prev = 0x00; /* set 0x00 */
11150 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11151 if (res != 0) /* check result */
11152 {
11153 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11154
11155 break; /* break */
11156 }
11157 prev = 0x02; /* set 0x02 */
11158 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11159 if (res != 0) /* check result */
11160 {
11161 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11162
11163 break; /* break */
11164 }
11165 prev = 0x03; /* set 0x03 */
11166 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11167 if (res != 0) /* check result */
11168 {
11169 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11170
11171 break; /* break */
11172 }
11173 prev = 0x38; /* set 0x38 */
11174 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11175 if (res != 0) /* check result */
11176 {
11177 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11178
11179 break; /* break */
11180 }
11181 prev = 0x38; /* set 0x38 */
11182 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11183 if (res != 0) /* check result */
11184 {
11185 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11186
11187 break; /* break */
11188 }
11189
11190 break; /* break */
11191 }
11192 case OV2640_COLOR_SATURATION_NEGATIVE_2 : /* saturation -2 */
11193 {
11194 prev = 0x00; /* set 0x00 */
11195 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11196 if (res != 0) /* check result */
11197 {
11198 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11199
11200 break; /* break */
11201 }
11202 prev = 0x02; /* set 0x02 */
11203 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11204 if (res != 0) /* check result */
11205 {
11206 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11207
11208 break; /* break */
11209 }
11210 prev = 0x03; /* set 0x03 */
11211 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11212 if (res != 0) /* check result */
11213 {
11214 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11215
11216 break; /* break */
11217 }
11218 prev = 0x28; /* set 0x28 */
11219 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11220 if (res != 0) /* check result */
11221 {
11222 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11223
11224 break; /* break */
11225 }
11226 prev = 0x28; /* set 0x28 */
11227 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11228 if (res != 0) /* check result */
11229 {
11230 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11231
11232 break; /* break */
11233 }
11234
11235 break; /* break */
11236 }
11237 default : /* default */
11238 {
11239 res = 1; /* set error */
11240
11241 break; /* break */
11242 }
11243 }
11244
11245 return res; /* success return 0 */
11246}
11247
11260{
11261 uint8_t res;
11262 uint8_t prev;
11263
11264 if (handle == NULL) /* check handle */
11265 {
11266 return 2; /* return error */
11267 }
11268 if (handle->inited != 1) /* check handle initialization */
11269 {
11270 return 3; /* return error */
11271 }
11272
11273 switch (brightness) /* select brightness */
11274 {
11275 case OV2640_BRIGHTNESS_POSITIVE_2 : /* brightness +2 */
11276 {
11277 prev = 0x00; /* set 0x00 */
11278 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11279 if (res != 0) /* check result */
11280 {
11281 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11282
11283 break; /* break */
11284 }
11285 prev = 0x04; /* set 0x04 */
11286 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11287 if (res != 0) /* check result */
11288 {
11289 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11290
11291 break; /* break */
11292 }
11293 prev = 0x09; /* set 0x09 */
11294 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11295 if (res != 0) /* check result */
11296 {
11297 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11298
11299 break; /* break */
11300 }
11301 prev = 0x40; /* set 0x40 */
11302 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11303 if (res != 0) /* check result */
11304 {
11305 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11306
11307 break; /* break */
11308 }
11309 prev = 0x00; /* set 0x00 */
11310 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11311 if (res != 0) /* check result */
11312 {
11313 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11314
11315 break; /* break */
11316 }
11317
11318 break; /* break */
11319 }
11320 case OV2640_BRIGHTNESS_POSITIVE_1 : /* brightness +1 */
11321 {
11322 prev = 0x00; /* set 0x00 */
11323 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11324 if (res != 0) /* check result */
11325 {
11326 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11327
11328 break; /* break */
11329 }
11330 prev = 0x04; /* set 0x04 */
11331 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11332 if (res != 0) /* check result */
11333 {
11334 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11335
11336 break; /* break */
11337 }
11338 prev = 0x09; /* set 0x09 */
11339 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11340 if (res != 0) /* check result */
11341 {
11342 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11343
11344 break; /* break */
11345 }
11346 prev = 0x30; /* set 0x30 */
11347 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11348 if (res != 0) /* check result */
11349 {
11350 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11351
11352 break; /* break */
11353 }
11354 prev = 0x00; /* set 0x00 */
11355 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11356 if (res != 0) /* check result */
11357 {
11358 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11359
11360 break; /* break */
11361 }
11362
11363 break; /* break */
11364 }
11365 case OV2640_BRIGHTNESS_0 : /* brightness 0 */
11366 {
11367 prev = 0x00; /* set 0x00 */
11368 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11369 if (res != 0) /* check result */
11370 {
11371 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11372
11373 break; /* break */
11374 }
11375 prev = 0x04; /* set 0x04 */
11376 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11377 if (res != 0) /* check result */
11378 {
11379 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11380
11381 break; /* break */
11382 }
11383 prev = 0x09; /* set 0x09 */
11384 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11385 if (res != 0) /* check result */
11386 {
11387 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11388
11389 break; /* break */
11390 }
11391 prev = 0x20; /* set 0x20 */
11392 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11393 if (res != 0) /* check result */
11394 {
11395 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11396
11397 break; /* break */
11398 }
11399 prev = 0x00; /* set 0x00 */
11400 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11401 if (res != 0) /* check result */
11402 {
11403 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11404
11405 break; /* break */
11406 }
11407
11408 break; /* break */
11409 }
11410 case OV2640_BRIGHTNESS_NEGATIVE_1 : /* brightness -1 */
11411 {
11412 prev = 0x00; /* set 0x00 */
11413 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11414 if (res != 0) /* check result */
11415 {
11416 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11417
11418 break; /* break */
11419 }
11420 prev = 0x04; /* set 0x04 */
11421 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11422 if (res != 0) /* check result */
11423 {
11424 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11425
11426 break; /* break */
11427 }
11428 prev = 0x09; /* set 0x09 */
11429 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11430 if (res != 0) /* check result */
11431 {
11432 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11433
11434 break; /* break */
11435 }
11436 prev = 0x10; /* set 0x10 */
11437 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11438 if (res != 0) /* check result */
11439 {
11440 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11441
11442 break; /* break */
11443 }
11444 prev = 0x00; /* set 0x00 */
11445 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11446 if (res != 0) /* check result */
11447 {
11448 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11449
11450 break; /* break */
11451 }
11452
11453 break; /* break */
11454 }
11455 case OV2640_BRIGHTNESS_NEGATIVE_2 : /* brightness -2 */
11456 {
11457 prev = 0x00; /* set 0x00 */
11458 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11459 if (res != 0) /* check result */
11460 {
11461 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11462
11463 break; /* break */
11464 }
11465 prev = 0x04; /* set 0x04 */
11466 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11467 if (res != 0) /* check result */
11468 {
11469 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11470
11471 break; /* break */
11472 }
11473 prev = 0x09; /* set 0x09 */
11474 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11475 if (res != 0) /* check result */
11476 {
11477 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11478
11479 break; /* break */
11480 }
11481 prev = 0x00; /* set 0x00 */
11482 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11483 if (res != 0) /* check result */
11484 {
11485 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11486
11487 break; /* break */
11488 }
11489 prev = 0x00; /* set 0x00 */
11490 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11491 if (res != 0) /* check result */
11492 {
11493 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11494
11495 break; /* break */
11496 }
11497
11498 break; /* break */
11499 }
11500 default : /* default */
11501 {
11502 res = 1; /* set error */
11503
11504 break; /* break */
11505 }
11506 }
11507
11508 return res; /* success return 0 */
11509}
11510
11523{
11524 uint8_t res;
11525 uint8_t prev;
11526
11527 if (handle == NULL) /* check handle */
11528 {
11529 return 2; /* return error */
11530 }
11531 if (handle->inited != 1) /* check handle initialization */
11532 {
11533 return 3; /* return error */
11534 }
11535
11536 switch (contrast) /* select contrast */
11537 {
11538 case OV2640_CONTRAST_POSITIVE_2 : /* contrast +2 */
11539 {
11540 prev = 0x00; /* set 0x00 */
11541 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11542 if (res != 0) /* check result */
11543 {
11544 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11545
11546 break; /* break */
11547 }
11548 prev = 0x04; /* set 0x04 */
11549 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11550 if (res != 0) /* check result */
11551 {
11552 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11553
11554 break; /* break */
11555 }
11556 prev = 0x07; /* set 0x07 */
11557 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11558 if (res != 0) /* check result */
11559 {
11560 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11561
11562 break; /* break */
11563 }
11564 prev = 0x20; /* set 0x20 */
11565 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11566 if (res != 0) /* check result */
11567 {
11568 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11569
11570 break; /* break */
11571 }
11572 prev = 0x28; /* set 0x28 */
11573 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11574 if (res != 0) /* check result */
11575 {
11576 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11577
11578 break; /* break */
11579 }
11580 prev = 0x0C; /* set 0x0C */
11581 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11582 if (res != 0) /* check result */
11583 {
11584 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11585
11586 break; /* break */
11587 }
11588 prev = 0x06; /* set 0x06 */
11589 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11590 if (res != 0) /* check result */
11591 {
11592 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11593
11594 break; /* break */
11595 }
11596
11597 break; /* break */
11598 }
11599 case OV2640_CONTRAST_POSITIVE_1 : /* contrast +1 */
11600 {
11601 prev = 0x00; /* set 0x00 */
11602 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11603 if (res != 0) /* check result */
11604 {
11605 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11606
11607 break; /* break */
11608 }
11609 prev = 0x04; /* set 0x04 */
11610 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11611 if (res != 0) /* check result */
11612 {
11613 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11614
11615 break; /* break */
11616 }
11617 prev = 0x07; /* set 0x07 */
11618 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11619 if (res != 0) /* check result */
11620 {
11621 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11622
11623 break; /* break */
11624 }
11625 prev = 0x20; /* set 0x20 */
11626 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11627 if (res != 0) /* check result */
11628 {
11629 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11630
11631 break; /* break */
11632 }
11633 prev = 0x24; /* set 0x24 */
11634 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11635 if (res != 0) /* check result */
11636 {
11637 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11638
11639 break; /* break */
11640 }
11641 prev = 0x16; /* set 0x16 */
11642 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11643 if (res != 0) /* check result */
11644 {
11645 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11646
11647 break; /* break */
11648 }
11649 prev = 0x06; /* set 0x06 */
11650 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11651 if (res != 0) /* check result */
11652 {
11653 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11654
11655 break; /* break */
11656 }
11657
11658 break; /* break */
11659 }
11660 case OV2640_CONTRAST_0 : /* contrast 0 */
11661 {
11662 prev = 0x00; /* set 0x00 */
11663 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11664 if (res != 0) /* check result */
11665 {
11666 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11667
11668 break; /* break */
11669 }
11670 prev = 0x04; /* set 0x04 */
11671 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11672 if (res != 0) /* check result */
11673 {
11674 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11675
11676 break; /* break */
11677 }
11678 prev = 0x07; /* set 0x07 */
11679 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11680 if (res != 0) /* check result */
11681 {
11682 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11683
11684 break; /* break */
11685 }
11686 prev = 0x20; /* set 0x20 */
11687 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11688 if (res != 0) /* check result */
11689 {
11690 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11691
11692 break; /* break */
11693 }
11694 prev = 0x20; /* set 0x20 */
11695 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11696 if (res != 0) /* check result */
11697 {
11698 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11699
11700 break; /* break */
11701 }
11702 prev = 0x20; /* set 0x20 */
11703 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11704 if (res != 0) /* check result */
11705 {
11706 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11707
11708 break; /* break */
11709 }
11710 prev = 0x06; /* set 0x06 */
11711 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11712 if (res != 0) /* check result */
11713 {
11714 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11715
11716 break; /* break */
11717 }
11718
11719 break; /* break */
11720 }
11721 case OV2640_CONTRAST_NEGATIVE_1 : /* contrast -1 */
11722 {
11723 prev = 0x00; /* set 0x00 */
11724 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11725 if (res != 0) /* check result */
11726 {
11727 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11728
11729 break; /* break */
11730 }
11731 prev = 0x04; /* set 0x04 */
11732 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11733 if (res != 0) /* check result */
11734 {
11735 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11736
11737 break; /* break */
11738 }
11739 prev = 0x07; /* set 0x07 */
11740 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11741 if (res != 0) /* check result */
11742 {
11743 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11744
11745 break; /* break */
11746 }
11747 prev = 0x20; /* set 0x20 */
11748 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11749 if (res != 0) /* check result */
11750 {
11751 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11752
11753 break; /* break */
11754 }
11755 prev = 0x1C; /* set 0x1C */
11756 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11757 if (res != 0) /* check result */
11758 {
11759 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11760
11761 break; /* break */
11762 }
11763 prev = 0x2A; /* set 0x2A */
11764 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11765 if (res != 0) /* check result */
11766 {
11767 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11768
11769 break; /* break */
11770 }
11771 prev = 0x06; /* set 0x06 */
11772 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11773 if (res != 0) /* check result */
11774 {
11775 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11776
11777 break; /* break */
11778 }
11779
11780 break; /* break */
11781 }
11782 case OV2640_CONTRAST_NEGATIVE_2 : /* contrast -2 */
11783 {
11784 prev = 0x00; /* set 0x00 */
11785 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11786 if (res != 0) /* check result */
11787 {
11788 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11789
11790 break; /* break */
11791 }
11792 prev = 0x04; /* set 0x04 */
11793 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11794 if (res != 0) /* check result */
11795 {
11796 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11797
11798 break; /* break */
11799 }
11800 prev = 0x07; /* set 0x07 */
11801 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11802 if (res != 0) /* check result */
11803 {
11804 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11805
11806 break; /* break */
11807 }
11808 prev = 0x20; /* set 0x20 */
11809 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11810 if (res != 0) /* check result */
11811 {
11812 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11813
11814 break; /* break */
11815 }
11816 prev = 0x18; /* set 0x18 */
11817 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11818 if (res != 0) /* check result */
11819 {
11820 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11821
11822 break; /* break */
11823 }
11824 prev = 0x34; /* set 0x34 */
11825 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11826 if (res != 0) /* check result */
11827 {
11828 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11829
11830 break; /* break */
11831 }
11832 prev = 0x06; /* set 0x06 */
11833 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11834 if (res != 0) /* check result */
11835 {
11836 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11837
11838 break; /* break */
11839 }
11840
11841 break; /* break */
11842 }
11843 default : /* default */
11844 {
11845 res = 1; /* set error */
11846
11847 break; /* break */
11848 }
11849 }
11850
11851 return res; /* success return 0 */
11852}
11853
11866{
11867 uint8_t res;
11868 uint8_t prev;
11869
11870 if (handle == NULL) /* check handle */
11871 {
11872 return 2; /* return error */
11873 }
11874 if (handle->inited != 1) /* check handle initialization */
11875 {
11876 return 3; /* return error */
11877 }
11878
11879 switch (effect) /* select effect */
11880 {
11881 case OV2640_SPECIAL_EFFECT_ANTIQUE : /* antique */
11882 {
11883 prev = 0x00; /* set 0x00 */
11884 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11885 if (res != 0) /* check result */
11886 {
11887 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11888
11889 break; /* break */
11890 }
11891 prev = 0x18; /* set 0x18 */
11892 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11893 if (res != 0) /* check result */
11894 {
11895 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11896
11897 break; /* break */
11898 }
11899 prev = 0x05; /* set 0x05 */
11900 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11901 if (res != 0) /* check result */
11902 {
11903 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11904
11905 break; /* break */
11906 }
11907 prev = 0x40; /* set 0x40 */
11908 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11909 if (res != 0) /* check result */
11910 {
11911 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11912
11913 break; /* break */
11914 }
11915 prev = 0xA6; /* set 0xA6 */
11916 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11917 if (res != 0) /* check result */
11918 {
11919 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11920
11921 break; /* break */
11922 }
11923
11924 break; /* break */
11925 }
11926 case OV2640_SPECIAL_EFFECT_BLUISH : /* bluish */
11927 {
11928 prev = 0x00; /* set 0x00 */
11929 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11930 if (res != 0) /* check result */
11931 {
11932 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11933
11934 break; /* break */
11935 }
11936 prev = 0x18; /* set 0x18 */
11937 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11938 if (res != 0) /* check result */
11939 {
11940 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11941
11942 break; /* break */
11943 }
11944 prev = 0x05; /* set 0x05 */
11945 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11946 if (res != 0) /* check result */
11947 {
11948 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11949
11950 break; /* break */
11951 }
11952 prev = 0xA0; /* set 0xA0 */
11953 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11954 if (res != 0) /* check result */
11955 {
11956 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11957
11958 break; /* break */
11959 }
11960 prev = 0x40; /* set 0x40 */
11961 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11962 if (res != 0) /* check result */
11963 {
11964 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11965
11966 break; /* break */
11967 }
11968
11969 break; /* break */
11970 }
11971 case OV2640_SPECIAL_EFFECT_GREENISH : /* greenish */
11972 {
11973 prev = 0x00; /* set 0x00 */
11974 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11975 if (res != 0) /* check result */
11976 {
11977 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11978
11979 break; /* break */
11980 }
11981 prev = 0x18; /* set 0x18 */
11982 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11983 if (res != 0) /* check result */
11984 {
11985 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11986
11987 break; /* break */
11988 }
11989 prev = 0x05; /* set 0x05 */
11990 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
11991 if (res != 0) /* check result */
11992 {
11993 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
11994
11995 break; /* break */
11996 }
11997 prev = 0x40; /* set 0x40 */
11998 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
11999 if (res != 0) /* check result */
12000 {
12001 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12002
12003 break; /* break */
12004 }
12005 prev = 0x40; /* set 0x40 */
12006 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
12007 if (res != 0) /* check result */
12008 {
12009 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12010
12011 break; /* break */
12012 }
12013
12014 break; /* break */
12015 }
12016 case OV2640_SPECIAL_EFFECT_REDDISH : /* reddish */
12017 {
12018 prev = 0x00; /* set 0x00 */
12019 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
12020 if (res != 0) /* check result */
12021 {
12022 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12023
12024 break; /* break */
12025 }
12026 prev = 0x18; /* set 0x18 */
12027 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
12028 if (res != 0) /* check result */
12029 {
12030 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12031
12032 break; /* break */
12033 }
12034 prev = 0x05; /* set 0x05 */
12035 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
12036 if (res != 0) /* check result */
12037 {
12038 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12039
12040 break; /* break */
12041 }
12042 prev = 0x40; /* set 0x40 */
12043 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
12044 if (res != 0) /* check result */
12045 {
12046 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12047
12048 break; /* break */
12049 }
12050 prev = 0xC0; /* set 0xC0 */
12051 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
12052 if (res != 0) /* check result */
12053 {
12054 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12055
12056 break; /* break */
12057 }
12058
12059 break; /* break */
12060 }
12061 case OV2640_SPECIAL_EFFECT_BW : /* b&w */
12062 {
12063 prev = 0x00; /* set 0x00 */
12064 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
12065 if (res != 0) /* check result */
12066 {
12067 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12068
12069 break; /* break */
12070 }
12071 prev = 0x18; /* set 0x18 */
12072 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
12073 if (res != 0) /* check result */
12074 {
12075 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12076
12077 break; /* break */
12078 }
12079 prev = 0x05; /* set 0x05 */
12080 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
12081 if (res != 0) /* check result */
12082 {
12083 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12084
12085 break; /* break */
12086 }
12087 prev = 0x80; /* set 0x80 */
12088 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
12089 if (res != 0) /* check result */
12090 {
12091 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12092
12093 break; /* break */
12094 }
12095 prev = 0x80; /* set 0x80 */
12096 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
12097 if (res != 0) /* check result */
12098 {
12099 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12100
12101 break; /* break */
12102 }
12103
12104 break; /* break */
12105 }
12106 case OV2640_SPECIAL_EFFECT_NEGATIVE : /* negative */
12107 {
12108 prev = 0x00; /* set 0x00 */
12109 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
12110 if (res != 0) /* check result */
12111 {
12112 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12113
12114 break; /* break */
12115 }
12116 prev = 0x40; /* set 0x40 */
12117 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
12118 if (res != 0) /* check result */
12119 {
12120 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12121
12122 break; /* break */
12123 }
12124 prev = 0x05; /* set 0x05 */
12125 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
12126 if (res != 0) /* check result */
12127 {
12128 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12129
12130 break; /* break */
12131 }
12132 prev = 0x80; /* set 0x80 */
12133 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
12134 if (res != 0) /* check result */
12135 {
12136 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12137
12138 break; /* break */
12139 }
12140 prev = 0x80; /* set 0x80 */
12141 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
12142 if (res != 0) /* check result */
12143 {
12144 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12145
12146 break; /* break */
12147 }
12148
12149 break; /* break */
12150 }
12151 case OV2640_SPECIAL_EFFECT_BW_NEGATIVE : /* b&w negative */
12152 {
12153 prev = 0x00; /* set 0x00 */
12154 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
12155 if (res != 0) /* check result */
12156 {
12157 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12158
12159 break; /* break */
12160 }
12161 prev = 0x58; /* set 0x58 */
12162 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
12163 if (res != 0) /* check result */
12164 {
12165 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12166
12167 break; /* break */
12168 }
12169 prev = 0x05; /* set 0x05 */
12170 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
12171 if (res != 0) /* check result */
12172 {
12173 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12174
12175 break; /* break */
12176 }
12177 prev = 0x80; /* set 0x80 */
12178 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
12179 if (res != 0) /* check result */
12180 {
12181 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12182
12183 break; /* break */
12184 }
12185 prev = 0x80; /* set 0x80 */
12186 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
12187 if (res != 0) /* check result */
12188 {
12189 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12190
12191 break; /* break */
12192 }
12193
12194 break; /* break */
12195 }
12196 case OV2640_SPECIAL_EFFECT_NORMAL : /* normal */
12197 {
12198 prev = 0x00; /* set 0x00 */
12199 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
12200 if (res != 0) /* check result */
12201 {
12202 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12203
12204 break; /* break */
12205 }
12206 prev = 0x00; /* set 0x00 */
12207 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
12208 if (res != 0) /* check result */
12209 {
12210 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12211
12212 break; /* break */
12213 }
12214 prev = 0x05; /* set 0x05 */
12215 res = a_ov2640_dsp_write(handle, 0x7C, prev); /* write 0x7c */
12216 if (res != 0) /* check result */
12217 {
12218 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12219
12220 break; /* break */
12221 }
12222 prev = 0x80; /* set 0x80 */
12223 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
12224 if (res != 0) /* check result */
12225 {
12226 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12227
12228 break; /* break */
12229 }
12230 prev = 0x80; /* set 0x80 */
12231 res = a_ov2640_dsp_write(handle, 0x7D, prev); /* write 0x7d */
12232 if (res != 0) /* check result */
12233 {
12234 handle->debug_print("ov2640: dsp write failed.\n"); /* dsp write failed */
12235
12236 break; /* break */
12237 }
12238
12239 break; /* break */
12240 }
12241 default : /* default */
12242 {
12243 res = 1; /* set error */
12244
12245 break; /* break */
12246 }
12247 }
12248
12249 return res; /* success return 0 */
12250}
12251
12264uint8_t ov2640_get_dsp_reg(ov2640_handle_t *handle, uint8_t reg, uint8_t *data)
12265{
12266 if (handle == NULL) /* check handle */
12267 {
12268 return 2; /* return error */
12269 }
12270 if (handle->inited != 1) /* check handle initialization */
12271 {
12272 return 3; /* return error */
12273 }
12274
12275 return a_ov2640_dsp_read(handle, reg, data); /* dsp read */
12276}
12277
12290uint8_t ov2640_set_dsp_reg(ov2640_handle_t *handle, uint8_t reg, uint8_t data)
12291{
12292 if (handle == NULL) /* check handle */
12293 {
12294 return 2; /* return error */
12295 }
12296 if (handle->inited != 1) /* check handle initialization */
12297 {
12298 return 3; /* return error */
12299 }
12300
12301 return a_ov2640_dsp_write(handle, reg, data); /* dsp write */
12302}
12303
12316uint8_t ov2640_get_sensor_reg(ov2640_handle_t *handle, uint8_t reg, uint8_t *data)
12317{
12318 if (handle == NULL) /* check handle */
12319 {
12320 return 2; /* return error */
12321 }
12322 if (handle->inited != 1) /* check handle initialization */
12323 {
12324 return 3; /* return error */
12325 }
12326
12327 return a_ov2640_sensor_read(handle, reg, data); /* sensor read */
12328}
12329
12342uint8_t ov2640_set_sensor_reg(ov2640_handle_t *handle, uint8_t reg, uint8_t data)
12343{
12344 if (handle == NULL) /* check handle */
12345 {
12346 return 2; /* return error */
12347 }
12348 if (handle->inited != 1) /* check handle initialization */
12349 {
12350 return 3; /* return error */
12351 }
12352
12353 return a_ov2640_sensor_write(handle, reg, data); /* sensor write */
12354}
12355
12365{
12366 if (info == NULL) /* check handle */
12367 {
12368 return 2; /* return error */
12369 }
12370
12371 memset(info, 0, sizeof(ov2640_info_t)); /* initialize ov2640 info structure */
12372 strncpy(info->chip_name, CHIP_NAME, 32); /* copy chip name */
12373 strncpy(info->manufacturer_name, MANUFACTURER_NAME, 32); /* copy manufacturer name */
12374 strncpy(info->interface, "SCCB DVP", 16); /* copy interface name */
12375 info->supply_voltage_min_v = SUPPLY_VOLTAGE_MIN; /* set minimal supply voltage */
12376 info->supply_voltage_max_v = SUPPLY_VOLTAGE_MAX; /* set maximum supply voltage */
12377 info->max_current_ma = MAX_CURRENT; /* set maximum current */
12378 info->temperature_max = TEMPERATURE_MAX; /* set minimal temperature */
12379 info->temperature_min = TEMPERATURE_MIN; /* set maximum temperature */
12380 info->driver_version = DRIVER_VERSION; /* set driver version */
12381
12382 return 0; /* success return 0 */
12383}
#define OV2640_REG_SENSOR_BANK_COM1
#define OV2640_REG_SENSOR_BANK_GAIN
chip sensor bank register definition
#define OV2640_REG_DSP_BANK_CTRL1
#define OV2640_REG_DSP_BANK_RESET
#define OV2640_REG_DSP_BANK_VHYX
#define OV2640_REG_DSP_BANK_CTRLI
#define OV2640_REG_SENSOR_BANK_COM25
#define OV2640_REG_SENSOR_BANK_VSTRT
#define OV2640_REG_DSP_BANK_HSIZE8
#define OV2640_REG_SENSOR_BANK_YAVG
#define OV2640_REG_DSP_BANK_P_CMD
#define OV2640_REG_SENSOR_BANK_AEW
#define OV2640_REG_SENSOR_BANK_MIDH
#define OV2640_REG_SENSOR_BANK_ADDVSL
#define OV2640_REG_SENSOR_BANK_FRARL
#define OV2640_REG_SENSOR_BANK_REG5E
#define MAX_CURRENT
#define OV2640_REG_SENSOR_BANK_REG2A
#define OV2640_REG_SENSOR_BANK_FLH
#define OV2640_REG_DSP_BANK_CTRL0
#define OV2640_REG_SENSOR_BANK_COM8
#define OV2640_REG_SENSOR_BANK_HSDY
#define OV2640_REG_DSP_BANK_MC_D
#define OV2640_REG_SENSOR_BANK_AEB
#define OV2640_ADDRESS
iic address definition
#define OV2640_REG_DSP_BANK_CTRL2
#define OV2640_REG_SENSOR_BANK_REG45
#define OV2640_REG_SENSOR_BANK_REG5F
#define OV2640_REG_SENSOR_BANK_HREFST
const uint8_t gsc_ov2640_jpeg_init_table[][2]
jpeg init table definition
#define OV2640_REG_SENSOR_BANK_PIDH
#define OV2640_REG_DSP_BANK_HSIZE
#define OV2640_REG_DSP_BANK_MS_SP
#define OV2640_REG_SENSOR_BANK_REG04
#define OV2640_REG_DSP_BANK_ZMOH
#define OV2640_REG_SENSOR_BANK_ZOOMS
const uint8_t gsc_ov2640_init_table[][2]
innter table globle definition
#define OV2640_REG_DSP_BANK_VSIZE
#define OV2640_REG_SENSOR_BANK_CLKRC
#define OV2640_REG_DSP_BANK_TEST
#define OV2640_REG_DSP_BANK_R_DVP_SP
#define OV2640_REG_DSP_BANK_IMAGE_MODE
#define SUPPLY_VOLTAGE_MAX
#define OV2640_REG_SENSOR_BANK_COM2
#define OV2640_REG_SENSOR_BANK_HREFEND
#define OV2640_REG_DSP_BANK_RA_DLMT
#define OV2640_REG_DSP_BANK_XOFFL
#define OV2640_REG_SENSOR_BANK_COM7
#define OV2640_REG_DSP_BANK_SS_CTRL
#define OV2640_REG_SENSOR_BANK_MIDL
#define OV2640_REG_SENSOR_BANK_BD60
#define OV2640_REG_SENSOR_BANK_REG5D
#define OV2640_REG_DSP_BANK_R_BYPASS
chip dsp bank register definition
#define OV2640_REG_SENSOR_BANK_COM3
#define OV2640_REG_DSP_BANK_SIZEL
#define OV2640_REG_SENSOR_BANK_HISTO_LOW
#define OV2640_REG_SENSOR_BANK_VEND
#define TEMPERATURE_MAX
#define OV2640_REG_SENSOR_BANK_COM22
#define OV2640_REG_SENSOR_BANK_COM4
#define OV2640_REG_DSP_BANK_VSIZE8
#define OV2640_REG_SENSOR_BANK_HISTO_HIGH
#define OV2640_REG_SENSOR_BANK_REG08
#define OV2640_REG_SENSOR_BANK_PIDL
#define OV2640_REG_DSP_BANK_YOFFL
#define OV2640_REG_SENSOR_BANK_COM19
#define MANUFACTURER_NAME
#define TEMPERATURE_MIN
#define SUPPLY_VOLTAGE_MIN
#define OV2640_REG_DSP_BANK_BPADDR
#define OV2640_REG_DSP_BANK_ZMOW
#define OV2640_REG_SENSOR_BANK_COM10
#define OV2640_REG_DSP_BANK_SS_ID
#define OV2640_REG_DSP_BANK_CTRL3
#define OV2640_REG_SENSOR_BANK_HEDY
#define OV2640_REG_SENSOR_BANK_AEC
#define OV2640_REG_DSP_BANK_BPDATA
#define OV2640_REG_SENSOR_BANK_FLL
#define OV2640_REG_SENSOR_BANK_ADDVSH
#define OV2640_REG_SENSOR_BANK_VV
#define OV2640_REG_DSP_BANK_MC_BIST
#define OV2640_REG_SENSOR_BANK_REG32
#define OV2640_REG_DSP_BANK_DPRP
#define CHIP_NAME
chip information definition
#define OV2640_REG_DSP_BANK_P_STATUS
#define OV2640_REG_SENSOR_BANK_ARCOM2
#define DRIVER_VERSION
#define OV2640_REG_DSP_BANK_MC_AL
#define OV2640_REG_SENSOR_BANK_REG60
#define OV2640_REG_DSP_BANK_QS
#define OV2640_REG_SENSOR_BANK_BD50
#define OV2640_REG_DSP_BANK_MC_AH
#define OV2640_REG_SENSOR_BANK_COM9
#define OV2640_REG_DSP_BANK_ZMHH
const uint8_t gsc_ov2640_rgb565_init_table[][2]
rgb565 init table definition
driver ov2640 header file
uint8_t ov2640_get_awb(ov2640_handle_t *handle, ov2640_bool_t *enable)
get awb status
uint8_t ov2640_set_offset_y(ov2640_handle_t *handle, uint16_t size)
set offset y
uint8_t ov2640_set_aec_enable(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable aec enable
uint8_t ov2640_set_vertical_size(ov2640_handle_t *handle, uint16_t size)
set vertical size
uint8_t ov2640_set_awb_gain(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable awb gain
uint8_t ov2640_get_byte_swap(ov2640_handle_t *handle, ov2640_byte_swap_t *byte_swap)
get byte swap
uint8_t ov2640_set_cip(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable cip
uint8_t ov2640_set_vfirst(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable vfirst
uint8_t ov2640_set_output_width(ov2640_handle_t *handle, uint16_t size)
set output width
ov2640_dvp_output_format_t
ov2640 dvp output format enumeration definition
uint8_t ov2640_get_sde(ov2640_handle_t *handle, ov2640_bool_t *enable)
get sde status
uint8_t ov2640_set_rgb(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable rgb
uint8_t ov2640_set_pre(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable pre
uint8_t ov2640_get_quantization_scale_factor(ov2640_handle_t *handle, uint8_t *factor)
get quantization scale factor
uint8_t ov2640_set_sccb_protocol_command(ov2640_handle_t *handle, uint8_t cmd)
set sccb protocol command
uint8_t ov2640_get_wpc(ov2640_handle_t *handle, ov2640_bool_t *enable)
get wpc status
uint8_t ov2640_get_yuv(ov2640_handle_t *handle, ov2640_bool_t *enable)
get yuv status
uint8_t ov2640_set_dg(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable dg
uint8_t ov2640_get_image_vertical(ov2640_handle_t *handle, uint16_t *size)
get image vertical
uint8_t ov2640_get_offset_x(ov2640_handle_t *handle, uint16_t *size)
get offset x
uint8_t ov2640_set_uv_avg(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable uv avg
uint8_t ov2640_get_aec_sel(ov2640_handle_t *handle, ov2640_bool_t *enable)
get aec sel status
uint8_t ov2640_get_sensor_pass_through_access(ov2640_handle_t *handle, ov2640_bool_t *enable)
get sensor pass through access status
uint8_t ov2640_get_dmy(ov2640_handle_t *handle, ov2640_bool_t *enable)
get dmy status
uint8_t ov2640_set_dvp_y8(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable dvp y8
uint8_t ov2640_set_sde(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable sde
uint8_t ov2640_set_sccb_master_access(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable sccb master access
uint8_t ov2640_get_cmx(ov2640_handle_t *handle, ov2640_bool_t *enable)
get cmx status
uint8_t ov2640_get_dvp_y8(ov2640_handle_t *handle, ov2640_bool_t *enable)
get dvp y8 status
uint8_t ov2640_set_address_auto_increase(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable address auto increase
uint8_t ov2640_set_round(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable round
uint8_t ov2640_get_dsp_bypass(ov2640_handle_t *handle, ov2640_bool_t *enable)
get dsp bypass status
uint8_t ov2640_get_dg(ov2640_handle_t *handle, ov2640_bool_t *enable)
get dg status
uint8_t ov2640_set_sccb_master_clock_delay(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable sccb master clock delay
uint8_t ov2640_set_sccb(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable sccb
uint8_t ov2640_get_sccb_master_clock_delay(ov2640_handle_t *handle, ov2640_bool_t *enable)
get sccb master clock delay status
uint8_t ov2640_get_stat_sel(ov2640_handle_t *handle, ov2640_bool_t *enable)
get stat sel status
uint8_t ov2640_set_lp_dp(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable lp dp
uint8_t ov2640_set_horizontal_divider(ov2640_handle_t *handle, uint8_t divider)
set horizontal divider
uint8_t ov2640_get_raw_gma(ov2640_handle_t *handle, ov2640_bool_t *enable)
get raw gma status
uint8_t ov2640_set_dvp_pclk(ov2640_handle_t *handle, uint8_t pclk)
set dvp pclk
uint8_t ov2640_get_lp_dp(ov2640_handle_t *handle, ov2640_bool_t *enable)
get lp dp status
uint8_t ov2640_set_bist(ov2640_handle_t *handle, ov2640_bist_t bist, ov2640_bool_t enable)
enable or disable bist
uint8_t ov2640_get_sde_indirect_register_address(ov2640_handle_t *handle, uint8_t *addr)
get sde indirect register address
uint8_t ov2640_get_vertical_divider(ov2640_handle_t *handle, uint8_t *divider)
get vertical divider
uint8_t ov2640_get_output_width(ov2640_handle_t *handle, uint16_t *size)
get output width
uint8_t ov2640_get_sccb_master_access(ov2640_handle_t *handle, ov2640_bool_t *enable)
get sccb master access status
uint8_t ov2640_set_program_memory_pointer_address(ov2640_handle_t *handle, uint16_t addr)
set program memory pointer address
uint8_t ov2640_set_raw(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable raw
uint8_t ov2640_set_yuv422(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable yuv422
uint8_t ov2640_set_uv_adj(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable uv adj
uint8_t ov2640_set_dp_selx(ov2640_handle_t *handle, uint8_t size)
set dp selx
uint8_t ov2640_get_sccb_protocol_command(ov2640_handle_t *handle, uint8_t *cmd)
get sccb protocol command
uint8_t ov2640_get_jpeg_output(ov2640_handle_t *handle, ov2640_bool_t *enable)
get jpeg output status
uint8_t ov2640_set_quantization_scale_factor(ov2640_handle_t *handle, uint8_t factor)
set quantization scale factor
uint8_t ov2640_set_horizontal_size(ov2640_handle_t *handle, uint16_t size)
set horizontal size
uint8_t ov2640_get_uv_avg(ov2640_handle_t *handle, ov2640_bool_t *enable)
get uv avg status
uint8_t ov2640_set_vertical_divider(ov2640_handle_t *handle, uint8_t divider)
set vertical divider
uint8_t ov2640_set_raw_gma(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable raw gma
uint8_t ov2640_set_stat_sel(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable stat sel
uint8_t ov2640_set_sensor_pass_through_access(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable sensor pass through access
uint8_t ov2640_get_output_height(ov2640_handle_t *handle, uint16_t *size)
get output height
ov2640_byte_swap_t
ov2640 byte sawp enumeration definition
uint8_t ov2640_set_output_height(ov2640_handle_t *handle, uint16_t size)
set output height
ov2640_bist_t
ov2640 bist enumeration definition
uint8_t ov2640_get_sccb_protocol_status(ov2640_handle_t *handle, uint8_t *status)
get sccb protocol status
uint8_t ov2640_get_vertical_size(ov2640_handle_t *handle, uint16_t *size)
get vertical size
uint8_t ov2640_set_reset(ov2640_handle_t *handle, ov2640_reset_t type, ov2640_bool_t enable)
enable or disable reset
uint8_t ov2640_set_image_horizontal(ov2640_handle_t *handle, uint16_t size)
set image horizontal
uint8_t ov2640_set_cmx(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable cmx
uint8_t ov2640_get_raw(ov2640_handle_t *handle, ov2640_bool_t *enable)
get raw status
uint8_t ov2640_get_image_horizontal(ov2640_handle_t *handle, uint16_t *size)
get image horizontal
uint8_t ov2640_set_bpc(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable bpc
uint8_t ov2640_get_sccb(ov2640_handle_t *handle, ov2640_bool_t *enable)
get sccb status
ov2640_reset_t
ov2640 reset enumeration definition
uint8_t ov2640_get_program_memory_pointer_access_address(ov2640_handle_t *handle, uint8_t *addr)
get program memory pointer access address
uint8_t ov2640_get_address_auto_increase(ov2640_handle_t *handle, ov2640_bool_t *enable)
get address auto increase status
uint8_t ov2640_set_byte_swap(ov2640_handle_t *handle, ov2640_byte_swap_t byte_swap)
set byte swap
uint8_t ov2640_get_zoom_speed(ov2640_handle_t *handle, uint8_t *speed)
get zoom speed
uint8_t ov2640_get_dcw(ov2640_handle_t *handle, ov2640_bool_t *enable)
get dcw status
uint8_t ov2640_get_round(ov2640_handle_t *handle, ov2640_bool_t *enable)
get round status
uint8_t ov2640_get_lenc(ov2640_handle_t *handle, ov2640_bool_t *enable)
get lenc status
uint8_t ov2640_set_zoom_speed(ov2640_handle_t *handle, uint8_t speed)
set zoom speed
ov2640_href_timing_t
ov2640 href timing enumeration definition
uint8_t ov2640_get_rgb(ov2640_handle_t *handle, ov2640_bool_t *enable)
get rgb status
uint8_t ov2640_set_dvp_jpeg_output_href_timing(ov2640_handle_t *handle, ov2640_href_timing_t timing)
set dvp jpeg output href timing
uint8_t ov2640_get_reset(ov2640_handle_t *handle, ov2640_reset_t type, ov2640_bool_t *enable)
get reset status
uint8_t ov2640_set_aec_sel(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable aec sel
uint8_t ov2640_set_awb(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable awb
uint8_t ov2640_set_offset_x(ov2640_handle_t *handle, uint16_t size)
set offset x
uint8_t ov2640_get_pre(ov2640_handle_t *handle, ov2640_bool_t *enable)
get pre status
uint8_t ov2640_set_sde_indirect_register_data(ov2640_handle_t *handle, uint8_t data)
set sde indirect register data
uint8_t ov2640_set_jpeg_output(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable jpeg output
uint8_t ov2640_get_sde_indirect_register_data(ov2640_handle_t *handle, uint8_t *data)
get sde indirect register data
uint8_t ov2640_set_sde_indirect_register_address(ov2640_handle_t *handle, uint8_t addr)
set sde indirect register address
uint8_t ov2640_set_image_vertical(ov2640_handle_t *handle, uint16_t size)
set image vertical
uint8_t ov2640_get_sccb_slave_id(ov2640_handle_t *handle, uint8_t *id)
get sccb slave id
uint8_t ov2640_get_bist(ov2640_handle_t *handle, ov2640_bist_t bist, ov2640_bool_t *enable)
get bist status
uint8_t ov2640_set_lenc(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable lenc
uint8_t ov2640_get_program_memory_pointer_address(ov2640_handle_t *handle, uint16_t *addr)
get program memory pointer address
uint8_t ov2640_get_uv_adj(ov2640_handle_t *handle, ov2640_bool_t *enable)
get uv adj status
uint8_t ov2640_set_dsp_bypass(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable dsp bypass
uint8_t ov2640_get_dvp_jpeg_output_href_timing(ov2640_handle_t *handle, ov2640_href_timing_t *timing)
get dvp jpeg output href timing
uint8_t ov2640_get_vfirst(ov2640_handle_t *handle, ov2640_bool_t *enable)
get vfirst status
uint8_t ov2640_get_horizontal_divider(ov2640_handle_t *handle, uint8_t *divider)
get horizontal divider
uint8_t ov2640_get_dvp_pclk(ov2640_handle_t *handle, uint8_t *pclk)
get dvp pclk
uint8_t ov2640_get_yuv422(ov2640_handle_t *handle, ov2640_bool_t *enable)
get yuv422 status
uint8_t ov2640_get_cip(ov2640_handle_t *handle, ov2640_bool_t *enable)
get cip status
uint8_t ov2640_get_dp_selx(ov2640_handle_t *handle, uint8_t *size)
get dp selx
uint8_t ov2640_set_auto_mode(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable auto_mode
uint8_t ov2640_set_sccb_slave_id(ov2640_handle_t *handle, uint8_t id)
set sccb slave id
uint8_t ov2640_get_bpc(ov2640_handle_t *handle, ov2640_bool_t *enable)
get bpc status
uint8_t ov2640_get_horizontal_size(ov2640_handle_t *handle, uint16_t *size)
get horizontal size
uint8_t ov2640_set_wpc(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable wpc
uint8_t ov2640_set_yuv(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable yuv
uint8_t ov2640_get_auto_mode(ov2640_handle_t *handle, ov2640_bool_t *enable)
get auto mode status
uint8_t ov2640_get_sccb_master_speed(ov2640_handle_t *handle, uint8_t *speed)
get sccb master speed
uint8_t ov2640_get_dvp_output_format(ov2640_handle_t *handle, ov2640_dvp_output_format_t *format)
get dvp output format
uint8_t ov2640_get_awb_gain(ov2640_handle_t *handle, ov2640_bool_t *enable)
get awb gain status
uint8_t ov2640_set_program_memory_pointer_access_address(ov2640_handle_t *handle, uint8_t addr)
set program memory pointer access address
uint8_t ov2640_set_sccb_master_speed(ov2640_handle_t *handle, uint8_t speed)
set sccb master speed
uint8_t ov2640_set_dmy(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable dmy
uint8_t ov2640_get_aec_enable(ov2640_handle_t *handle, ov2640_bool_t *enable)
get aec enable status
uint8_t ov2640_set_sccb_protocol_status(ov2640_handle_t *handle, uint8_t status)
set sccb protocol status
uint8_t ov2640_set_dcw(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable dcw
uint8_t ov2640_set_dvp_output_format(ov2640_handle_t *handle, ov2640_dvp_output_format_t format)
set dvp output format
uint8_t ov2640_set_dp_sely(ov2640_handle_t *handle, uint8_t size)
set dp sely
uint8_t ov2640_get_offset_y(ov2640_handle_t *handle, uint16_t *size)
get offset y
uint8_t ov2640_get_dp_sely(ov2640_handle_t *handle, uint8_t *size)
get dp sely
uint8_t ov2640_get_dsp_reg(ov2640_handle_t *handle, uint8_t reg, uint8_t *data)
get dsp reg
uint8_t ov2640_set_dsp_reg(ov2640_handle_t *handle, uint8_t reg, uint8_t data)
set dsp reg
uint8_t ov2640_set_sensor_reg(ov2640_handle_t *handle, uint8_t reg, uint8_t data)
set sensor reg
uint8_t ov2640_get_sensor_reg(ov2640_handle_t *handle, uint8_t reg, uint8_t *data)
get sensor reg
uint8_t ov2640_set_special_effect(ov2640_handle_t *handle, ov2640_special_effect_t effect)
set special effect
ov2640_special_effect_t
ov2640 special effect enumeration definition
uint8_t ov2640_set_light_mode(ov2640_handle_t *handle, ov2640_light_mode_t mode)
set light mode
ov2640_contrast_t
ov2640 contrast enumeration definition
ov2640_brightness_t
ov2640 brightness enumeration definition
ov2640_color_saturation_t
ov2640 color saturation enumeration definition
uint8_t ov2640_set_color_saturation(ov2640_handle_t *handle, ov2640_color_saturation_t color)
set color saturation
uint8_t ov2640_set_contrast(ov2640_handle_t *handle, ov2640_contrast_t contrast)
set contrast
ov2640_light_mode_t
ov2640 light mode enumeration definition
uint8_t ov2640_set_brightness(ov2640_handle_t *handle, ov2640_brightness_t brightness)
set brightness
@ OV2640_SPECIAL_EFFECT_ANTIQUE
@ OV2640_SPECIAL_EFFECT_BW_NEGATIVE
@ OV2640_SPECIAL_EFFECT_GREENISH
@ OV2640_SPECIAL_EFFECT_BLUISH
@ OV2640_SPECIAL_EFFECT_REDDISH
@ OV2640_SPECIAL_EFFECT_NEGATIVE
@ OV2640_SPECIAL_EFFECT_NORMAL
@ OV2640_SPECIAL_EFFECT_BW
@ OV2640_CONTRAST_POSITIVE_1
@ OV2640_CONTRAST_0
@ OV2640_CONTRAST_NEGATIVE_1
@ OV2640_CONTRAST_POSITIVE_2
@ OV2640_CONTRAST_NEGATIVE_2
@ OV2640_BRIGHTNESS_0
@ OV2640_BRIGHTNESS_NEGATIVE_1
@ OV2640_BRIGHTNESS_NEGATIVE_2
@ OV2640_BRIGHTNESS_POSITIVE_2
@ OV2640_BRIGHTNESS_POSITIVE_1
@ OV2640_COLOR_SATURATION_NEGATIVE_1
@ OV2640_COLOR_SATURATION_POSITIVE_2
@ OV2640_COLOR_SATURATION_POSITIVE_1
@ OV2640_COLOR_SATURATION_0
@ OV2640_COLOR_SATURATION_NEGATIVE_2
@ OV2640_LIGHT_MODE_OFFICE
@ OV2640_LIGHT_MODE_CLOUDY
@ OV2640_LIGHT_MODE_SUNNY
@ OV2640_LIGHT_MODE_HOME
@ OV2640_LIGHT_MODE_AUTO
uint8_t ov2640_get_power_reset_pin_remap(ov2640_handle_t *handle, ov2640_bool_t *enable)
get power reset pin remap status
uint8_t ov2640_table_jpeg_init(ov2640_handle_t *handle)
table jpeg init
uint8_t ov2640_get_line_interval_adjust(ov2640_handle_t *handle, uint16_t *adjust)
get line interval adjust
uint8_t ov2640_get_luminance_signal_high_range(ov2640_handle_t *handle, uint8_t *range)
get luminance signal high range
uint8_t ov2640_table_rgb565_init(ov2640_handle_t *handle)
table rgb565 init
uint8_t ov2640_set_vertical_flip(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable vertical flip
ov2640_edge_t
ov2640 edge enumeration definition
uint8_t ov2640_get_hsync_position_and_width_end_point(ov2640_handle_t *handle, uint16_t *position)
get hsync position and width end point
uint8_t ov2640_get_agc_gain(ov2640_handle_t *handle, uint16_t *gain)
get agc gain
uint8_t ov2640_get_luminance_average(ov2640_handle_t *handle, uint8_t *average)
get luminance average
uint8_t ov2640_set_hsync_polarity(ov2640_handle_t *handle, ov2640_polarity_t polarity)
set hsync polarity
uint8_t ov2640_set_60hz_banding_aec(ov2640_handle_t *handle, uint16_t aec)
set 60hz banding aec
uint8_t ov2640_set_horizontal_window_end(ov2640_handle_t *handle, uint16_t end)
set horizontal window end
uint8_t ov2640_set_mode(ov2640_handle_t *handle, ov2640_mode_t mode)
set mode
uint8_t ov2640_get_16_zone_average_weight_option(ov2640_handle_t *handle, uint32_t *avg)
get 16 zone average weight option
uint8_t ov2640_get_band_filter(ov2640_handle_t *handle, ov2640_bool_t *enable)
get band filter status
uint8_t ov2640_get_href_chsync_swap(ov2640_handle_t *handle, ov2640_bool_t *enable)
get href chsync swap status
uint8_t ov2640_set_frame_length_adjustment(ov2640_handle_t *handle, uint16_t frame)
set frame length adjustment
ov2640_resolution_t
ov2640 resolution enumeration definition
struct ov2640_info_s ov2640_info_t
ov2640 information structure definition
uint8_t ov2640_set_hsync_position_and_width_end_point(ov2640_handle_t *handle, uint16_t position)
set hsync position and width end point
uint8_t ov2640_set_clock_rate_double(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable double clock rate
uint8_t ov2640_set_href_chsync_swap(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable href chsync swap
uint8_t ov2640_table_init(ov2640_handle_t *handle)
table init
uint8_t ov2640_set_pclk(ov2640_handle_t *handle, ov2640_pclk_t pclk)
set pclk
uint8_t ov2640_get_clock_divider(ov2640_handle_t *handle, uint8_t *divider)
get clock divider
uint8_t ov2640_deinit(ov2640_handle_t *handle)
close the chip
ov2640_agc_gain_t
ov2640 agc gain enumeration definition
uint8_t ov2640_set_output_drive(ov2640_handle_t *handle, ov2640_output_drive_t select)
set output drive
uint8_t ov2640_set_flash_light(ov2640_handle_t *handle, uint8_t control)
set flash light
uint8_t ov2640_get_histogram_algorithm_high_level(ov2640_handle_t *handle, uint8_t *level)
get histogram algorithm high level
uint8_t ov2640_get_frame_length_adjustment(ov2640_handle_t *handle, uint16_t *frame)
get frame length adjustment
uint8_t ov2640_get_horizontal_window_start(ov2640_handle_t *handle, uint16_t *start)
get horizontal window start
uint8_t ov2640_set_vertical_window_line_start(ov2640_handle_t *handle, uint16_t start)
set vertical window line start
uint8_t ov2640_get_luminance_signal_low_range(ov2640_handle_t *handle, uint8_t *range)
get luminance signal low range
uint8_t ov2640_set_zoom(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable zoom
uint8_t ov2640_get_zoom_mode_vertical_window_start_point(ov2640_handle_t *handle, uint16_t *point)
get zoom mode vertical window start point
uint8_t ov2640_set_vertical_window_line_end(ov2640_handle_t *handle, uint16_t end)
set vertical window line end
uint8_t ov2640_get_resolution(ov2640_handle_t *handle, ov2640_resolution_t *resolution)
get resolution
ov2640_pin_status_t
ov2640 pin status enumeration definition
uint8_t ov2640_get_pclk(ov2640_handle_t *handle, ov2640_pclk_t *pclk)
get pclk
uint8_t ov2640_set_live_video_after_snapshot(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable live video after snapshot
uint8_t ov2640_get_zoom_window_horizontal_start_point(ov2640_handle_t *handle, ov2640_bool_t *enable)
get zoom window horizontal start point status
uint8_t ov2640_get_output_drive(ov2640_handle_t *handle, ov2640_output_drive_t *select)
get output drive
uint8_t ov2640_set_pclk_edge(ov2640_handle_t *handle, ov2640_edge_t edge)
set pclk edge
uint8_t ov2640_get_fast_mode_large_step_range(ov2640_handle_t *handle, uint8_t *high_threshold, uint8_t *low_threshold)
get fast mode large step range
uint8_t ov2640_set_band(ov2640_handle_t *handle, ov2640_band_t band)
set band
ov2640_control_t
ov2640 control enumeration definition
uint8_t ov2640_set_aec(ov2640_handle_t *handle, uint16_t aec)
set aec
uint8_t ov2640_info(ov2640_info_t *info)
get chip's information
uint8_t ov2640_set_clock_output_power_down_pin_status(ov2640_handle_t *handle, ov2640_pin_status_t status)
set clock output power down pin status
uint8_t ov2640_get_vertical_window_line_start(ov2640_handle_t *handle, uint16_t *start)
get vertical window line start
uint8_t ov2640_get_60hz_banding_aec(ov2640_handle_t *handle, uint16_t *aec)
get 60hz banding aec
uint8_t ov2640_set_line_interval_adjust(ov2640_handle_t *handle, uint16_t adjust)
set line interval adjust
uint8_t ov2640_set_pclk_output_qualified_by_href(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable pclk output qualified by href
uint8_t ov2640_set_auto_band(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable auto band
uint8_t ov2640_get_horizontal_window_end(ov2640_handle_t *handle, uint16_t *end)
get horizontal window end
uint8_t ov2640_set_zoom_mode_vertical_window_start_point(ov2640_handle_t *handle, uint16_t point)
set zoom mode vertical window start point
uint8_t ov2640_get_vsync_polarity(ov2640_handle_t *handle, ov2640_polarity_t *polarity)
get vsync polarity
uint8_t ov2640_get_chsync_href_swap(ov2640_handle_t *handle, ov2640_bool_t *enable)
get chsync href swap status
uint8_t ov2640_set_exposure_control(ov2640_handle_t *handle, ov2640_control_t control)
set exposure control
uint8_t ov2640_set_luminance_signal_low_range(ov2640_handle_t *handle, uint8_t range)
set luminance signal low range
uint8_t ov2640_get_frame_exposure_pre_charge_row_number(ov2640_handle_t *handle, uint8_t *num)
get frame exposure pre charge row number
uint8_t ov2640_get_flash_light(ov2640_handle_t *handle, uint8_t *control)
get flash light
uint8_t ov2640_get_aec(ov2640_handle_t *handle, uint16_t *aec)
get aec
uint8_t ov2640_set_dummy_frame(ov2640_handle_t *handle, ov2640_dummy_frame_t frame)
set dummy frame
uint8_t ov2640_get_hsync_position_and_width_start_point(ov2640_handle_t *handle, uint16_t *position)
get hsync position and width start point
uint8_t ov2640_set_16_zone_average_weight_option(ov2640_handle_t *handle, uint32_t avg)
set 16 zone average weight option
uint8_t ov2640_set_color_bar_test(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable color bar test
uint8_t ov2640_get_vsync_pulse_width(ov2640_handle_t *handle, uint16_t *width)
get vsync pulse width
ov2640_bool_t
ov2640 bool enumeration definition
ov2640_output_drive_t
ov2640 output drive enumeration definition
uint8_t ov2640_set_chsync_href_swap(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable chsync href swap
struct ov2640_handle_s ov2640_handle_t
ov2640 handle structure definition
uint8_t ov2640_set_frame_exposure_pre_charge_row_number(ov2640_handle_t *handle, uint8_t num)
set frame exposure pre charge row number
uint8_t ov2640_get_hsync_polarity(ov2640_handle_t *handle, ov2640_polarity_t *polarity)
get hsync polarity
uint8_t ov2640_set_50hz_banding_aec(ov2640_handle_t *handle, uint16_t aec)
set 50hz banding aec
uint8_t ov2640_get_agc_control(ov2640_handle_t *handle, ov2640_control_t *control)
get agc control
uint8_t ov2640_set_resolution(ov2640_handle_t *handle, ov2640_resolution_t resolution)
set resolution
uint8_t ov2640_init(ov2640_handle_t *handle)
initialize the chip
uint8_t ov2640_set_clock_divider(ov2640_handle_t *handle, uint8_t divider)
set clock divider
ov2640_mode_t
ov2640 mode enumeration definition
uint8_t ov2640_set_fast_mode_large_step_range(ov2640_handle_t *handle, uint8_t high_threshold, uint8_t low_threshold)
set fast mode large step range
uint8_t ov2640_set_agc_gain_ceiling(ov2640_handle_t *handle, ov2640_agc_gain_t agc)
set agc
uint8_t ov2640_get_pclk_edge(ov2640_handle_t *handle, ov2640_edge_t *edge)
get pclk edge
uint8_t ov2640_set_horizontal_mirror(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable horizontal mirror
uint8_t ov2640_get_zoom(ov2640_handle_t *handle, ov2640_bool_t *enable)
get zoom status
uint8_t ov2640_get_exposure_control(ov2640_handle_t *handle, ov2640_control_t *control)
get exposure control
uint8_t ov2640_set_vsync_polarity(ov2640_handle_t *handle, ov2640_polarity_t polarity)
set vsync polarity
uint8_t ov2640_get_vertical_flip(ov2640_handle_t *handle, ov2640_bool_t *enable)
get vertical flip status
uint8_t ov2640_set_agc_control(ov2640_handle_t *handle, ov2640_control_t control)
set agc control
uint8_t ov2640_get_auto_band(ov2640_handle_t *handle, ov2640_bool_t *enable)
get auto band status
uint8_t ov2640_set_histogram_algorithm_high_level(ov2640_handle_t *handle, uint8_t level)
set histogram algorithm high level
uint8_t ov2640_set_band_filter(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable band filter
uint8_t ov2640_get_histogram_algorithm_low_level(ov2640_handle_t *handle, uint8_t *level)
get histogram algorithm low level
uint8_t ov2640_get_clock_output_power_down_pin_status(ov2640_handle_t *handle, ov2640_pin_status_t *status)
get clock output power down pin status
uint8_t ov2640_get_pclk_output_qualified_by_href(ov2640_handle_t *handle, ov2640_bool_t *enable)
get pclk output qualified by href status
ov2640_polarity_t
ov2640 polarity enumeration definition
uint8_t ov2640_get_mode(ov2640_handle_t *handle, ov2640_mode_t *mode)
get mode
ov2640_band_t
ov2640 band enumeration definition
uint8_t ov2640_set_luminance_signal_high_range(ov2640_handle_t *handle, uint8_t range)
set luminance signal high range
uint8_t ov2640_set_luminance_average(ov2640_handle_t *handle, uint8_t average)
set luminance average
uint8_t ov2640_get_50hz_banding_aec(ov2640_handle_t *handle, uint16_t *aec)
get 50hz banding aec
uint8_t ov2640_get_horizontal_mirror(ov2640_handle_t *handle, ov2640_bool_t *enable)
get horizontal mirror status
uint8_t ov2640_set_horizontal_window_start(ov2640_handle_t *handle, uint16_t start)
set horizontal window start
uint8_t ov2640_get_agc_gain_ceiling(ov2640_handle_t *handle, ov2640_agc_gain_t *agc)
get agc
uint8_t ov2640_set_hsync_position_and_width_start_point(ov2640_handle_t *handle, uint16_t position)
set hsync position and width start point
uint8_t ov2640_set_href_polarity(ov2640_handle_t *handle, ov2640_polarity_t polarity)
set href polarity
uint8_t ov2640_get_href_polarity(ov2640_handle_t *handle, ov2640_polarity_t *polarity)
get href polarity
uint8_t ov2640_get_band(ov2640_handle_t *handle, ov2640_band_t *band)
get band
uint8_t ov2640_set_zoom_window_horizontal_start_point(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable zoom window horizontal start point
uint8_t ov2640_set_power_reset_pin_remap(ov2640_handle_t *handle, ov2640_bool_t enable)
enable or disable power reset pin remap
uint8_t ov2640_set_agc_gain(ov2640_handle_t *handle, uint16_t gain)
set agc gain
uint8_t ov2640_soft_reset(ov2640_handle_t *handle)
soft reset
uint8_t ov2640_get_live_video_after_snapshot(ov2640_handle_t *handle, ov2640_bool_t *enable)
get live video after snapshot status
uint8_t ov2640_set_histogram_algorithm_low_level(ov2640_handle_t *handle, uint8_t level)
set histogram algorithm low level
uint8_t ov2640_get_color_bar_test(ov2640_handle_t *handle, ov2640_bool_t *enable)
get color bar test status
ov2640_pclk_t
ov2640 pclk enumeration definition
uint8_t ov2640_get_dummy_frame(ov2640_handle_t *handle, ov2640_dummy_frame_t *frame)
get dummy frame
ov2640_dummy_frame_t
ov2640 dummy frame enumeration definition
uint8_t ov2640_set_vsync_pulse_width(ov2640_handle_t *handle, uint16_t width)
set vsync pulse width
uint8_t ov2640_get_vertical_window_line_end(ov2640_handle_t *handle, uint16_t *end)
get vertical window line end
uint8_t ov2640_get_clock_rate_double(ov2640_handle_t *handle, ov2640_bool_t *enable)
get clock rate double status
uint8_t(* power_down_init)(void)
uint8_t(* sccb_deinit)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* reset_write)(uint8_t level)
uint8_t(* sccb_init)(void)
void(* debug_print)(const char *const fmt,...)
uint8_t(* power_down_write)(uint8_t level)
uint8_t(* sccb_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* reset_deinit)(void)
uint8_t(* reset_init)(void)
uint8_t(* sccb_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* power_down_deinit)(void)
float supply_voltage_max_v
uint32_t driver_version
char interface[16]
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]