5MP Motion Camera  1.1.1.1
A waterproof, low power, battery operated, motion activated, 5 mega-pixel, WiFi camera.
ArduCAM.h
Go to the documentation of this file.
1 /*
2  ArduCAM.h - Arduino library support for CMOS Image Sensor
3  Copyright (C)2011-2015 ArduCAM.com. All right reserved
4 
5  Basic functionality of this library are based on the demo-code provided by
6  ArduCAM.com. You can find the latest version of the library at
7  http://www.ArduCAM.com
8 
9  Now supported controllers:
10  - OV7670
11  - MT9D111
12  - OV7675
13  - OV2640
14  - OV3640
15  - OV5642
16  - OV5640
17  - OV7660
18  - OV7725
19  - MT9M112
20  - MT9V111
21  - OV5640
22  - MT9M001
23  - MT9T112
24  - MT9D112
25 
26  We will add support for many other sensors in next release.
27 
28  Supported MCU platform
29  - Theoretically support all Arduino families
30  - Arduino UNO R3 (Tested)
31  - Arduino MEGA2560 R3 (Tested)
32  - Arduino Leonardo R3 (Tested)
33  - Arduino Nano (Tested)
34  - Arduino DUE (Tested)
35  - Arduino Yun (Tested)
36  - Raspberry Pi (Tested)
37  - ESP8266-12 (Tested)
38  * Feather M0 (Tested with OV5642)
39 
40  If you make any modifications or improvements to the code, I would appreciate
41  that you share the code with me so that I might include it in the next release.
42  I can be contacted through http://www.ArduCAM.com
43 
44  This library is free software; you can redistribute it and/or
45  modify it under the terms of the GNU Lesser General Public
46  License as published by the Free Software Foundation; either
47  version 2.1 of the License, or (at your option) any later version.
48 
49  This library is distributed in the hope that it will be useful,
50  but WITHOUT ANY WARRANTY; without even the implied warranty of
51  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
52  Lesser General Public License for more details.
53 
54  You should have received a copy of the GNU Lesser General Public
55  License along with this library; if not, write to the Free Software
56  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
57 */
58 
59 /*------------------------------------
60  Revision History:
61  2012/09/20 V1.0.0 by Lee first release
62  2012/10/23 V1.0.1 by Lee Resolved some timing issue for the Read/Write Register
63  2012/11/29 V1.1.0 by Lee Add support for MT9D111 sensor
64  2012/12/13 V1.2.0 by Lee Add support for OV7675 sensor
65  2012/12/28 V1.3.0 by Lee Add support for OV2640,OV3640,OV5642 sensors
66  2013/02/26 V2.0.0 by Lee New Rev.B shield hardware, add support for FIFO control
67  and support Mega1280/2560 boards
68  2013/05/28 V2.1.0 by Lee Add support all drawing functions derived from UTFT library
69  2013/08/24 V3.0.0 by Lee Support ArudCAM shield Rev.C hardware, features SPI interface and low power mode.
70  Support almost all series of Arduino boards including DUE.
71  2014/03/09 V3.1.0 by Lee Add the more impressive example sketches.
72  Optimise the OV5642 settings, improve image quality.
73  Add live preview before JPEG capture.
74  Add play back photos one by one after BMP capture.
75  2014/05/01 V3.1.1 by Lee Minor changes to add support Arduino IDE for linux distributions.
76  2014/09/30 V3.2.0 by Lee Improvement on OV5642 camera dirver.
77  2014/10/06 V3.3.0 by Lee Add OV7660,OV7725 camera support.
78  2015/02/27 V3.4.0 by Lee Add the support for Arduino Yun board, update the latest UTFT library for ArduCAM.
79  2015/06/09 V3.4.1 by Lee Minor changes and add some comments
80  2015/06/19 V3.4.2 by Lee Add support for MT9M112 camera.
81  2015/06/20 V3.4.3 by Lee Add support for MT9V111 camera.
82  2015/06/22 V3.4.4 by Lee Add support for OV5640 camera.
83  2015/06/22 V3.4.5 by Lee Add support for MT9M001 camera.
84  2015/08/05 V3.4.6 by Lee Add support for MT9T112 camera.
85  2015/08/08 V3.4.7 by Lee Add support for MT9D112 camera.
86  2015/09/20 V3.4.8 by Lee Add support for ESP8266 processor.
87  2016/02/03 V3.4.9 by Lee Add support for Arduino ZERO board.
88  2016/06/07 V3.5.0 by Lee Add support for OV5642_CAM_BIT_ROTATION_FIXED.
89  2016/06/14 V3.5.1 by Lee Add support for ArduCAM-Mini-5MP-Plus OV5640_CAM.
90  2016/09/29 V3.5.2 by Lee Optimize the OV5642 register settings
91  2016/10/05 V4.0.0 by Lee Add support for second generation of ArduCAM shield V2, ArduCAM-Mini-5MP-Plus(OV5642/OV5640).
92  2016/10/28 V4.0.1 by Lee Add support for Raspberry Pi
93  2017/04/27 V4.1.0 by Lee Add support for OV2640/OV5640/OV5642 functions.
94  2017/07/07 V4.1.0 by Lee Add support for ArduCAM_ESP32 paltform
95  2017/07/25 V4.1.1 by Lee Add support for MT9V034
96  2017/11/27 V4.1.2 by Max Add support for Feather M0
97  2018/10/15 V4.1.2 by Lee Add support for NRF52
98  2018/10/15 V4.1.2 by Lee Add support for TEENSYDUINO
99 --------------------------------------*/
100 
101 #ifndef ArduCAM_H
102 #define ArduCAM_H
103 #include "memorysaver.h"
104 #if defined ( RASPBERRY_PI )
105 #else
106  #include "Arduino.h"
107  #include <pins_arduino.h>
108  #include "memorysaver.h"
109 #endif
110 
111 #if defined (__AVR__)
112 #define cbi(reg, bitmask) *reg &= ~bitmask
113 #define sbi(reg, bitmask) *reg |= bitmask
114 #define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask);
115 #define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask);
116 #define cport(port, data) port &= data
117 #define sport(port, data) port |= data
118 #define swap(type, i, j) {type t = i; i = j; j = t;}
119 #define fontbyte(x) pgm_read_byte(&cfont.font[x])
120 #define regtype volatile uint8_t
121 #define regsize uint8_t
122 #endif
123 
124 #if defined(__SAM3X8E__)
125 
126 #define cbi(reg, bitmask) *reg &= ~bitmask
127 #define sbi(reg, bitmask) *reg |= bitmask
128 
129 #define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask);
130 #define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask);
131 
132 #define cport(port, data) port &= data
133 #define sport(port, data) port |= data
134 
135 #define swap(type, i, j) {type t = i; i = j; j = t;}
136 #define fontbyte(x) cfont.font[x]
137 
138 #define regtype volatile uint32_t
139 #define regsize uint32_t
140 
141 #define PROGMEM
142 
143 #define pgm_read_byte(x) (*((char *)x))
144 #define pgm_read_word(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x)))
145 #define pgm_read_byte_near(x) (*((char *)x))
146 #define pgm_read_byte_far(x) (*((char *)x))
147 #define pgm_read_word_near(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x)))
148 #define pgm_read_word_far(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))))
149 #define PSTR(x) x
150 #if defined F
151  #undef F
152 #endif
153 #define F(X) (X)
154 #endif
155 
156 #if defined(ESP8266)
157  #define cbi(reg, bitmask) digitalWrite(bitmask, LOW)
158  #define sbi(reg, bitmask) digitalWrite(bitmask, HIGH)
159  #define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask);
160  #define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask);
161 
162  #define cport(port, data) port &= data
163  #define sport(port, data) port |= data
164 
165  #define swap(type, i, j) {type t = i; i = j; j = t;}
166 
167  #define fontbyte(x) cfont.font[x]
168 
169  #define regtype volatile uint32_t
170  #define regsize uint32_t
171 #endif
172 
173 #if defined(__SAMD51__) || defined(__SAMD21G18A__)
174  #define Serial SERIAL_PORT_USBVIRTUAL
175 
176  #define cbi(reg, bitmask) *reg &= ~bitmask
177  #define sbi(reg, bitmask) *reg |= bitmask
178 
179  #define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask);
180  #define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask);
181 
182  #define cport(port, data) port &= data
183  #define sport(port, data) port |= data
184 
185  #define swap(type, i, j) {type t = i; i = j; j = t;}
186  #define fontbyte(x) cfont.font[x]
187 
188  #define regtype volatile uint32_t
189  #define regsize uint32_t
190 #endif
191 
192 #if defined(ESP32)
193  #define cbi(reg, bitmask) digitalWrite(bitmask, LOW)
194  #define sbi(reg, bitmask) digitalWrite(bitmask, HIGH)
195  #define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask);
196  #define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask);
197 
198  #define cport(port, data) port &= data
199  #define sport(port, data) port |= data
200 
201  #define swap(type, i, j) {type t = i; i = j; j = t;}
202 
203  #define fontbyte(x) cfont.font[x]
204 
205  #define regtype volatile uint32_t
206  #define regsize uint32_t
207 #endif
208 
209 #if defined(__CPU_ARC__)
210  #define cbi(reg, bitmask) *reg &= ~bitmask
211  #define sbi(reg, bitmask) *reg |= bitmask
212  #define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask);
213  #define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask);
214  #define cport(port, data) port &= data
215  #define sport(port, data) port |= data
216  #define swap(type, i, j) {type t = i; i = j; j = t;}
217  #define fontbyte(x) pgm_read_byte(&cfont.font[x])
218  #define regtype volatile uint32_t
219  #define regsize uint32_t
220 #endif
221 
222 #if defined (RASPBERRY_PI)
223  #define regtype volatile uint32_t
224  #define regsize uint32_t
225  #define byte uint8_t
226  #define cbi(reg, bitmask) digitalWrite(bitmask, LOW)
227  #define sbi(reg, bitmask) digitalWrite(bitmask, HIGH)
228  #define PROGMEM
229 
230  #define PSTR(x) x
231  #if defined F
232  #undef F
233  #endif
234  #define F(X) (X)
235 #endif
236 
237 #if defined(ARDUINO_ARCH_NRF52)
238  #define cbi(reg, bitmask) digitalWrite(bitmask, LOW)
239  #define sbi(reg, bitmask) digitalWrite(bitmask, HIGH)
240  #define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask);
241  #define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask);
242 
243  #define cport(port, data) port &= data
244  #define sport(port, data) port |= data
245 
246  #define swap(type, i, j) {type t = i; i = j; j = t;}
247 
248  #define fontbyte(x) cfont.font[x]
249 
250  #define regtype volatile uint32_t
251  #define regsize uint32_t
252 
253 #endif
254 
255 #if defined(TEENSYDUINO)
256  #define cbi(reg, bitmask) digitalWriteFast(bitmask, LOW)
257  #define sbi(reg, bitmask) digitalWriteFast(bitmask, HIGH)
258 #define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask);
259 #define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask);
260  #define cport(port, data) port &= data
261 #define sport(port, data) port |= data
262  #define swap(type, i, j) {type t = i; i = j; j = t;}
263  #define fontbyte(x) cfont.font[x]
264  #define regtype volatile uint8_t
265 #define regsize uint8_t
266  #endif
267 
268 
269 /****************************************************/
270 /* Sensor related definition */
271 /****************************************************/
272 #define BMP 0
273 #define JPEG 1
274 #define RAW 2
275 
276 #define OV7670 0
277 #define MT9D111_A 1
278 #define OV7675 2
279 #define OV5642 3
280 #define OV3640 4
281 #define OV2640 5
282 #define OV9655 6
283 #define MT9M112 7
284 #define OV7725 8
285 #define OV7660 9
286 #define MT9M001 10
287 #define OV5640 11
288 #define MT9D111_B 12
289 #define OV9650 13
290 #define MT9V111 14
291 #define MT9T112 15
292 #define MT9D112 16
293 #define MT9V034 17
294 #define MT9M034 18
295 
296 #define OV2640_160x120 0 //160x120
297 #define OV2640_176x144 1 //176x144
298 #define OV2640_320x240 2 //320x240
299 #define OV2640_352x288 3 //352x288
300 #define OV2640_640x480 4 //640x480
301 #define OV2640_800x600 5 //800x600
302 #define OV2640_1024x768 6 //1024x768
303 #define OV2640_1280x1024 7 //1280x1024
304 #define OV2640_1600x1200 8 //1600x1200
305 
306 
307 
308 #define OV3640_176x144 0 //176x144
309 #define OV3640_320x240 1 //320x240
310 #define OV3640_352x288 2 //352x288
311 #define OV3640_640x480 3 //640x480
312 #define OV3640_800x600 4 //800x600
313 #define OV3640_1024x768 5 //1024x768
314 #define OV3640_1280x960 6 //1280x960
315 #define OV3640_1600x1200 7 //1600x1200
316 #define OV3640_2048x1536 8 //2048x1536
317 
318 
319 #define OV5642_320x240 0 //320x240
320 #define OV5642_640x480 1 //640x480
321 #define OV5642_1024x768 2 //1024x768
322 #define OV5642_1280x960 3 //1280x960
323 #define OV5642_1600x1200 4 //1600x1200
324 #define OV5642_2048x1536 5 //2048x1536
325 #define OV5642_2592x1944 6 //2592x1944
326 #define OV5642_1920x1080 7
327 
328 
329 #define OV5640_320x240 0 //320x240
330 #define OV5640_352x288 1 //352x288
331 #define OV5640_640x480 2 //640x480
332 #define OV5640_800x480 3 //800x480
333 #define OV5640_1024x768 4 //1024x768
334 #define OV5640_1280x960 5 //1280x960
335 #define OV5640_1600x1200 6 //1600x1200
336 #define OV5640_2048x1536 7 //2048x1536
337 #define OV5640_2592x1944 8 //2592x1944
338 
339 
340 
341 //Light Mode
342 
343 #define Auto 0
344 #define Sunny 1
345 #define Cloudy 2
346 #define Office 3
347 #define Home 4
348 
349 #define Advanced_AWB 0
350 #define Simple_AWB 1
351 #define Manual_day 2
352 #define Manual_A 3
353 #define Manual_cwf 4
354 #define Manual_cloudy 5
355 
356 
357 
358 //Color Saturation
359 
360 #define Saturation4 0
361 #define Saturation3 1
362 #define Saturation2 2
363 #define Saturation1 3
364 #define Saturation0 4
365 #define Saturation_1 5
366 #define Saturation_2 6
367 #define Saturation_3 7
368 #define Saturation_4 8
369 
370 //Brightness
371 
372 #define Brightness4 0
373 #define Brightness3 1
374 #define Brightness2 2
375 #define Brightness1 3
376 #define Brightness0 4
377 #define Brightness_1 5
378 #define Brightness_2 6
379 #define Brightness_3 7
380 #define Brightness_4 8
381 
382 
383 //Contrast
384 
385 #define Contrast4 0
386 #define Contrast3 1
387 #define Contrast2 2
388 #define Contrast1 3
389 #define Contrast0 4
390 #define Contrast_1 5
391 #define Contrast_2 6
392 #define Contrast_3 7
393 #define Contrast_4 8
394 
395 
396 
397 #define degree_180 0
398 #define degree_150 1
399 #define degree_120 2
400 #define degree_90 3
401 #define degree_60 4
402 #define degree_30 5
403 #define degree_0 6
404 #define degree30 7
405 #define degree60 8
406 #define degree90 9
407 #define degree120 10
408 #define degree150 11
409 
410 
411 
412 //Special effects
413 
414 #define Antique 0
415 #define Bluish 1
416 #define Greenish 2
417 #define Reddish 3
418 #define BW 4
419 #define Negative 5
420 #define BWnegative 6
421 #define Normal 7
422 #define Sepia 8
423 #define Overexposure 9
424 #define Solarize 10
425 #define Blueish 11
426 #define Yellowish 12
427 
428 #define Exposure_17_EV 0
429 #define Exposure_13_EV 1
430 #define Exposure_10_EV 2
431 #define Exposure_07_EV 3
432 #define Exposure_03_EV 4
433 #define Exposure_default 5
434 #define Exposure03_EV 6
435 #define Exposure07_EV 7
436 #define Exposure10_EV 8
437 #define Exposure13_EV 9
438 #define Exposure17_EV 10
439 
440 #define Auto_Sharpness_default 0
441 #define Auto_Sharpness1 1
442 #define Auto_Sharpness2 2
443 #define Manual_Sharpnessoff 3
444 #define Manual_Sharpness1 4
445 #define Manual_Sharpness2 5
446 #define Manual_Sharpness3 6
447 #define Manual_Sharpness4 7
448 #define Manual_Sharpness5 8
449 
450 
451 
452 #define Sharpness1 0
453 #define Sharpness2 1
454 #define Sharpness3 2
455 #define Sharpness4 3
456 #define Sharpness5 4
457 #define Sharpness6 5
458 #define Sharpness7 6
459 #define Sharpness8 7
460 #define Sharpness_auto 8
461 
462 
463 
464 
465 #define EV3 0
466 #define EV2 1
467 #define EV1 2
468 #define EV0 3
469 #define EV_1 4
470 #define EV_2 5
471 #define EV_3 6
472 
473 #define MIRROR 0
474 #define FLIP 1
475 #define MIRROR_FLIP 2
476 
477 
478 
479 
480 #define high_quality 0
481 #define default_quality 1
482 #define low_quality 2
483 
484 #define Color_bar 0
485 #define Color_square 1
486 #define BW_square 2
487 #define DLI 3
488 
489 
490 #define Night_Mode_On 0
491 #define Night_Mode_Off 1
492 
493 #define Off 0
494 #define Manual_50HZ 1
495 #define Manual_60HZ 2
496 #define Auto_Detection 3
497 
498 /****************************************************/
499 /* I2C Control Definition */
500 /****************************************************/
501 #define I2C_ADDR_8BIT 0
502 #define I2C_ADDR_16BIT 1
503 #define I2C_REG_8BIT 0
504 #define I2C_REG_16BIT 1
505 #define I2C_DAT_8BIT 0
506 #define I2C_DAT_16BIT 1
507 
508 /* Register initialization tables for SENSORs */
509 /* Terminating list entry for reg */
510 #define SENSOR_REG_TERM_8BIT 0xFF
511 #define SENSOR_REG_TERM_16BIT 0xFFFF
512 /* Terminating list entry for val */
513 #define SENSOR_VAL_TERM_8BIT 0xFF
514 #define SENSOR_VAL_TERM_16BIT 0xFFFF
515 
516 //Define maximum frame buffer size
517 #if (defined OV2640_MINI_2MP)
518 #define MAX_FIFO_SIZE 0x5FFFF //384KByte
519 #elif (defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED || defined ARDUCAM_SHIELD_REVC)
520 #define MAX_FIFO_SIZE 0x7FFFF //512KByte
521 #else
522 #define MAX_FIFO_SIZE 0x7FFFFF //8MByte
523 #endif
524 
525 /****************************************************/
526 /* ArduChip registers definition */
527 /****************************************************/
528 #define RWBIT 0x80 //READ AND WRITE BIT IS BIT[7]
529 
530 #define ARDUCHIP_TEST1 0x00 //TEST register
531 
532 #if !(defined OV2640_MINI_2MP)
533  #define ARDUCHIP_FRAMES 0x01 //FRAME control register, Bit[2:0] = Number of frames to be captured //On 5MP_Plus platforms bit[2:0] = 7 means continuous capture until frame buffer is full
534 #endif
535 
536 #define ARDUCHIP_MODE 0x02 //Mode register
537 #define MCU2LCD_MODE 0x00
538 #define CAM2LCD_MODE 0x01
539 #define LCD2MCU_MODE 0x02
540 
541 #define ARDUCHIP_TIM 0x03 //Timming control
542 #if !(defined OV2640_MINI_2MP)
543  #define HREF_LEVEL_MASK 0x01 //0 = High active , 1 = Low active
544  #define VSYNC_LEVEL_MASK 0x02 //0 = High active , 1 = Low active
545  #define LCD_BKEN_MASK 0x04 //0 = Enable, 1 = Disable
546  #if (defined ARDUCAM_SHIELD_V2)
547  #define PCLK_REVERSE_MASK 0x08 //0 = Normal PCLK, 1 = REVERSED PCLK
548  #else
549  #define PCLK_DELAY_MASK 0x08 //0 = data no delay, 1 = data delayed one PCLK
550  #endif
551  //#define MODE_MASK 0x10 //0 = LCD mode, 1 = FIFO mode
552 #endif
553 //#define FIFO_PWRDN_MASK 0x20 //0 = Normal operation, 1 = FIFO power down
554 //#define LOW_POWER_MODE 0x40 //0 = Normal mode, 1 = Low power mode
555 
556 #define ARDUCHIP_FIFO 0x04 //FIFO and I2C control
557 #define FIFO_CLEAR_MASK 0x01
558 #define FIFO_START_MASK 0x02
559 #define FIFO_RDPTR_RST_MASK 0x10
560 #define FIFO_WRPTR_RST_MASK 0x20
561 
562 #define ARDUCHIP_GPIO 0x06 //GPIO Write Register
563 #if !(defined (ARDUCAM_SHIELD_V2) || defined (ARDUCAM_SHIELD_REVC))
564 #define GPIO_RESET_MASK 0x01 //0 = Sensor reset, 1 = Sensor normal operation
565 #define GPIO_PWDN_MASK 0x02 //0 = Sensor normal operation, 1 = Sensor standby
566 #define GPIO_PWREN_MASK 0x04 //0 = Sensor LDO disable, 1 = sensor LDO enable
567 #endif
568 
569 #define BURST_FIFO_READ 0x3C //Burst FIFO read operation
570 #define SINGLE_FIFO_READ 0x3D //Single FIFO read operation
571 
572 #define ARDUCHIP_REV 0x40 //ArduCHIP revision
573 #define VER_LOW_MASK 0x3F
574 #define VER_HIGH_MASK 0xC0
575 
576 #define ARDUCHIP_TRIG 0x41 //Trigger source
577 #define VSYNC_MASK 0x01
578 #define SHUTTER_MASK 0x02
579 #define CAP_DONE_MASK 0x08
580 
581 #define FIFO_SIZE1 0x42 //Camera write FIFO size[7:0] for burst to read
582 #define FIFO_SIZE2 0x43 //Camera write FIFO size[15:8]
583 #define FIFO_SIZE3 0x44 //Camera write FIFO size[18:16]
584 
585 
586 /****************************************************/
587 
588 
589 /****************************************************************/
590 /* define a structure for sensor register initialization values */
591 /****************************************************************/
592 struct sensor_reg {
593  uint16_t reg;
594  uint16_t val;
595 };
596 
597 
598 
599 /****************************************************************/
600 /* define a structure for sensor register initialization values */
601 /****************************************************************/
602 
603 class ArduCAM
604 {
605  public:
606  ArduCAM( void );
607  ArduCAM(byte model ,int CS);
608  void InitCAM( void );
609 
610  void CS_HIGH(void);
611  void CS_LOW(void);
612 
613  void flush_fifo(void);
614  void start_capture(void);
615  void clear_fifo_flag(void);
616  uint8_t read_fifo(void);
617 
618  uint8_t read_reg(uint8_t addr);
619  void write_reg(uint8_t addr, uint8_t data);
620 
621  uint32_t read_fifo_length(void);
622  void set_fifo_burst(void);
623 
624  void set_bit(uint8_t addr, uint8_t bit);
625  void clear_bit(uint8_t addr, uint8_t bit);
626  uint8_t get_bit(uint8_t addr, uint8_t bit);
627  void set_mode(uint8_t mode);
628 
629  uint8_t bus_write(int address, int value);
630  uint8_t bus_read(int address);
631 
632  // Write 8 bit values to 8 bit register address
633  int wrSensorRegs8_8(const struct sensor_reg*);
634 
635  // Write 16 bit values to 8 bit register address
636  int wrSensorRegs8_16(const struct sensor_reg*);
637 
638  // Write 8 bit values to 16 bit register address
639  int wrSensorRegs16_8(const struct sensor_reg*);
640 
641  // Write 16 bit values to 16 bit register address
642  int wrSensorRegs16_16(const struct sensor_reg*);
643 
644  // Read/write 8 bit value to/from 8 bit register address
645  byte wrSensorReg8_8(int regID, int regDat);
646  byte rdSensorReg8_8(uint8_t regID, uint8_t* regDat);
647 
648  // Read/write 16 bit value to/from 8 bit register address
649  byte wrSensorReg8_16(int regID, int regDat);
650  byte rdSensorReg8_16(uint8_t regID, uint16_t* regDat);
651 
652  // Read/write 8 bit value to/from 16 bit register address
653  byte wrSensorReg16_8(int regID, int regDat);
654  byte rdSensorReg16_8(uint16_t regID, uint8_t* regDat);
655 
656  // Read/write 16 bit value to/from 16 bit register address
657  byte wrSensorReg16_16(int regID, int regDat);
658  byte rdSensorReg16_16(uint16_t regID, uint16_t* regDat);
659 
660  void OV2640_set_JPEG_size(uint8_t size);
661  void OV3640_set_JPEG_size(uint8_t size);
662  void OV5642_set_JPEG_size(uint8_t size);
663  void OV5640_set_JPEG_size(uint8_t size);
664 
665  void OV5642_set_RAW_size (uint8_t size);
666 
667 
668  void OV2640_set_Light_Mode(uint8_t Light_Mode);
669  void OV3640_set_Light_Mode(uint8_t Light_Mode);
670  void OV5642_set_Light_Mode(uint8_t Light_Mode);
671  void OV5640_set_Light_Mode(uint8_t Light_Mode);
672 
673  void OV2640_set_Color_Saturation(uint8_t Color_Saturation);
674  void OV3640_set_Color_Saturation(uint8_t Color_Saturation);
675  void OV5642_set_Color_Saturation(uint8_t Color_Saturation);
676  void OV5640_set_Color_Saturation(uint8_t Color_Saturation);
677 
678 
679  void OV2640_set_Brightness(uint8_t Brightness);
680  void OV3640_set_Brightness(uint8_t Brightness);
681  void OV5642_set_Brightness(uint8_t Brightness);
682  void OV5640_set_Brightness(uint8_t Brightness);
683 
684  void OV2640_set_Contrast(uint8_t Contrast);
685  void OV3640_set_Contrast(uint8_t Contrast);
686  void OV5642_set_Contrast(uint8_t Contrast);
687  void OV5640_set_Contrast(uint8_t Contrast);
688 
689  void OV2640_set_Special_effects(uint8_t Special_effect);
690  void OV3640_set_Special_effects(uint8_t Special_effect);
691  void OV5642_set_Special_effects(uint8_t Special_effect);
692  void OV5640_set_Special_effects(uint8_t Special_effect);
693 
694 
695  void OV3640_set_Exposure_level(uint8_t level);
696  void OV3640_set_Sharpness(uint8_t Sharpness);
697  void OV3640_set_Mirror_Flip(uint8_t Mirror_Flip);
698 
699 
700  void OV5642_set_hue(uint8_t degree);
701  void OV5642_set_Exposure_level(uint8_t level);
702  void OV5642_set_Sharpness(uint8_t Sharpness);
703  void OV5642_set_Mirror_Flip(uint8_t Mirror_Flip);
704  void OV5642_set_Compress_quality(uint8_t quality);
705  void OV5642_Test_Pattern(uint8_t Pattern);
706 
707 
708  void OV5640_set_EV(uint8_t EV);
709  void OV5640_set_Night_Mode(uint8_t Night_mode);
710  void OV5640_set_Banding_Filter(uint8_t Banding_Filter);
711 
712 
713 
714 
715  void set_format(byte fmt);
716 
717  #if defined (RASPBERRY_PI)
718  uint8_t transfer(uint8_t data);
719  void transfers(uint8_t *buf, uint32_t size);
720  #endif
721 
722  void transferBytes_(uint8_t * out, uint8_t * in, uint8_t size);
723  void transferBytes(uint8_t * out, uint8_t * in, uint32_t size);
724  inline void setDataBits(uint16_t bits);
725 
726  protected:
727  regtype *P_CS;
728  regsize B_CS;
729  byte m_fmt;
732 };
733 
734 #if defined OV7660_CAM
735  #include "ov7660_regs.h"
736 #endif
737 
738 #if defined OV7725_CAM
739  #include "ov7725_regs.h"
740 #endif
741 
742 #if defined OV7670_CAM
743  #include "ov7670_regs.h"
744 #endif
745 
746 #if defined OV7675_CAM
747  #include "ov7675_regs.h"
748 #endif
749 
750 #if ( defined(OV5642_CAM) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP_PLUS) )
751  #include "ov5642_regs.h"
752 #endif
753 
754 #if (defined(OV3640_CAM) || defined(OV3640_MINI_3MP))
755  #include "ov3640_regs.h"
756 #endif
757 
758 #if (defined(OV2640_CAM) || defined(OV2640_MINI_2MP) || defined(OV2640_MINI_2MP_PLUS))
759  #include "ov2640_regs.h"
760 #endif
761 
762 #if defined MT9D111A_CAM || defined MT9D111B_CAM
763  #include "mt9d111_regs.h"
764 #endif
765 
766 #if defined MT9M112_CAM
767  #include "mt9m112_regs.h"
768 #endif
769 
770 #if defined MT9V111_CAM
771  #include "mt9v111_regs.h"
772 #endif
773 
774 #if ( defined(OV5640_CAM) || defined(OV5640_MINI_5MP_PLUS) )
775  #include "ov5640_regs.h"
776 #endif
777 
778 #if defined MT9M001_CAM
779  #include "mt9m001_regs.h"
780 #endif
781 
782 #if defined MT9T112_CAM
783  #include "mt9t112_regs.h"
784 #endif
785 
786 #if defined MT9D112_CAM
787  #include "mt9d112_regs.h"
788 #endif
789 
790 #if defined MT9M034_CAM
791  #include "mt9m034_regs.h"
792 #endif
793 
794 
795 
796 #endif
regtype * P_CS
Definition: ArduCAM.h:727
uint16_t val
Definition: ArduCAM.h:594
byte sensor_addr
Definition: ArduCAM.h:731
Definition: ArduCAM.h:592
Definition: ArduCAM.h:603
byte m_fmt
Definition: ArduCAM.h:729
byte sensor_model
Definition: ArduCAM.h:730
regsize B_CS
Definition: ArduCAM.h:728
uint16_t reg
Definition: ArduCAM.h:593